Package java.util.concurrent

Examples of java.util.concurrent.TimeUnit


        if (profile != null) {
            // fallback to use values from default profile if not specified
            Integer poolSize = profile.getPoolSize() != null ? profile.getPoolSize() : defaultProfile.getPoolSize();
            Integer maxPoolSize = profile.getMaxPoolSize() != null ? profile.getMaxPoolSize() : defaultProfile.getMaxPoolSize();
            Long keepAliveTime = profile.getKeepAliveTime() != null ? profile.getKeepAliveTime() : defaultProfile.getKeepAliveTime();
            TimeUnit timeUnit = profile.getTimeUnit() != null ? profile.getTimeUnit() : defaultProfile.getTimeUnit();
            Integer maxQueueSize = profile.getMaxQueueSize() != null ? profile.getMaxQueueSize() : defaultProfile.getMaxQueueSize();
            RejectedExecutionHandler handler = profile.getRejectedExecutionHandler() != null ? profile.getRejectedExecutionHandler() : defaultProfile.getRejectedExecutionHandler();
            // create the pool
            return newThreadPool(source, name, poolSize, maxPoolSize, keepAliveTime, timeUnit, maxQueueSize, handler, false);
        } else {
View Full Code Here


   * Helper to create an invoker pool
   */
  protected static ExecutorService createInvokerPool(Args options) {
    int workerThreads = options.workerThreads;
    int stopTimeoutVal = options.stopTimeoutVal;
    TimeUnit stopTimeoutUnit = options.stopTimeoutUnit;

    LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>();
    ExecutorService invoker = new ThreadPoolExecutor(workerThreads,
      workerThreads, stopTimeoutVal, stopTimeoutUnit, queue);

View Full Code Here

    }
  }

  private static void setupGraphiteReporter(BlurConfiguration configuration) {
    long period = configuration.getLong(BLUR_SHARD_METRICS_REPORTER_PREFIX + "graphite." + "period", 5l);
    TimeUnit unit = TimeUnit.valueOf(configuration.get(BLUR_SHARD_METRICS_REPORTER_PREFIX + "graphite." + "unit",
        "SECONDS").toUpperCase());
    String host = configuration.get(BLUR_SHARD_METRICS_REPORTER_PREFIX + "graphite." + "host", "localhost");
    int port = configuration.getInt(BLUR_SHARD_METRICS_REPORTER_PREFIX + "graphite." + "port", -1);
    String prefix = configuration.get(BLUR_SHARD_METRICS_REPORTER_PREFIX + "graphite." + "prefix", "");
    GraphiteReporter.enable(period, unit, host, port, prefix);
View Full Code Here

    GraphiteReporter.enable(period, unit, host, port, prefix);
  }

  private static void setupGangliaReporter(BlurConfiguration configuration) {
    long period = configuration.getLong(BLUR_SHARD_METRICS_REPORTER_PREFIX + "ganglia." + "period", 5l);
    TimeUnit unit = TimeUnit.valueOf(configuration.get(BLUR_SHARD_METRICS_REPORTER_PREFIX + "ganglia." + "unit",
        "SECONDS").toUpperCase());
    String host = configuration.get(BLUR_SHARD_METRICS_REPORTER_PREFIX + "ganglia." + "host", "localhost");
    int port = configuration.getInt(BLUR_SHARD_METRICS_REPORTER_PREFIX + "ganglia." + "port", -1);
    String prefix = configuration.get(BLUR_SHARD_METRICS_REPORTER_PREFIX + "ganglia." + "prefix", "");
    boolean compressPackageNames = configuration.getBoolean(BLUR_SHARD_METRICS_REPORTER_PREFIX + "ganglia."
View Full Code Here

        compressPackageNames);
  }

  private static void setupCsvReporter(BlurConfiguration configuration) {
    long period = configuration.getLong(BLUR_SHARD_METRICS_REPORTER_PREFIX + "csv." + "period", 5l);
    TimeUnit unit = TimeUnit.valueOf(configuration.get(BLUR_SHARD_METRICS_REPORTER_PREFIX + "csv." + "unit", "SECONDS")
        .toUpperCase());
    File outputDir = new File(configuration.get(BLUR_SHARD_METRICS_REPORTER_PREFIX + "csv." + "outputDir", "."));
    CsvReporter.enable(outputDir, period, unit);
  }
View Full Code Here

    CsvReporter.enable(outputDir, period, unit);
  }

  private static void setupConsoleReporter(BlurConfiguration configuration) {
    long period = configuration.getLong(BLUR_SHARD_METRICS_REPORTER_PREFIX + "console." + "period", 5l);
    TimeUnit unit = TimeUnit.valueOf(configuration.get(BLUR_SHARD_METRICS_REPORTER_PREFIX + "console." + "unit",
        "SECONDS").toUpperCase());
    ConsoleReporter.enable(period, unit);
  }
View Full Code Here

            } else {
                maxPoolSize = max(calcPoolSize(maxPoolSizeMetaData), max(1, corePoolSize));
            }
            final TimeMetaData timeMetaData = metaData.getKeepAliveTime();
            final long time;
            final TimeUnit unit;
            if (timeMetaData == null) {
                time = Long.MAX_VALUE;
                unit = TimeUnit.NANOSECONDS;
            } else {
                time = max(0L, timeMetaData.getTime());
View Full Code Here

               ret = cache.remove(key);
            else
               ret = null;
         } else {
            long duration = ttl.getDurationAmount();
            TimeUnit timeUnit = ttl.getTimeUnit();
            ret = isPutIfAbsent
                  ? cache.putIfAbsent(key, value, duration, timeUnit)
                  : cache.put(key, value, duration, timeUnit);
         }
View Full Code Here

            // TODO: Can this be avoided?
            // Remove explicitly
            return cache.remove(key) != null;
         } else {
            long duration = ttl.getDurationAmount();
            TimeUnit timeUnit = ttl.getTimeUnit();
            return isConditional
                  ? cache.replace(key, oldValue, value, duration, timeUnit)
                  : cache.replace(key, value, duration, timeUnit) != null;
         }
      }
View Full Code Here

            // TODO: Can this be avoided?
            // Remove explicitly
            return cache.remove(key);
         } else {
            long duration = ttl.getDurationAmount();
            TimeUnit timeUnit = ttl.getTimeUnit();
            return cache.replace(key, value, duration, timeUnit);
         }
      }

      verifyNewValue(value);
View Full Code Here

TOP

Related Classes of java.util.concurrent.TimeUnit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.