本文整理了Java中org.influxdb.InfluxDB.enableBatch()
方法的一些代码示例,展示了InfluxDB.enableBatch()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。InfluxDB.enableBatch()
方法的具体详情如下:
包路径:org.influxdb.InfluxDB
类名称:InfluxDB
方法名:enableBatch
[英]Enable batching of single Point writes to speed up writes significantly. This is the same as calling InfluxDB.enableBatch(BatchingOptions.DEFAULTS)
[中]启用单点写入的批处理以显著加快写入速度。这与调用XDB相同。启用批处理(BatchingOptions.DEFAULTS)
代码示例来源:origin: SeldonIO/seldon-server
influxDB.enableBatch(50, 5, TimeUnit.SECONDS);
代码示例来源:origin: SeldonIO/seldon-server
influxDB.enableBatch(50, 5, TimeUnit.SECONDS);
代码示例来源:origin: inspectIT/inspectIT
/**
* Enables batching of the current {@link #influxDB} client.
*/
private void enableBatching() {
if ((null != influxDB) && !influxDB.isBatchEnabled()) {
influxDB.enableBatch(BATCH_BUFFER_SIZE, BATCH_FLUSH_TIMER, TimeUnit.SECONDS);
}
}
代码示例来源:origin: amient/kafka-metrics
public void tryPublish(MeasurementV1 m) {
if (influxDB == null) {
influxDB = InfluxDBFactory.connect(address, username, password);
influxDB.enableBatch(1000, 100, TimeUnit.MILLISECONDS);
}
Point.Builder builder = Point.measurement(m.getName().toString()).time(m.getTimestamp(), TimeUnit.MILLISECONDS);
for (java.util.Map.Entry<String, String> tag : m.getTags().entrySet()) {
builder.tag(tag.getKey().toString(), tag.getValue().toString());
}
for (java.util.Map.Entry<String, Double> field : m.getFields().entrySet()) {
builder.field(field.getKey().toString(), field.getValue());
}
influxDB.write(dbName, retention, builder.build());
}
代码示例来源:origin: dataArtisans/oscon
@Override
public void open(Configuration parameters) throws Exception {
super.open(parameters);
influxDB = InfluxDBFactory.connect("http://localhost:8086", "admin", "admin");
influxDB.createDatabase(dataBaseName);
influxDB.enableBatch(2000, 100, TimeUnit.MILLISECONDS);
}
代码示例来源:origin: inspectIT/inspectIT
@Test
public void reconnectedDatabaseExists() {
influxDao.active = true;
when(influxDb.isBatchEnabled()).thenReturn(false);
when(influxDb.describeDatabases()).thenReturn(Arrays.asList(influxDao.database));
influxDao.onReconnection();
verify(influxDb).isBatchEnabled();
verify(influxDb).enableBatch(InfluxDBDao.BATCH_BUFFER_SIZE, InfluxDBDao.BATCH_FLUSH_TIMER, TimeUnit.SECONDS);
verify(influxDb).describeDatabases();
verifyNoMoreInteractions(influxDb);
verifyZeroInteractions(future, executor, availabilityChecker, clientFactory);
}
}
代码示例来源:origin: inspectIT/inspectIT
@Test
public void reconnected() {
influxDao.active = true;
when(influxDb.isBatchEnabled()).thenReturn(false);
influxDao.onReconnection();
assertThat(influxDao.isConnected(), is(true));
assertThat(influxDao.getServiceStatus(), is(ExternalServiceStatus.CONNECTED));
verify(influxDb).isBatchEnabled();
verify(influxDb).enableBatch(InfluxDBDao.BATCH_BUFFER_SIZE, InfluxDBDao.BATCH_FLUSH_TIMER, TimeUnit.SECONDS);
verify(influxDb).describeDatabases();
verify(influxDb).createDatabase(influxDao.database);
verifyNoMoreInteractions(influxDb);
verifyZeroInteractions(future, executor, availabilityChecker, clientFactory);
}
代码示例来源:origin: inspectIT/inspectIT
@Test
public void enableInflux() {
influxDao.active = true;
influxDao.propertiesUpdated();
assertThat(influxDao.isConnected(), is(true));
assertThat(influxDao.getServiceType(), is(ExternalServiceType.INFLUXDB));
assertThat(influxDao.getServiceStatus(), is(ExternalServiceStatus.CONNECTED));
verify(executor, times(1)).submit(any(Runnable.class));
verify(influxDb).ping();
verify(influxDb).write(any(String.class), any(String.class), any(Point.class));
verify(influxDb).query(any(Query.class));
verify(influxDb).isBatchEnabled();
verify(influxDb).enableBatch(InfluxDBDao.BATCH_BUFFER_SIZE, InfluxDBDao.BATCH_FLUSH_TIMER, TimeUnit.SECONDS);
verify(availabilityChecker).deactivate();
verify(availabilityChecker).setInflux(influxDb);
verify(availabilityChecker).activate();
verify(clientFactory).createClient();
verifyNoMoreInteractions(influxDb, availabilityChecker, executor, clientFactory);
verifyZeroInteractions(future);
}
代码示例来源:origin: inspectIT/inspectIT
@Test
public void executeNullQuery() {
influxDao.active = true;
influxDao.propertiesUpdated();
influxDao.query(null);
assertThat(influxDao.isConnected(), is(true));
assertThat(influxDao.getServiceStatus(), is(ExternalServiceStatus.CONNECTED));
verify(influxDb).ping();
verify(influxDb).write(any(String.class), any(String.class), any(Point.class));
verify(influxDb).isBatchEnabled();
verify(influxDb).enableBatch(InfluxDBDao.BATCH_BUFFER_SIZE, InfluxDBDao.BATCH_FLUSH_TIMER, TimeUnit.SECONDS);
verify(influxDb).query(any(Query.class));
verify(executor).submit(any(Runnable.class));
verify(availabilityChecker).deactivate();
verify(availabilityChecker).setInflux(influxDb);
verify(availabilityChecker).activate();
verify(clientFactory).createClient();
verifyNoMoreInteractions(clientFactory, availabilityChecker, executor, influxDb);
verifyZeroInteractions(future);
}
代码示例来源:origin: inspectIT/inspectIT
@Test
public void insertNull() {
influxDao.active = true;
influxDao.propertiesUpdated();
influxDao.insert(null);
assertThat(influxDao.isConnected(), is(true));
assertThat(influxDao.getServiceStatus(), is(ExternalServiceStatus.CONNECTED));
verify(executor).submit(any(Runnable.class));
verify(influxDb).ping();
verify(influxDb).isBatchEnabled();
verify(influxDb).enableBatch(InfluxDBDao.BATCH_BUFFER_SIZE, InfluxDBDao.BATCH_FLUSH_TIMER, TimeUnit.SECONDS);
verify(availabilityChecker).deactivate();
verify(availabilityChecker).setInflux(influxDb);
verify(availabilityChecker).activate();
verify(clientFactory).createClient();
verifyNoMoreInteractions(executor, availabilityChecker, clientFactory);
verifyZeroInteractions(future, dataPoint);
}
代码示例来源: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: NovatecConsulting/JMeter-InfluxDB-Writer
/**
* Setup influxDB client.
*
* @param context
* {@link BackendListenerContext}.
*/
private void setupInfluxClient(BackendListenerContext context) {
influxDBConfig = new InfluxDBConfig(context);
influxDB = InfluxDBFactory.connect(influxDBConfig.getInfluxDBURL(), influxDBConfig.getInfluxUser(), influxDBConfig.getInfluxPassword());
influxDB.enableBatch(100, 5, TimeUnit.SECONDS);
createDatabaseIfNotExistent();
}
代码示例来源: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
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: dataArtisans/flink-training-exercises
@Override
public void open(Configuration unused) throws Exception {
super.open(unused);
influxDB = InfluxDBFactory.connect(parameters.get("url", "http://localhost:8086"),
parameters.get("user", "admin"),
parameters.get("password", "admin"));
influxDB.createDatabase(parameters.get("db", DEFAULT_DATABASE_NAME));
influxDB.enableBatch(2000, 100, TimeUnit.MILLISECONDS);
this.fieldName = parameters.get("field", DEFAULT_FIELD_NAME);
}
代码示例来源:origin: com.remondis.limbus/limbus-monitoring-influx
@Override
protected void performInitialize() throws Exception {
super.performInitialize();
PublisherUtils.denyRequired("databaseUrl", databaseUrl);
PublisherUtils.denyRequired("username", username);
PublisherUtils.denyRequired("password", password);
PublisherUtils.denyRequired("database", database);
Lang.defaultIfNull(retentionPolicy, "default");
influxDB = InfluxDBFactory.connect(databaseUrl, username, password);
influxDB.enableBatch(2000, 1000, TimeUnit.MILLISECONDS);
influxDB.setLogLevel(LogLevel.NONE);
}
代码示例来源: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: sitewhere/sitewhere
@Override
public void initialize(ILifecycleProgressMonitor monitor) throws SiteWhereException {
super.start(monitor);
String connectionUrl = "http://" + getHostname().getValue() + ":" + getConfiguration().getPort();
this.influx = InfluxDBFactory.connect(connectionUrl, getConfiguration().getUsername(),
getConfiguration().getPassword());
influx.createDatabase(getDatabase().getValue());
if (getConfiguration().isEnableBatch()) {
influx.enableBatch(getConfiguration().getBatchChunkSize(), getConfiguration().getBatchIntervalMs(),
TimeUnit.MILLISECONDS);
}
influx.setLogLevel(convertLogLevel(getConfiguration().getLogLevel()));
}
内容来源于网络,如有侵权,请联系作者删除!