org.influxdb.InfluxDB.setDatabase()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.influxdb.InfluxDB.setDatabase()方法的一些代码示例,展示了InfluxDB.setDatabase()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。InfluxDB.setDatabase()方法的具体详情如下:
包路径:org.influxdb.InfluxDB
类名称:InfluxDB
方法名:setDatabase

InfluxDB.setDatabase介绍

[英]Set the database which is used for writing points.
[中]设置用于写入点的数据库。

代码示例

代码示例来源:origin: testcontainers/testcontainers-java

/**
   * @return a influxDb client
   */
  public InfluxDB getNewInfluxDB() {
    InfluxDB influxDB = InfluxDBFactory.connect(getUrl(), username, password);
    influxDB.setDatabase(database);
    return influxDB;
  }
}

代码示例来源:origin: org.testcontainers/influxdb

/**
   * @return a influxDb client
   */
  public InfluxDB getNewInfluxDB() {
    InfluxDB influxDB = InfluxDBFactory.connect(getUrl(), username, password);
    influxDB.setDatabase(database);
    return influxDB;
  }
}

代码示例来源:origin: org.mycontroller.standalone/mycontroller-core

@Override
public void connect() {
  if (_config.getUsername() != null && _config.getUsername().trim().length() > 0) {
    _client = InfluxDBFactory.connect(_config.getUrl(), _config.getUsername(), _config.getPassword());
  } else {
    _client = InfluxDBFactory.connect(_config.getUrl());
  }
  _client.setDatabase(_config.getDatabase());
  _client.enableBatch(BatchOptions.DEFAULTS.actions(FLUSH_POINTS).flushDuration(FLUSH_DURATION));
  _logger.debug("External server:{}, Influxdb client BatchSettings[flush, points:{}, duration:{} ms]",
      _config.getName(), FLUSH_POINTS, FLUSH_DURATION);
}

代码示例来源:origin: mycontroller-org/mycontroller

@Override
public void connect() {
  if (_config.getUsername() != null && _config.getUsername().trim().length() > 0) {
    _client = InfluxDBFactory.connect(_config.getUrl(), _config.getUsername(), _config.getPassword());
  } else {
    _client = InfluxDBFactory.connect(_config.getUrl());
  }
  _client.setDatabase(_config.getDatabase());
  _client.enableBatch(BatchOptions.DEFAULTS.actions(FLUSH_POINTS).flushDuration(FLUSH_DURATION));
  _logger.debug("External server:{}, Influxdb client BatchSettings[flush, points:{}, duration:{} ms]",
      _config.getName(), FLUSH_POINTS, FLUSH_DURATION);
}

代码示例来源:origin: Scrin/RuuviCollector

public LegacyInfluxDBConnection() {
  influxDB = InfluxDBFactory.connect(Config.getInfluxUrl(), Config.getInfluxUser(), Config.getInfluxPassword());
  influxDB.setDatabase(Config.getInfluxDatabase());
  influxDB.enableGzip();
  influxDB.enableBatch(2000, 100, TimeUnit.MILLISECONDS); // TODO: make these configurable
}

代码示例来源:origin: Scrin/RuuviCollector

private InfluxDB createInfluxDB() {
  InfluxDB influxDB = InfluxDBFactory.connect(Config.getInfluxUrl(), Config.getInfluxUser(), Config.getInfluxPassword());
  influxDB.setDatabase(Config.getInfluxDatabase());
  influxDB.enableGzip();
  influxDB.enableBatch(BATCH_SIZE, 100, TimeUnit.MILLISECONDS);
  return influxDB;
}

代码示例来源:origin: Scrin/RuuviCollector

int batchTime
) {
  influxDB = InfluxDBFactory.connect(url, user, password).setDatabase(database).setRetentionPolicy(retentionPolicy);
  if (gzip) {
    influxDB.enableGzip();

代码示例来源:origin: mycontroller-org/mycontroller

public MetricEngineInfluxDB(MetricEngineConfigInfluxDB _config) throws URISyntaxException {
  if (_config.getUsername() != null) {
    _client = InfluxDBFactory.connect(_config.getUrl(), _config.getUsername(), _config.getPassword());
    _clientQuery = new InfluxDBClient(_config.getUrl(), _config.getUsername(), _config.getPassword(),
        _config.getDatabase(), _config.getTrustHostType());
  } else {
    _clientQuery = new InfluxDBClient(_config.getUrl(), _config.getDatabase(), _config.getTrustHostType());
    _client = InfluxDBFactory.connect(_config.getUrl());
  }
  _client.setDatabase(_config.getDatabase());
  _client.enableBatch(BatchOptions.DEFAULTS.actions(FLUSH_POINTS).flushDuration(FLUSH_DURATION));
  _logger.debug("MetricEngine, Influxdb client BatchSettings[flush, points:{}, duration:{} ms]",
      FLUSH_POINTS, FLUSH_DURATION);
}

代码示例来源:origin: org.mycontroller.standalone/mycontroller-core

public MetricEngineInfluxDB(MetricEngineConfigInfluxDB _config) throws URISyntaxException {
  if (_config.getUsername() != null) {
    _client = InfluxDBFactory.connect(_config.getUrl(), _config.getUsername(), _config.getPassword());
    _clientQuery = new InfluxDBClient(_config.getUrl(), _config.getUsername(), _config.getPassword(),
        _config.getDatabase(), _config.getTrustHostType());
  } else {
    _clientQuery = new InfluxDBClient(_config.getUrl(), _config.getDatabase(), _config.getTrustHostType());
    _client = InfluxDBFactory.connect(_config.getUrl());
  }
  _client.setDatabase(_config.getDatabase());
  _client.enableBatch(BatchOptions.DEFAULTS.actions(FLUSH_POINTS).flushDuration(FLUSH_DURATION));
  _logger.debug("MetricEngine, Influxdb client BatchSettings[flush, points:{}, duration:{} ms]",
      FLUSH_POINTS, FLUSH_DURATION);
}

代码示例来源:origin: apache/bahir-flink

/**
 * Initializes the connection to InfluxDB by either cluster or sentinels or single server.
 */
@Override
public void open(Configuration parameters) throws Exception {
  super.open(parameters);
  influxDBClient = InfluxDBFactory.connect(influxDBConfig.getUrl(), influxDBConfig.getUsername(), influxDBConfig.getPassword());
  if (!influxDBClient.databaseExists(influxDBConfig.getDatabase())) {
    if(influxDBConfig.isCreateDatabase()) {
      influxDBClient.createDatabase(influxDBConfig.getDatabase());
    }
    else {
      throw new RuntimeException("This " + influxDBConfig.getDatabase() + " database does not exist!");
    }
  }
  influxDBClient.setDatabase(influxDBConfig.getDatabase());
  if (influxDBConfig.getBatchActions() > 0) {
    influxDBClient.enableBatch(influxDBConfig.getBatchActions(), influxDBConfig.getFlushDuration(), influxDBConfig.getFlushDurationTimeUnit());
  }
  if (influxDBConfig.isEnableGzip()) {
    influxDBClient.enableGzip();
  }
}

相关文章