use of org.apache.kafka.common.utils.SystemTime in project kafka by apache.
the class SensorTest method testShouldRecord.
@Test
public void testShouldRecord() {
MetricConfig debugConfig = new MetricConfig().recordLevel(Sensor.RecordingLevel.DEBUG);
MetricConfig infoConfig = new MetricConfig().recordLevel(Sensor.RecordingLevel.INFO);
Sensor infoSensor = new Sensor(null, "infoSensor", null, debugConfig, new SystemTime(), 0, Sensor.RecordingLevel.INFO);
assertTrue(infoSensor.shouldRecord());
infoSensor = new Sensor(null, "infoSensor", null, debugConfig, new SystemTime(), 0, Sensor.RecordingLevel.DEBUG);
assertTrue(infoSensor.shouldRecord());
Sensor debugSensor = new Sensor(null, "debugSensor", null, infoConfig, new SystemTime(), 0, Sensor.RecordingLevel.INFO);
assertTrue(debugSensor.shouldRecord());
debugSensor = new Sensor(null, "debugSensor", null, infoConfig, new SystemTime(), 0, Sensor.RecordingLevel.DEBUG);
assertFalse(debugSensor.shouldRecord());
}
use of org.apache.kafka.common.utils.SystemTime in project ignite by apache.
the class IgniteSourceConnectorTest method beforeTest.
/**
* {@inheritDoc}
*/
@Override
protected void beforeTest() throws Exception {
kafkaBroker = new TestKafkaBroker();
WorkerConfig workerCfg = new StandaloneConfig(makeWorkerProps());
MemoryOffsetBackingStore offBackingStore = new MemoryOffsetBackingStore();
offBackingStore.configure(workerCfg);
worker = new Worker(WORKER_ID, new SystemTime(), workerCfg, offBackingStore);
worker.start();
herder = new StandaloneHerder(worker);
herder.start();
}
use of org.apache.kafka.common.utils.SystemTime in project ksql by confluentinc.
the class MetricCollectors method initialize.
// visible for testing.
// We need to call this from the MetricCollectorsTest because otherwise tests clobber each
// others metric data. We also need it from the KsqlEngineMetricsTest
public static void initialize() {
MetricConfig metricConfig = new MetricConfig().samples(100).timeWindow(1000, TimeUnit.MILLISECONDS);
List<MetricsReporter> reporters = new ArrayList<>();
reporters.add(new JmxReporter("io.confluent.ksql.metrics"));
// Replace all static contents other than Time to ensure they are cleaned for tests that are
// not aware of the need to initialize/cleanup this test, in case test processes are reused.
// Tests aware of the class clean everything up properly to get the state into a clean state,
// a full, fresh instantiation here ensures something like KsqlEngineMetricsTest running after
// another test that used MetricsCollector without running cleanUp will behave correctly.
metrics = new Metrics(metricConfig, reporters, new SystemTime());
collectorMap = new ConcurrentHashMap<>();
}
use of org.apache.kafka.common.utils.SystemTime in project apache-kafka-on-k8s by banzaicloud.
the class SensorTest method testShouldRecord.
@Test
public void testShouldRecord() {
MetricConfig debugConfig = new MetricConfig().recordLevel(Sensor.RecordingLevel.DEBUG);
MetricConfig infoConfig = new MetricConfig().recordLevel(Sensor.RecordingLevel.INFO);
Sensor infoSensor = new Sensor(null, "infoSensor", null, debugConfig, new SystemTime(), 0, Sensor.RecordingLevel.INFO);
assertTrue(infoSensor.shouldRecord());
infoSensor = new Sensor(null, "infoSensor", null, debugConfig, new SystemTime(), 0, Sensor.RecordingLevel.DEBUG);
assertTrue(infoSensor.shouldRecord());
Sensor debugSensor = new Sensor(null, "debugSensor", null, infoConfig, new SystemTime(), 0, Sensor.RecordingLevel.INFO);
assertTrue(debugSensor.shouldRecord());
debugSensor = new Sensor(null, "debugSensor", null, infoConfig, new SystemTime(), 0, Sensor.RecordingLevel.DEBUG);
assertFalse(debugSensor.shouldRecord());
}
use of org.apache.kafka.common.utils.SystemTime in project apache-kafka-on-k8s by banzaicloud.
the class TopologyTestDriverTest method shouldReturnAllStores.
@Test
public void shouldReturnAllStores() {
final Topology topology = setupSourceSinkTopology();
topology.addStateStore(new KeyValueStoreBuilder<>(Stores.inMemoryKeyValueStore("store"), Serdes.ByteArray(), Serdes.ByteArray(), new SystemTime()).withLoggingDisabled());
topology.addGlobalStore(new KeyValueStoreBuilder<>(Stores.inMemoryKeyValueStore("globalStore"), Serdes.ByteArray(), Serdes.ByteArray(), new SystemTime()).withLoggingDisabled(), "sourceProcessorName", Serdes.ByteArray().deserializer(), Serdes.ByteArray().deserializer(), "globalTopicName", "globalProcessorName", new ProcessorSupplier() {
@Override
public Processor get() {
return null;
}
});
testDriver = new TopologyTestDriver(topology, config);
final Set<String> expectedStoreNames = new HashSet<>();
expectedStoreNames.add("store");
expectedStoreNames.add("globalStore");
assertThat(testDriver.getAllStateStores().keySet(), equalTo(expectedStoreNames));
}
Aggregations