org.elasticsearch.action.support.HandledTransportAction Java Examples
The following examples show how to use
org.elasticsearch.action.support.HandledTransportAction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PeerRecoveryTargetService.java From crate with Apache License 2.0 | 5 votes |
@Override public void messageReceived(RecoveryPrepareForTranslogOperationsRequest request, TransportChannel channel, Task task) throws Exception { try (RecoveryRef recoveryRef = onGoingRecoveries.getRecoverySafe(request.recoveryId(), request.shardId())) { final ActionListener<TransportResponse> listener = new HandledTransportAction.ChannelActionListener<>(channel, Actions.PREPARE_TRANSLOG, request); recoveryRef.target().prepareForTranslogOperations( request.isFileBasedRecovery(), request.totalTranslogOps(), ActionListener.wrap( nullVal -> listener.onResponse(TransportResponse.Empty.INSTANCE), listener::onFailure) ); } }
Example #2
Source File: PeerRecoveryTargetService.java From crate with Apache License 2.0 | 5 votes |
@Override public void messageReceived(RecoveryFinalizeRecoveryRequest request, TransportChannel channel, Task task) throws Exception { try (RecoveryRef recoveryRef = onGoingRecoveries.getRecoverySafe(request.recoveryId(), request.shardId())) { final ActionListener<TransportResponse> listener = new HandledTransportAction.ChannelActionListener<>(channel, Actions.FINALIZE, request); recoveryRef.target().finalizeRecovery( request.globalCheckpoint(), ActionListener.wrap( nullVal -> listener.onResponse(TransportResponse.Empty.INSTANCE), listener::onFailure ) ); } }
Example #3
Source File: PeerRecoveryTargetService.java From crate with Apache License 2.0 | 5 votes |
@Override public void messageReceived(final RecoveryFileChunkRequest request, TransportChannel channel, Task task) throws Exception { try (RecoveryRef recoveryRef = onGoingRecoveries.getRecoverySafe(request.recoveryId(), request.shardId())) { final RecoveryTarget recoveryTarget = recoveryRef.target(); final RecoveryState.Index indexState = recoveryTarget.state().getIndex(); if (request.sourceThrottleTimeInNanos() != RecoveryState.Index.UNKNOWN) { indexState.addSourceThrottling(request.sourceThrottleTimeInNanos()); } RateLimiter rateLimiter = recoverySettings.rateLimiter(); if (rateLimiter != null) { long bytes = bytesSinceLastPause.addAndGet(request.content().length()); if (bytes > rateLimiter.getMinPauseCheckBytes()) { // Time to pause bytesSinceLastPause.addAndGet(-bytes); long throttleTimeInNanos = rateLimiter.pause(bytes); indexState.addTargetThrottling(throttleTimeInNanos); recoveryTarget.indexShard().recoveryStats().addThrottleTime(throttleTimeInNanos); } } final ActionListener<TransportResponse> listener = new HandledTransportAction.ChannelActionListener<>(channel, Actions.FILE_CHUNK, request); recoveryTarget.writeFileChunk( request.metadata(), request.position(), request.content(), request.lastChunk(), request.totalTranslogOps(), ActionListener.wrap( nullVal -> listener.onResponse(TransportResponse.Empty.INSTANCE), listener::onFailure) ); } channel.sendResponse(TransportResponse.Empty.INSTANCE); }
Example #4
Source File: PeerRecoveryTargetService.java From crate with Apache License 2.0 | 4 votes |
@Override public void messageReceived(final RecoveryTranslogOperationsRequest request, final TransportChannel channel, Task task) throws IOException { try (RecoveryRef recoveryRef = onGoingRecoveries.getRecoverySafe(request.recoveryId(), request.shardId())) { final ClusterStateObserver observer = new ClusterStateObserver(clusterService, null, LOGGER); final RecoveryTarget recoveryTarget = recoveryRef.target(); final ActionListener<RecoveryTranslogOperationsResponse> listener = new HandledTransportAction.ChannelActionListener<>(channel, Actions.TRANSLOG_OPS, request); final Consumer<Exception> retryOnMappingException = exception -> { // in very rare cases a translog replay from primary is processed before // a mapping update on this node which causes local mapping changes since // the mapping (clusterstate) might not have arrived on this node. LOGGER.debug("delaying recovery due to missing mapping changes", exception); // we do not need to use a timeout here since the entire recovery mechanism has an // inactivity protection (it will be canceled) observer.waitForNextChange(new ClusterStateObserver.Listener() { @Override public void onNewClusterState(ClusterState state) { try { messageReceived(request, channel, task); } catch (Exception e) { listener.onFailure(e); } } @Override public void onClusterServiceClose() { listener.onFailure(new ElasticsearchException( "cluster service was closed while waiting for mapping updates")); } @Override public void onTimeout(TimeValue timeout) { // note that we do not use a timeout (see comment above) listener.onFailure(new ElasticsearchTimeoutException( "timed out waiting for mapping updates (timeout [" + timeout + "])")); } }); }; recoveryTarget.indexTranslogOperations( request.operations(), request.totalTranslogOps(), request.maxSeenAutoIdTimestampOnPrimary(), request.maxSeqNoOfUpdatesOrDeletesOnPrimary(), ActionListener.wrap( checkpoint -> listener.onResponse(new RecoveryTranslogOperationsResponse(checkpoint)), e -> { if (e instanceof MapperException) { retryOnMappingException.accept(e); } else { listener.onFailure(e); } }) ); } }
Example #5
Source File: PeerRecoverySourceService.java From crate with Apache License 2.0 | 4 votes |
@Override public void messageReceived(final StartRecoveryRequest request, final TransportChannel channel, Task task) throws Exception { recover(request, new HandledTransportAction.ChannelActionListener<>(channel, Actions.START_RECOVERY, request)); }