本文整理匯總了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();
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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());
}
示例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);
}
示例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() + ".");
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}