本文整理汇总了Java中org.apache.cassandra.db.ColumnFamilyStore.snapshot方法的典型用法代码示例。如果您正苦于以下问题:Java ColumnFamilyStore.snapshot方法的具体用法?Java ColumnFamilyStore.snapshot怎么用?Java ColumnFamilyStore.snapshot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.db.ColumnFamilyStore
的用法示例。
在下文中一共展示了ColumnFamilyStore.snapshot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: takeColumnFamilySnapshot
import org.apache.cassandra.db.ColumnFamilyStore; //导入方法依赖的package包/类
/**
* Takes the snapshot of a specific column family. A snapshot name must be specified.
*
* @param keyspaceName the keyspace which holds the specified column family
* @param columnFamilyName the column family to snapshot
* @param tag the tag given to the snapshot; may not be null or empty
*/
public void takeColumnFamilySnapshot(String keyspaceName, String columnFamilyName, String tag) throws IOException
{
if (keyspaceName == null)
throw new IOException("You must supply a keyspace name");
if (operationMode.equals(Mode.JOINING))
throw new IOException("Cannot snapshot until bootstrap completes");
if (columnFamilyName == null)
throw new IOException("You must supply a column family name");
if (columnFamilyName.contains("."))
throw new IllegalArgumentException("Cannot take a snapshot of a secondary index by itself. Run snapshot on the column family that owns the index.");
if (tag == null || tag.equals(""))
throw new IOException("You must supply a snapshot name.");
Keyspace keyspace = getValidKeyspace(keyspaceName);
ColumnFamilyStore columnFamilyStore = keyspace.getColumnFamilyStore(columnFamilyName);
if (columnFamilyStore.snapshotExists(tag))
throw new IOException("Snapshot " + tag + " already exists.");
columnFamilyStore.snapshot(tag);
}
示例2: dropKeyspace
import org.apache.cassandra.db.ColumnFamilyStore; //导入方法依赖的package包/类
public void dropKeyspace(String ksName)
{
KeyspaceMetadata ksm = Schema.instance.getKSMetaData(ksName);
String snapshotName = Keyspace.getTimestampedSnapshotName(ksName);
CompactionManager.instance.interruptCompactionFor(ksm.tablesAndViews(), true);
Keyspace keyspace = Keyspace.open(ksm.name);
// remove all cfs from the keyspace instance.
List<UUID> droppedCfs = new ArrayList<>();
for (CFMetaData cfm : ksm.tablesAndViews())
{
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfm.cfName);
unload(cfm);
if (DatabaseDescriptor.isAutoSnapshot())
cfs.snapshot(snapshotName);
Keyspace.open(ksm.name).dropCf(cfm.cfId);
droppedCfs.add(cfm.cfId);
}
// remove the keyspace from the static instances.
Keyspace.clear(ksm.name);
clearKeyspaceMetadata(ksm);
Keyspace.writeOrder.awaitNewBarrier();
// force a new segment in the CL
CommitLog.instance.forceRecycleAllSegments(droppedCfs);
MigrationManager.instance.notifyDropKeyspace(ksm);
}
示例3: testCompactionHook
import org.apache.cassandra.db.ColumnFamilyStore; //导入方法依赖的package包/类
@Test
public void testCompactionHook() throws Exception
{
Assume.assumeTrue(FBUtilities.isWindows());
Keyspace keyspace = Keyspace.open(KEYSPACE1);
ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF_STANDARD1);
store.clearUnsafe();
populate(10000);
store.snapshot("snapshot1");
// Confirm snapshot deletion fails. Sleep for a bit just to make sure the SnapshotDeletingTask has
// time to run and fail.
Thread.sleep(500);
store.clearSnapshot("snapshot1");
assertEquals(1, SnapshotDeletingTask.pendingDeletionCount());
// Compact the cf and confirm that the executor's after hook calls rescheduleDeletion
populate(20000);
store.forceBlockingFlush();
store.forceMajorCompaction();
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < 1000 && SnapshotDeletingTask.pendingDeletionCount() > 0)
{
Thread.yield();
}
assertEquals(0, SnapshotDeletingTask.pendingDeletionCount());
}