use of com.datastax.oss.driver.internal.core.metadata.schema.refresh.SchemaRefresh in project java-driver by datastax.
the class GraphSchemaRefreshTest method should_detect_created_keyspace_without_graph_engine.
@Test
public void should_detect_created_keyspace_without_graph_engine() {
DefaultDseKeyspaceMetadata ks2 = newKeyspace("ks2", null);
SchemaRefresh refresh = new SchemaRefresh(ImmutableMap.of(OLD_KS1.getName(), OLD_KS1, KS_WITH_ENGINE.getName(), KS_WITH_ENGINE, ks2.getName(), ks2));
MetadataRefresh.Result result = refresh.compute(oldMetadata, false, context);
assertThat(result.newMetadata.getKeyspaces()).hasSize(3);
assertThat(result.events).containsExactly(KeyspaceChangeEvent.created(ks2));
}
use of com.datastax.oss.driver.internal.core.metadata.schema.refresh.SchemaRefresh in project java-driver by datastax.
the class SchemaParserTest method should_parse_keyspace_with_all_children.
@Test
public void should_parse_keyspace_with_all_children() {
// Needed to parse the aggregate
when(context.getCodecRegistry()).thenReturn(CodecRegistry.DEFAULT);
SchemaRefresh refresh = (SchemaRefresh) parse(rows -> rows.withKeyspaces(ImmutableList.of(mockModernKeyspaceRow("ks"))).withTypes(ImmutableList.of(mockTypeRow("ks", "t", ImmutableList.of("i"), ImmutableList.of("int")))).withTables(ImmutableList.of(TableParserTest.TABLE_ROW_3_0)).withColumns(TableParserTest.COLUMN_ROWS_3_0).withIndexes(TableParserTest.INDEX_ROWS_3_0).withViews(ImmutableList.of(ViewParserTest.VIEW_ROW_3_0)).withColumns(ViewParserTest.COLUMN_ROWS_3_0).withFunctions(ImmutableList.of(FunctionParserTest.ID_ROW_3_0)).withAggregates(ImmutableList.of(AggregateParserTest.SUM_AND_TO_STRING_ROW_3_0)));
assertThat(refresh.newKeyspaces).hasSize(1);
KeyspaceMetadata keyspace = refresh.newKeyspaces.values().iterator().next();
checkKeyspace(keyspace);
assertThat(keyspace.getUserDefinedTypes()).hasSize(1).containsKey(CqlIdentifier.fromInternal("t"));
assertThat(keyspace.getTables()).hasSize(1).containsKey(CqlIdentifier.fromInternal("foo"));
assertThat(keyspace.getViews()).hasSize(1).containsKey(CqlIdentifier.fromInternal("alltimehigh"));
assertThat(keyspace.getFunctions()).hasSize(1).containsKey(new FunctionSignature(CqlIdentifier.fromInternal("id"), DataTypes.INT));
assertThat(keyspace.getAggregates()).hasSize(1).containsKey(new FunctionSignature(CqlIdentifier.fromInternal("sum_and_to_string"), DataTypes.INT));
}
use of com.datastax.oss.driver.internal.core.metadata.schema.refresh.SchemaRefresh in project java-driver by datastax.
the class SchemaParserTest method should_parse_legacy_keyspace_row.
@Test
public void should_parse_legacy_keyspace_row() {
SchemaRefresh refresh = (SchemaRefresh) parse(rows -> rows.withKeyspaces(ImmutableList.of(mockLegacyKeyspaceRow("ks"))));
assertThat(refresh.newKeyspaces).hasSize(1);
KeyspaceMetadata keyspace = refresh.newKeyspaces.values().iterator().next();
checkKeyspace(keyspace);
}
use of com.datastax.oss.driver.internal.core.metadata.schema.refresh.SchemaRefresh in project java-driver by datastax.
the class CassandraSchemaParser method parse.
@Override
public SchemaRefresh parse() {
ImmutableMap.Builder<CqlIdentifier, KeyspaceMetadata> keyspacesBuilder = ImmutableMap.builder();
for (AdminRow row : rows.keyspaces()) {
KeyspaceMetadata keyspace = parseKeyspace(row);
keyspacesBuilder.put(keyspace.getName(), keyspace);
}
for (AdminRow row : rows.virtualKeyspaces()) {
KeyspaceMetadata keyspace = parseVirtualKeyspace(row);
keyspacesBuilder.put(keyspace.getName(), keyspace);
}
SchemaRefresh refresh = new SchemaRefresh(keyspacesBuilder.build());
LOG.debug("[{}] Schema parsing took {}", logPrefix, NanoTime.formatTimeSince(startTimeNs));
return refresh;
}
use of com.datastax.oss.driver.internal.core.metadata.schema.refresh.SchemaRefresh in project java-driver by datastax.
the class DseSchemaParser method parse.
@Override
public SchemaRefresh parse() {
ImmutableMap.Builder<CqlIdentifier, KeyspaceMetadata> keyspacesBuilder = ImmutableMap.builder();
for (AdminRow row : rows.keyspaces()) {
DseKeyspaceMetadata keyspace = parseKeyspace(row);
keyspacesBuilder.put(keyspace.getName(), keyspace);
}
for (AdminRow row : rows.virtualKeyspaces()) {
DseKeyspaceMetadata keyspace = parseVirtualKeyspace(row);
keyspacesBuilder.put(keyspace.getName(), keyspace);
}
SchemaRefresh refresh = new SchemaRefresh(keyspacesBuilder.build());
LOG.debug("[{}] Schema parsing took {}", logPrefix, NanoTime.formatTimeSince(startTimeNs));
return refresh;
}
Aggregations