当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionsHelper.status方法代码示例

本文整理汇总了Java中org.elasticsearch.ExceptionsHelper.status方法的典型用法代码示例。如果您正苦于以下问题:Java ExceptionsHelper.status方法的具体用法?Java ExceptionsHelper.status怎么用?Java ExceptionsHelper.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.ExceptionsHelper的用法示例。


在下文中一共展示了ExceptionsHelper.status方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: NotSerializableExceptionWrapper

import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
public NotSerializableExceptionWrapper(Throwable other) {
    super(ElasticsearchException.getExceptionName(other) +
                    ": " + other.getMessage(), other.getCause());
    this.name = ElasticsearchException.getExceptionName(other);
    this.status = ExceptionsHelper.status(other);
    setStackTrace(other.getStackTrace());
    for (Throwable otherSuppressed : other.getSuppressed()) {
        addSuppressed(otherSuppressed);
    }
    if (other instanceof ElasticsearchException) {
        ElasticsearchException ex = (ElasticsearchException) other;
        for (String key : ex.getHeaderKeys()) {
            this.addHeader(key, ex.getHeader(key));
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:NotSerializableExceptionWrapper.java

示例2: ShardSearchFailure

import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
public ShardSearchFailure(Exception e, @Nullable SearchShardTarget shardTarget) {
    final Throwable actual = ExceptionsHelper.unwrapCause(e);
    if (actual != null && actual instanceof SearchException) {
        this.shardTarget = ((SearchException) actual).shard();
    } else if (shardTarget != null) {
        this.shardTarget = shardTarget;
    }
    status = ExceptionsHelper.status(actual);
    this.reason = ExceptionsHelper.detailedMessage(e);
    this.cause = actual;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:ShardSearchFailure.java

示例3: Failure

import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
/**
 * Read from a stream.
 */
public Failure(StreamInput in) throws IOException {
    index = in.readString();
    type = in.readString();
    id = in.readOptionalString();
    cause = in.readException();
    status = ExceptionsHelper.status(cause);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:BulkItemResponse.java

示例4: testFailureToAndFromXContent

import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
public void testFailureToAndFromXContent() throws IOException {
    final XContentType xContentType = randomFrom(XContentType.values());

    int itemId = randomIntBetween(0, 100);
    String index = randomAsciiOfLength(5);
    String type = randomAsciiOfLength(5);
    String id = randomAsciiOfLength(5);
    DocWriteRequest.OpType opType = randomFrom(DocWriteRequest.OpType.values());

    final Tuple<Throwable, ElasticsearchException> exceptions = randomExceptions();

    Exception bulkItemCause = (Exception) exceptions.v1();
    Failure bulkItemFailure = new Failure(index, type, id, bulkItemCause);
    BulkItemResponse bulkItemResponse = new BulkItemResponse(itemId, opType, bulkItemFailure);
    Failure expectedBulkItemFailure = new Failure(index, type, id, exceptions.v2(), ExceptionsHelper.status(bulkItemCause));
    BulkItemResponse expectedBulkItemResponse = new BulkItemResponse(itemId, opType, expectedBulkItemFailure);
    BytesReference originalBytes = toXContent(bulkItemResponse, xContentType, randomBoolean());

    // Shuffle the XContent fields
    if (randomBoolean()) {
        try (XContentParser parser = createParser(xContentType.xContent(), originalBytes)) {
            originalBytes = shuffleXContent(parser, randomBoolean()).bytes();
        }
    }

    BulkItemResponse parsedBulkItemResponse;
    try (XContentParser parser = createParser(xContentType.xContent(), originalBytes)) {
        assertEquals(XContentParser.Token.START_OBJECT, parser.nextToken());
        parsedBulkItemResponse = BulkItemResponse.fromXContent(parser, itemId);
        assertNull(parser.nextToken());
    }
    assertBulkItemResponse(expectedBulkItemResponse, parsedBulkItemResponse);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:BulkItemResponseTests.java

示例5: ShardSearchFailure

import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
public ShardSearchFailure(Throwable t, @Nullable SearchShardTarget shardTarget) {
    Throwable actual = ExceptionsHelper.unwrapCause(t);
    if (actual != null && actual instanceof SearchException) {
        this.shardTarget = ((SearchException) actual).shard();
    } else if (shardTarget != null) {
        this.shardTarget = shardTarget;
    }
    status = ExceptionsHelper.status(actual);
    this.reason = ExceptionsHelper.detailedMessage(t);
    this.cause = actual;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:ShardSearchFailure.java

示例6: doFinish

import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
private void doFinish() {
    if (finished.compareAndSet(false, true)) {
        setPhase(task, "finished");
        Releasables.close(indexShardReference);
        final ActionWriteResponse.ShardInfo.Failure[] failuresArray;
        if (!shardReplicaFailures.isEmpty()) {
            int slot = 0;
            failuresArray = new ActionWriteResponse.ShardInfo.Failure[shardReplicaFailures.size()];
            for (Map.Entry<String, Throwable> entry : shardReplicaFailures.entrySet()) {
                RestStatus restStatus = ExceptionsHelper.status(entry.getValue());
                failuresArray[slot++] = new ActionWriteResponse.ShardInfo.Failure(
                    shardId.getIndex(), shardId.getId(), entry.getKey(), entry.getValue(), restStatus, false
                );
            }
        } else {
            failuresArray = ActionWriteResponse.EMPTY;
        }
        finalResponse.setShardInfo(new ActionWriteResponse.ShardInfo(
                totalShards,
                success.get(),
                failuresArray

            )
        );
        try {
            channel.sendResponse(finalResponse);
        } catch (IOException responseException) {
            logger.warn("failed to send error message back to client for action [" + transportReplicaAction + "]", responseException);
        }
        if (logger.isTraceEnabled()) {
            logger.trace("action [{}] completed on all replicas [{}] for request [{}]", transportReplicaAction, shardId, replicaRequest);
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:35,代码来源:TransportReplicationAction.java

示例7: Failure

import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
public Failure(String index, String type, String id, Throwable t) {
    this.index = index;
    this.type = type;
    this.id = id;
    this.cause = t;
    this.status = ExceptionsHelper.status(t);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:BulkItemResponse.java

示例8: BytesRestResponse

import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
public BytesRestResponse(RestChannel channel, Exception e) throws IOException {
    this(channel, ExceptionsHelper.status(e), e);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:BytesRestResponse.java

示例9: TaskOperationFailure

import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
public TaskOperationFailure(String nodeId, long taskId, Exception e) {
    this.nodeId = nodeId;
    this.taskId = taskId;
    this.reason = e;
    status = ExceptionsHelper.status(e);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:TaskOperationFailure.java

示例10: DefaultShardOperationFailedException

import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
public DefaultShardOperationFailedException(String index, int shardId, Throwable reason) {
    this.index = index;
    this.shardId = shardId;
    this.reason = reason;
    this.status = ExceptionsHelper.status(reason);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:DefaultShardOperationFailedException.java

示例11: testToAndFromXContent

import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
public void testToAndFromXContent() throws IOException {
    XContentType xContentType = randomFrom(XContentType.values());
    boolean humanReadable = randomBoolean();

    long took = randomFrom(randomNonNegativeLong(), -1L);
    long ingestTook = randomFrom(randomNonNegativeLong(), NO_INGEST_TOOK);
    int nbBulkItems = randomIntBetween(1, 10);

    BulkItemResponse[] bulkItems = new BulkItemResponse[nbBulkItems];
    BulkItemResponse[] expectedBulkItems = new BulkItemResponse[nbBulkItems];

    for (int i = 0; i < nbBulkItems; i++) {
        DocWriteRequest.OpType opType = randomFrom(DocWriteRequest.OpType.values());

        if (frequently()) {
            Tuple<? extends DocWriteResponse, ? extends DocWriteResponse> randomDocWriteResponses = null;
            if (opType == DocWriteRequest.OpType.INDEX || opType == DocWriteRequest.OpType.CREATE) {
                randomDocWriteResponses = IndexResponseTests.randomIndexResponse();
            } else if (opType == DocWriteRequest.OpType.DELETE) {
                randomDocWriteResponses = DeleteResponseTests.randomDeleteResponse();
            } else if (opType == DocWriteRequest.OpType.UPDATE) {
                randomDocWriteResponses = UpdateResponseTests.randomUpdateResponse(xContentType);
            } else {
                fail("Test does not support opType [" + opType + "]");
            }

            bulkItems[i] = new BulkItemResponse(i, opType, randomDocWriteResponses.v1());
            expectedBulkItems[i] = new BulkItemResponse(i, opType, randomDocWriteResponses.v2());
        } else {
            String index = randomAsciiOfLength(5);
            String type = randomAsciiOfLength(5);
            String id = randomAsciiOfLength(5);

            Tuple<Throwable, ElasticsearchException> failures = randomExceptions();

            Exception bulkItemCause = (Exception) failures.v1();
            bulkItems[i] = new BulkItemResponse(i, opType,
                    new BulkItemResponse.Failure(index, type, id, bulkItemCause));
            expectedBulkItems[i] = new BulkItemResponse(i, opType,
                    new BulkItemResponse.Failure(index, type, id, failures.v2(), ExceptionsHelper.status(bulkItemCause)));
        }
    }

    BulkResponse bulkResponse = new BulkResponse(bulkItems, took, ingestTook);
    BytesReference originalBytes = toXContent(bulkResponse, xContentType, humanReadable);

    if (randomBoolean()) {
        try (XContentParser parser = createParser(xContentType.xContent(), originalBytes)) {
            originalBytes = shuffleXContent(parser, randomBoolean()).bytes();
        }
    }

    BulkResponse parsedBulkResponse;
    try (XContentParser parser = createParser(xContentType.xContent(), originalBytes)) {
        parsedBulkResponse = BulkResponse.fromXContent(parser);
        assertNull(parser.nextToken());
    }

    assertEquals(took, parsedBulkResponse.getTookInMillis());
    assertEquals(ingestTook, parsedBulkResponse.getIngestTookInMillis());
    assertEquals(expectedBulkItems.length, parsedBulkResponse.getItems().length);

    for (int i = 0; i < expectedBulkItems.length; i++) {
        assertBulkItemResponse(expectedBulkItems[i], parsedBulkResponse.getItems()[i]);
    }

    BytesReference finalBytes = toXContent(parsedBulkResponse, xContentType, humanReadable);
    BytesReference expectedFinalBytes = toXContent(parsedBulkResponse, xContentType, humanReadable);
    assertToXContentEquivalent(expectedFinalBytes, finalBytes, xContentType);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:71,代码来源:BulkResponseTests.java

示例12: BytesRestResponse

import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
public BytesRestResponse(RestChannel channel, Throwable t) throws IOException {
    this(channel, ExceptionsHelper.status(t), t);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:4,代码来源:BytesRestResponse.java

示例13: TaskOperationFailure

import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
public TaskOperationFailure(String nodeId, long taskId, Throwable t) {
    this.nodeId = nodeId;
    this.taskId = taskId;
    this.reason = t;
    status = ExceptionsHelper.status(t);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:7,代码来源:TaskOperationFailure.java

示例14: DefaultShardOperationFailedException

import org.elasticsearch.ExceptionsHelper; //导入方法依赖的package包/类
public DefaultShardOperationFailedException(String index, int shardId, Throwable t) {
    this.index = index;
    this.shardId = shardId;
    this.reason = t;
    status = ExceptionsHelper.status(t);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:7,代码来源:DefaultShardOperationFailedException.java


注:本文中的org.elasticsearch.ExceptionsHelper.status方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。