/** * Send a request to the given address * * @return the client request to poll for a response, or null if the request could not be written * at the moment */ public ActorFuture<ClientResponse> sendRequest( final int nodeId, final BufferWriter writer, final Duration timeout) { return clientTransport.getOutput().sendRequest(nodeId, writer, timeout); }
public ExecuteCommandRequest send(Predicate<DirectBuffer> retryFunction) { if (responseFuture != null) { throw new RuntimeException("Cannot send request more than once"); } responseFuture = output.sendRequestWithRetry(() -> target, retryFunction, this, Duration.ofSeconds(5)); return this; }
/** * Send a {@link TransportMessage} to the given remote * * @return true if the message was written to the send buffer, false otherwise */ public boolean sendMessage(final int nodeId, final BufferWriter writer) { return clientTransport.getOutput().sendMessage(nodeId, writer); }
public ControlMessageRequest send(Predicate<DirectBuffer> retryFunction) { if (responseFuture != null) { throw new RuntimeException("Cannot send request more than once"); } responseFuture = output.sendRequestWithRetry(() -> target, retryFunction, this, Duration.ofSeconds(5)); return this; }
private ActorFuture<ClientResponse> sendEventTo(GossipEvent event, int nodeId, Duration timeout) { return clientTransport.getOutput().sendRequest(nodeId, event, timeout); }
/** * Send a {@link TransportMessage} to the given remote * * @return true if the message was written to the send buffer, false otherwise */ public boolean sendMessage(final int nodeId, final BufferWriter writer) { return clientTransport.getOutput().sendMessage(nodeId, writer); }
public ExecuteCommandRequest send(Predicate<DirectBuffer> retryFunction) { if (responseFuture != null) { throw new RuntimeException("Cannot send request more than once"); } responseFuture = output.sendRequestWithRetry(() -> target, retryFunction, this, Duration.ofSeconds(5)); return this; }
/** * Send a request to the given address * * @return the client request to poll for a response, or null if the request could not be written * at the moment */ public ActorFuture<ClientResponse> sendRequest( final int nodeId, final BufferWriter writer, final Duration timeout) { return clientTransport.getOutput().sendRequest(nodeId, writer, timeout); }
private boolean sendSubscriptionCommand( final int receiverPartitionId, final BufferWriter command) { final Int2ObjectHashMap<NodeInfo> partitionLeaders = partitionListener.getPartitionLeaders(); final NodeInfo partitionLeader = partitionLeaders.get(receiverPartitionId); if (partitionLeader == null) { // retry when no leader is known return true; } return subscriptionClient.getOutput().sendMessage(partitionLeader.getNodeId(), command); }
public ControlMessageRequest send(Predicate<DirectBuffer> retryFunction) { if (responseFuture != null) { throw new RuntimeException("Cannot send request more than once"); } responseFuture = output.sendRequestWithRetry(() -> target, retryFunction, this, Duration.ofSeconds(5)); return this; }
private ActorFuture<ClientResponse> sendEventTo(GossipEvent event, int nodeId, Duration timeout) { return clientTransport.getOutput().sendRequest(nodeId, event, timeout); }
private boolean sendSubscriptionCommand( final int receiverPartitionId, final BufferWriter command) { final Int2ObjectHashMap<NodeInfo> partitionLeaders = partitionListener.getPartitionLeaders(); final NodeInfo partitionLeader = partitionLeaders.get(receiverPartitionId); if (partitionLeader == null) { // retry when no leader is known return true; } return subscriptionClient.getOutput().sendMessage(partitionLeader.getNodeId(), command); }
private <T> void sendRequestInternal( BrokerRequest<T> request, BiConsumer<BrokerResponse<T>, Throwable> responseConsumer) { final BrokerNodeIdProvider nodeIdProvider = determineBrokerNodeIdProvider(request); final ActorFuture<ClientResponse> responseFuture = clientOutput.sendRequestWithRetry( nodeIdProvider, BrokerRequestManager::shouldRetryRequest, request, requestTimeout); if (responseFuture != null) { actor.runOnCompletion( responseFuture, (clientResponse, error) -> { try { if (error == null) { final BrokerResponse<T> response = request.getResponse(clientResponse); checkForTopologyResponse(response); responseConsumer.accept(response, null); } else { responseConsumer.accept(null, error); } } catch (RuntimeException e) { responseConsumer.accept(null, new ClientResponseException(e)); } }); } else { responseConsumer.accept(null, new ClientOutOfMemoryException()); } }
private void refreshTopology() { final BrokerClusterStateImpl brokerClusterState = topology.get(); final int endpoint; if (brokerClusterState != null) { endpoint = brokerClusterState.getRandomBroker(); } else { // never fetched topology before so use initial contact point node endpoint = ClientTransport.UNKNOWN_NODE_ID; } final ActorFuture<ClientResponse> responseFuture = output.sendRequest(endpoint, topologyRequest, Duration.ofSeconds(1)); refreshAttempt++; lastRefreshTime = ActorClock.currentTimeMillis(); actor.runOnCompletion(responseFuture, this::handleResponse); actor.runDelayed(MAX_REFRESH_INTERVAL_MILLIS, scheduleIdleRefresh()); }
if (clientOutput.sendMessage(nodeId, appendRequest)) { lastRequestTimestamp = now;
managementApi .getOutput() .sendRequestWithRetry( () -> partitionLeaderId, (response) -> !pushDeploymentResponse.tryWrap(response),
/** Only use if node id is not known, i.e. on initial join with contact points */ public ActorFuture<ClientResponse> sendPing(SocketAddress socketAddress, Duration timeout) { gossipFailureDetectionEvent .reset() .eventType(GossipEventType.PING) .senderId(membershipList.self().getId()); clientTransport.registerEndpoint(UNKNOWN_NODE_ID, socketAddress); return clientTransport .getOutput() .sendRequest(UNKNOWN_NODE_ID, gossipFailureDetectionEvent, timeout); } }
if (clientOutput.sendMessage(nodeId, appendRequest)) { lastRequestTimestamp = now;
managementApi .getOutput() .sendRequestWithRetry( () -> partitionLeaderId, (response) -> !pushDeploymentResponse.tryWrap(response),
/** Only use if node id is not known, i.e. on initial join with contact points */ public ActorFuture<ClientResponse> sendPing(SocketAddress socketAddress, Duration timeout) { gossipFailureDetectionEvent .reset() .eventType(GossipEventType.PING) .senderId(membershipList.self().getId()); clientTransport.registerEndpoint(UNKNOWN_NODE_ID, socketAddress); return clientTransport .getOutput() .sendRequest(UNKNOWN_NODE_ID, gossipFailureDetectionEvent, timeout); } }