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


Java Priority类代码示例

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


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

示例1: ensureStableCluster

import org.elasticsearch.common.Priority; //导入依赖的package包/类
protected void ensureStableCluster(int nodeCount, TimeValue timeValue, boolean local, @Nullable String viaNode) {
    if (viaNode == null) {
        viaNode = randomFrom(internalCluster().getNodeNames());
    }
    logger.debug("ensuring cluster is stable with [{}] nodes. access node: [{}]. timeout: [{}]", nodeCount, viaNode, timeValue);
    ClusterHealthResponse clusterHealthResponse = client(viaNode).admin().cluster().prepareHealth()
        .setWaitForEvents(Priority.LANGUID)
        .setWaitForNodes(Integer.toString(nodeCount))
        .setTimeout(timeValue)
        .setLocal(local)
        .setWaitForNoRelocatingShards(true)
        .get();
    if (clusterHealthResponse.isTimedOut()) {
        ClusterStateResponse stateResponse = client(viaNode).admin().cluster().prepareState().get();
        fail("failed to reach a stable cluster of [" + nodeCount + "] nodes. Tried via [" + viaNode + "]. last cluster state:\n"
            + stateResponse.getState());
    }
    assertThat(clusterHealthResponse.isTimedOut(), is(false));
    ensureFullyConnectedCluster();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:ESIntegTestCase.java

示例2: deleteIndices

import org.elasticsearch.common.Priority; //导入依赖的package包/类
public void deleteIndices(final DeleteIndexClusterStateUpdateRequest request,
        final ActionListener<ClusterStateUpdateResponse> listener) {
    if (request.indices() == null || request.indices().length == 0) {
        throw new IllegalArgumentException("Index name is required");
    }

    clusterService.submitStateUpdateTask("delete-index " + Arrays.toString(request.indices()),
        new AckedClusterStateUpdateTask<ClusterStateUpdateResponse>(Priority.URGENT, request, listener) {

        @Override
        protected ClusterStateUpdateResponse newResponse(boolean acknowledged) {
            return new ClusterStateUpdateResponse(acknowledged);
        }

        @Override
        public ClusterState execute(final ClusterState currentState) {
            return deleteIndices(currentState, Sets.newHashSet(request.indices()));
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:MetaDataDeleteIndexService.java

示例3: wrapRunnable

import org.elasticsearch.common.Priority; //导入依赖的package包/类
@Override
protected Runnable wrapRunnable(Runnable command) {
    if (command instanceof PrioritizedRunnable) {
        if ((command instanceof TieBreakingPrioritizedRunnable)) {
            return command;
        }
        Priority priority = ((PrioritizedRunnable) command).priority();
        return new TieBreakingPrioritizedRunnable(super.wrapRunnable(command), priority, insertionOrder.incrementAndGet());
    } else if (command instanceof PrioritizedFutureTask) {
        return command;
    } else { // it might be a callable wrapper...
        if (command instanceof TieBreakingPrioritizedRunnable) {
            return command;
        }
        return new TieBreakingPrioritizedRunnable(super.wrapRunnable(command), Priority.NORMAL, insertionOrder.incrementAndGet());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:PrioritizedEsThreadPoolExecutor.java

示例4: readFrom

import org.elasticsearch.common.Priority; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    int size = in.readVInt();
    if (size == 0) {
        indices = Strings.EMPTY_ARRAY;
    } else {
        indices = new String[size];
        for (int i = 0; i < indices.length; i++) {
            indices[i] = in.readString();
        }
    }
    timeout = new TimeValue(in);
    if (in.readBoolean()) {
        waitForStatus = ClusterHealthStatus.fromValue(in.readByte());
    }
    waitForNoRelocatingShards = in.readBoolean();
    waitForActiveShards = ActiveShardCount.readFrom(in);
    waitForNodes = in.readString();
    if (in.readBoolean()) {
        waitForEvents = Priority.readFrom(in);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:ClusterHealthRequest.java

示例5: testUpdateMappingWithoutTypeMultiObjects

import org.elasticsearch.common.Priority; //导入依赖的package包/类
public void testUpdateMappingWithoutTypeMultiObjects() throws Exception {
    client().admin().indices().prepareCreate("test")
            .setSettings(
                    Settings.builder()
                            .put("index.number_of_shards", 1)
                            .put("index.number_of_replicas", 0)
            ).execute().actionGet();
    client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();

    PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("doc")
            .setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", XContentType.JSON)
            .execute().actionGet();

    assertThat(putMappingResponse.isAcknowledged(), equalTo(true));

    GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("test").execute().actionGet();
    assertThat(getMappingsResponse.mappings().get("test").get("doc").source().toString(),
            equalTo("{\"doc\":{\"properties\":{\"date\":{\"type\":\"integer\"}}}}"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:UpdateMappingIntegrationIT.java

示例6: testUpdateMappingWithConflicts

import org.elasticsearch.common.Priority; //导入依赖的package包/类
public void testUpdateMappingWithConflicts() throws Exception {
    client().admin().indices().prepareCreate("test")
            .setSettings(
                    Settings.builder()
                            .put("index.number_of_shards", 2)
                            .put("index.number_of_replicas", 0)
            ).addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}", XContentType.JSON)
            .execute().actionGet();
    client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();

    try {
        client().admin().indices().preparePutMapping("test").setType("type")
                .setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"integer\"}}}}", XContentType.JSON).execute().actionGet();
        fail("Expected MergeMappingException");
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage(), containsString("mapper [body] of different type, current_type [text], merged_type [integer]"));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:UpdateMappingIntegrationIT.java

示例7: testUpdateMappingNoChanges

import org.elasticsearch.common.Priority; //导入依赖的package包/类
public void testUpdateMappingNoChanges() throws Exception {
    client().admin().indices().prepareCreate("test")
            .setSettings(
                    Settings.builder()
                            .put("index.number_of_shards", 2)
                            .put("index.number_of_replicas", 0)
            ).addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}", XContentType.JSON)
            .execute().actionGet();
    client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();

    PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("type")
            .setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}", XContentType.JSON)
            .execute().actionGet();

    //no changes, we return
    assertThat(putMappingResponse.isAcknowledged(), equalTo(true));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:UpdateMappingIntegrationIT.java

示例8: execute

import org.elasticsearch.common.Priority; //导入依赖的package包/类
public void execute(Runnable command, final ScheduledExecutorService timer, final TimeValue timeout, final Runnable timeoutCallback) {
    if (command instanceof PrioritizedRunnable) {
        command = new TieBreakingPrioritizedRunnable((PrioritizedRunnable) command, insertionOrder.incrementAndGet());
    } else if (!(command instanceof PrioritizedFutureTask)) { // it might be a callable wrapper...
        command = new TieBreakingPrioritizedRunnable(command, Priority.NORMAL, insertionOrder.incrementAndGet());
    }
    super.execute(command);
    if (timeout.nanos() >= 0) {
        if (command instanceof TieBreakingPrioritizedRunnable) {
            ((TieBreakingPrioritizedRunnable) command).scheduleTimeout(timer, timeoutCallback, timeout);
        } else {
            // We really shouldn't be here. The only way we can get here if somebody created PrioritizedFutureTask
            // and passed it to execute, which doesn't make much sense
            throw new UnsupportedOperationException("Execute with timeout is not supported for future tasks");
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:PrioritizedEsThreadPoolExecutor.java

示例9: readFrom

import org.elasticsearch.common.Priority; //导入依赖的package包/类
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    int size = in.readVInt();
    if (size == 0) {
        indices = Strings.EMPTY_ARRAY;
    } else {
        indices = new String[size];
        for (int i = 0; i < indices.length; i++) {
            indices[i] = in.readString();
        }
    }
    timeout = readTimeValue(in);
    if (in.readBoolean()) {
        waitForStatus = ClusterHealthStatus.fromValue(in.readByte());
    }
    waitForRelocatingShards = in.readInt();
    waitForActiveShards = in.readInt();
    waitForNodes = in.readString();
    if (in.readBoolean()) {
        waitForEvents = Priority.readFrom(in);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:ClusterHealthRequest.java

示例10: testJustMasterNode

import org.elasticsearch.common.Priority; //导入依赖的package包/类
public void testJustMasterNode() throws Exception {
    logger.info("--> cleaning nodes");

    logger.info("--> starting 1 master node non data");
    internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false).build());

    logger.info("--> create an index");
    client().admin().indices().prepareCreate("test").setWaitForActiveShards(ActiveShardCount.NONE).execute().actionGet();

    logger.info("--> closing master node");
    internalCluster().closeNonSharedNodes(false);

    logger.info("--> starting 1 master node non data again");
    internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false).build());

    logger.info("--> waiting for test index to be created");
    ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setIndices("test")
        .execute().actionGet();
    assertThat(health.isTimedOut(), equalTo(false));

    logger.info("--> verify we have an index");
    ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().setIndices("test").execute().actionGet();
    assertThat(clusterStateResponse.getState().metaData().hasIndex("test"), equalTo(true));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:GatewayIndexStateIT.java

示例11: testPrioritizedTasks

import org.elasticsearch.common.Priority; //导入依赖的package包/类
/**
 * Note, this test can only work as long as we have a single thread executor executing the state update tasks!
 */
public void testPrioritizedTasks() throws Exception {
    BlockingTask block = new BlockingTask(Priority.IMMEDIATE);
    clusterService.submitStateUpdateTask("test", block);
    int taskCount = randomIntBetween(5, 20);

    // will hold all the tasks in the order in which they were executed
    List<PrioritizedTask> tasks = new ArrayList<>(taskCount);
    CountDownLatch latch = new CountDownLatch(taskCount);
    for (int i = 0; i < taskCount; i++) {
        Priority priority = randomFrom(Priority.values());
        clusterService.submitStateUpdateTask("test", new PrioritizedTask(priority, latch, tasks));
    }

    block.close();
    latch.await();

    Priority prevPriority = null;
    for (PrioritizedTask task : tasks) {
        if (prevPriority == null) {
            prevPriority = task.priority();
        } else {
            assertThat(task.priority().sameOrAfter(prevPriority), is(true));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:ClusterServiceTests.java

示例12: testPriorityQueue

import org.elasticsearch.common.Priority; //导入依赖的package包/类
public void testPriorityQueue() throws Exception {
    PriorityBlockingQueue<Priority> queue = new PriorityBlockingQueue<>();
    List<Priority> priorities = Arrays.asList(Priority.values());
    Collections.shuffle(priorities, random());

    for (Priority priority : priorities) {
        queue.add(priority);
    }

    Priority prevPriority = null;
    while (!queue.isEmpty()) {
        if (prevPriority == null) {
            prevPriority = queue.poll();
        } else {
            assertThat(queue.poll().after(prevPriority), is(true));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:PrioritizedExecutorsTests.java

示例13: ensureColor

import org.elasticsearch.common.Priority; //导入依赖的package包/类
private ClusterHealthStatus ensureColor(ClusterHealthStatus clusterHealthStatus, TimeValue timeout, String... indices) {
    String color = clusterHealthStatus.name().toLowerCase(Locale.ROOT);
    String method = "ensure" + Strings.capitalize(color);

    ClusterHealthRequest healthRequest = Requests.clusterHealthRequest(indices)
        .timeout(timeout)
        .waitForStatus(clusterHealthStatus)
        .waitForEvents(Priority.LANGUID)
        .waitForNoRelocatingShards(true)
        // We currently often use ensureGreen or ensureYellow to check whether the cluster is back in a good state after shutting down
        // a node. If the node that is stopped is the master node, another node will become master and publish a cluster state where it
        // is master but where the node that was stopped hasn't been removed yet from the cluster state. It will only subsequently
        // publish a second state where the old master is removed. If the ensureGreen/ensureYellow is timed just right, it will get to
        // execute before the second cluster state update removes the old master and the condition ensureGreen / ensureYellow will
        // trivially hold if it held before the node was shut down. The following "waitForNodes" condition ensures that the node has
        // been removed by the master so that the health check applies to the set of nodes we expect to be part of the cluster.
        .waitForNodes(Integer.toString(cluster().size()));

    ClusterHealthResponse actionGet = client().admin().cluster().health(healthRequest).actionGet();
    if (actionGet.isTimedOut()) {
        logger.info("{} timed out, cluster state:\n{}\n{}",
            method,
            client().admin().cluster().prepareState().get().getState(),
            client().admin().cluster().preparePendingClusterTasks().get());
        fail("timed out waiting for " + color + " state");
    }
    assertThat("Expected at least " + clusterHealthStatus + " but got " + actionGet.getStatus(),
        actionGet.getStatus().value(), lessThanOrEqualTo(clusterHealthStatus.value()));
    logger.debug("indices {} are {}", indices.length == 0 ? "[_all]" : indices, color);
    return actionGet.getStatus();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:ESIntegTestCase.java

示例14: ensureGreen

import org.elasticsearch.common.Priority; //导入依赖的package包/类
/**
 * Ensures the cluster has a green state via the cluster health API. This method will also wait for relocations.
 * It is useful to ensure that all action on the cluster have finished and all shards that were currently relocating
 * are now allocated and started.
 *
 * @param timeout time out value to set on {@link org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest}
 */
public ClusterHealthStatus ensureGreen(TimeValue timeout, String... indices) {
    ClusterHealthResponse actionGet = client().admin().cluster()
            .health(Requests.clusterHealthRequest(indices).timeout(timeout).waitForGreenStatus().waitForEvents(Priority.LANGUID)
                    .waitForNoRelocatingShards(true)).actionGet();
    if (actionGet.isTimedOut()) {
        logger.info("ensureGreen timed out, cluster state:\n{}\n{}", client().admin().cluster().prepareState().get().getState(),
            client().admin().cluster().preparePendingClusterTasks().get());
        assertThat("timed out waiting for green state", actionGet.isTimedOut(), equalTo(false));
    }
    assertThat(actionGet.getStatus(), equalTo(ClusterHealthStatus.GREEN));
    logger.debug("indices {} are green", indices.length == 0 ? "[_all]" : indices);
    return actionGet.getStatus();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:ESSingleNodeTestCase.java

示例15: handleJoinRequest

import org.elasticsearch.common.Priority; //导入依赖的package包/类
/**
 * processes or queues an incoming join request.
 * <p>
 * Note: doesn't do any validation. This should have been done before.
 */
public synchronized void handleJoinRequest(final DiscoveryNode node, final MembershipAction.JoinCallback callback) {
    if (electionContext != null) {
        electionContext.addIncomingJoin(node, callback);
        checkPendingJoinsAndElectIfNeeded();
    } else {
        clusterService.submitStateUpdateTask("zen-disco-node-join",
            node, ClusterStateTaskConfig.build(Priority.URGENT),
            joinTaskExecutor, new JoinTaskListener(callback, logger));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:NodeJoinController.java


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