/** * Clears persisted read rates from system.sstable_activity for SSTables that have been deleted. */ public static void clearSSTableReadMeter(String keyspace, String table, int generation) { String cql = "DELETE FROM system.%s WHERE keyspace_name=? AND columnfamily_name=? and generation=?"; executeInternal(String.format(cql, SSTABLE_ACTIVITY), keyspace, table, generation); }
public static void beginViewBuild(String ksname, String viewName, int generationNumber) { executeInternal(String.format("INSERT INTO system.%s (keyspace_name, view_name, generation_number) VALUES (?, ?, ?)", VIEWS_BUILDS_IN_PROGRESS), ksname, viewName, generationNumber); }
/** * Clears size estimates for a table (on table drop) */ public static void clearSizeEstimates(String keyspace, String table) { String cql = String.format("DELETE FROM %s.%s WHERE keyspace_name = ? AND table_name = ?", SchemaConstants.SYSTEM_KEYSPACE_NAME, SIZE_ESTIMATES); executeInternal(cql, keyspace, table); }
public static TabularData getCompactionHistory() throws OpenDataException { UntypedResultSet queryResultSet = executeInternal(String.format("SELECT * from system.%s", COMPACTION_HISTORY)); return CompactionHistoryTabularData.from(queryResultSet); }
public static boolean isViewBuilt(String keyspaceName, String viewName) { String req = "SELECT view_name FROM %s.\"%s\" WHERE keyspace_name=? AND view_name=?"; UntypedResultSet result = executeInternal(String.format(req, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_VIEWS), keyspaceName, viewName); return !result.isEmpty(); }
public static void setIndexRemoved(String keyspaceName, String indexName) { String req = "DELETE FROM %s.\"%s\" WHERE table_name = ? AND index_name = ?"; executeInternal(String.format(req, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_INDEXES), keyspaceName, indexName); forceBlockingFlush(BUILT_INDEXES); }
public static void writePreparedStatement(String loggedKeyspace, MD5Digest key, String cql) { executeInternal(String.format("INSERT INTO %s.%s" + " (logged_keyspace, prepared_id, query_string) VALUES (?, ?, ?)", SchemaConstants.SYSTEM_KEYSPACE_NAME, PREPARED_STATEMENTS), loggedKeyspace, key.byteBuffer(), cql); logger.debug("stored prepared statement for logged keyspace '{}': '{}'", loggedKeyspace, cql); }
public static boolean isViewBuilt(String keyspaceName, String viewName) { String req = "SELECT view_name FROM %s.\"%s\" WHERE keyspace_name=? AND view_name=?"; UntypedResultSet result = executeInternal(String.format(req, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_VIEWS), keyspaceName, viewName); return !result.isEmpty(); }
public static void setViewBuilt(String keyspaceName, String viewName, boolean replicated) { String req = "INSERT INTO %s.\"%s\" (keyspace_name, view_name, status_replicated) VALUES (?, ?, ?)"; executeInternal(String.format(req, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_VIEWS), keyspaceName, viewName, replicated); forceBlockingFlush(BUILT_VIEWS); }
public static void setIndexBuilt(String keyspaceName, String indexName) { String req = "INSERT INTO %s.\"%s\" (table_name, index_name) VALUES (?, ?)"; executeInternal(String.format(req, SchemaConstants.SYSTEM_KEYSPACE_NAME, BUILT_INDEXES), keyspaceName, indexName); forceBlockingFlush(BUILT_INDEXES); }
public static Future<?> updatePeerInfo(final InetAddress ep, final String columnName, final Object value, ExecutorService executorService) { if (ep.equals(FBUtilities.getBroadcastAddress())) return Futures.immediateFuture(null); String req = "INSERT INTO system.%s (peer, %s) VALUES (?, ?)"; return executorService.submit((Runnable) () -> executeInternal(String.format(req, PEERS, columnName), ep, value)); }
public static void setBootstrapState(BootstrapState state) { String req = "INSERT INTO system.%s (key, bootstrapped) VALUES ('%s', ?)"; executeInternal(String.format(req, LOCAL, LOCAL), state.name()); forceBlockingFlush(LOCAL); }
public static void updateViewBuildStatus(String ksname, String viewName, Token token) { String req = "INSERT INTO system.%s (keyspace_name, view_name, last_token) VALUES (?, ?, ?)"; Token.TokenFactory factory = ViewsBuildsInProgress.partitioner.getTokenFactory(); executeInternal(String.format(req, VIEWS_BUILDS_IN_PROGRESS), ksname, viewName, factory.toString(token)); }
public static synchronized void saveTruncationRecord(ColumnFamilyStore cfs, long truncatedAt, CommitLogPosition position) { String req = "UPDATE system.%s SET truncated_at = truncated_at + ? WHERE key = '%s'"; executeInternal(String.format(req, LOCAL, LOCAL), truncationAsMapEntry(cfs, truncatedAt, position)); truncationRecords = null; forceBlockingFlush(LOCAL); }
/** * Record tokens being used by another node */ public static Future<?> updateTokens(final InetAddress ep, final Collection<Token> tokens, ExecutorService executorService) { if (ep.equals(FBUtilities.getBroadcastAddress())) return Futures.immediateFuture(null); String req = "INSERT INTO system.%s (peer, tokens) VALUES (?, ?)"; return executorService.submit((Runnable) () -> executeInternal(String.format(req, PEERS), ep, tokensAsSet(tokens))); }
@VisibleForTesting public int countAllBatches() { String query = String.format("SELECT count(*) FROM %s.%s", SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.BATCHES); UntypedResultSet results = executeInternal(query); if (results == null || results.isEmpty()) return 0; return (int) results.one().getLong("count"); }
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(String.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"); }
public static Collection<Token> getSavedTokens() { String req = "SELECT tokens FROM system.%s WHERE key='%s'"; UntypedResultSet result = executeInternal(String.format(req, LOCAL, LOCAL)); return result.isEmpty() || !result.one().has("tokens") ? Collections.<Token>emptyList() : deserializeTokens(result.one().getSet("tokens", UTF8Type.instance)); }
/** * Gets the stored data center for the local node, or null if none have been set yet. */ public static String getDatacenter() { String req = "SELECT data_center FROM system.%s WHERE key='%s'"; UntypedResultSet result = executeInternal(String.format(req, LOCAL, LOCAL)); // Look up the Data center (return it if found) if (!result.isEmpty() && result.one().has("data_center")) return result.one().getString("data_center"); return null; }
/** * Gets the stored data center for the local node, or null if none have been set yet. */ public static String getDatacenter() { String req = "SELECT data_center FROM system.%s WHERE key='%s'"; UntypedResultSet result = executeInternal(String.format(req, LOCAL, LOCAL)); // Look up the Data center (return it if found) if (!result.isEmpty() && result.one().has("data_center")) return result.one().getString("data_center"); return null; }