當前位置: 首頁>>代碼示例>>Java>>正文


Java ElasticsearchException.addHeader方法代碼示例

本文整理匯總了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;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:17,代碼來源:CompoundProcessor.java

示例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);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:13,代碼來源:ConfigurationUtils.java

示例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")));
        }
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:38,代碼來源:TransportMasterNodeActionTests.java


注:本文中的org.elasticsearch.ElasticsearchException.addHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。