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


Java Priority.NORMAL属性代码示例

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


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

示例1: wrapRunnable

@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,代码行数:17,代码来源:PrioritizedEsThreadPoolExecutor.java

示例2: execute

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,代码行数:17,代码来源:PrioritizedEsThreadPoolExecutor.java

示例3: testGetAgeInMillis

public void testGetAgeInMillis() throws Exception {
    AtomicLong time = new AtomicLong();

    PrioritizedRunnable runnable = new PrioritizedRunnable(Priority.NORMAL, time::get) {
        @Override
        public void run() {
        }
    };
    assertEquals(0, runnable.getAgeInMillis());
    int milliseconds = randomIntBetween(1, 256);
    time.addAndGet(TimeUnit.NANOSECONDS.convert(milliseconds, TimeUnit.MILLISECONDS));
    assertEquals(milliseconds, runnable.getAgeInMillis());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:PrioritizedRunnableTests.java

示例4: testGetAgeInMillisWithRealClock

public void testGetAgeInMillisWithRealClock() throws InterruptedException {
    PrioritizedRunnable runnable = new PrioritizedRunnable(Priority.NORMAL) {
        @Override
        public void run() {
        }
    };

    long elapsed = spinForAtLeastOneMillisecond();

    // creation happened before start, so age will be at least as
    // large as elapsed
    assertThat(runnable.getAgeInMillis(), greaterThanOrEqualTo(TimeUnit.MILLISECONDS.convert(elapsed, TimeUnit.NANOSECONDS)));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:PrioritizedRunnableTests.java

示例5: ClusterStateUpdateTask

public ClusterStateUpdateTask() {
    this(Priority.NORMAL);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:3,代码来源:ClusterStateUpdateTask.java

示例6: AckedClusterStateUpdateTask

protected AckedClusterStateUpdateTask(AckedRequest request, ActionListener<Response> listener) {
    this(Priority.NORMAL, request, listener);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:3,代码来源:AckedClusterStateUpdateTask.java

示例7: LocalClusterUpdateTask

public LocalClusterUpdateTask() {
    this(Priority.NORMAL);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:3,代码来源:LocalClusterUpdateTask.java


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