本文整理了Java中io.opencensus.common.Duration.compareTo()
方法的一些代码示例,展示了Duration.compareTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Duration.compareTo()
方法的具体详情如下:
包路径:io.opencensus.common.Duration
类名称:Duration
方法名:compareTo
[英]Compares this Duration to the specified Duration.
[中]将此持续时间与指定的持续时间进行比较。
代码示例来源:origin: census-instrumentation/opencensus-java
IntervalBucket(Timestamp start, Duration duration, Aggregation aggregation, Measure measure) {
this.start = checkNotNull(start, "Start");
this.duration = checkNotNull(duration, "Duration");
checkArgument(duration.compareTo(ZERO) > 0, "Duration must be positive");
this.aggregation = checkNotNull(aggregation, "Aggregation");
this.measure = checkNotNull(measure, "measure");
}
代码示例来源:origin: io.opencensus/opencensus-impl-core
IntervalBucket(Timestamp start, Duration duration, Aggregation aggregation, Measure measure) {
this.start = checkNotNull(start, "Start");
this.duration = checkNotNull(duration, "Duration");
checkArgument(duration.compareTo(ZERO) > 0, "Duration must be positive");
this.aggregation = checkNotNull(aggregation, "Aggregation");
this.measure = checkNotNull(measure, "measure");
}
代码示例来源:origin: census-instrumentation/opencensus-java
private OcAgentMetricsExporter(
String endPoint,
Boolean useInsecure,
String serviceName,
Duration exportInterval,
Duration retryInterval,
MetricProducerManager metricProducerManager) {
checkArgument(exportInterval.compareTo(ZERO) > 0, "Duration must be positive");
checkArgument(retryInterval.compareTo(ZERO) > 0, "Duration must be positive");
OcAgentMetricsExporterWorker worker =
new OcAgentMetricsExporterWorker(
endPoint,
useInsecure,
exportInterval,
retryInterval,
serviceName,
metricProducerManager);
workerThread = new Thread(worker);
workerThread.setDaemon(true);
workerThread.setName("OcAgentMetricsExporterWorker");
}
}
代码示例来源:origin: census-instrumentation/opencensus-java
double getFraction(Timestamp now) {
Duration elapsedTime = now.subtractTimestamp(start);
checkArgument(
elapsedTime.compareTo(ZERO) >= 0 && elapsedTime.compareTo(duration) < 0,
"This bucket must be current.");
return ((double) elapsedTime.toMillis()) / duration.toMillis();
}
代码示例来源:origin: io.opencensus/opencensus-impl-core
double getFraction(Timestamp now) {
Duration elapsedTime = now.subtractTimestamp(start);
checkArgument(
elapsedTime.compareTo(ZERO) >= 0 && elapsedTime.compareTo(duration) < 0,
"This bucket must be current.");
return ((double) elapsedTime.toMillis()) / duration.toMillis();
}
代码示例来源:origin: census-instrumentation/opencensus-java
/**
* Constructs an interval {@code AggregationWindow} that has a finite explicit {@code
* Duration}.
*
* <p>The {@code Duration} should be able to round to milliseconds. Currently interval window
* cannot have smaller {@code Duration} such as microseconds or nanoseconds.
*
* @return an interval {@code AggregationWindow}.
* @since 0.8
*/
public static Interval create(Duration duration) {
Utils.checkArgument(duration.compareTo(ZERO) > 0, "Duration must be positive");
return new AutoValue_View_AggregationWindow_Interval(duration);
}
代码示例来源:origin: census-instrumentation/opencensus-java
/**
* Builds a new {@link SignalFxStatsConfiguration} with current settings.
*
* @return a {@code SignalFxStatsConfiguration}.
* @since 0.11
*/
public SignalFxStatsConfiguration build() {
SignalFxStatsConfiguration config = autoBuild();
Preconditions.checkArgument(
!Strings.isNullOrEmpty(config.getToken()), "Invalid SignalFx token");
Preconditions.checkArgument(
config.getExportInterval().compareTo(ZERO) > 0, "Interval duration must be positive");
return config;
}
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/**
* Constructs an interval {@code AggregationWindow} that has a finite explicit {@code
* Duration}.
*
* <p>The {@code Duration} should be able to round to milliseconds. Currently interval window
* cannot have smaller {@code Duration} such as microseconds or nanoseconds.
*
* @return an interval {@code AggregationWindow}.
*/
public static Interval create(Duration duration) {
checkArgument(duration.compareTo(ZERO) > 0, "Duration must be positive");
return new AutoValue_View_AggregationWindow_Interval(duration);
}
代码示例来源:origin: census-instrumentation/opencensus-java
/**
* Creates a new {@link IntervalMetricReader}.
*
* @param metricExporter the {@link MetricExporter} to be called after.
* @param metricReader the {@link MetricReader} to be used to read metrics.
* @param options the {@link Options} for the new {@link IntervalMetricReader}.
* @return a new {@link IntervalMetricReader}.
* @since 0.19
*/
public static IntervalMetricReader create(
MetricExporter metricExporter, MetricReader metricReader, Options options) {
checkNotNull(options, "options");
Duration exportInterval = checkNotNull(options.getExportInterval(), "exportInterval");
checkArgument(exportInterval.compareTo(ZERO) > 0, "Export interval must be positive");
return new IntervalMetricReader(
new Worker(
checkNotNull(metricExporter, "metricExporter"),
exportInterval.toMillis(),
checkNotNull(metricReader, "metricReader")));
}
代码示例来源:origin: io.opencensus/opencensus-exporter-metrics-util
/**
* Creates a new {@link IntervalMetricReader}.
*
* @param metricExporter the {@link MetricExporter} to be called after.
* @param metricReader the {@link MetricReader} to be used to read metrics.
* @param options the {@link Options} for the new {@link IntervalMetricReader}.
* @return a new {@link IntervalMetricReader}.
* @since 0.19
*/
public static IntervalMetricReader create(
MetricExporter metricExporter, MetricReader metricReader, Options options) {
checkNotNull(options, "options");
Duration exportInterval = checkNotNull(options.getExportInterval(), "exportInterval");
checkArgument(exportInterval.compareTo(ZERO) > 0, "Export interval must be positive");
return new IntervalMetricReader(
new Worker(
checkNotNull(metricExporter, "metricExporter"),
exportInterval.toMillis(),
checkNotNull(metricReader, "metricReader")));
}
代码示例来源:origin: census-instrumentation/opencensus-java
@Test
public void duration_CompareLength() {
assertThat(Duration.create(0, 0).compareTo(Duration.create(0, 0))).isEqualTo(0);
assertThat(Duration.create(24, 42).compareTo(Duration.create(24, 42))).isEqualTo(0);
assertThat(Duration.create(-24, -42).compareTo(Duration.create(-24, -42))).isEqualTo(0);
assertThat(Duration.create(25, 42).compareTo(Duration.create(24, 42))).isEqualTo(1);
assertThat(Duration.create(24, 45).compareTo(Duration.create(24, 42))).isEqualTo(1);
assertThat(Duration.create(24, 42).compareTo(Duration.create(25, 42))).isEqualTo(-1);
assertThat(Duration.create(24, 42).compareTo(Duration.create(24, 45))).isEqualTo(-1);
assertThat(Duration.create(-24, -45).compareTo(Duration.create(-24, -42))).isEqualTo(-1);
assertThat(Duration.create(-24, -42).compareTo(Duration.create(-25, -42))).isEqualTo(1);
assertThat(Duration.create(24, 42).compareTo(Duration.create(-24, -42))).isEqualTo(1);
}
内容来源于网络,如有侵权,请联系作者删除!