当前位置: 首页>>代码示例>>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;未经允许,请勿转载。