當前位置: 首頁>>代碼示例>>Java>>正文


Java Clock類代碼示例

本文整理匯總了Java中com.codahale.metrics.Clock的典型用法代碼示例。如果您正苦於以下問題:Java Clock類的具體用法?Java Clock怎麽用?Java Clock使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Clock類屬於com.codahale.metrics包,在下文中一共展示了Clock類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: DecayingEstimatedHistogramReservoir

import com.codahale.metrics.Clock; //導入依賴的package包/類
@VisibleForTesting
DecayingEstimatedHistogramReservoir(boolean considerZeroes, int bucketCount, Clock clock)
{
    if (bucketCount == DEFAULT_BUCKET_COUNT)
    {
        if (considerZeroes == true)
        {
            bucketOffsets = DEFAULT_WITH_ZERO_BUCKET_OFFSETS;
        }
        else
        {
            bucketOffsets = DEFAULT_WITHOUT_ZERO_BUCKET_OFFSETS;
        }
    }
    else
    {
        bucketOffsets = EstimatedHistogram.newOffsets(bucketCount, considerZeroes);
    }
    decayingBuckets = new AtomicLongArray(bucketOffsets.length + 1);
    buckets = new AtomicLongArray(bucketOffsets.length + 1);
    this.clock = clock;
    decayLandmark = clock.getTime();
}
 
開發者ID:Netflix,項目名稱:sstable-adaptor,代碼行數:24,代碼來源:DecayingEstimatedHistogramReservoir.java

示例2: onResponseReceived

import com.codahale.metrics.Clock; //導入依賴的package包/類
public void onResponseReceived(HttpRequest request, HttpResponse response) {
  Long startTime = removeObjectProperty(request, START_TIME_PROPERTY_NAME);
  if (startTime == null) {
    return;
  }

  long t = Clock.defaultClock().getTick() - startTime;

  String method = request.getRequestLine().getMethod();
  int statusCode = response.getStatusLine().getStatusCode();

  String metricName = ROOT_NAME.withTags(
      "method", method,
      "status", "" + statusCode).toString();
  Timer timer = RegistryService.getMetricRegistry().timer(metricName);
  timer.update(t, TimeUnit.NANOSECONDS);

}
 
開發者ID:ApptuitAI,項目名稱:JInsight,代碼行數:19,代碼來源:HttpAsyncClientRuleHelper.java

示例3: onGetInputStream

import com.codahale.metrics.Clock; //導入依賴的package包/類
public void onGetInputStream(HttpURLConnection urlConnection, int statusCode) {
  Long startTime = removeObjectProperty(urlConnection, START_TIME_PROPERTY_NAME);
  if (startTime == null) {
    return;
  }

  long t = Clock.defaultClock().getTick() - startTime;
  String method = urlConnection.getRequestMethod();
  String status = "" + statusCode;
  Timer timer = timers.computeIfAbsent(status + method, s -> {
    TagEncodedMetricName metricName = ROOT_NAME.withTags(
        "method", method,
        "status", status);
    return getTimer(metricName);
  });

  timer.update(t, TimeUnit.NANOSECONDS);
}
 
開發者ID:ApptuitAI,項目名稱:JInsight,代碼行數:19,代碼來源:UrlConnectionRuleHelper.java

示例4: ElasticsearchReporter

import com.codahale.metrics.Clock; //導入依賴的package包/類
private ElasticsearchReporter(MetricRegistry registry, MetricFilter filter, TimeUnit rateUnit,
		TimeUnit durationUnit, String host, String port, String indexName, String timestampField) {

	super(registry, "elasticsearch-reporter", filter, rateUnit, durationUnit);

	this.clock = Clock.defaultClock();
	this.connector = new ElasticsearchConnector(host, port, indexName);
	this.timestampField = timestampField;
	this.timestampFormat = new SimpleDateFormat(timeStampString);
	this.localhost = Utils.localHostName();

	jsonFactory = new JsonFactory();

	indexInitialized = connector.addDefaultMappings();
	if (!indexInitialized) {
		LOGGER.warn("Failed to initialize Elasticsearch index '" + indexName + "' on " + host + ":" + port);
	}
}
 
開發者ID:ibmruntimes,項目名稱:spelk,代碼行數:19,代碼來源:ElasticsearchReporter.java

示例5: HawkularReporter

import com.codahale.metrics.Clock; //導入依賴的package包/類
HawkularReporter(MetricRegistry registry,
                 HawkularHttpClient hawkularClient,
                 Optional<String> prefix,
                 MetricsDecomposer decomposer,
                 MetricsTagger tagger,
                 TimeUnit rateUnit,
                 TimeUnit durationUnit,
                 MetricFilter filter) {
    super(registry, "hawkular-reporter", filter, rateUnit, durationUnit);

    this.prefix = prefix;
    this.clock = Clock.defaultClock();
    this.hawkularClient = hawkularClient;
    this.decomposer = decomposer;
    this.tagger = tagger;
}
 
