コード例 #1
0
 @Override
 public ServiceStatusDetail apply(final CheckException input) {
   final ServiceConfiguration config =
       ServiceConfigurations.lookupByName(input.getServiceName());
   return new ServiceStatusDetail() {
     {
       this.setSeverity(input.getSeverity().toString());
       this.setUuid(input.getCorrelationId());
       this.setTimestamp(input.getTimestamp().toString());
       this.setMessage(
           input.getMessage() != null
               ? input.getMessage()
               : "No summary information available.");
       this.setStackTrace(
           input.getStackString() != null
               ? input.getStackString()
               : Exceptions.string(
                   new RuntimeException(
                       "Error while mapping service event record:  No stack information available")));
       this.setServiceFullName(config.getFullName().toString());
       this.setServiceHost(config.getHostName());
       this.setServiceName(input.getServiceName());
     }
   };
 }
コード例 #2
0
  public static ServiceConfiguration findService(final String name) {
    checkParam(name, notNullValue());
    Predicate<ServiceConfiguration> nameOrFullName =
        new Predicate<ServiceConfiguration>() {

          @Override
          public boolean apply(ServiceConfiguration input) {
            return name.equals(input.getName()) || name.equals(input.getFullName().toString());
          }
        };
    for (final ComponentId compId : ComponentIds.list()) {
      ServiceConfiguration a;
      try {
        return Iterables.find(Components.lookup(compId).services(), nameOrFullName);
      } catch (NoSuchElementException ex) {
        if (compId.isRegisterable()) {
          try {
            return ServiceConfigurations.lookupByName(compId.getClass(), name);
          } catch (Exception ex1) {
          }
        }
      }
    }
    throw new NoSuchElementException("Failed to lookup service named: " + name);
  }