示例#1
0
 public DependencyId(String groupId, String artifactId, String classifier, String extension) {
   this.groupId = groupId;
   this.artifactId = artifactId;
   this.classifier = classifier;
   this.extension = extension;
   this.hashCode = Objects.hashCode(groupId, artifactId, classifier, extension);
 }
示例#2
0
 @Override
 public void handle(final NetSocket socket) {
   NetClient client = null;
   List<String> paths = serviceMap.getPaths();
   TcpClientRequestFacade requestFacade = new TcpClientRequestFacade(socket);
   String path = pathLoadBalancer.choose(paths, requestFacade);
   if (path != null) {
     List<ServiceDetails> services = serviceMap.getServices(path);
     if (!services.isEmpty()) {
       ServiceDetails serviceDetails = serviceLoadBalancer.choose(services, requestFacade);
       if (serviceDetails != null) {
         List<String> urlStrings = serviceDetails.getServices();
         for (String urlString : urlStrings) {
           if (Strings.notEmpty(urlString)) {
             // lets create a client for this request...
             try {
               URI uri = new URI(urlString);
               // URL url = new URL(urlString);
               String urlProtocol = uri.getScheme();
               if (Objects.equal(protocol, urlProtocol)) {
                 Handler<AsyncResult<NetSocket>> handler =
                     new Handler<AsyncResult<NetSocket>>() {
                       public void handle(final AsyncResult<NetSocket> asyncSocket) {
                         NetSocket clientSocket = asyncSocket.result();
                         Pump.createPump(clientSocket, socket).start();
                         Pump.createPump(socket, clientSocket).start();
                       }
                     };
                 client = createClient(socket, uri, handler);
                 break;
               }
             } catch (MalformedURLException e) {
               LOG.warn("Failed to parse URL: " + urlString + ". " + e, e);
             } catch (URISyntaxException e) {
               LOG.warn("Failed to parse URI: " + urlString + ". " + e, e);
             }
           }
         }
       }
     }
   }
   if (client == null) {
     // fail to route
     LOG.info("No service available for protocol " + protocol + " for paths " + paths);
     socket.close();
   }
 }
  protected void checkProcessesStatus() {
    ProcessManager manager = getProcessManager();
    FabricService fabric = getFabricService();
    if (manager != null && fabric != null) {
      ImmutableMap<String, Installation> map = manager.listInstallationMap();
      ImmutableSet<Map.Entry<String, Installation>> entries = map.entrySet();
      for (Map.Entry<String, Installation> entry : entries) {
        String id = entry.getKey();
        Installation installation = entry.getValue();
        try {
          Container container = null;
          try {
            container = fabric.getContainer(id);
          } catch (Exception e) {
            LOG.debug("No container for id: " + id + ". " + e, e);
          }
          if (container != null) {
            Long pid = installation.getActivePid();
            if (LOG.isDebugEnabled()) {
              LOG.debug("Polling container " + id + " for its PID");
            }
            if (pid == null) {
              if (container.isAlive()) {
                container.setAlive(false);
              }
            } else if (pid != null && pid != 0) {
              if (!container.isAlive()) {
                container.setAlive(true);
              }
              if (!Objects.equal(container.getProvisionResult(), Container.PROVISION_SUCCESS)) {
                container.setProvisionResult(Container.PROVISION_SUCCESS);
              }

              JolokiaAgentHelper.jolokiaKeepAliveCheck(fabric, container);
            }
          }
        } catch (Exception e) {
          LOG.warn("Failed to get PID for process " + id + ". " + e, e);
        }
      }
    }
  }