当前位置: 首页>>代码示例>>Java>>正文


Java ColumnFamilyStore.snapshot方法代码示例

本文整理汇总了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);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:30,代码来源:StorageService.java

示例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);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:36,代码来源:Schema.java

示例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());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:32,代码来源:SnapshotDeletingTest.java


注:本文中的org.apache.cassandra.db.ColumnFamilyStore.snapshot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。