示例#1
0
 // return the PlatformClientFetchedEntity object linked to this clientDescriptor
 private static Optional<? extends Map.Entry<String, PlatformClientFetchedEntity>>
     getPlatformClientFetchedEntity(IMonitoringConsumer consumer, Object clientDescriptor) {
   return 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().clientDescriptor.equals(clientDescriptor))
                   .findFirst());
 }
示例#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()));
 }