当前位置: 首页>>代码示例>>Java>>正文


Java BatchPoints类代码示例

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


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

示例1: writeToInflux

import org.influxdb.dto.BatchPoints; //导入依赖的package包/类
private void writeToInflux(Target target, InfluxDB influxDB, List<Point> pointsToWrite) {
    /**
     * build batchpoints for a single write.
     */
    try {
        BatchPoints batchPoints = BatchPoints
                 .database(target.getDatabase())
                .points(pointsToWrite.toArray(new Point[0]))
                .retentionPolicy(target.getRetentionPolicy())
                .consistency(ConsistencyLevel.ANY)
                .build();
        influxDB.write(batchPoints);
    } catch (Exception e) {
        if (target.isExposeExceptions()) {
            throw new InfluxReportException(e);
        } else {
            //Exceptions not exposed by configuration. Just log and ignore.
            logger.log(Level.WARNING, "Could not report to InfluxDB. Ignoring Exception.", e);
        }
    }
}
 
开发者ID:jenkinsci,项目名称:influxdb-plugin,代码行数:22,代码来源:InfluxDbPublisher.java

示例2: toLegacyInflux

import org.influxdb.dto.BatchPoints; //导入依赖的package包/类
public static BatchPoints toLegacyInflux(RuuviMeasurement measurement) {
    List<Point> points = new ArrayList<>();
    createAndAddLegacyFormatPointIfNotNull(points, "temperature", measurement.temperature, null, null);
    createAndAddLegacyFormatPointIfNotNull(points, "humidity", measurement.humidity, null, null);
    createAndAddLegacyFormatPointIfNotNull(points, "pressure", measurement.pressure, null, null);
    createAndAddLegacyFormatPointIfNotNull(points, "acceleration", measurement.accelerationX, "axis", "x");
    createAndAddLegacyFormatPointIfNotNull(points, "acceleration", measurement.accelerationY, "axis", "y");
    createAndAddLegacyFormatPointIfNotNull(points, "acceleration", measurement.accelerationZ, "axis", "z");
    createAndAddLegacyFormatPointIfNotNull(points, "acceleration", measurement.accelerationTotal, "axis", "total");
    createAndAddLegacyFormatPointIfNotNull(points, "batteryVoltage", measurement.batteryVoltage, null, null);
    createAndAddLegacyFormatPointIfNotNull(points, "rssi", measurement.rssi, null, null);
    return BatchPoints
            .database(Config.getInfluxDatabase())
            .tag("protocolVersion", String.valueOf(measurement.dataFormat))
            .tag("mac", measurement.mac)
            .points(points.toArray(new Point[points.size()]))
            .build();
}
 
开发者ID:Scrin,项目名称:RuuviCollector,代码行数:19,代码来源:InfluxDBConverter.java

示例3: insert

