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


Java TimeUnit.MILLISECONDS属性代码示例

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


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

示例1: testDuplicationWithinCleanUpTimeout

@Test
public void testDuplicationWithinCleanUpTimeout() throws Exception {
    final int timeout = 300;
    final int collectionSize = 1;
    DuplicationDetector instance = new DuplicationDetector(TimeUnit.MILLISECONDS, timeout, collectionSize, Executors.newSingleThreadScheduledExecutor());
    final int cleanupInterval = 100;
    instance.setCleanDelayMili(cleanupInterval);
    instance.start();
    try {
        CoapPacket packet = mock(CoapPacket.class);
        when(packet.getRemoteAddress()).thenReturn(InetSocketAddress.createUnresolved("testHost", 8080));
        when(packet.getMessageId()).thenReturn(9);

        CoapPacket firstIsDuplicated = instance.isMessageRepeated(packet);
        Thread.sleep(cleanupInterval + 1);
        CoapPacket secondIsDuplicated = instance.isMessageRepeated(packet);

        assertNull("insertion to empty duplicate check list fails", firstIsDuplicated);
        assertNotNull("second insertion within timeout with same id succeeds", secondIsDuplicated);
    } finally {
        instance.stop();
    }
}
 
开发者ID:ARMmbed,项目名称:java-coap,代码行数:23,代码来源:DuplicationDetectorTest.java

示例2: create

public HttpClientConnectionManager create(ApacheSdkHttpClientFactory configuration,
                                          AttributeMap standardOptions) {
    ConnectionSocketFactory sslsf = getPreferredSocketFactory(standardOptions);

    final PoolingHttpClientConnectionManager cm = new
            PoolingHttpClientConnectionManager(
            createSocketFactoryRegistry(sslsf),
            null,
            DefaultSchemePortResolver.INSTANCE,
            null,
            configuration.connectionTimeToLive().orElse(Defaults.CONNECTION_POOL_TTL).toMillis(),
            TimeUnit.MILLISECONDS);

    cm.setDefaultMaxPerRoute(standardOptions.get(SdkHttpConfigurationOption.MAX_CONNECTIONS));
    cm.setMaxTotal(standardOptions.get(SdkHttpConfigurationOption.MAX_CONNECTIONS));
    cm.setDefaultSocketConfig(buildSocketConfig(standardOptions));

    return cm;
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:19,代码来源:ApacheConnectionManagerFactory.java

示例3: open

@Override
    public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
        initialized = false;
        this.context = context;

        // Spout internals
        this.collector = collector;
        numUncommittedOffsets = 0;

        // Offset management
        firstPollOffsetStrategy = kafkaSpoutConfig.getFirstPollOffsetStrategy();
        // with AutoCommitMode, offset will be periodically committed in the background by Kafka consumer
//        consumerAutoCommitMode = kafkaSpoutConfig.isConsumerAutoCommitMode();
        //永远设置为false
        consumerAutoCommitMode = false;

        // Retries management
        retryService = kafkaSpoutConfig.getRetryService();

        if (!consumerAutoCommitMode) {     // If it is auto commit, no need to commit offsets manually
            commitTimer = new Timer(TIMER_DELAY_MS, kafkaSpoutConfig.getOffsetsCommitPeriodMs(), TimeUnit.MILLISECONDS);
        }
        refreshSubscriptionTimer = new Timer(TIMER_DELAY_MS, kafkaSpoutConfig.getPartitionRefreshPeriodMs(), TimeUnit.MILLISECONDS);

        acked = new HashMap<>();
        emitted = new HashSet<>();
        waitingToEmit = Collections.emptyListIterator();

        LOG.info("Kafka Spout opened with the following configuration: {}", kafkaSpoutConfig);
    }
 
开发者ID:Paleozoic,项目名称:storm_spring_boot_demo,代码行数:30,代码来源:KafkaSpout.java

示例4: toTimeUnit

/**
 * Convert a protocol buffer TimeUnit to a client TimeUnit
 * @param proto
 * @return the converted client TimeUnit
 */