開發者ID:hawkular,項目名稱:hawkular-dropwizard-reporter,代碼行數:17,代碼來源:HawkularReporter.java

示例6: testBasic

import com.codahale.metrics.Clock; //導入依賴的package包/類
@Test
public void testBasic() throws Exception {
  FileUtil.removeIfExist("build/ServerLogMetricPlugin", false);
  
  YaraServiceImpl yaraService = new YaraServiceImpl() ;
  server.getServiceRegistry().register(YaraService.newReflectiveBlockingService(yaraService));
  
  MetricRegistry server1 = createMetricRegistry("server1") ;
  MetricRegistry server2 = createMetricRegistry("server2") ;
  
  Random rand = new Random() ;
  for(int i = 0; i < 100000; i++) {
    long timestamp = Clock.defaultClock().getTick() ;
    
    server1.counter("counter").incr() ;
    server1.timer("timer").update(timestamp, rand.nextInt(1000)) ;
    
    server2.counter("counter").incr() ;
    server2.timer("timer").update(timestamp, rand.nextInt(1000)) ;
  }
  Thread.sleep(6000);
  new ClusterMetricPrinter().print(yaraService.getClusterMetricRegistry()); 
}
 
開發者ID:DemandCube,項目名稱:NeverwinterDP-Commons,代碼行數:24,代碼來源:ServerLogMetricForwarderUnitTest.java

示例7: StorageReporter

import com.codahale.metrics.Clock; //導入依賴的package包/類
private StorageReporter(MetricRegistry registry,
                        Locale locale,
                        Clock clock,
                        TimeZone timeZone,
                        TimeUnit rateUnit,
                        TimeUnit durationUnit,
                        MetricFilter filter, StorageAdapter storageAdapter) {
    super(registry, "storage-reporter", filter, rateUnit, durationUnit);
    this.locale = locale;
    this.clock = clock;
    this.storageAdapter = storageAdapter;
    this.dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT,
            DateFormat.MEDIUM,
            locale);
    dateFormat.setTimeZone(timeZone);
}
 
開發者ID:hawkular,項目名稱:wildfly-monitor,代碼行數:17,代碼來源:StorageReporter.java

示例8: ReporterV08

import com.codahale.metrics.Clock; //導入依賴的package包/類
public ReporterV08(MetricRegistry registry,
		Influxdb influxdb,
		Clock clock,
		String prefix,
		TimeUnit rateUnit,
		TimeUnit durationUnit,
		MetricFilter filter,
		boolean skipIdleMetrics,
		ScheduledExecutorService executor) {
	super(registry, "influxdb-reporter", filter, rateUnit, durationUnit, executor);
	this.skipIdleMetrics = skipIdleMetrics;
	this.previousValues = new TreeMap<String, Long>();
	this.influxdb = influxdb;
	this.clock = clock;
	this.prefix = (prefix == null) ? "" : (prefix.trim() + ".");
}
 
開發者ID:davidB,項目名稱:metrics-influxdb,代碼行數:17,代碼來源:ReporterV08.java

示例9: ElasticsearchReporter

import com.codahale.metrics.Clock; //導入依賴的package包/類
protected ElasticsearchReporter(MetricRegistry registry, Clock clock,
        String elasticsearchIndexPrefix, String timestampFieldName,
        String metricPrefix, TimeUnit rateUnit, TimeUnit durationUnit,
        MetricFilter filter) {
    super(registry, "elasticsearch-reporter", filter, rateUnit,
            durationUnit);
    this.clock = clock;
    this.metricPrefix = metricPrefix;
    this.timestampFieldName = timestampFieldName;

    if (elasticsearchIndexPrefix.endsWith("-")) {
        this.elasticsearchIndexPrefix = elasticsearchIndexPrefix;
    } else {
        this.elasticsearchIndexPrefix = elasticsearchIndexPrefix + "-";
    }
    jsonFactory = new JsonFactory();
}
 
開發者ID:tomcashman,項目名稱:metrics-elasticsearch,代碼行數:18,代碼來源:ElasticsearchReporter.java

示例10: setUp

