本文整理了Java中org.elasticsearch.action.ActionListener.onResponse()
方法的一些代码示例,展示了ActionListener.onResponse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ActionListener.onResponse()
方法的具体详情如下:
包路径:org.elasticsearch.action.ActionListener
类名称:ActionListener
方法名:onResponse
[英]Notifies every given listener with the response passed to #onResponse(Object). If a listener itself throws an exception the exception is forwarded to #onFailure(Exception). If in turn #onFailure(Exception) fails all remaining listeners will be processed and the caught exception will be re-thrown.
[中]用传递给#onResponse(对象)的响应通知每个给定侦听器。如果侦听器本身抛出异常,则该异常将转发到#onFailure(异常)。如果反过来#onFailure(Exception)失败,则将处理所有剩余的侦听器,并重新抛出捕获的异常。
代码示例来源:origin: floragunncom/search-guard
@Override
protected void doExecute(WhoAmIRequest request, ActionListener<WhoAmIResponse> listener) {
final User user = threadPool.getThreadContext().getTransient(ConfigConstants.SG_USER);
final String dn = user==null?threadPool.getThreadContext().getTransient(ConfigConstants.SG_SSL_TRANSPORT_PRINCIPAL):user.getName();
final boolean isAdmin = adminDNs.isAdminDN(dn);
final boolean isAuthenticated = isAdmin?true: user != null;
final boolean isNodeCertificateRequest = HeaderHelper.isInterClusterRequest(threadPool.getThreadContext()) ||
HeaderHelper.isTrustedClusterRequest(threadPool.getThreadContext());
listener.onResponse(new WhoAmIResponse(dn, isAdmin, isAuthenticated, isNodeCertificateRequest));
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void onResponse(R r) {
try (ThreadContext.StoredContext ignore = context.get()) {
delegate.onResponse(r);
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected void doRun() throws Exception {
listener.onResponse(shardOperation(request, shardId));
}
});
代码示例来源:origin: org.elasticsearch/elasticsearch
public void respond(ActionListener<TransportResponse.Empty> listener) {
if (finalFailure == null) {
listener.onResponse(TransportResponse.Empty.INSTANCE);
} else {
listener.onFailure(finalFailure);
}
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void onResponse(Response response) {
taskManager.unregister(task);
listener.onResponse(response);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void onFailure(Exception e) {
int index = indexCounter.getAndIncrement();
indexResponses.set(index, e);
if (completionCounter.decrementAndGet() == 0) {
listener.onResponse(merge(indexResponses));
}
}
});
代码示例来源:origin: org.elasticsearch/elasticsearch
private void onFreedContext(boolean freed) {
if (freed) {
freedSearchContexts.incrementAndGet();
}
if (expectedOps.countDown()) {
boolean succeeded = hasFailed.get() == false;
listener.onResponse(new ClearScrollResponse(succeeded, freedSearchContexts.get()));
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void onResponse(ShardsSyncedFlushResult syncedFlushResult) {
results.get(index).add(syncedFlushResult);
if (countDown.countDown()) {
listener.onResponse(new SyncedFlushResponse(results));
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void onResponse(UpgradeResponse upgradeResponse) {
try {
if (upgradeResponse.versions().isEmpty()) {
listener.onResponse(upgradeResponse);
} else {
updateSettings(upgradeResponse, listener);
}
} catch (Exception e) {
listener.onFailure(e);
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void onResponse(Void ignore) {
resyncTask.setPhase("finished");
taskManager.unregister(resyncTask);
listener.onResponse(resyncTask);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void handleResponse(HandshakeResponse response) {
if (isDone.compareAndSet(false, true)) {
Version version = response.responseVersion;
if (currentVersion.isCompatible(version) == false) {
listener.onFailure(new IllegalStateException("Received message from unsupported version: [" + version
+ "] minimal compatible version is: [" + currentVersion.minimumCompatibilityVersion() + "]"));
} else {
listener.onResponse(version);
}
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Called once all the nodes have acknowledged the cluster state update request. Must be
* very lightweight execution, since it gets executed on the cluster service thread.
*
* @param e optional error that might have been thrown
*/
public void onAllNodesAcked(@Nullable Exception e) {
listener.onResponse(newResponse(e == null));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected void masterOperation(GetPipelineRequest request, ClusterState state, ActionListener<GetPipelineResponse> listener)
throws Exception {
listener.onResponse(new GetPipelineResponse(IngestService.getPipelines(state, request.getIds())));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected void doExecute(RemoteInfoRequest remoteInfoRequest, ActionListener<RemoteInfoResponse> listener) {
remoteClusterService.getRemoteConnectionInfos(ActionListener.wrap(remoteConnectionInfos
-> listener.onResponse(new RemoteInfoResponse(remoteConnectionInfos)), listener::onFailure));
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
private void finishHim() {
listener.onResponse(new MultiTermVectorsResponse(
responses.toArray(new MultiTermVectorsItemResponse[responses.length()])));
}
});
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void onTimeout(TimeValue timeout) {
try {
listener.onResponse(new ClusterStateResponse(clusterState.getClusterName(), null, 0L, true));
} catch (Exception e) {
listener.onFailure(e);
}
}
}, metadataVersionPredicate);
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected void sendReplicaRequest(
final ConcreteReplicaRequest<ResyncReplicationRequest> replicaRequest,
final DiscoveryNode node,
final ActionListener<ReplicationOperation.ReplicaResponse> listener) {
if (node.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) {
super.sendReplicaRequest(replicaRequest, node, listener);
} else {
final long pre60NodeCheckpoint = SequenceNumbers.PRE_60_NODE_CHECKPOINT;
listener.onResponse(new ReplicaResponse(pre60NodeCheckpoint, pre60NodeCheckpoint));
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
ActionListener<BulkResponse> wrapActionListenerIfNeeded(long ingestTookInMillis, ActionListener<BulkResponse> actionListener) {
if (itemResponses.isEmpty()) {
return ActionListener.wrap(
response -> actionListener.onResponse(new BulkResponse(response.getItems(),
response.getTook().getMillis(), ingestTookInMillis)),
actionListener::onFailure);
} else {
return new IngestBulkResponseListener(ingestTookInMillis, originalSlots, itemResponses, actionListener);
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected void doExecute(MainRequest request, ActionListener<MainResponse> listener) {
ClusterState clusterState = clusterService.state();
final boolean available = clusterState.getBlocks().hasGlobalBlock(RestStatus.SERVICE_UNAVAILABLE) == false;
listener.onResponse(
new MainResponse(nodeName, Version.CURRENT, clusterState.getClusterName(),
clusterState.metaData().clusterUUID(), Build.CURRENT, available));
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void onResponse(RepositoriesService.VerifyResponse verifyResponse) {
if (verifyResponse.failed()) {
listener.onFailure(new RepositoryVerificationException(request.name(), verifyResponse.failureDescription()));
} else {
listener.onResponse(new VerifyRepositoryResponse(clusterService.getClusterName(), verifyResponse.nodes()));
}
}
内容来源于网络,如有侵权,请联系作者删除!