• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Delta类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.boot.actuate.metrics.writer.Delta的典型用法代码示例。如果您正苦于以下问题:Java Delta类的具体用法?Java Delta怎么用?Java Delta使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Delta类属于org.springframework.boot.actuate.metrics.writer包,在下文中一共展示了Delta类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: increment

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Override
public void increment(Delta<?> delta) {
	final String metricName = delta.getName();
	final int amount = delta.getValue().intValue();
	final Date timestamp = delta.getTimestamp();
	this.metrics.update(metricName, new Callback<Metric<?>>() {
		@Override
		public Metric<?> modify(Metric<?> current) {
			if (current != null) {
				Metric<? extends Number> metric = current;
				return new Metric<Long>(metricName,
						metric.increment(amount).getValue(), timestamp);
			}
			else {
				return new Metric<Long>(metricName, Long.valueOf(amount), timestamp);
			}
		}
	});
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:InMemoryMetricRepository.java


示例2: increment

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void increment() {
	this.repository.increment("foo", new Delta<Number>("foo.bar", 1));
	this.repository.increment("foo", new Delta<Number>("foo.bar", 2));
	this.repository.increment("foo", new Delta<Number>("foo.spam", 1));
	Metric<?> bar = null;
	Set<String> names = new HashSet<String>();
	for (Metric<?> metric : this.repository.findAll("foo")) {
		names.add(metric.getName());
		if (metric.getName().equals("foo.bar")) {
			bar = metric;
		}
	}
	assertThat(names).hasSize(2).contains("foo.bar");
	assertThat(bar.getValue()).isEqualTo(3d);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:RedisMultiMetricRepositoryTests.java


示例3: counterWithGaugeWriter

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void counterWithGaugeWriter() throws Exception {
	SimpleGaugeWriter writer = new SimpleGaugeWriter();
	MetricCopyExporter exporter = new MetricCopyExporter(this.reader, writer);
	try {
		this.reader.increment(new Delta<Number>("counter.foo", 2));
		exporter.export();
		this.reader.increment(new Delta<Number>("counter.foo", 3));
		exporter.export();
		exporter.flush();
		assertThat(writer.getValue().getValue()).isEqualTo(5L);
	}
	finally {
		exporter.close();
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:MetricCopyExporterTests.java


示例4: increment

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Override
public void increment(Delta<?> delta) {
	final String metricName = delta.getName();
	final int amount = delta.getValue().intValue();
	final Date timestamp = delta.getTimestamp();
	this.metrics.update(metricName, new Callback<Metric<?>>() {
		@Override
		public Metric<?> modify(Metric<?> current) {
			if (current != null) {
				Metric<? extends Number> metric = current;
				return new Metric<Long>(metricName,
						metric.increment(amount).getValue(), timestamp);
			}
			else {
				return new Metric<Long>(metricName, new Long(amount), timestamp);
			}
		}
	});
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:20,代码来源:InMemoryMetricRepository.java


示例5: increment

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void increment() {
	this.repository.increment("foo", new Delta<Number>("foo.bar", 1));
	this.repository.increment("foo", new Delta<Number>("foo.bar", 2));
	this.repository.increment("foo", new Delta<Number>("foo.spam", 1));
	Metric<?> bar = null;
	Set<String> names = new HashSet<String>();
	for (Metric<?> metric : this.repository.findAll("foo")) {
		names.add(metric.getName());
		if (metric.getName().equals("foo.bar")) {
			bar = metric;
		}
	}
	assertEquals(2, names.size());
	assertTrue("Wrong names: " + names, names.contains("foo.bar"));
	assertEquals(3d, bar.getValue());
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:18,代码来源:RedisMultiMetricRepositoryTests.java


示例6: ingestMetric

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
/**
 * Ingest a raw {@link Delta}.
 *
 * @param delta Raw {@link Delta} exported by springboot
 */
public void ingestMetric(Delta<?> delta) {
    ExportedMetric exportedMetric = new ExportedMetric.Builder()
            .withName(delta.getName())
            .withValue(delta.getValue().doubleValue())
            .withTimestamp(delta.getTimestamp().getTime() / 1000L)
            .build();

    ingest(exportedMetric);
}
 
开发者ID:statful,项目名称:statful-client-springboot,代码行数:15,代码来源:StatfulClientProxy.java


示例7: shouldIngestMetricOnIncrement

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void shouldIngestMetricOnIncrement() {
    // When
    Delta delta = new Delta<>("foo", 1L);
    subject.increment(delta);

    // Then
    verify(statfulClientProxy).ingestMetric(delta);
}
 
开发者ID:statful,项目名称:statful-client-springboot,代码行数:10,代码来源:StatfulMetricWriterTest.java


示例8: shouldIngestFromDelta

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void shouldIngestFromDelta() {
    // Given
    when(statfulMetricProcessor.validate(any())).thenReturn(true);
    List<ProcessedMetric> processedMetrics = Lists.newArrayList(getProcessedMetric());
    when(statfulMetricProcessor.process(any())).thenReturn(processedMetrics);
    Delta delta = new Delta<>(METRIC_NAME, 1L);

    // When
    subject.ingestMetric(delta);

    // Then
    verify(statfulClient).put(eq(INGESTED_METRIC_NAME), eq(Double.toString(1L)), any(Tags.class), eq(null),
            eq(null), anyInt(), eq(NAMESPACE), anyInt());
}
 
开发者ID:statful,项目名称:statful-client-springboot,代码行数:16,代码来源:StatfulClientProxyTest.java


示例9: increment

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Override
public void increment(Delta<?> delta) {
	String name = delta.getName();
	String key = keyFor(name);
	trackMembership(key);
	double value = this.zSetOperations.incrementScore(key,
			delta.getValue().doubleValue());
	String raw = serialize(new Metric<Double>(name, value, delta.getTimestamp()));
	this.redisOperations.opsForValue().set(key, raw);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:RedisMetricRepository.java


示例10: increment

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Override
public void increment(String group, Delta<?> delta) {
	String groupKey = keyFor(group);
	trackMembership(groupKey);
	BoundZSetOperations<String, String> zSetOperations = this.redisOperations
			.boundZSetOps(groupKey);
	String key = keyFor(delta.getName());
	double value = zSetOperations.incrementScore(key, delta.getValue().doubleValue());
	String raw = serialize(
			new Metric<Double>(delta.getName(), value, delta.getTimestamp()));
	this.redisOperations.opsForValue().set(key, raw);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:RedisMultiMetricRepository.java


示例11: calculateDelta

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
private Delta<?> calculateDelta(Metric<?> value) {
	long delta = value.getValue().longValue();
	Long old = this.counts.replace(value.getName(), delta);
	if (old != null) {
		delta = delta - old;
	}
	else {
		this.counts.putIfAbsent(value.getName(), delta);
	}
	return new Delta<Long>(value.getName(), delta, value.getTimestamp());
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:MetricCopyExporter.java


示例12: incrementCounter

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void incrementCounter() {
	this.source.increment(new Delta<Long>("foo.bar.counter.spam", 2L));
	this.source.increment(new Delta<Long>("oof.rab.counter.spam", 3L));
	assertThat(this.reader.findOne("aggregate.counter.spam").getValue())
			.isEqualTo(5L);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:AggregateMetricReaderTests.java


示例13: countGaugesAndCounters

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void countGaugesAndCounters() {
	this.source.set(new Metric<Double>("foo.bar.spam", 2.3));
	this.source.set(new Metric<Double>("oof.rab.spam", 2.4));
	this.source.increment(new Delta<Long>("foo.bar.counter.spam", 2L));
	this.source.increment(new Delta<Long>("oof.rab.counter.spam", 3L));
	assertThat(this.reader.count()).isEqualTo(2);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:AggregateMetricReaderTests.java


示例14: setIncrementAndGet

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void setIncrementAndGet() {
	this.repository.set(new Metric<Number>("foo", 12.3));
	this.repository.increment(new Delta<Long>("foo", 3L));
	Metric<?> metric = this.repository.findOne("foo");
	assertThat(metric.getName()).isEqualTo("foo");
	assertThat(metric.getValue().doubleValue()).isEqualTo(15.3, offset(0.01));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:RedisMetricRepositoryTests.java


示例15: registeredPrefixCounted

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void registeredPrefixCounted() {
	this.repository.increment(new Delta<Number>("foo.bar", 1));
	this.repository.increment(new Delta<Number>("foo.bar", 1));
	this.repository.increment(new Delta<Number>("foo.spam", 1));
	Set<String> names = new HashSet<String>();
	for (Metric<?> metric : this.repository.findAll("foo")) {
		names.add(metric.getName());
	}
	assertThat(names).hasSize(2);
	assertThat(names.contains("foo.bar")).isTrue();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:InMemoryPrefixMetricRepositoryTests.java


示例16: prefixWithWildcard

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void prefixWithWildcard() {
	this.repository.increment(new Delta<Number>("foo.bar", 1));
	Set<String> names = new HashSet<String>();
	for (Metric<?> metric : this.repository.findAll("foo.*")) {
		names.add(metric.getName());
	}
	assertThat(names).hasSize(1);
	assertThat(names.contains("foo.bar")).isTrue();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:InMemoryPrefixMetricRepositoryTests.java


示例17: prefixWithPeriod

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void prefixWithPeriod() {
	this.repository.increment(new Delta<Number>("foo.bar", 1));
	Set<String> names = new HashSet<String>();
	for (Metric<?> metric : this.repository.findAll("foo.")) {
		names.add(metric.getName());
	}
	assertThat(names).hasSize(1);
	assertThat(names.contains("foo.bar")).isTrue();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:InMemoryPrefixMetricRepositoryTests.java


示例18: onlyRegisteredPrefixCounted

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void onlyRegisteredPrefixCounted() {
	this.repository.increment(new Delta<Number>("foo.bar", 1));
	this.repository.increment(new Delta<Number>("foobar.spam", 1));
	Set<String> names = new HashSet<String>();
	for (Metric<?> metric : this.repository.findAll("foo")) {
		names.add(metric.getName());
	}
	assertThat(names).hasSize(1);
	assertThat(names.contains("foo.bar")).isTrue();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:InMemoryPrefixMetricRepositoryTests.java


示例19: incrementGroup

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void incrementGroup() {
	this.repository.increment("foo", new Delta<Number>("foo.bar", 1));
	this.repository.increment("foo", new Delta<Number>("foo.bar", 2));
	this.repository.increment("foo", new Delta<Number>("foo.spam", 1));
	Set<String> names = new HashSet<String>();
	for (Metric<?> metric : this.repository.findAll("foo")) {
		names.add(metric.getName());
	}
	assertThat(names).hasSize(2);
	assertThat(names.contains("foo.bar")).isTrue();
	assertThat(this.repository.findOne("foo.bar").getValue()).isEqualTo(3L);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:InMemoryPrefixMetricRepositoryTests.java


示例20: counter

import org.springframework.boot.actuate.metrics.writer.Delta; //导入依赖的package包/类
@Test
public void counter() {
	this.reader.increment(new Delta<Number>("counter.foo", 2));
	this.exporter.export();
	assertThat(this.writer.count()).isEqualTo(1);
	this.reader.increment(new Delta<Number>("counter.foo", 3));
	this.exporter.export();
	this.exporter.flush();
	assertThat(this.writer.findOne("counter.foo").getValue()).isEqualTo(5L);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:MetricCopyExporterTests.java



注:本文中的org.springframework.boot.actuate.metrics.writer.Delta类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ServerAuthContext类代码示例发布时间:2022-05-22
下一篇:
Java KillJobRequestPBImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap