本文整理汇总了Java中org.apache.cassandra.utils.FBUtilities.waitOnFuture方法的典型用法代码示例。如果您正苦于以下问题:Java FBUtilities.waitOnFuture方法的具体用法?Java FBUtilities.waitOnFuture怎么用?Java FBUtilities.waitOnFuture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.utils.FBUtilities
的用法示例。
在下文中一共展示了FBUtilities.waitOnFuture方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: announce
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/**
* actively announce a new version to active hosts via rpc
* @param schema The schema mutation to be applied
*/
private static void announce(Mutation schema, boolean announceLocally)
{
if (announceLocally)
{
try
{
DefsTables.mergeSchemaInternal(Collections.singletonList(schema), false);
}
catch (ConfigurationException | IOException e)
{
throw new RuntimeException(e);
}
}
else
{
FBUtilities.waitOnFuture(announce(Collections.singletonList(schema)));
}
}
示例2: buildIndexBlocking
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/**
* Builds the index using the data in the underlying CFS
* Blocks till it's complete
*/
protected void buildIndexBlocking()
{
logger.info(String.format("Submitting index build of %s for data in %s",
getIndexName(), StringUtils.join(baseCfs.getSSTables(), ", ")));
try (Refs<SSTableReader> sstables = baseCfs.selectAndReference(ColumnFamilyStore.CANONICAL_SSTABLES).refs)
{
SecondaryIndexBuilder builder = new SecondaryIndexBuilder(baseCfs,
Collections.singleton(getIndexName()),
new ReducingKeyIterator(sstables));
Future<?> future = CompactionManager.instance.submitIndexBuild(builder);
FBUtilities.waitOnFuture(future);
forceBlockingFlush();
setIndexBuilt();
}
logger.info("Index build of {} complete", getIndexName());
}
示例3: maybeBuildSecondaryIndexes
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/**
* Does a full, blocking rebuild of the indexes specified by columns from the sstables.
* Does nothing if columns is empty.
*
* Caller must acquire and release references to the sstables used here.
*
* @param sstables the data to build from
* @param idxNames the list of columns to index, ordered by comparator
*/
public void maybeBuildSecondaryIndexes(Collection<SSTableReader> sstables, Set<String> idxNames)
{
if (idxNames.isEmpty())
return;
logger.info(String.format("Submitting index build of %s for data in %s",
idxNames, StringUtils.join(sstables, ", ")));
SecondaryIndexBuilder builder = new SecondaryIndexBuilder(baseCfs, idxNames, new ReducingKeyIterator(sstables));
Future<?> future = CompactionManager.instance.submitIndexBuild(builder);
FBUtilities.waitOnFuture(future);
flushIndexesBlocking();
logger.info("Index build of {} complete", idxNames);
}
示例4: buildIndexBlocking
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/**
* Builds the index using the data in the underlying CFS
* Blocks till it's complete
*/
protected void buildIndexBlocking()
{
logger.info(String.format("Submitting index build of %s for data in %s",
getIndexName(), StringUtils.join(baseCfs.getSSTables(), ", ")));
Collection<SSTableReader> sstables = baseCfs.markCurrentSSTablesReferenced();
SecondaryIndexBuilder builder = new SecondaryIndexBuilder(baseCfs,
Collections.singleton(getIndexName()),
new ReducingKeyIterator(sstables));
Future<?> future = CompactionManager.instance.submitIndexBuild(builder);
FBUtilities.waitOnFuture(future);
forceBlockingFlush();
setIndexBuilt();
logger.info("Index build of {} complete", getIndexName());
}
示例5: buildIndexesBlocking
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
private void buildIndexesBlocking(Collection<SSTableReader> sstables, Set<Index> indexes)
{
if (indexes.isEmpty())
return;
logger.info("Submitting index build of {} for data in {}",
indexes.stream().map(i -> i.getIndexMetadata().name).collect(Collectors.joining(",")),
sstables.stream().map(SSTableReader::toString).collect(Collectors.joining(",")));
SecondaryIndexBuilder builder = new SecondaryIndexBuilder(baseCfs,
indexes,
new ReducingKeyIterator(sstables));
Future<?> future = CompactionManager.instance.submitIndexBuild(builder);
FBUtilities.waitOnFuture(future);
flushIndexesBlocking(indexes);
logger.info("Index build of {} complete",
indexes.stream().map(i -> i.getIndexMetadata().name).collect(Collectors.joining(",")));
}
示例6: resetLocalSchema
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/**
* Clear all locally stored schema information and reset schema to initial state.
* Called by user (via JMX) who wants to get rid of schema disagreement.
*
* @throws IOException if schema tables truncation fails
*/
public static void resetLocalSchema() throws IOException
{
logger.info("Starting local schema reset...");
logger.debug("Truncating schema tables...");
// truncate schema tables
for (String cf : SystemKeyspace.allSchemaCfs)
SystemKeyspace.schemaCFS(cf).truncateBlocking();
logger.debug("Clearing local schema keyspace definitions...");
Schema.instance.clear();
Set<InetAddress> liveEndpoints = Gossiper.instance.getLiveMembers();
liveEndpoints.remove(FBUtilities.getBroadcastAddress());
// force migration if there are nodes around
for (InetAddress node : liveEndpoints)
{
if (shouldPullSchemaFrom(node))
{
logger.debug("Requesting schema from {}", node);
FBUtilities.waitOnFuture(submitMigrationTask(node));
break;
}
}
logger.info("Local schema reset is complete.");
}
示例7: streamHints
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
private Future<StreamState> streamHints()
{
// StreamPlan will not fail if there are zero files to transfer, so flush anyway (need to get any in-memory hints, as well)
ColumnFamilyStore hintsCF = Keyspace.open(Keyspace.SYSTEM_KS).getColumnFamilyStore(SystemKeyspace.HINTS_CF);
FBUtilities.waitOnFuture(hintsCF.forceFlush());
// gather all live nodes in the cluster that aren't also leaving
List<InetAddress> candidates = new ArrayList<>(StorageService.instance.getTokenMetadata().cloneAfterAllLeft().getAllEndpoints());
candidates.remove(FBUtilities.getBroadcastAddress());
for (Iterator<InetAddress> iter = candidates.iterator(); iter.hasNext(); )
{
InetAddress address = iter.next();
if (!FailureDetector.instance.isAlive(address))
iter.remove();
}
if (candidates.isEmpty())
{
logger.warn("Unable to stream hints since no live endpoints seen");
return Futures.immediateFuture(null);
}
else
{
// stream to the closest peer as chosen by the snitch
DatabaseDescriptor.getEndpointSnitch().sortByProximity(FBUtilities.getBroadcastAddress(), candidates);
InetAddress hintsDestinationHost = candidates.get(0);
InetAddress preferred = SystemKeyspace.getPreferredIP(hintsDestinationHost);
// stream all hints -- range list will be a singleton of "the entire ring"
Token token = StorageService.getPartitioner().getMinimumToken();
List<Range<Token>> ranges = Collections.singletonList(new Range<>(token, token));
return new StreamPlan("Hints").transferRanges(hintsDestinationHost,
preferred,
Keyspace.SYSTEM_KS,
ranges,
SystemKeyspace.HINTS_CF)
.execute();
}
}
示例8: forceBlockingFlush
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
public void forceBlockingFlush()
{
Future<?> wait;
// we synchronise on the baseCfs to make sure we are ordered correctly with other flushes to the base CFS
synchronized (baseCfs.getDataTracker())
{
wait = indexCfs.forceFlush();
}
FBUtilities.waitOnFuture(wait);
}
示例9: waitForDeletions
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/** for tests */
public static void waitForDeletions()
{
Runnable runnable = new Runnable()
{
public void run()
{
}
};
FBUtilities.waitOnFuture(ScheduledExecutors.nonPeriodicTasks.schedule(runnable, 0, TimeUnit.MILLISECONDS));
}
示例10: waitForDeletions
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/** for tests */
public static void waitForDeletions()
{
Runnable runnable = new Runnable()
{
public void run()
{
}
};
FBUtilities.waitOnFuture(StorageService.tasks.schedule(runnable, 0, TimeUnit.MILLISECONDS));
}
示例11: testCompactionOfHintsCF
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
@Test
public void testCompactionOfHintsCF() throws Exception
{
// prepare hints column family
Keyspace systemKeyspace = Keyspace.open("system");
ColumnFamilyStore hintStore = systemKeyspace.getColumnFamilyStore(SystemKeyspace.HINTS_CF);
hintStore.clearUnsafe();
hintStore.metadata.gcGraceSeconds(36000); // 10 hours
hintStore.setCompactionStrategyClass(SizeTieredCompactionStrategy.class.getCanonicalName());
hintStore.disableAutoCompaction();
// insert 1 hint
RowMutation rm = new RowMutation(KEYSPACE4, ByteBufferUtil.bytes(1));
rm.add(STANDARD1_CF, ByteBufferUtil.bytes(String.valueOf(COLUMN1)), ByteBufferUtil.EMPTY_BYTE_BUFFER, System.currentTimeMillis());
HintedHandOffManager.instance.hintFor(rm, HintedHandOffManager.calculateHintTTL(rm), UUID.randomUUID()).apply();
// flush data to disk
hintStore.forceBlockingFlush();
assertEquals(1, hintStore.getSSTables().size());
// submit compaction
FBUtilities.waitOnFuture(HintedHandOffManager.instance.compact());
while (CompactionManager.instance.getPendingTasks() > 0 || CompactionManager.instance.getActiveCompactions() > 0)
TimeUnit.SECONDS.sleep(1);
// single row should not be removed because of gc_grace_seconds
// is 10 hours and there are no any tombstones in sstable
assertEquals(1, hintStore.getSSTables().size());
}
示例12: announce
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/**
* actively announce a new version to active hosts via rpc
* @param schema The schema mutation to be applied
*/
private static void announce(Mutation schema, boolean announceLocally)
{
if (announceLocally)
SchemaKeyspace.mergeSchema(Collections.singletonList(schema));
else
FBUtilities.waitOnFuture(announce(Collections.singletonList(schema)));
}
示例13: resetLocalSchema
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/**
* Clear all locally stored schema information and reset schema to initial state.
* Called by user (via JMX) who wants to get rid of schema disagreement.
*/
public static void resetLocalSchema()
{
logger.info("Starting local schema reset...");
logger.debug("Truncating schema tables...");
SchemaKeyspace.truncate();
logger.debug("Clearing local schema keyspace definitions...");
Schema.instance.clear();
Set<InetAddress> liveEndpoints = Gossiper.instance.getLiveMembers();
liveEndpoints.remove(FBUtilities.getBroadcastAddress());
// force migration if there are nodes around
for (InetAddress node : liveEndpoints)
{
if (shouldPullSchemaFrom(node))
{
logger.debug("Requesting schema from {}", node);
FBUtilities.waitOnFuture(submitMigrationTask(node));
break;
}
}
logger.info("Local schema reset is complete.");
}
示例14: buildBlocking
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
private void buildBlocking()
{
baseCfs.forceBlockingFlush();
try (ColumnFamilyStore.RefViewFragment viewFragment = baseCfs.selectAndReference(View.selectFunction(SSTableSet.CANONICAL));
Refs<SSTableReader> sstables = viewFragment.refs)
{
if (sstables.isEmpty())
{
logger.info("No SSTable data for {}.{} to build index {} from, marking empty index as built",
baseCfs.metadata.ksName,
baseCfs.metadata.cfName,
metadata.name);
baseCfs.indexManager.markIndexBuilt(metadata.name);
return;
}
logger.info("Submitting index build of {} for data in {}",
metadata.name,
getSSTableNames(sstables));
SecondaryIndexBuilder builder = new SecondaryIndexBuilder(baseCfs,
Collections.singleton(this),
new ReducingKeyIterator(sstables));
Future<?> future = CompactionManager.instance.submitIndexBuild(builder);
FBUtilities.waitOnFuture(future);
indexCfs.forceBlockingFlush();
baseCfs.indexManager.markIndexBuilt(metadata.name);
}
logger.info("Index build of {} complete", metadata.name);
}
示例15: announce
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/**
* actively announce a new version to active hosts via rpc
* @param schema The schema mutation to be applied
*/
public static void announce(RowMutation schema)
{
FBUtilities.waitOnFuture(announce(Collections.singletonList(schema)));
}