本文整理了Java中org.influxdb.InfluxDB.isBatchEnabled()
方法的一些代码示例,展示了InfluxDB.isBatchEnabled()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。InfluxDB.isBatchEnabled()
方法的具体详情如下:
包路径:org.influxdb.InfluxDB
类名称:InfluxDB
方法名:isBatchEnabled
[英]Returns whether Batching is enabled.
[中]返回是否启用批处理。
代码示例来源: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: inspectIT/inspectIT
/**
* Disables batching of the current {@link #influxDB} client.
*/
private void disableBatching() {
if ((null != influxDB) && influxDB.isBatchEnabled()) {
influxDB.disableBatch();
}
}
代码示例来源:origin: apache/bahir-flink
@Override
public void close() {
if (influxDBClient.isBatchEnabled()) {
influxDBClient.disableBatch();
}
influxDBClient.close();
}
}
代码示例来源:origin: inspectIT/inspectIT
@Test
public void disconnectedBatchDisabled() {
influxDao.active = true;
when(influxDb.isBatchEnabled()).thenReturn(false);
influxDao.onDisconnection();
verify(influxDb).isBatchEnabled();
verifyNoMoreInteractions(influxDb);
verifyZeroInteractions(future, executor, availabilityChecker, clientFactory);
}
}
代码示例来源:origin: inspectIT/inspectIT
@Test
public void reconnectedBatchEnabled() {
influxDao.active = true;
when(influxDb.isBatchEnabled()).thenReturn(true);
influxDao.onReconnection();
verify(influxDb).isBatchEnabled();
verify(influxDb).describeDatabases();
verify(influxDb).createDatabase(influxDao.database);
verifyNoMoreInteractions(influxDb);
verifyZeroInteractions(future, executor, availabilityChecker, clientFactory);
}
代码示例来源:origin: inspectIT/inspectIT
@Test
public void disconnected() {
influxDao.active = true;
when(influxDb.isBatchEnabled()).thenReturn(true);
influxDao.onDisconnection();
assertThat(influxDao.isConnected(), is(false));
assertThat(influxDao.getServiceStatus(), is(ExternalServiceStatus.DISCONNECTED));
verify(influxDb).isBatchEnabled();
verify(influxDb).disableBatch();
verifyNoMoreInteractions(influxDb);
verifyZeroInteractions(future, executor, availabilityChecker, clientFactory);
}
代码示例来源: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 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: inspectIT/inspectIT
@Test
public void writeTestFailsDatabaseCreationSucceeds() {
influxDao.active = true;
Mockito.doThrow(new RuntimeException()).when(influxDb).write(any(String.class), any(String.class), any(Point.class));
influxDao.propertiesUpdated();
assertThat(influxDao.isConnected(), is(true));
verify(executor, times(1)).submit(any(Runnable.class));
verify(influxDb).write(any(String.class), any(String.class), any(Point.class));
verify(clientFactory).createClient();
verify(influxDb).describeDatabases();
verify(influxDb).createDatabase(any(String.class));
verify(influxDb, times(1)).isBatchEnabled();
verify(influxDb).enableBatch(InfluxDBDao.BATCH_BUFFER_SIZE, InfluxDBDao.BATCH_FLUSH_TIMER, TimeUnit.SECONDS);
verify(influxDb).ping();
verify(availabilityChecker, times(1)).deactivate();
verify(availabilityChecker).setInflux(influxDb);
verify(availabilityChecker).activate();
verifyNoMoreInteractions(future, influxDb, executor, clientFactory);
}
代码示例来源:origin: inspectIT/inspectIT
@Test
public void enableInfluxDatabaseExists() {
influxDao.active = true;
when(influxDb.describeDatabases()).thenReturn(Arrays.asList(influxDao.database));
influxDao.propertiesUpdated();
assertThat(influxDao.isConnected(), is(true));
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 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 disableInflux() {
when(future.isDone()).thenReturn(true);
when(influxDb.isBatchEnabled()).thenReturn(false, true);
influxDao.active = true;
influxDao.propertiesUpdated();
influxDao.active = false;
influxDao.propertiesUpdated();
assertThat(influxDao.isConnected(), is(false));
assertThat(influxDao.getServiceStatus(), is(ExternalServiceStatus.DISABLED));
verify(future).isDone();
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, times(2)).isBatchEnabled();
verify(influxDb).enableBatch(InfluxDBDao.BATCH_BUFFER_SIZE, InfluxDBDao.BATCH_FLUSH_TIMER, TimeUnit.SECONDS);
verify(influxDb).disableBatch();
verify(availabilityChecker, times(2)).deactivate();
verify(availabilityChecker).setInflux(influxDb);
verify(availabilityChecker).activate();
verify(clientFactory).createClient();
verifyNoMoreInteractions(future, influxDb, availabilityChecker, executor, clientFactory);
}
代码示例来源:origin: inspectIT/inspectIT
@Test
public void disableInfluxConnectionOngoing() {
when(future.isDone()).thenReturn(false);
when(influxDb.isBatchEnabled()).thenReturn(false, true);
influxDao.active = true;
influxDao.propertiesUpdated();
influxDao.active = false;
influxDao.propertiesUpdated();
assertThat(influxDao.isConnected(), is(false));
assertThat(influxDao.getServiceStatus(), is(ExternalServiceStatus.DISABLED));
verify(future).cancel(true);
verify(future).isDone();
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, times(2)).isBatchEnabled();
verify(influxDb).enableBatch(InfluxDBDao.BATCH_BUFFER_SIZE, InfluxDBDao.BATCH_FLUSH_TIMER, TimeUnit.SECONDS);
verify(influxDb).disableBatch();
verify(availabilityChecker, times(2)).deactivate();
verify(availabilityChecker).setInflux(influxDb);
verify(availabilityChecker).activate();
verify(clientFactory).createClient();
verifyNoMoreInteractions(future, influxDb, availabilityChecker, executor, clientFactory);
}
代码示例来源:origin: inspectIT/inspectIT
@Test
@SuppressWarnings("unchecked")
public void enableInfluxButNotAvailable() {
influxDao.active = true;
when(influxDb.ping()).thenThrow(Exception.class);
influxDao.propertiesUpdated();
assertThat(influxDao.isConnected(), is(false));
assertThat(influxDao.getServiceStatus(), is(ExternalServiceStatus.DISCONNECTED));
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 executeQuery() {
influxDao.active = true;
influxDao.propertiesUpdated();
influxDao.query("myQuery");
assertThat(influxDao.isConnected(), is(true));
assertThat(influxDao.getServiceStatus(), is(ExternalServiceStatus.CONNECTED));
ArgumentCaptor<Query> queryCaptor = ArgumentCaptor.forClass(Query.class);
verify(influxDb, times(2)).query(queryCaptor.capture());
assertThat(queryCaptor.getValue().getCommand(), equalTo("myQuery"));
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(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 insertPoint() {
influxDao.active = true;
influxDao.propertiesUpdated();
influxDao.insert(dataPoint);
assertThat(influxDao.isConnected(), is(true));
assertThat(influxDao.getServiceStatus(), is(ExternalServiceStatus.CONNECTED));
verify(executor).submit(any(Runnable.class));
verify(influxDb).write(influxDao.database, influxDao.retentionPolicy, dataPoint);
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);
}
内容来源于网络,如有侵权,请联系作者删除!