本文整理汇总了Java中org.elasticsearch.action.Action.name方法的典型用法代码示例。如果您正苦于以下问题:Java Action.name方法的具体用法?Java Action.name怎么用?Java Action.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.action.Action
的用法示例。
在下文中一共展示了Action.name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExecute
import org.elasticsearch.action.Action; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>>
void doExecute(Action<Request, Response, RequestBuilder> action, Request request, ActionListener<Response> listener) {
HttpElasticsearchClient.ActionEntry entry = actionMap.get(action.name());
if (entry == null) {
throw new IllegalStateException("no action entry for " + action.name());
}
HttpAction<Request, Response> httpAction = entry.httpAction;
if (httpAction == null) {
throw new IllegalStateException("failed to find action [" + action + "] to execute");
}
HttpInvocationContext<Request, Response> httpInvocationContext = new HttpInvocationContext(httpAction, listener, new LinkedList<>(), request);
try {
httpInvocationContext.httpRequest = httpAction.createHttpRequest(this.url, request);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
ChannelFuture future = bootstrap.connect(new InetSocketAddress(url.getHost(), url.getPort()));
future.awaitUninterruptibly();
if (!future.isSuccess()) {
bootstrap.releaseExternalResources();
logger.error("can't connect to {}", url);
} else {
Channel channel = future.getChannel();
httpInvocationContext.setChannel(channel);
contexts.put(channel, httpInvocationContext);
channel.getConfig().setConnectTimeoutMillis(settings.getAsInt("http.client.timeout", 5000));
httpAction.execute(httpInvocationContext, listener);
}
}
示例2: doExecute
import org.elasticsearch.action.Action; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> void doExecute(Action<Request, Response, RequestBuilder> action, Request request, ActionListener<Response> listener) {
ActionEntry entry = actionMap.get(action.name());
if (entry == null) {
throw new IllegalStateException("no action entry for " + action.name());
}
HttpAction<Request, Response> httpAction = entry.httpAction;
if (httpAction == null) {
throw new IllegalStateException("failed to find action [" + action + "] to execute");
}
HttpInvocationContext<Request, Response> httpInvocationContext = new HttpInvocationContext(httpAction, listener, new LinkedList<>(), request);
try {
httpInvocationContext.httpRequest = httpAction.createHttpRequest(this.url, request);
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
ChannelFuture future = bootstrap.connect(new InetSocketAddress(url.getHost(), url.getPort()));
future.awaitUninterruptibly();
if (!future.isSuccess()) {
bootstrap.releaseExternalResources();
logger.error("can't connect to {}", url);
} else {
Channel channel = future.getChannel();
httpInvocationContext.setChannel(channel);
contextMap.put(channel, httpInvocationContext);
channel.getConfig().setConnectTimeoutMillis(settings.getAsInt("http.client.timeout", 5000));
httpAction.execute(httpInvocationContext, listener);
}
}