use of io.confluent.ksql.metastore.MetaStoreImpl in project ksql by confluentinc.
the class CommandStoreTest method shouldCollectTerminatedQueries.
@Test
public void shouldCollectTerminatedQueries() {
final CommandId terminated = new CommandId(CommandId.Type.TERMINATE, "queryId", CommandId.Action.EXECUTE);
final ConsumerRecords<CommandId, Command> records = new ConsumerRecords<>(Collections.singletonMap(new TopicPartition("topic", 0), Collections.singletonList(new ConsumerRecord<>("topic", 0, 0, terminated, new Command("terminate query 'queryId'", Collections.emptyMap())))));
EasyMock.expect(commandConsumer.partitionsFor(COMMAND_TOPIC)).andReturn(Collections.emptyList());
EasyMock.expect(commandConsumer.poll(anyLong())).andReturn(records).andReturn(new ConsumerRecords<>(Collections.emptyMap()));
EasyMock.replay(commandConsumer);
final CommandStore commandStore = new CommandStore(COMMAND_TOPIC, commandConsumer, commandProducer, new CommandIdAssigner(new MetaStoreImpl()));
final RestoreCommands restoreCommands = commandStore.getRestoreCommands();
assertThat(restoreCommands.terminatedQueries(), equalTo(Collections.singletonMap(new QueryId("queryId"), terminated)));
}
use of io.confluent.ksql.metastore.MetaStoreImpl in project ksql by confluentinc.
the class MetaStoreFixture method getNewMetaStore.
public static MetaStore getNewMetaStore() {
MetaStore metaStore = new MetaStoreImpl();
SchemaBuilder schemaBuilder1 = SchemaBuilder.struct().field("COL0", SchemaBuilder.INT64_SCHEMA).field("COL1", SchemaBuilder.STRING_SCHEMA).field("COL2", SchemaBuilder.STRING_SCHEMA).field("COL3", SchemaBuilder.FLOAT64_SCHEMA).field("COL4", SchemaBuilder.array(SchemaBuilder.FLOAT64_SCHEMA)).field("COL5", SchemaBuilder.map(SchemaBuilder.STRING_SCHEMA, SchemaBuilder.FLOAT64_SCHEMA));
KsqlTopic ksqlTopic1 = new KsqlTopic("TEST1", "test1", new KsqlJsonTopicSerDe());
KsqlStream ksqlStream = new KsqlStream("sqlexpression", "TEST1", schemaBuilder1, schemaBuilder1.field("COL0"), null, ksqlTopic1);
metaStore.putTopic(ksqlTopic1);
metaStore.putSource(ksqlStream);
SchemaBuilder schemaBuilder2 = SchemaBuilder.struct().field("COL0", SchemaBuilder.INT64_SCHEMA).field("COL1", SchemaBuilder.STRING_SCHEMA).field("COL2", SchemaBuilder.STRING_SCHEMA).field("COL3", SchemaBuilder.FLOAT64_SCHEMA).field("COL4", SchemaBuilder.BOOLEAN_SCHEMA);
KsqlTopic ksqlTopic2 = new KsqlTopic("TEST2", "test2", new KsqlJsonTopicSerDe());
KsqlTable ksqlTable = new KsqlTable("sqlexpression", "TEST2", schemaBuilder2, schemaBuilder2.field("COL0"), null, ksqlTopic2, "TEST2", false);
metaStore.putTopic(ksqlTopic2);
metaStore.putSource(ksqlTable);
SchemaBuilder schemaBuilderOrders = SchemaBuilder.struct().field("ORDERTIME", SchemaBuilder.INT64_SCHEMA).field("ORDERID", SchemaBuilder.STRING_SCHEMA).field("ITEMID", SchemaBuilder.STRING_SCHEMA).field("ORDERUNITS", SchemaBuilder.FLOAT64_SCHEMA);
KsqlTopic ksqlTopicOrders = new KsqlTopic("ORDERS_TOPIC", "orders_topic", new KsqlJsonTopicSerDe());
KsqlStream ksqlStreamOrders = new KsqlStream("sqlexpression", "ORDERS", schemaBuilderOrders, schemaBuilderOrders.field("ORDERTIME"), null, ksqlTopicOrders);
metaStore.putTopic(ksqlTopicOrders);
metaStore.putSource(ksqlStreamOrders);
return metaStore;
}
use of io.confluent.ksql.metastore.MetaStoreImpl in project ksql by confluentinc.
the class KsqlContext method create.
public static KsqlContext create(KsqlConfig ksqlConfig, SchemaRegistryClient schemaRegistryClient) {
if (ksqlConfig == null) {
ksqlConfig = new KsqlConfig(Collections.emptyMap());
}
Map<String, Object> streamsProperties = ksqlConfig.getKsqlStreamConfigProps();
if (!streamsProperties.containsKey(StreamsConfig.APPLICATION_ID_CONFIG)) {
streamsProperties.put(StreamsConfig.APPLICATION_ID_CONFIG, APPLICATION_ID_OPTION_DEFAULT);
}
if (!streamsProperties.containsKey(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG)) {
streamsProperties.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, KAFKA_BOOTSTRAP_SERVER_OPTION_DEFAULT);
}
AdminClient adminClient = AdminClient.create(ksqlConfig.getKsqlAdminClientConfigProps());
KafkaTopicClient topicClient = new KafkaTopicClientImpl(adminClient);
if (schemaRegistryClient == null) {
return new KsqlContext(adminClient, topicClient, new KsqlEngine(ksqlConfig, topicClient));
} else {
return new KsqlContext(adminClient, topicClient, new KsqlEngine(ksqlConfig, topicClient, schemaRegistryClient, new MetaStoreImpl()));
}
}
use of io.confluent.ksql.metastore.MetaStoreImpl in project ksql by confluentinc.
the class KsqlResourceTest method setUp.
@Before
public void setUp() throws IOException, RestClientException {
SchemaRegistryClient schemaRegistryClient = new MockSchemaRegistryClient();
registerSchema(schemaRegistryClient);
ksqlRestConfig = new KsqlRestConfig(TestKsqlResourceUtil.getDefaultKsqlConfig());
KsqlConfig ksqlConfig = new KsqlConfig(ksqlRestConfig.getKsqlConfigProperties());
ksqlEngine = new KsqlEngine(ksqlConfig, new MockKafkaTopicClient(), schemaRegistryClient, new MetaStoreImpl());
}
Aggregations