use of org.apache.cassandra.cql3.UntypedResultSet.Row in project cassandra by apache.
the class SystemKeyspace method isViewStatusReplicated.
public static boolean isViewStatusReplicated(String keyspaceName, String viewName) {
String req = "SELECT status_replicated FROM %s.\"%s\" WHERE keyspace_name=? AND view_name=?";
UntypedResultSet result = executeInternal(format(req, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_VIEWS), keyspaceName, viewName);
if (result.isEmpty())
return false;
UntypedResultSet.Row row = result.one();
return row.has("status_replicated") && row.getBoolean("status_replicated");
}
use of org.apache.cassandra.cql3.UntypedResultSet.Row in project cassandra by apache.
the class SystemKeyspace method loadDcRackInfo.
/**
* Return a map of IP addresses containing a map of dc and rack info
*/
public static Map<InetAddress, Map<String, String>> loadDcRackInfo() {
Map<InetAddress, Map<String, String>> result = new HashMap<>();
for (UntypedResultSet.Row row : executeInternal("SELECT peer, data_center, rack from system." + PEERS)) {
InetAddress peer = row.getInetAddress("peer");
if (row.has("data_center") && row.has("rack")) {
Map<String, String> dcRack = new HashMap<>();
dcRack.put("data_center", row.getString("data_center"));
dcRack.put("rack", row.getString("rack"));
result.put(peer, dcRack);
}
}
return result;
}
use of org.apache.cassandra.cql3.UntypedResultSet.Row in project cassandra by apache.
the class SystemKeyspace method loadPreparedStatements.
public static List<Pair<String, String>> loadPreparedStatements() {
String query = format("SELECT logged_keyspace, query_string FROM %s", PreparedStatements.toString());
UntypedResultSet resultSet = executeOnceInternal(query);
List<Pair<String, String>> r = new ArrayList<>();
for (UntypedResultSet.Row row : resultSet) r.add(Pair.create(row.has("logged_keyspace") ? row.getString("logged_keyspace") : null, row.getString("query_string")));
return r;
}
use of org.apache.cassandra.cql3.UntypedResultSet.Row in project cassandra by apache.
the class SystemKeyspace method getViewBuildStatus.
public static Pair<Integer, Token> getViewBuildStatus(String ksname, String viewName) {
String req = "SELECT generation_number, last_token FROM system.%s WHERE keyspace_name = ? AND view_name = ?";
UntypedResultSet queryResultSet = executeInternal(format(req, VIEWS_BUILDS_IN_PROGRESS), ksname, viewName);
if (queryResultSet == null || queryResultSet.isEmpty())
return null;
UntypedResultSet.Row row = queryResultSet.one();
Integer generation = null;
Token lastKey = null;
if (row.has("generation_number"))
generation = row.getInt("generation_number");
if (row.has("last_key")) {
Token.TokenFactory factory = ViewsBuildsInProgress.partitioner.getTokenFactory();
lastKey = factory.fromString(row.getString("last_key"));
}
return Pair.create(generation, lastKey);
}
use of org.apache.cassandra.cql3.UntypedResultSet.Row in project cassandra by apache.
the class SystemKeyspace method getAvailableRanges.
public static synchronized Set<Range<Token>> getAvailableRanges(String keyspace, IPartitioner partitioner) {
Set<Range<Token>> result = new HashSet<>();
String query = "SELECT * FROM system.%s WHERE keyspace_name=?";
UntypedResultSet rs = executeInternal(format(query, AVAILABLE_RANGES), keyspace);
for (UntypedResultSet.Row row : rs) {
Set<ByteBuffer> rawRanges = row.getSet("ranges", BytesType.instance);
for (ByteBuffer rawRange : rawRanges) {
result.add(byteBufferToRange(rawRange, partitioner));
}
}
return ImmutableSet.copyOf(result);
}
Aggregations