@Override public <T> Optional<T> getConnectionEndpoint(Class<T> protocol) { return member.getConnectionEndpoint(protocol); }
@Override public <T> Optional<T> getConnectionEndpoint(Class<T> protocol) { return member.getConnectionEndpoint(protocol); }
@Override public <T> Optional<T> getConnectionEndpoint(Class<T> protocol) { return member.getConnectionEndpoint(protocol); }
/** * Resolve the JGroups Address of the given {@code Member}. * * @param destination The node of which to solve the Address * @return The JGroups Address of the given node * * @throws CommandBusConnectorCommunicationException when an error occurs resolving the adress */ protected Address resolveAddress(Member destination) { return destination.getConnectionEndpoint(Address.class) .orElseThrow(() -> new CommandBusConnectorCommunicationException( "The target member doesn't expose a JGroups endpoint" )); }
/** * Resolve the JGroups Address of the given {@code Member}. * * @param destination The node of which to solve the Address * @return The JGroups Address of the given node * * @throws CommandBusConnectorCommunicationException when an error occurs resolving the adress */ protected Address resolveAddress(Member destination) { return destination.getConnectionEndpoint(Address.class).orElseThrow( () -> new CommandBusConnectorCommunicationException( "The target member doesn't expose a JGroups endpoint")); }
CommandMessage<? extends C> commandMessage, boolean expectReply) { Optional<URI> optionalEndpoint = destination.getConnectionEndpoint(URI.class); if (optionalEndpoint.isPresent()) { URI endpointUri = optionalEndpoint.get();
private Optional<MessageRoutingInformation> requestMessageRoutingInformation(ServiceInstance serviceInstance) { Member member = buildMember(serviceInstance); if (member.local()) { return Optional.of(getLocalMessageRoutingInformation()); } URI endpoint = member.getConnectionEndpoint(URI.class) .orElseThrow(() -> new IllegalArgumentException(String.format( "No Connection Endpoint found in Member [%s] for protocol [%s] to send a " + "%s request to", member, URI.class, MessageRoutingInformation.class.getSimpleName() ))); URI destinationUri = buildURIForPath(endpoint, messageRoutingInformationEndpoint); try { ResponseEntity<MessageRoutingInformation> responseEntity = restTemplate.exchange(destinationUri, HttpMethod.GET, HttpEntity.EMPTY, MessageRoutingInformation.class); return Optional.ofNullable(responseEntity.getBody()); } catch (HttpClientErrorException e) { logger.info("Blacklisting Service [" + serviceInstance.getServiceId() + "], " + "as requesting message routing information from it resulted in an exception.", logger.isDebugEnabled() ? e : null); return Optional.empty(); } catch (Exception e) { logger.info("Failed to receive message routing information from Service [" + serviceInstance.getServiceId() + "] due to an exception. " + "Will temporarily set this instance to deny all incoming messages", logger.isDebugEnabled()?e:null); return Optional.of(unreachableService); } }