Java Code Examples for org.influxdb.InfluxDB#ConsistencyLevel

The following examples show how to use org.influxdb.InfluxDB#ConsistencyLevel . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InfluxDBMethodInterceptorTest.java    From skywalking with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    // write
    writeArguments = new Object[] {
        "sw8", "auto_gen", InfluxDB.ConsistencyLevel.ALL, TimeUnit.SECONDS,
        "weather,location=us-midwest temperature=82 1465839830100400200"
    };
    writeArgumentTypes = new Class[] {
        String.class, String.class, InfluxDB.ConsistencyLevel.class, TimeUnit.class, String.class
    };

    // query
    queryArguments = new Object[] {
        new Query("select * from weather limit 1", "sw8")
    };
    queryArgumentTypes = new Class[] {
        Query.class
    };

    interceptor = new InfluxDBMethodInterceptor();
    when(enhancedInstance.getSkyWalkingDynamicField()).thenReturn("http://127.0.0.1:8086");
}
 
Example 2
Source File: InfluxdbReporterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testMetricReporting() throws Exception {
	String retentionPolicy = "one_hour";
	InfluxDB.ConsistencyLevel consistencyLevel = InfluxDB.ConsistencyLevel.ANY;
	MetricRegistryImpl metricRegistry = createMetricRegistry(retentionPolicy, consistencyLevel);
	try {
		String metricName = "TestCounter";
		Counter counter = registerTestMetric(metricName, metricRegistry);
		counter.inc(42);

		stubFor(post(urlPathEqualTo("/write"))
			.willReturn(aResponse()
				.withStatus(200)));

		InfluxdbReporter reporter = (InfluxdbReporter) metricRegistry.getReporters().get(0);
		reporter.report();

		verify(postRequestedFor(urlPathEqualTo("/write"))
			.withQueryParam("db", equalTo(TEST_INFLUXDB_DB))
			.withQueryParam("rp", equalTo(retentionPolicy))
			.withQueryParam("consistency", equalTo(consistencyLevel.name().toLowerCase()))
			.withHeader("Content-Type", containing("text/plain"))
			.withRequestBody(containing("taskmanager_" + metricName + ",host=" + METRIC_HOSTNAME + ",tm_id=" + METRIC_TM_ID + " count=42i")));
	} finally {
		metricRegistry.shutdown().get();
	}
}
 
Example 3
Source File: InfluxdbReporterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private MetricRegistryImpl createMetricRegistry(String retentionPolicy, InfluxDB.ConsistencyLevel consistencyLevel) {
	MetricConfig metricConfig = new MetricConfig();
	metricConfig.setProperty(InfluxdbReporterOptions.HOST.key(), "localhost");
	metricConfig.setProperty(InfluxdbReporterOptions.PORT.key(), String.valueOf(wireMockRule.port()));
	metricConfig.setProperty(InfluxdbReporterOptions.DB.key(), TEST_INFLUXDB_DB);
	metricConfig.setProperty(InfluxdbReporterOptions.RETENTION_POLICY.key(), retentionPolicy);
	metricConfig.setProperty(InfluxdbReporterOptions.CONSISTENCY.key(), consistencyLevel.name());

	return new MetricRegistryImpl(
		MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
		Collections.singletonList(ReporterSetup.forReporter("test", metricConfig, new InfluxdbReporter())));
}
 
Example 4
Source File: BatchPointTest.java    From influxdb-java with MIT License 5 votes vote down vote up
@Test
public void testEquals() throws Exception {
    // GIVEN two batchpoint objects with the same values
    Map<String, String> tags = new HashMap<>();
    tags.put("key", "value");

    InfluxDB.ConsistencyLevel consistencyLevel = InfluxDB.ConsistencyLevel.ANY;

    String db = "my database";

    List<Point> points = new ArrayList<>();
    Point p = new Point();
    p.setPrecision(TimeUnit.MILLISECONDS);
    p.setMeasurement("my measurements");
    points.add(p);

    String retentionPolicy = "autogen";

    BatchPoints b1 = new BatchPoints();
    b1.setTags(tags);
    b1.setConsistency(consistencyLevel);
    b1.setDatabase(db);
    b1.setPoints(points);
    b1.setRetentionPolicy(retentionPolicy);

    BatchPoints b2 = new BatchPoints();
    b2.setTags(tags);
    b2.setConsistency(consistencyLevel);
    b2.setDatabase(db);
    b2.setPoints(points);
    b2.setRetentionPolicy(retentionPolicy);

    // WHEN I call equals on the first with the second
    boolean equals = b1.equals(b2);

    // THEN equals returns true
    assertThat(equals).isEqualTo(true);
}
 
Example 5
Source File: ConsistencyLevelChooserValues.java    From datacollector with Apache License 2.0 4 votes vote down vote up
public ConsistencyLevelChooserValues() {
  super(InfluxDB.ConsistencyLevel.class);
}
 
Example 6
Source File: InfluxdbReporterOptions.java    From flink with Apache License 2.0 4 votes vote down vote up
static InfluxDB.ConsistencyLevel getConsistencyLevel(MetricConfig config, ConfigOption<InfluxDB.ConsistencyLevel> key) {
	return InfluxDB.ConsistencyLevel.valueOf(config.getProperty(key.key(), key.defaultValue().name()));
}
 
Example 7
Source File: BatchPointTest.java    From influxdb-java with MIT License 4 votes vote down vote up
@Test
public void testUnEquals() throws Exception {
    // GIVEN two batchpoint objects with different values
    Map<String, String> tags1 = new HashMap<>();
    tags1.put("key", "value1");

    Map<String, String> tags2 = new HashMap<>();
    tags2.put("key", "value2");

    InfluxDB.ConsistencyLevel consistencyLevel1 = InfluxDB.ConsistencyLevel.ANY;
    InfluxDB.ConsistencyLevel consistencyLevel2 = InfluxDB.ConsistencyLevel.ALL;

    String db1 = "my database 1";
    String db2 = "my database 2";

    List<Point> points = new ArrayList<>();
    Point p = new Point();
    p.setPrecision(TimeUnit.MILLISECONDS);
    p.setMeasurement("my measurements");
    points.add(p);

    String retentionPolicy1 = "autogen";
    String retentionPolicy2 = "default";

    BatchPoints b1 = new BatchPoints();
    b1.setTags(tags1);
    b1.setConsistency(consistencyLevel1);
    b1.setDatabase(db1);
    b1.setPoints(points);
    b1.setRetentionPolicy(retentionPolicy1);

    BatchPoints b2 = new BatchPoints();
    b2.setTags(tags2);
    b2.setConsistency(consistencyLevel2);
    b2.setDatabase(db2);
    b2.setPoints(points);
    b2.setRetentionPolicy(retentionPolicy2);

    // WHEN I call equals on the first with the second
    boolean equals = b1.equals(b2);

    // THEN equals returns true
    assertThat(equals).isEqualTo(false);
}