示例#1
0
 // return the PlatformConnectedClient object representing the connection used by this
 // clientDescriptor
 private static Optional<Map.Entry<String, PlatformConnectedClient>> getPlatformConnectedClient(
     IMonitoringConsumer consumer, Object clientDescriptor) {
   return getPlatformClientFetchedEntity(consumer, clientDescriptor)
       .flatMap(
           entry ->
               consumer
                   .getValueForNode(
                       CLIENTS_PATH,
                       entry.getValue().clientIdentifier,
                       PlatformConnectedClient.class)
                   .map(
                       platformConnectedClient ->
                           new AbstractMap.SimpleEntry<>(
                               entry.getValue().clientIdentifier, platformConnectedClient)));
 }
示例#2
0
 static Optional<ClientDescriptor> getClientDescriptor(
     IMonitoringConsumer consumer, ClientIdentifier clientIdentifier) {
   return consumer
       .getChildValuesForNode(CLIENTS_PATH)
       // walk on all platform clients having same client identifier
       .flatMap(
           children ->
               children
                   .entrySet()
                   .stream()
                   .filter(entry -> entry.getValue() instanceof PlatformConnectedClient)
                   .map(
                       entry ->
                           new AbstractMap.SimpleEntry<>(
                               entry.getKey(), (PlatformConnectedClient) entry.getValue()))
                   .filter(entry -> toClientIdentifier(entry.getValue()).equals(clientIdentifier))
                   .map(Map.Entry::getKey)
                   .findFirst())
       // then find all fetches for this client
       .flatMap(
           voltronConnectionId ->
               consumer
                   .getChildValuesForNode(FETCHED_PATH)
                   .flatMap(
                       children ->
                           children
                               .entrySet()
                               .stream()
                               .filter(
                                   entry ->
                                       entry.getValue() instanceof PlatformClientFetchedEntity)
                               .map(
                                   entry ->
                                       new AbstractMap.SimpleEntry<>(
                                           entry.getKey(),
                                           (PlatformClientFetchedEntity) entry.getValue()))
                               .filter(
                                   entry ->
                                       entry
                                           .getValue()
                                           .clientIdentifier
                                           .equals(voltronConnectionId))
                               .map(Map.Entry::getValue)
                               // only interested in the fetch for the management entity
                               .filter(
                                   platformClientFetchedEntity ->
                                       consumer
                                           .getValueForNode(
                                               ENTITIES_PATH,
                                               platformClientFetchedEntity.entityIdentifier,
                                               PlatformEntity.class)
                                           .filter(
                                               platformEntity ->
                                                   platformEntity.typeName.equals(
                                                       ManagementAgentConfig.ENTITY_TYPE))
                                           .isPresent())
                               // return the client descriptor for the client that has fetched the
                               // management entity
                               .map(
                                   platformClientFetchedEntity ->
                                       platformClientFetchedEntity.clientDescriptor)
                               .findFirst()));
 }