private static Map<String, CFMetaData> fetchTables(String keyspace, Session session, IPartitioner partitioner, Types types) { Map<String, CFMetaData> tables = new HashMap<>(); String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, SchemaKeyspace.TABLES); for (Row row : session.execute(query, keyspace)) { String name = row.getString("table_name"); tables.put(name, createTableMetadata(keyspace, session, partitioner, false, row, name, types)); } return tables; }
public void init(String keyspace) { Cluster.Builder builder = Cluster.builder().addContactPoints(hosts).withPort(port); if (sslOptions != null) builder.withSSL(sslOptions); if (authProvider != null) builder = builder.withAuthProvider(authProvider); try (Cluster cluster = builder.build(); Session session = cluster.connect()) { Metadata metadata = cluster.getMetadata(); Set<TokenRange> tokenRanges = metadata.getTokenRanges(); IPartitioner partitioner = FBUtilities.newPartitioner(metadata.getPartitioner()); TokenFactory tokenFactory = partitioner.getTokenFactory(); for (TokenRange tokenRange : tokenRanges) { Set<Host> endpoints = metadata.getReplicas(Metadata.quote(keyspace), tokenRange); Range<Token> range = new Range<>(tokenFactory.fromString(tokenRange.getStart().getValue().toString()), tokenFactory.fromString(tokenRange.getEnd().getValue().toString())); for (Host endpoint : endpoints) addRangeForEndpoint(range, endpoint.getAddress()); } Types types = fetchTypes(keyspace, session); tables.putAll(fetchTables(keyspace, session, partitioner, types)); // We only need the CFMetaData for the views, so we only load that. tables.putAll(fetchViews(keyspace, session, partitioner, types)); } }
defs.add(createDefinitionFromRow(colRow, keyspace, name, types)); for (Row colRow : session.execute(droppedColumnsQuery, keyspace, name)) CFMetaData.DroppedColumn droppedColumn = createDroppedColumnFromRow(colRow, keyspace); droppedColumns.put(UTF8Type.instance.decompose(droppedColumn.name), droppedColumn);
public void init(String keyspace) { Cluster.Builder builder = Cluster.builder().addContactPoints(hosts).withPort(port); if (sslOptions != null) builder.withSSL(sslOptions); if (authProvider != null) builder = builder.withAuthProvider(authProvider); try (Cluster cluster = builder.build(); Session session = cluster.connect()) { Metadata metadata = cluster.getMetadata(); Set<TokenRange> tokenRanges = metadata.getTokenRanges(); IPartitioner partitioner = FBUtilities.newPartitioner(metadata.getPartitioner()); TokenFactory tokenFactory = partitioner.getTokenFactory(); for (TokenRange tokenRange : tokenRanges) { Set<Host> endpoints = metadata.getReplicas(Metadata.quote(keyspace), tokenRange); Range<Token> range = new Range<>(tokenFactory.fromString(tokenRange.getStart().getValue().toString()), tokenFactory.fromString(tokenRange.getEnd().getValue().toString())); for (Host endpoint : endpoints) addRangeForEndpoint(range, endpoint.getAddress()); } Types types = fetchTypes(keyspace, session); tables.putAll(fetchTables(keyspace, session, partitioner, types)); // We only need the CFMetaData for the views, so we only load that. tables.putAll(fetchViews(keyspace, session, partitioner, types)); } }
defs.add(createDefinitionFromRow(colRow, keyspace, name, types)); for (Row colRow : session.execute(droppedColumnsQuery, keyspace, name)) CFMetaData.DroppedColumn droppedColumn = createDroppedColumnFromRow(colRow, keyspace); droppedColumns.put(UTF8Type.instance.decompose(droppedColumn.name), droppedColumn);
public void init(String keyspace) { Cluster.Builder builder = Cluster.builder().addContactPoints(hosts).withPort(port); if (sslOptions != null) builder.withSSL(sslOptions); if (authProvider != null) builder = builder.withAuthProvider(authProvider); try (Cluster cluster = builder.build(); Session session = cluster.connect()) { Metadata metadata = cluster.getMetadata(); Set<TokenRange> tokenRanges = metadata.getTokenRanges(); IPartitioner partitioner = FBUtilities.newPartitioner(metadata.getPartitioner()); TokenFactory tokenFactory = partitioner.getTokenFactory(); for (TokenRange tokenRange : tokenRanges) { Set<Host> endpoints = metadata.getReplicas(Metadata.quote(keyspace), tokenRange); Range<Token> range = new Range<>(tokenFactory.fromString(tokenRange.getStart().getValue().toString()), tokenFactory.fromString(tokenRange.getEnd().getValue().toString())); for (Host endpoint : endpoints) addRangeForEndpoint(range, endpoint.getAddress()); } Types types = fetchTypes(keyspace, session); tables.putAll(fetchTables(keyspace, session, partitioner, types)); // We only need the CFMetaData for the views, so we only load that. tables.putAll(fetchViews(keyspace, session, partitioner, types)); } }
defs.add(createDefinitionFromRow(colRow, keyspace, name, types)); for (Row colRow : session.execute(droppedColumnsQuery, keyspace, name)) CFMetaData.DroppedColumn droppedColumn = createDroppedColumnFromRow(colRow, keyspace); droppedColumns.put(UTF8Type.instance.decompose(droppedColumn.name), droppedColumn);
private static Map<String, CFMetaData> fetchTables(String keyspace, Session session, IPartitioner partitioner, Types types) { Map<String, CFMetaData> tables = new HashMap<>(); String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, SchemaKeyspace.TABLES); for (Row row : session.execute(query, keyspace)) { String name = row.getString("table_name"); tables.put(name, createTableMetadata(keyspace, session, partitioner, false, row, name, types)); } return tables; }
private static Map<String, CFMetaData> fetchViews(String keyspace, Session session, IPartitioner partitioner, Types types) { Map<String, CFMetaData> tables = new HashMap<>(); String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, SchemaKeyspace.VIEWS); for (Row row : session.execute(query, keyspace)) { String name = row.getString("view_name"); tables.put(name, createTableMetadata(keyspace, session, partitioner, true, row, name, types)); } return tables; }
private static Map<String, CFMetaData> fetchTables(String keyspace, Session session, IPartitioner partitioner, Types types) { Map<String, CFMetaData> tables = new HashMap<>(); String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, SchemaKeyspace.TABLES); for (Row row : session.execute(query, keyspace)) { String name = row.getString("table_name"); tables.put(name, createTableMetadata(keyspace, session, partitioner, false, row, name, types)); } return tables; }
private static Map<String, CFMetaData> fetchViews(String keyspace, Session session, IPartitioner partitioner, Types types) { Map<String, CFMetaData> tables = new HashMap<>(); String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, SchemaKeyspace.VIEWS); for (Row row : session.execute(query, keyspace)) { String name = row.getString("view_name"); tables.put(name, createTableMetadata(keyspace, session, partitioner, true, row, name, types)); } return tables; }
private static Map<String, CFMetaData> fetchViews(String keyspace, Session session, IPartitioner partitioner, Types types) { Map<String, CFMetaData> tables = new HashMap<>(); String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ?", SchemaConstants.SCHEMA_KEYSPACE_NAME, SchemaKeyspace.VIEWS); for (Row row : session.execute(query, keyspace)) { String name = row.getString("view_name"); tables.put(name, createTableMetadata(keyspace, session, partitioner, true, row, name, types)); } return tables; }