public static TimeUnit toTimeUnit(final HBaseProtos.TimeUnit proto) {
  switch (proto) {
  case NANOSECONDS:
    return TimeUnit.NANOSECONDS;
  case MICROSECONDS:
    return TimeUnit.MICROSECONDS;
  case MILLISECONDS:
    return TimeUnit.MILLISECONDS;
  case SECONDS:
    return TimeUnit.SECONDS;
  case MINUTES:
    return TimeUnit.MINUTES;
  case HOURS:
    return TimeUnit.HOURS;
  case DAYS:
    return TimeUnit.DAYS;
  default:
    throw new RuntimeException("Invalid TimeUnit " + proto);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:ProtobufUtil.java

示例5: init

/**
 * Initial MiniDownloader.
 *
 * @param context
 */
public void init(Context context) {
    this.appContext = context.getApplicationContext();
    /** Create work executor. */
    this.workExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), Runtime.getRuntime().availableProcessors(), 0L, TimeUnit.MILLISECONDS, new PriorityBlockingQueue<Runnable>()) {
        @Override
        protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable) {
            if (callable instanceof CustomFutureCallable) {
                return ((CustomFutureCallable) callable).newTaskFor();
            }
            return super.newTaskFor(callable);
        }
    };
    /** Create command executor. */
    this.commandExecutor = Executors.newSingleThreadExecutor();
    /** Create and initial task manager. */
    taskManager = new TaskManager();
    taskManager.init(context);
    /** Create and start ProgressUpdater. */
    progressUpdater = new ProgressUpdater();
    progressUpdater.start();
}
 
开发者ID:xyhuangjinfu,项目名称:MiniDownloader,代码行数:26,代码来源:MiniDownloader.java

示例6: testEqualsMethodReflexivity

@Test
public void testEqualsMethodReflexivity() {
    FakeLoad child1 = new SimpleFakeLoad(5, TimeUnit.SECONDS);
    FakeLoad child2 = new SimpleFakeLoad(500, TimeUnit.MILLISECONDS);
    FakeLoad child3 = new SimpleFakeLoad(1, TimeUnit.MINUTES);

    // test reflexivity
    assertEqualsReflexivity(fakeload);


    fakeload = fakeload.lasting(300, TimeUnit.MILLISECONDS).repeat(3)
            .withCpu(50)
            .withMemory(300, MemoryUnit.MB)
            .withDiskInput(5000, MemoryUnit.BYTES);
    assertEqualsReflexivity(fakeload);



    fakeload = fakeload.lasting(30, TimeUnit.SECONDS).repeat(6)
            .withCpu(80)
            .withMemory(300, MemoryUnit.KB)
            .withDiskInput(51200, MemoryUnit.BYTES)
            .addLoad(child1).addLoad(child2).addLoad(child3);
    assertEqualsReflexivity(fakeload);

}
 
开发者ID:msigwart,项目名称:fakeload,代码行数:26,代码来源:AbstractFakeLoadTest.java

示例7: test

