本文整理匯總了Java中org.elasticsearch.ElasticsearchException.addHeader方法的典型用法代碼示例。如果您正苦於以下問題:Java ElasticsearchException.addHeader方法的具體用法?Java ElasticsearchException.addHeader怎麽用?Java ElasticsearchException.addHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.elasticsearch.ElasticsearchException
的用法示例。
在下文中一共展示了ElasticsearchException.addHeader方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: newCompoundProcessorException
import org.elasticsearch.ElasticsearchException; //導入方法依賴的package包/類
private ElasticsearchException newCompoundProcessorException(Exception e, String processorType, String processorTag) {
if (e instanceof ElasticsearchException && ((ElasticsearchException)e).getHeader("processor_type") != null) {
return (ElasticsearchException) e;
}
ElasticsearchException exception = new ElasticsearchException(new IllegalArgumentException(e));
if (processorType != null) {
exception.addHeader("processor_type", processorType);
}
if (processorTag != null) {
exception.addHeader("processor_tag", processorTag);
}
return exception;
}
示例2: addHeadersToException
import org.elasticsearch.ElasticsearchException; //導入方法依賴的package包/類
private static void addHeadersToException(ElasticsearchException exception, String processorType,
String processorTag, String propertyName) {
if (processorType != null) {
exception.addHeader("processor_type", processorType);
}
if (processorTag != null) {
exception.addHeader("processor_tag", processorTag);
}
if (propertyName != null) {
exception.addHeader("property_name", propertyName);
}
}
示例3: testDelegateToFailingMaster
import org.elasticsearch.ElasticsearchException; //導入方法依賴的package包/類
public void testDelegateToFailingMaster() throws ExecutionException, InterruptedException {
boolean failsWithConnectTransportException = randomBoolean();
Request request = new Request().masterNodeTimeout(TimeValue.timeValueSeconds(failsWithConnectTransportException ? 60 : 0));
setState(clusterService, ClusterStateCreationUtils.state(localNode, remoteNode, allNodes));
PlainActionFuture<Response> listener = new PlainActionFuture<>();
new Action(Settings.EMPTY, "testAction", transportService, clusterService, threadPool).execute(request, listener);
assertThat(transport.capturedRequests().length, equalTo(1));
CapturingTransport.CapturedRequest capturedRequest = transport.capturedRequests()[0];
assertTrue(capturedRequest.node.isMasterNode());
assertThat(capturedRequest.request, equalTo(request));
assertThat(capturedRequest.action, equalTo("testAction"));
if (failsWithConnectTransportException) {
transport.handleRemoteError(capturedRequest.requestId, new ConnectTransportException(remoteNode, "Fake error"));
assertFalse(listener.isDone());
setState(clusterService, ClusterStateCreationUtils.state(localNode, localNode, allNodes));
assertTrue(listener.isDone());
listener.get();
} else {
ElasticsearchException t = new ElasticsearchException("test");
t.addHeader("header", "is here");
transport.handleRemoteError(capturedRequest.requestId, t);
assertTrue(listener.isDone());
try {
listener.get();
fail("Expected exception but returned proper result");
} catch (ExecutionException ex) {
final Throwable cause = ex.getCause().getCause();
assertThat(cause, instanceOf(ElasticsearchException.class));
final ElasticsearchException es = (ElasticsearchException) cause;
assertThat(es.getMessage(), equalTo(t.getMessage()));
assertThat(es.getHeader("header"), equalTo(t.getHeader("header")));
}
}
}