use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.
the class StandaloneExecutorTest method shouldAddConfigurableMetricsReportersIfPresentInKsqlConfig.
@Test
public void shouldAddConfigurableMetricsReportersIfPresentInKsqlConfig() {
// When:
final MetricsReporter mockReporter = mock(MetricsReporter.class);
final KsqlConfig mockKsqlConfig = mock(KsqlConfig.class);
when(mockKsqlConfig.getConfiguredInstances(anyString(), any(), any())).thenReturn(Collections.singletonList(mockReporter));
when(mockKsqlConfig.getString(KsqlConfig.KSQL_SERVICE_ID_CONFIG)).thenReturn("ksql-id");
final MetricCollectors metricCollectors = new MetricCollectors();
standaloneExecutor = new StandaloneExecutor(serviceContext, processingLogConfig, mockKsqlConfig, ksqlEngine, queriesFile.toString(), udfLoader, false, versionChecker, injectorFactory, metricCollectors);
// Then:
final List<MetricsReporter> reporters = metricCollectors.getMetrics().reporters();
assertThat(reporters, hasItem(mockReporter));
}
use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.
the class TestKsqlRestApp method initialize.
protected void initialize() {
if (ksqlRestApplication != null) {
after();
}
ksqlRestConfig = buildConfig(bootstrapServers, baseConfig);
try {
Vertx vertx = Vertx.vertx();
ksqlRestApplication = KsqlRestApplication.buildApplication(metricsPrefix, ksqlRestConfig, (booleanSupplier) -> mock(VersionCheckerAgent.class), 3, serviceContext.get(), () -> serviceContext.get().getSchemaRegistryClient(), (authHeader, requestHeaders, userPrincipal) -> serviceContext.get().getConnectClient(), vertx, InternalKsqlClientFactory.createInternalClient(PropertiesUtil.toMapStrings(ksqlRestConfig.originals()), SocketAddress::inetSocketAddress, vertx), TestRestServiceContextFactory.createDefault(internalSimpleKsqlClientFactory), TestRestServiceContextFactory.createUser(internalSimpleKsqlClientFactory), new MetricCollectors());
} catch (final Exception e) {
throw new RuntimeException("Failed to initialise", e);
}
}
use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.
the class KsqlRestApplicationTest method shouldConfigureIQWithFirstListenerIfInterNodeNotSet.
@Test
public void shouldConfigureIQWithFirstListenerIfInterNodeNotSet() {
// Given:
givenAppWithRestConfig(ImmutableMap.of(KsqlRestConfig.LISTENERS_CONFIG, "http://some.host:1244,https://some.other.host:1258"), new MetricCollectors());
// When:
final KsqlConfig ksqlConfig = app.buildConfigWithPort();
// Then:
assertThat(ksqlConfig.getKsqlStreamConfigProps().get(StreamsConfig.APPLICATION_SERVER_CONFIG), is("http://some.host:1244"));
}
use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.
the class KsqlRestApplicationTest method setUp.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Before
public void setUp() {
when(processingLogConfig.getBoolean(ProcessingLogConfig.STREAM_AUTO_CREATE)).thenReturn(true);
when(processingLogConfig.getString(ProcessingLogConfig.STREAM_NAME)).thenReturn(LOG_STREAM_NAME);
when(processingLogConfig.getString(ProcessingLogConfig.TOPIC_NAME)).thenReturn(LOG_TOPIC_NAME);
when(processingLogConfig.getBoolean(ProcessingLogConfig.TOPIC_AUTO_CREATE)).thenReturn(true);
when(processingLogContext.getConfig()).thenReturn(processingLogConfig);
when(ksqlEngine.parse(any())).thenReturn(ImmutableList.of(parsedStatement));
when(ksqlEngine.prepare(any())).thenReturn((PreparedStatement) preparedStatement);
when(commandQueue.getCommandTopicName()).thenReturn(CMD_TOPIC_NAME);
when(serviceContext.getTopicClient()).thenReturn(topicClient);
when(topicClient.isTopicExists(CMD_TOPIC_NAME)).thenReturn(false);
when(ksqlConfig.getString(KsqlConfig.KSQL_SERVICE_ID_CONFIG)).thenReturn("ksql-id");
when(ksqlConfig.getKsqlStreamConfigProps()).thenReturn(ImmutableMap.of("state.dir", "/tmp/cat"));
when(precondition1.checkPrecondition(any(), any(), any())).thenReturn(Optional.empty());
when(precondition2.checkPrecondition(any(), any(), any())).thenReturn(Optional.empty());
when(response.getStatus()).thenReturn(200);
when(response.getEntity()).thenReturn(new KsqlEntityList(Collections.singletonList(new StreamsList(LIST_STREAMS_SQL, Collections.emptyList()))));
when(ksqlResource.handleKsqlStatements(any(), any())).thenReturn(response);
securityContext = new KsqlSecurityContext(Optional.empty(), serviceContext);
logCreateStatement = ProcessingLogServerUtils.processingLogStreamCreateStatement(processingLogConfig, ksqlConfig);
givenAppWithRestConfig(ImmutableMap.of(KsqlRestConfig.LISTENERS_CONFIG, "http://localhost:0"), new MetricCollectors());
}
use of io.confluent.ksql.metrics.MetricCollectors in project ksql by confluentinc.
the class JsonFormatTest method before.
@Before
public void before() {
streamName = "STREAM_" + COUNTER.getAndIncrement();
ksqlConfig = KsqlConfigTestUtil.create(TEST_HARNESS.kafkaBootstrapServers());
serviceContext = ServiceContextFactory.create(ksqlConfig, DisabledKsqlClient::instance);
functionRegistry = new InternalFunctionRegistry();
UserFunctionLoader.newInstance(ksqlConfig, functionRegistry, ".", new Metrics()).load();
ksqlEngine = new KsqlEngine(serviceContext, ProcessingLogContext.create(), functionRegistry, ServiceInfo.create(ksqlConfig), new SequentialQueryIdGenerator(), ksqlConfig, Collections.emptyList(), new MetricCollectors());
topicClient = serviceContext.getTopicClient();
metaStore = ksqlEngine.getMetaStore();
createInitTopics();
produceInitData();
execInitCreateStreamQueries();
}
Aggregations