import org.influxdb.dto.BatchPoints; //导入依赖的package包/类
@Override
    public void insert() {
        InfluxDB influxDB = null;
        try {
            influxDB = InfluxDBFactory.connect(influxDBUrl);
            if (!influxDB.databaseExists(dbName)) {
                influxDB.createDatabase(dbName);
            }
            for (OffsetInfo offsetInfo : offsetInfoList) {
                String group = offsetInfo.getGroup();
                String topic = offsetInfo.getTopic();
                Long logSize = offsetInfo.getLogSize();
                Long offsets = offsetInfo.getCommittedOffset();
                Long lag = offsetInfo.getLag();
                Long timestamp = offsetInfo.getTimestamp();

                BatchPoints batchPoints = BatchPoints
                        .database(dbName)
                        .tag("group", group)
                        .tag("topic", topic)
                        .build();
                Point point = Point.measurement("offsetsConsumer")
                        .time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
//                        .time(timestamp, TimeUnit.MILLISECONDS)
                        .addField("logSize", logSize)
                        .addField("offsets", offsets)
                        .addField("lag", lag)
                        .build();
                batchPoints.point(point);
                influxDB.write(batchPoints);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (influxDB != null) {
                influxDB.close();
            }
        }

    }
 
开发者ID:dubin555,项目名称:Kafka-Insight,代码行数:41,代码来源:OffsetsInfluxDBDaoImpl.java

示例4: run

import org.influxdb.dto.BatchPoints; //导入依赖的package包/类
@Override
public void run() {
    try {
        this.batchPoints = BatchPoints
                .database(this.database)
                .retentionPolicy(this.retentionPolicy)
                .consistency(this.consistencyLevel)
                .build();
        printRegularMetrics(context);
        if (this.printVMMetrics) {
            printVmMetrics(context);
        }

        this.influxDBclient.write(batchPoints);
    } catch (Exception e) {
        LOG.error("Cannot send metrics to InfluxDB {}", e);
    }
}
 
开发者ID:jasper-zhang,项目名称:kafka-influxdb,代码行数:19,代码来源:InfluxDBReporter.java

示例5: add

import org.influxdb.dto.BatchPoints; //导入依赖的package包/类
@Test
public void add() throws Exception {
    final GroupName group = GroupName.valueOf(SimpleGroupPath.valueOf("foo", "bar"), Tags.valueOf(singletonMap("x", MetricValue.fromIntValue(17))));
    final ImmutableTimeSeriesValue tsv0 = new ImmutableTimeSeriesValue(group, singletonMap(MetricName.valueOf("met", "ric"), MetricValue.fromStrValue("value")));
    final TimeSeriesCollection tsdata = new SimpleTimeSeriesCollection(DateTime.parse("2017-09-17T10:00:00.000Z"), singleton(tsv0));

    boolean historyAddResult = history.add(tsdata);

    assertTrue(historyAddResult);

    verify(influxDB, times(1)).write(Mockito.<BatchPoints>argThat(
            Matchers.hasProperty(
                    "points",
                    Matchers.contains(
                            Point.measurement("foo.bar")
                            .tag("x", "17")
                            .time(DateTime.parse("2017-09-17T10:00:00.000Z").getMillis(), TimeUnit.MILLISECONDS)
                            .addField("met.ric", "value")
                            .build()
                    )
            )
    ));
    verifyNoMoreInteractions(influxDB);
}
 
开发者ID:groupon,项目名称:monsoon,代码行数:25,代码来源:InfluxHistoryTest.java

示例6: write

import org.influxdb.dto.BatchPoints; //导入依赖的package包/类
@Override
public void write(final String database, final RetentionPolicy retentionPolicy, final Point point) throws InflowException {
  if (this.batchEnabled.get()) {
    BatchEntry batchEntry = new BatchEntry(point, database, retentionPolicy);
    this.batchProcessor.put(batchEntry);
  } else {
    BatchPoints batchPoints = BatchPoints.database(database).retentionPolicy(retentionPolicy).build();
    batchPoints.point(point);
    this.write(batchPoints);
    this.unBatchedCount.incrementAndGet();
  }
  this.writeCount.incrementAndGet();
}
 
开发者ID:nkiraly,项目名称:influxdb-inflow,代码行数:14,代码来源:DriverHTTP.java

示例7: createClient

import org.influxdb.dto.BatchPoints; //导入依赖的package包/类
private InfluxDBClient createClient (Answer answer) {

    return InfluxDBClient.prepareForTest (mapWrap -> {
      InfluxDB mock = mock (InfluxDB.class);
      doAnswer (answer).when (mock).write (any (BatchPoints.class));
      return mock;
    });
  }
 
开发者ID:sonyxperiadev,项目名称:lumber-mill,代码行数:9,代码来源:InfluxDBClientTest.java

示例8: savePoint

import org.influxdb.dto.BatchPoints; //导入依赖的package包/类
private void savePoint(String message, InfluxDB influxDB) {
    try {
        System.out.println(" [x] Received '" + message + "'");
        JSONObject msg = new JSONObject(message);
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        Date date = format.parse(msg.get("dateModified").toString());
        long timeMillisec = date.getTime();
        Point event2add = Point.measurement("events")
                .time(timeMillisec, TimeUnit.MILLISECONDS)
                .field("id", msg.get("id"))
                .field("status", msg.get("status"))
                .field("billingModel", msg.get("billingModel").toString())
                .field("productType", msg.get("productType").toString())
                .field("productId", msg.get("productId").toString())
                .field("instanceId", msg.get("instanceId").toString())
                .field("setupCost", msg.get("setupCost"))
                .field("periodCost", msg.get("periodCost"))
                .field("period", msg.get("period"))
                .field("providerId", msg.get("providerId").toString())
                .field("clientId", msg.get("clientId").toString())
                .field("startDate", msg.get("startDate"))
                .field("lastBillDate", msg.get("lastBillDate"))
                .field("agreementId", msg.get("agreementId").toString())
                .field("relatives", msg.get("relatives"))
                .field("renew", msg.get("renew"))
                .field("dateCreated", msg.get("dateCreated"))
                .field("priceUnit", msg.get("priceUnit"))
                .build();
        BatchPoints batchPoints = giveMeEmptyContainer();
        batchPoints.point(event2add);
        saveContainerToDB(batchPoints);
        //influxDB.write(load.configuration.get("dbName"), "default", event2add);
    } catch (Exception ex) {
        System.err.println("Caught exception in client thread: " + ex.getMessage());
    }
}
 
开发者ID:icclab,项目名称:cyclops-udr,代码行数:37,代码来源:InfluxDBClient.java

示例9: emptyContainer

import org.influxdb.dto.BatchPoints; //导入依赖的package包/类
/**
 * Asks for InfluxDB BatchPoints container
 * @return empty container
 */
private BatchPoints emptyContainer(String db) {
    return BatchPoints
            .database(db)
            .retentionPolicy("default")
            .consistency(InfluxDB.ConsistencyLevel.ALL)
            .build();
}
 
开发者ID:icclab,项目名称:cyclops-udr,代码行数:12,代码来源:InfluxDBClient.java

示例10: updateRecords

import org.influxdb.dto.BatchPoints; //导入依赖的package包/类
/**
 * Query UDR and create CDRs
 */
private void updateRecords() {
    BatchPoints container = dbClient.giveMeEmptyContainer();

    Puller puller = new Puller();

    // get list of active meters
    List<String> meters = puller.getMeterList();

    // cycle over them
    for (String meter: meters) {

        // ask for UDR records of that particular meter
        UDRRecord records = puller.getUDRRecords(meter); //TODO only do it for recent data

        // now create CDRs based on UDRs
        records.populateContainerWithCDRs(container);
    }

    // save container to DB (empty container won't be saved)
    dbClient.saveContainerToDB(container);
}
 
开发者ID:icclab,项目名称:cyclops-rc,代码行数:25,代码来源:UDRtoCDRRunner.java

示例11: populateContainerWithCDRs

import org.influxdb.dto.BatchPoints; //导入依赖的package包/类
public void populateContainerWithCDRs(BatchPoints container) {
    // get indexes
    Integer timeIndex = columns.indexOf("time");
    Integer rawUsageIndex = columns.indexOf("rawusage");
    Integer projectidIndex = columns.indexOf("projectid");
    Integer accountIndex = columns.indexOf("account");

    // create UDREntries
    for (List<String> point : points) {
        UDREntry entry = new UDREntry();

        entry.setTime(point.get(timeIndex));
        entry.setRawusage(point.get(rawUsageIndex));
        entry.setProjectid(point.get(projectidIndex));
        entry.setAccount(point.get(accountIndex));
        entry.setMetername(name);

        // now save CDR to container
        CDR cdr = entry.getCDR();

        // only add if we have valid CDR
        if (cdr != null) {
            container.point(cdr.toDBPoint());
        }
    }
}
 
开发者ID:icclab,项目名称:cyclops-rc,代码行数:27,代码来源:UDRRecord.java

示例12: write

import org.influxdb.dto.BatchPoints; //导入依赖的package包/类
@Override
public void write(Batch batch) throws StageException {
  BatchPoints batchPoints = BatchPoints
      .database(conf.dbName)
      .retentionPolicy(conf.retentionPolicy)
      .consistency(conf.consistencyLevel)
      .build();

  Iterator<Record> recordIterator = batch.getRecords();

  while (recordIterator.hasNext()) {
    Record record = recordIterator.next();

    for (Point point : converter.getPoints(record)) {
      batchPoints.point(point);
    }
  }

  client.write(batchPoints);
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:21,代码来源:InfluxTarget.java

示例13: testCase

import org.influxdb.dto.BatchPoints; //导入依赖的package包/类
@Override
protected void testCase(Object[] args) {
    assertEquals(1, args.length);

    BatchPoints actual = (BatchPoints) args[0];

    Point expectedPoint = Point.measurement("fake")
            .field(InfluxDBReporter.VALUE_COLUMN, 100L)
            .tag(TagUtil.PREFIX_TAG, "influxdb.reporter.test")
            .build();

    BatchPoints expected = BatchPoints.database("database").build();
    expected.point(expectedPoint);

    assertEquals(expected.getDatabase(), actual.getDatabase());
    assertEquals(expected.getPoints().size(), actual.getPoints().size());

    Point actualPoint = actual.getPoints().get(0);

    // All the fields on Point are private
    assertTrue(actualPoint.lineProtocol().startsWith("fake"));
    assertTrue(actualPoint.lineProtocol().contains("value=100"));
    assertTrue(actualPoint.lineProtocol().contains("prefix=influxdb.reporter.test"));
}
 
开发者ID:etsy,项目名称:statsd-jvm-profiler,代码行数:25,代码来源:InfluxDBReporterTest.java

示例14: sendData

import org.influxdb.dto.BatchPoints; //导入依赖的package包/类
@Override
public Object sendData(Map<String, Object> data) {

    BatchPoints batchPoints = BatchPoints
            .database(databaseName)//.tag("async", "true").retentionPolicy("default").consistency(ConsistencyLevel.ALL)
            .build();

    for (Map.Entry<String, Object> entry : data.entrySet()) {
        Point point;
        if (Map.class.isAssignableFrom(entry.getValue().getClass())) {
            point = Point.measurement(entry.getKey()).fields((Map<String, Object>) entry.getValue())
                    .build();
        } else {
            point = Point.measurement(entry.getKey()).field("value", entry.getValue()).build();
        }
        batchPoints.point(point);
    }

    influxDB.write(batchPoints);
    return null;
}
 
开发者ID:stropa,项目名称:datapipes,代码行数:22,代码来源:InfluxDBSender.java

示例15: InfluxDbHttpSender

import org.influxdb.dto.BatchPoints; //导入依赖的package包/类
/**
 * Creates a new http sender given connection details.
 *
 * @param hostname        the influxDb hostname
 * @param port            the influxDb http port
 * @param database        the influxDb database to write to
 * @param username        the influxDb username
 * @param password        the influxDb password
 * @param retentionPolicy Retention policy to use
 * @param timePrecision   the time precision of the metrics
 * @throws Exception exception while creating the influxDb sender(MalformedURLException)
 */
public InfluxDbHttpSender(
        final String hostname,
        final int port,
        final String database,
        final String username,
        final String password,
        final String retentionPolicy,
        final TimeUnit timePrecision) throws Exception {
    this.timePrecision = timePrecision;
    this.influxDB = InfluxDBFactory.connect(
            String.format("http://%s:%d", hostname, port),
            username,
            password
    );
    // Creates the database
    this.influxDB.createDatabase(database);
    // Batch configuration
    batchPoints = BatchPoints
            .database(database)
            .tag("async", "true")
            .retentionPolicy(retentionPolicy)
            .consistency(InfluxDB.ConsistencyLevel.ALL)
            .build();
}
 
开发者ID:nemerosa,项目名称:ontrack,代码行数:37,代码来源:InfluxDbHttpSender.java


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