@Test
public void test() {
	
	int threads = 40;
	
	ThreadPoolExecutor executor = new ThreadPoolExecutor(threads, threads, 1000, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
	
	try {
		int jobs = 1000;
		int add = 1000;
		
		latch = new CountDownLatch(jobs);
		
		for (int i = 0; i < jobs; ++i) {
			executor.execute(new IncReadDecValueAsync(add));
		}
		
		try {
			latch.await();
		} catch (InterruptedException e) {
			throw new RuntimeException("Interrupted.", e);
		}
		
		log.info("Checking value, expecting 0 ...");
		
		if (value != 0) {
			testFailed("value == " + value + " != 0");
		}
		
		testOk();
	} finally {
		executor.shutdownNow();
	}
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:34,代码来源:Test10_SyncAccessToInt.java

示例8: BlockingExecutor

/**
 * Creates a BlockingExecutor which will block and prevent further
 * submission to the pool when the specified queue size has been reached.
 *
 * @param poolSize  the number of the threads in the pool
 * @param queueSize the size of the queue
 */
public BlockingExecutor(final int poolSize, final int queueSize) {
    super(poolSize, poolSize, 0L, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<Runnable>());

    // the semaphore is bounding both the number of tasks currently executing
    // and those queued up
    semaphore = new Semaphore(poolSize + queueSize);
}
 
开发者ID:MineboxOS,项目名称:tools,代码行数:15,代码来源:BlockingExecutor.java

示例9: init

@Override
public void init() throws EventException {
	//Configure the QueueController-EventService connector
	eventConnector = new QueueControllerEventConnector();
	eventConnector.setEventService(eservice);
	eventConnector.setUri(uri);

	resultHandler = new ExceptionHandler() {

		@Override
		public Logger getLogger() {
			return logger;
		}

	};

	//Set up requester to handle remote requests
	requester = eservice.createRequestor(uri,
			IQueueService.QUEUE_REQUEST_TOPIC,
			IQueueService.QUEUE_RESPONSE_TOPIC);

	long timeout = Long.getLong("org.eclipse.scanning.event.remote.queueControllerServiceTimeout", 5000);
    logger.debug("Setting timeout {} {}" , timeout , " ms");
	ResponseConfiguration conf = new ResponseConfiguration( ResponseType.ONE,
															timeout,
															TimeUnit.MILLISECONDS);
	requester.setResponseConfiguration(conf);
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:28,代码来源:_QueueControllerService.java

示例10: startMDSListenServer

private void startMDSListenServer() {

        boolean isStartMDFListener = DataConvertHelper
                .toBoolean(this.getConfigManager().getFeatureConfiguration(this.feature, "http.enable"), false);

        if (isStartMDFListener == true) {

            // start MDFListenServer
            int port = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.port"));
            int backlog = Integer
                    .parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.backlog"));
            int core = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.core"));
            int max = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.max"));
            int bqsize = Integer.parseInt(this.getConfigManager().getFeatureConfiguration(this.feature, "http.bqsize"));

            mdfListenServer = new MDFListenServer("MDFListenServer", this.feature, "mdfhandlers");

            @SuppressWarnings({ "rawtypes", "unchecked" })
            ThreadPoolExecutor exe = new ThreadPoolExecutor(core, max, 30000, TimeUnit.MILLISECONDS,
                    new ArrayBlockingQueue(bqsize));

            mdfListenServer.start(exe, port, backlog);

            if (log.isTraceEnable()) {
                log.info(this, "MDFListenServer started");
            }
        }
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:28,代码来源:MonitorAgent.java

示例11: TimeValue

public TimeValue(long millis) {
    this(millis, TimeUnit.MILLISECONDS);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:3,代码来源:TimeValue.java

示例12: StressAddMultiThreadedTest

public StressAddMultiThreadedTest() {
    queue = new ArrayBlockingQueue<>(THREADS);
    executor = new ThreadPoolExecutor(THREADS, THREADS, 100,
            TimeUnit.MILLISECONDS, queue,
            new ThreadPoolExecutor.CallerRunsPolicy());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:StressAddMultiThreadedTest.java

示例13: appNamespaceCacheScanIntervalTimeUnit

@Override
public TimeUnit appNamespaceCacheScanIntervalTimeUnit() {
  return TimeUnit.MILLISECONDS;
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:4,代码来源:AbstractBaseIntegrationTest.java

示例14: getConfigCacheExpireTimeUnit

@Override
public TimeUnit getConfigCacheExpireTimeUnit() {
  return TimeUnit.MILLISECONDS;
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:4,代码来源:DefaultConfigTest.java

示例15: StandardThreadExecutor

public StandardThreadExecutor(int coreThreads, int maxThreads, int queueCapacity,
                              ThreadFactory threadFactory) {
    this(coreThreads, maxThreads, DEFAULT_MAX_IDLE_TIME, TimeUnit.MILLISECONDS, queueCapacity,
        threadFactory);
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:5,代码来源:StandardThreadExecutor.java


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