private static void setupVersion() { String req = "INSERT INTO system.%s (key, release_version, cql_version, thrift_version, data_center, rack, partitioner) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s')"; IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch(); processInternal(String.format(req, LOCAL_CF, LOCAL_KEY, FBUtilities.getReleaseVersionString(), QueryProcessor.CQL_VERSION.toString(), Constants.VERSION, snitch.getDatacenter(FBUtilities.getBroadcastAddress()), snitch.getRack(FBUtilities.getBroadcastAddress()), DatabaseDescriptor.getPartitioner().getClass().getName())); }
public synchronized void initServer() throws IOException, org.apache.cassandra.config.ConfigurationException { logger_.info("Cassandra version: " + FBUtilities.getReleaseVersionString()); logger_.info("Thrift API version: " + Constants.VERSION); if (initialized) { if (isClientMode) throw new UnsupportedOperationException("StorageService does not support switching modes."); return; } initialized = true; isClientMode = false; if (Boolean.parseBoolean(System.getProperty("cassandra.load_ring_state", "true"))) { logger_.info("Loading persisted ring state"); for (Map.Entry<Token, InetAddress> entry : SystemTable.loadTokens().entrySet()) { tokenMetadata_.updateNormalToken(entry.getKey(), entry.getValue()); Gossiper.instance.addSavedEndpoint(entry.getValue()); } } if (Boolean.parseBoolean(System.getProperty("cassandra.renew_counter_id", "false"))) { logger_.info("Renewing local node id (as requested)"); NodeId.renewLocalId(); } // daemon threads, like our executors', continue to run while shutdown hooks are invoked Thread drainOnShutdown = new Thread(new WrappedRunnable() { public void runMayThrow() throws ExecutionException, InterruptedException, IOException { ThreadPoolExecutor mutationStage = StageManager.getStage(Stage.MUTATION); if (!mutationStage.isShutdown()) { mutationStage.shutdown(); mutationStage.awaitTermination(1, TimeUnit.SECONDS); CommitLog.instance.shutdownBlocking(); } List<Future<?>> flushes = new ArrayList<Future<?>>(); for (Table table : Table.all()) { KSMetaData ksm = DatabaseDescriptor.getKSMetaData(table.name); if (!ksm.isDurableWrites()) { for (ColumnFamilyStore cfs : table.getColumnFamilyStores()) { Future<?> future = cfs.forceFlush(); if (future != null) flushes.add(future); } } } FBUtilities.waitOnFutures(flushes); } }); Runtime.getRuntime().addShutdownHook(drainOnShutdown); if (Boolean.parseBoolean(System.getProperty("cassandra.join_ring", "true"))) { joinTokenRing(); } else { logger_.info("Not joining ring as requested. Use JMX (StorageService->joinRing()) to initiate ring joining"); } }