private void scheduleSetupTask(final Callable<Void> setupTask) { // The delay is to give the node a chance to see its peers before attempting the operation ScheduledExecutors.optionalTasks.schedule(new Runnable() { public void run() { // If not all nodes are on 2.2, we don't want to initialize the role manager as this will confuse 2.1 // nodes (see CASSANDRA-9761 for details). So we re-schedule the setup for later, hoping that the upgrade // will be finished by then. if (!MessagingService.instance().areAllNodesAtLeast22()) { logger.trace("Not all nodes are upgraded to a version that supports Roles yet, rescheduling setup task"); scheduleSetupTask(setupTask); return; } isClusterReady = true; try { setupTask.call(); } catch (Exception e) { logger.info("Setup task failed with error, rescheduling"); scheduleSetupTask(setupTask); } } }, AuthKeyspace.SUPERUSER_SETUP_DELAY, TimeUnit.MILLISECONDS); }
private void scheduleSetupTask(final Callable<Void> setupTask) { // The delay is to give the node a chance to see its peers before attempting the operation ScheduledExecutors.optionalTasks.schedule(new Runnable() { public void run() { // If not all nodes are on 2.2, we don't want to initialize the role manager as this will confuse 2.1 // nodes (see CASSANDRA-9761 for details). So we re-schedule the setup for later, hoping that the upgrade // will be finished by then. if (!MessagingService.instance().areAllNodesAtLeast22()) { logger.trace("Not all nodes are upgraded to a version that supports Roles yet, rescheduling setup task"); scheduleSetupTask(setupTask); return; } isClusterReady = true; try { setupTask.call(); } catch (Exception e) { logger.info("Setup task failed with error, rescheduling"); scheduleSetupTask(setupTask); } } }, AuthKeyspace.SUPERUSER_SETUP_DELAY, TimeUnit.MILLISECONDS); }
private void scheduleSetupTask(final Callable<Void> setupTask) { // The delay is to give the node a chance to see its peers before attempting the operation ScheduledExecutors.optionalTasks.schedule(new Runnable() { public void run() { // If not all nodes are on 2.2, we don't want to initialize the role manager as this will confuse 2.1 // nodes (see CASSANDRA-9761 for details). So we re-schedule the setup for later, hoping that the upgrade // will be finished by then. if (!MessagingService.instance().areAllNodesAtLeast22()) { logger.trace("Not all nodes are upgraded to a version that supports Roles yet, rescheduling setup task"); scheduleSetupTask(setupTask); return; } isClusterReady = true; try { setupTask.call(); } catch (Exception e) { logger.info("Setup task failed with error, rescheduling"); scheduleSetupTask(setupTask); } } }, AuthKeyspace.SUPERUSER_SETUP_DELAY, TimeUnit.MILLISECONDS); }
ScheduledExecutors.scheduledTasks.schedule(runnable, period, TimeUnit.MILLISECONDS);
/** for tests */ public static void waitForDeletions() { Runnable runnable = new Runnable() { public void run() { } }; FBUtilities.waitOnFuture(ScheduledExecutors.nonPeriodicTasks.schedule(runnable, 0, TimeUnit.MILLISECONDS)); } }
static void waitForDeletions() { FBUtilities.waitOnFuture(ScheduledExecutors.nonPeriodicTasks.schedule(Runnables.doNothing(), 0, TimeUnit.MILLISECONDS)); }
static void waitForDeletions() { FBUtilities.waitOnFuture(ScheduledExecutors.nonPeriodicTasks.schedule(Runnables.doNothing(), 0, TimeUnit.MILLISECONDS)); }
static void waitForDeletions() { FBUtilities.waitOnFuture(ScheduledExecutors.nonPeriodicTasks.schedule(Runnables.doNothing(), 0, TimeUnit.MILLISECONDS)); }
public static void userFunctionTimeout(Throwable t) { switch (DatabaseDescriptor.getUserFunctionTimeoutPolicy()) { case die: // policy to give 250ms grace time to ScheduledExecutors.nonPeriodicTasks.schedule(() -> killer.killCurrentJVM(t), 250, TimeUnit.MILLISECONDS); break; case die_immediate: killer.killCurrentJVM(t); break; case ignore: logger.error(t.getMessage()); break; } }
public static void userFunctionTimeout(Throwable t) { switch (DatabaseDescriptor.getUserFunctionTimeoutPolicy()) { case die: // policy to give 250ms grace time to ScheduledExecutors.nonPeriodicTasks.schedule(() -> killer.killCurrentJVM(t), 250, TimeUnit.MILLISECONDS); break; case die_immediate: killer.killCurrentJVM(t); break; case ignore: logger.error(t.getMessage()); break; } }
public static void userFunctionTimeout(Throwable t) { switch (DatabaseDescriptor.getUserFunctionTimeoutPolicy()) { case die: // policy to give 250ms grace time to ScheduledExecutors.nonPeriodicTasks.schedule(() -> killer.killCurrentJVM(t), 250, TimeUnit.MILLISECONDS); break; case die_immediate: killer.killCurrentJVM(t); break; case ignore: logger.error(t.getMessage()); break; } }
private void updateDistributed(String ksname, String viewName, UUID localHostId) { try { SystemDistributedKeyspace.successfulViewBuild(ksname, viewName, localHostId); SystemKeyspace.setViewBuiltReplicated(ksname, viewName); } catch (Exception e) { ScheduledExecutors.nonPeriodicTasks.schedule(() -> CompactionManager.instance.submitViewBuilder(this), 5, TimeUnit.MINUTES); logger.warn("Failed to updated the distributed status of view, sleeping 5 minutes before retrying", e); } }
private void updateDistributed(String ksname, String viewName, UUID localHostId) { try { SystemDistributedKeyspace.successfulViewBuild(ksname, viewName, localHostId); SystemKeyspace.setViewBuiltReplicated(ksname, viewName); } catch (Exception e) { ScheduledExecutors.nonPeriodicTasks.schedule(() -> CompactionManager.instance.submitViewBuilder(this), 5, TimeUnit.MINUTES); logger.warn("Failed to updated the distributed status of view, sleeping 5 minutes before retrying", e); } }
private void updateDistributed(String ksname, String viewName, UUID localHostId) { try { SystemDistributedKeyspace.successfulViewBuild(ksname, viewName, localHostId); SystemKeyspace.setViewBuiltReplicated(ksname, viewName); } catch (Exception e) { ScheduledExecutors.nonPeriodicTasks.schedule(() -> CompactionManager.instance.submitViewBuilder(this), 5, TimeUnit.MINUTES); logger.warn("Failed to updated the distributed status of view, sleeping 5 minutes before retrying", e); } }
public void setup() { Auth.setupTable(CREDENTIALS_CF, CREDENTIALS_CF_SCHEMA); // the delay is here to give the node some time to see its peers - to reduce // "skipped default user setup: some nodes are were not ready" log spam. // It's the only reason for the delay. ScheduledExecutors.nonPeriodicTasks.schedule(new Runnable() { public void run() { setupDefaultUser(); } }, Auth.SUPERUSER_SETUP_DELAY, TimeUnit.MILLISECONDS); try { String query = String.format("SELECT %s FROM %s.%s WHERE username = ?", SALTED_HASH, Auth.AUTH_KS, CREDENTIALS_CF); authenticateStatement = (SelectStatement) QueryProcessor.parseStatement(query).prepare().statement; } catch (RequestValidationException e) { throw new AssertionError(e); // not supposed to happen } }
public void setup() { authorizeRoleStatement = prepare(ROLE, AuthKeyspace.ROLE_PERMISSIONS); // If old user permissions table exists, migrate the legacy authz data to the new table // The delay is to give the node a chance to see its peers before attempting the conversion if (Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, "permissions") != null) { legacyAuthorizeRoleStatement = prepare(USERNAME, USER_PERMISSIONS); ScheduledExecutors.optionalTasks.schedule(new Runnable() { public void run() { convertLegacyData(); } }, AuthKeyspace.SUPERUSER_SETUP_DELAY, TimeUnit.MILLISECONDS); } }
public void setup() { authorizeRoleStatement = prepare(ROLE, AuthKeyspace.ROLE_PERMISSIONS); // If old user permissions table exists, migrate the legacy authz data to the new table // The delay is to give the node a chance to see its peers before attempting the conversion if (Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, "permissions") != null) { legacyAuthorizeRoleStatement = prepare(USERNAME, USER_PERMISSIONS); ScheduledExecutors.optionalTasks.schedule(new Runnable() { public void run() { convertLegacyData(); } }, AuthKeyspace.SUPERUSER_SETUP_DELAY, TimeUnit.MILLISECONDS); } }
public void setup() { authorizeRoleStatement = prepare(ROLE, AuthKeyspace.ROLE_PERMISSIONS); // If old user permissions table exists, migrate the legacy authz data to the new table // The delay is to give the node a chance to see its peers before attempting the conversion if (Schema.instance.getCFMetaData(SchemaConstants.AUTH_KEYSPACE_NAME, "permissions") != null) { legacyAuthorizeRoleStatement = prepare(USERNAME, USER_PERMISSIONS); ScheduledExecutors.optionalTasks.schedule(new Runnable() { public void run() { convertLegacyData(); } }, AuthKeyspace.SUPERUSER_SETUP_DELAY, TimeUnit.MILLISECONDS); } }
private void excise(Collection<Token> tokens, InetAddress endpoint) { logger.info("Removing tokens {} for {}", tokens, endpoint); UUID hostId = tokenMetadata.getHostId(endpoint); if (hostId != null && tokenMetadata.isMember(endpoint)) { // enough time for writes to expire and MessagingService timeout reporter callback to fire, which is where // hints are mostly written from - using getMinRpcTimeout() / 2 for the interval. long delay = DatabaseDescriptor.getMinRpcTimeout() + DatabaseDescriptor.getWriteRpcTimeout(); ScheduledExecutors.optionalTasks.schedule(() -> HintsService.instance.excise(hostId), delay, TimeUnit.MILLISECONDS); } removeEndpoint(endpoint); tokenMetadata.removeEndpoint(endpoint); if (!tokens.isEmpty()) tokenMetadata.removeBootstrapTokens(tokens); notifyLeft(endpoint); PendingRangeCalculatorService.instance.update(); }
private void excise(Collection<Token> tokens, InetAddress endpoint) { logger.info("Removing tokens {} for {}", tokens, endpoint); UUID hostId = tokenMetadata.getHostId(endpoint); if (hostId != null && tokenMetadata.isMember(endpoint)) { // enough time for writes to expire and MessagingService timeout reporter callback to fire, which is where // hints are mostly written from - using getMinRpcTimeout() / 2 for the interval. long delay = DatabaseDescriptor.getMinRpcTimeout() + DatabaseDescriptor.getWriteRpcTimeout(); ScheduledExecutors.optionalTasks.schedule(() -> HintsService.instance.excise(hostId), delay, TimeUnit.MILLISECONDS); } removeEndpoint(endpoint); tokenMetadata.removeEndpoint(endpoint); if (!tokens.isEmpty()) tokenMetadata.removeBootstrapTokens(tokens); notifyLeft(endpoint); PendingRangeCalculatorService.instance.update(); }