import com.codahale.metrics.Clock; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
	httpClient = mock(HttpClient.class);
	Clock clock = mock(Clock.class);
	timestamp = System.currentTimeMillis();
	when(clock.getTime()).thenReturn(timestamp);
	final CorePlugin corePlugin = mock(CorePlugin.class);
	when(corePlugin.getInfluxDbUrl()).thenReturn(new URL("http://localhost:8086"));
	when(corePlugin.getInfluxDbDb()).thenReturn("stm");
	influxDbReporter = InfluxDbReporter.forRegistry(new Metric2Registry(), corePlugin)
			.convertRatesTo(TimeUnit.SECONDS)
			.convertDurationsTo(DURATION_UNIT)
			.globalTags(singletonMap("app", "test"))
			.httpClient(httpClient)
			.clock(clock)
			.build();
}
 
開發者ID:stagemonitor,項目名稱:stagemonitor,代碼行數:18,代碼來源:InfluxDbReporterTest.java

示例11: AsyncRequestLog

import com.codahale.metrics.Clock; //導入依賴的package包/類
public AsyncRequestLog(Clock clock,
                       AppenderAttachableImpl<ILoggingEvent> appenders,
                       final TimeZone timeZone,
                       List<String> cookies) {
    this.clock = clock;
    this.cookies = cookies;
    this.queue = new LinkedBlockingQueue<String>();
    this.dispatcher = new Dispatcher();
    this.dispatchThread = new Thread(dispatcher);
    dispatchThread.setName("async-request-log-dispatcher-" + THREAD_COUNTER.incrementAndGet());
    dispatchThread.setDaemon(true);

    this.dateCache = new ThreadLocal<DateCache>() {
        @Override
        protected DateCache initialValue() {
            final DateCache cache = new DateCache("dd/MMM/yyyy:HH:mm:ss Z", Locale.US);
            cache.setTimeZoneID(timeZone.getID());
            return cache;
        }
    };

    this.appenders = appenders;
}
 
開發者ID:wotifgroup,項目名稱:grails-lightweight-deploy,代碼行數:24,代碼來源:AsyncRequestLog.java

示例12: configureExternalHttpsConnector

import com.codahale.metrics.Clock; //導入依賴的package包/類
private AbstractConnector configureExternalHttpsConnector() {
    logger.info("Creating https connector");

    final SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setCertAlias(getConfiguration().getSslConfiguration().getKeyStoreAlias());
    sslContextFactory.setKeyStorePath(getConfiguration().getSslConfiguration().getKeyStorePath());
    sslContextFactory.setKeyStorePassword(getConfiguration().getSslConfiguration().getKeyStorePassword());

    final Integer port = getConfiguration().getSslConfiguration().getPort() != null ?
            getConfiguration().getSslConfiguration().getPort() :
            getConfiguration().getPort();

    final InstrumentedSslSocketConnector connector = new InstrumentedSslSocketConnector(
            this.metricRegistry,
            port,
            sslContextFactory,
            Clock.defaultClock());
    connector.setName(EXTERNAL_HTTPS_CONNECTOR_NAME);

    return connector;
}
 
開發者ID:wotifgroup,項目名稱:grails-lightweight-deploy,代碼行數:22,代碼來源:ExternalConnectorFactory.java

示例13: onTransactionExec

import com.codahale.metrics.Clock; //導入依賴的package包/類
public void onTransactionExec(Transaction tx) {
  Long startTime = removeObjectProperty(tx, TRANSACTION_START_TIME_PROP_NAME);
  if (startTime == null) {
    return;
  }

  long t = Clock.defaultClock().getTick() - startTime;
  txExecTimer.update(t, TimeUnit.NANOSECONDS);
}
 
開發者ID:ApptuitAI,項目名稱:JInsight,代碼行數:10,代碼來源:JedisRuleHelper.java

示例14: onTransactionDiscard

import com.codahale.metrics.Clock; //導入依賴的package包/類
public void onTransactionDiscard(Transaction tx) {
  Long startTime = removeObjectProperty(tx, TRANSACTION_START_TIME_PROP_NAME);
  if (startTime == null) {
    return;
  }
  long t = Clock.defaultClock().getTick() - startTime;
  txDiscardTimer.update(t, TimeUnit.NANOSECONDS);
}
 
開發者ID:ApptuitAI,項目名稱:JInsight,代碼行數:9,代碼來源:JedisRuleHelper.java

示例15: onPipelineSync

import com.codahale.metrics.Clock; //導入依賴的package包/類
public void onPipelineSync(Pipeline pipeline) {
  Long startTime = removeObjectProperty(pipeline, TRANSACTION_START_TIME_PROP_NAME);
  if (startTime == null) {
    return;
  }

  long t = Clock.defaultClock().getTick() - startTime;
  pipelineSyncTimer.update(t, TimeUnit.NANOSECONDS);
}
 
開發者ID:ApptuitAI,項目名稱:JInsight,代碼行數:10,代碼來源:JedisRuleHelper.java


注:本文中的com.codahale.metrics.Clock類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。