public Builder incrementVersion() { this.version = version + 1; this.clusterUUID = SystemKeyspace.getLocalHostId().toString(); return this; }
private static void migrateIndexBuildStatus(String keyspace, String table, IndexMetadata index) { if (SystemKeyspace.isIndexBuilt(keyspace, table + '.' + index.name)) { SystemKeyspace.setIndexBuilt(keyspace, index.name); SystemKeyspace.setIndexRemoved(keyspace, table + '.' + index.name); } }
public static long getTruncatedAt(UUID cfId) { Pair<CommitLogPosition, Long> record = getTruncationRecord(cfId); return record == null ? Long.MIN_VALUE : record.right; }
if (SystemKeyspace.wasDecommissioned()) SystemKeyspace.setBootstrapState(SystemKeyspace.BootstrapState.COMPLETED); MessagingService.instance().listen(); UUID localHostId = SystemKeyspace.getLocalHostId(); SystemKeyspace.updateTokens(bootstrapTokens); checkForEndpointCollision(localHostId, SystemKeyspace.loadHostIds().keySet()); Gossiper.instance.start(SystemKeyspace.incrementAndGetGeneration(), appStates); // needed for node-ring gathering. gossipActive = true;
UUID localHostId = SystemKeyspace.getLocalHostId(); String ksname = baseCfs.metadata.ksName, viewName = view.name; if (SystemKeyspace.isViewBuilt(ksname, viewName)) if (!SystemKeyspace.isViewStatusReplicated(ksname, viewName)) updateDistributed(ksname, viewName, localHostId); return; final Pair<Integer, Token> buildStatus = SystemKeyspace.getViewBuildStatus(ksname, viewName); Token lastToken; Function<org.apache.cassandra.db.lifecycle.View, Iterable<SSTableReader>> function; SystemKeyspace.beginViewBuild(ksname, viewName, 0); SystemKeyspace.updateViewBuildStatus(ksname, viewName, key.getToken()); prevToken = token; SystemKeyspace.finishViewBuildStatus(ksname, viewName); updateDistributed(ksname, viewName, localHostId);
SystemKeyspace.bootstrapInProgress(), SystemKeyspace.bootstrapComplete(), DatabaseDescriptor.getSeeds().contains(FBUtilities.getBroadcastAddress())); if (DatabaseDescriptor.isAutoBootstrap() && !SystemKeyspace.bootstrapComplete() && DatabaseDescriptor.getSeeds().contains(FBUtilities.getBroadcastAddress())) if (bootstrap) if (SystemKeyspace.bootstrapInProgress()) logger.warn("Detected previous bootstrap failure; retrying"); else SystemKeyspace.setBootstrapState(SystemKeyspace.BootstrapState.IN_PROGRESS); setMode(Mode.JOINING, "waiting for ring information", true); waitForSchema(delay); bootstrapTokens = SystemKeyspace.getSavedTokens(); if (bootstrapTokens.isEmpty()) logger.warn("Some data streaming failed. Use nodetool to check bootstrap state and resume. For more, see `nodetool help bootstrap`. {}", SystemKeyspace.getBootstrapState());
if (SystemKeyspace.snapshotOnVersionChange()) SystemKeyspace.migrateDataDirs(); SystemKeyspace.persistLocalMetadata(); SystemKeyspace.finishStartup();
private synchronized UUID prepareForReplacement() throws ConfigurationException if (SystemKeyspace.bootstrapComplete()) throw new RuntimeException("Cannot replace address with a node that is already bootstrapped"); UUID localHostId = SystemKeyspace.getLocalHostId(); SystemKeyspace.setLocalHostId(localHostId); // use the replacee's host Id as our own so we receive hints, etc
if (DatabaseDescriptor.isReplacing()) if (SystemKeyspace.bootstrapComplete()) throw new RuntimeException("Cannot replace address with a node that is already bootstrapped"); if (!DatabaseDescriptor.isAutoBootstrap()) UUID localHostId = SystemKeyspace.getLocalHostId(); getTokenMetadata().updateHostId(localHostId, FBUtilities.getBroadcastAddress()); appStates.put(ApplicationState.NET_VERSION, valueFactory.networkVersion()); logger.info("Starting up server gossip"); Gossiper.instance.register(this); Gossiper.instance.start(SystemKeyspace.incrementAndGetGeneration(), appStates); // needed for node-ring gathering.
public boolean waitIndexRebuilt(String keyspace, List<String> types, long timeout) throws InterruptedException { for(int i = 0; i < timeout; i+=200) { if (types.stream().filter(t -> !SystemKeyspace.isIndexBuilt(keyspace, String.format(Locale.ROOT, "elastic_%s_idx", t))).count() == 0) return true; Thread.sleep(200); } return false; }
SystemKeyspace.updatePeerInfo(endpoint, "release_version", entry.getValue().value); break; case DC: SystemKeyspace.updatePeerInfo(endpoint, "data_center", entry.getValue().value); break; case RACK: SystemKeyspace.updatePeerInfo(endpoint, "rack", entry.getValue().value); break; case RPC_ADDRESS: try SystemKeyspace.updatePeerInfo(endpoint, "rpc_address", InetAddress.getByName(entry.getValue().value)); SystemKeyspace.updatePeerInfo(endpoint, "schema_version", UUID.fromString(entry.getValue().value)); break; case HOST_ID: SystemKeyspace.updatePeerInfo(endpoint, "host_id", UUID.fromString(entry.getValue().value)); break;
try SystemKeyspace.checkHealth(); Map<Pair<String, String>, Map<Integer, UUID>> unfinishedCompactions = SystemKeyspace.getUnfinishedCompactions(); for (Pair<String, String> kscf : unfinishedCompactions.keySet()) ColumnFamilyStore.removeUnfinishedCompactionLeftovers(cfm, unfinishedCompactions.get(kscf)); SystemKeyspace.discardCompactionsInProgress(); SystemKeyspace.finishStartup();
public boolean resumeBootstrap() if (isBootstrapMode && SystemKeyspace.bootstrapInProgress()) final Collection<Token> tokens = SystemKeyspace.getSavedTokens();
@Override protected void before() { if (server != null) return; DatabaseDescriptor.daemonInitialization(); // Cleanup first try { cleanupAndLeaveDirs(); } catch (IOException e) { throw new RuntimeException("Failed to cleanup and recreate directories.", e); } Keyspace.setInitialized(); SystemKeyspace.persistLocalMetadata(); SystemKeyspace.finishStartup(); StorageService.instance.initServer(); server = new Server.Builder().withHost(nativeAddr).withPort(nativePort).build(); server.start(); }
private boolean isReplacing() { if (System.getProperty("cassandra.replace_address_first_boot", null) != null && SystemKeyspace.bootstrapComplete()) { logger.info("Replace address on first boot requested; this node is already bootstrapped"); return false; } return DatabaseDescriptor.getReplaceAddress() != null; }
public void run() { if (obsoletion == null) { meterSyncThrottle.acquire(); SystemKeyspace.persistSSTableReadMeter(desc.ksname, desc.cfname, desc.generation, readMeter); } } }, 1, 5, TimeUnit.MINUTES));
public void tidy() { lookup.remove(desc); if (readMeterSyncFuture != null) readMeterSyncFuture.cancel(true); if (isCompacted.get()) SystemKeyspace.clearSSTableReadMeter(desc.ksname, desc.cfname, desc.generation); // don't ideally want to dropPageCache for the file until all instances have been released CLibrary.trySkipCache(desc.filenameFor(Component.DATA), 0, 0); CLibrary.trySkipCache(desc.filenameFor(Component.PRIMARY_INDEX), 0, 0); }
void ensureReadMeter() { if (readMeter != null) return; // Don't track read rates for tables in the system keyspace and don't bother trying to load or persist // the read meter when in client mode. if (Keyspace.SYSTEM_KS.equals(desc.ksname) || Config.isClientMode()) { readMeter = null; readMeterSyncFuture = null; return; } readMeter = SystemKeyspace.getSSTableReadMeter(desc.ksname, desc.cfname, desc.generation); // sync the average read rate to system.sstable_activity every five minutes, starting one minute from now readMeterSyncFuture = syncExecutor.scheduleAtFixedRate(new Runnable() { public void run() { if (!isCompacted.get()) { meterSyncThrottle.acquire(); SystemKeyspace.persistSSTableReadMeter(desc.ksname, desc.cfname, desc.generation, readMeter); } } }, 1, 5, TimeUnit.MINUTES); }
if (SystemKeyspace.wasDecommissioned()) SystemKeyspace.setBootstrapState(SystemKeyspace.BootstrapState.COMPLETED); MessagingService.instance().listen(); UUID localHostId = SystemKeyspace.getLocalHostId(); SystemKeyspace.updateTokens(bootstrapTokens); checkForEndpointCollision(localHostId, SystemKeyspace.loadHostIds().keySet()); Gossiper.instance.start(SystemKeyspace.incrementAndGetGeneration(), appStates); // needed for node-ring gathering. gossipActive = true;
UUID localHostId = SystemKeyspace.getLocalHostId(); String ksname = baseCfs.metadata.ksName, viewName = view.name; if (SystemKeyspace.isViewBuilt(ksname, viewName)) if (!SystemKeyspace.isViewStatusReplicated(ksname, viewName)) updateDistributed(ksname, viewName, localHostId); return; final Pair<Integer, Token> buildStatus = SystemKeyspace.getViewBuildStatus(ksname, viewName); Token lastToken; Function<org.apache.cassandra.db.lifecycle.View, Iterable<SSTableReader>> function; SystemKeyspace.beginViewBuild(ksname, viewName, 0); SystemKeyspace.updateViewBuildStatus(ksname, viewName, key.getToken()); prevToken = token; SystemKeyspace.finishViewBuildStatus(ksname, viewName); updateDistributed(ksname, viewName, localHostId);