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


Java ColumnFamilyStore.getSSTables方法代码示例

本文整理汇总了Java中org.apache.cassandra.db.ColumnFamilyStore.getSSTables方法的典型用法代码示例。如果您正苦于以下问题:Java ColumnFamilyStore.getSSTables方法的具体用法?Java ColumnFamilyStore.getSSTables怎么用?Java ColumnFamilyStore.getSSTables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.db.ColumnFamilyStore的用法示例。


在下文中一共展示了ColumnFamilyStore.getSSTables方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: antiCompactionSizeTest

import org.apache.cassandra.db.ColumnFamilyStore; //导入方法依赖的package包/类
@Test
public void antiCompactionSizeTest() throws ExecutionException, InterruptedException, IOException
{
    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
    cfs.disableAutoCompaction();
    SSTableReader s = writeFile(cfs, 1000);
    cfs.addSSTable(s);
    long origSize = s.bytesOnDisk();
    Range<Token> range = new Range<Token>(new BytesToken(ByteBufferUtil.bytes(0)), new BytesToken(ByteBufferUtil.bytes(500)));
    Collection<SSTableReader> sstables = cfs.getSSTables();
    CompactionManager.instance.performAnticompaction(cfs, Arrays.asList(range), Refs.tryRef(sstables), 12345);
    long sum = 0;
    for (SSTableReader x : cfs.getSSTables())
        sum += x.bytesOnDisk();
    assertEquals(sum, cfs.metric.liveDiskSpaceUsed.count());
    assertEquals(origSize, cfs.metric.liveDiskSpaceUsed.count(), 100000);

}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:20,代码来源:AntiCompactionTest.java

示例2: testGetScannerForNoIntersectingRanges

import org.apache.cassandra.db.ColumnFamilyStore; //导入方法依赖的package包/类
/** see CASSANDRA-5407 */
@Test
public void testGetScannerForNoIntersectingRanges()
{
    Keyspace keyspace = Keyspace.open("Keyspace1");
    ColumnFamilyStore store = keyspace.getColumnFamilyStore("Standard1");
    ByteBuffer key = ByteBufferUtil.bytes(String.valueOf("k1"));
    Mutation rm = new Mutation("Keyspace1", key);
    rm.add("Standard1", cellname("xyz"), ByteBufferUtil.bytes("abc"), 0);
    rm.apply();
    store.forceBlockingFlush();
    boolean foundScanner = false;
    for (SSTableReader s : store.getSSTables())
    {
        ISSTableScanner scanner = s.getScanner(new Range<Token>(t(0), t(1), s.partitioner), null);
        scanner.next(); // throws exception pre 5407
        foundScanner = true;
    }
    assertTrue(foundScanner);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:21,代码来源:SSTableReaderTest.java

示例3: getActiveSSTables

import org.apache.cassandra.db.ColumnFamilyStore; //导入方法依赖的package包/类
private Set<SSTableReader> getActiveSSTables(UUID cfId)
{
    if (!columnFamilyStores.containsKey(cfId))
        return null;

    Set<String> repairedSSTables = sstableMap.get(cfId);
    Set<SSTableReader> activeSSTables = new HashSet<>();
    Set<String> activeSSTableNames = new HashSet<>();
    ColumnFamilyStore cfs = columnFamilyStores.get(cfId);
    for (SSTableReader sstable : cfs.getSSTables(SSTableSet.CANONICAL))
    {
        if (repairedSSTables.contains(sstable.getFilename()))
        {
            activeSSTables.add(sstable);
            activeSSTableNames.add(sstable.getFilename());
        }
    }
    sstableMap.put(cfId, activeSSTableNames);
    return activeSSTables;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:ActiveRepairService.java

示例4: getSSTableMetadata

import org.apache.cassandra.db.ColumnFamilyStore; //导入方法依赖的package包/类
public List<SSTableMetadata> getSSTableMetadata(String ksName, String cfName) {
    ColumnFamilyStore cfStore = getStore(ksName, cfName);
    Collection<SSTableReader> tables = cfStore.getSSTables();
    List<SSTableMetadata> metaData = new ArrayList<>(tables.size());
    for (SSTableReader table : tables) {
        SSTableMetadata tableMetadata = new SSTableMetadata();
        File dataFile = new File(table.descriptor.filenameFor(Component.DATA));
        tableMetadata.filename = dataFile.getName();
        tableMetadata.generation = table.descriptor.generation;
        try {
            tableMetadata.fileTimestamp = Files.getLastModifiedTime(dataFile.toPath()).toMillis();
        } catch (IOException e) {
            tableMetadata.fileTimestamp = 0;
        }
        tableMetadata.minTimestamp = table.getMinTimestamp();
        tableMetadata.maxTimestamp = table.getMaxTimestamp();
        tableMetadata.diskLength = table.onDiskLength();
        tableMetadata.uncompressedLength = table.uncompressedLength();
        tableMetadata.keys = table.estimatedKeys();
        EstimatedHistogram rowSizeHistogram = table.getEstimatedRowSize();
        tableMetadata.maxRowSize = rowSizeHistogram.max();
        tableMetadata.avgRowSize = rowSizeHistogram.mean();
        EstimatedHistogram columnCountHistogram = table.getEstimatedColumnCount();
        tableMetadata.maxColumnCount = columnCountHistogram.max();
        tableMetadata.avgColumnCount = columnCountHistogram.mean();
        tableMetadata.droppableTombstones = table.getDroppableTombstonesBefore(Util.NOW_SECONDS - table.metadata.getGcGraceSeconds());
        tableMetadata.level = table.getSSTableLevel();
        tableMetadata.isRepaired = table.isRepaired();
        tableMetadata.repairedAt = table.getSSTableMetadata().repairedAt;
        metaData.add(tableMetadata);
    }
    return metaData;
}
 
开发者ID:instaclustr,项目名称:cassandra-sstable-tools,代码行数:34,代码来源:CassandraBackend.java

示例5: getSSTableMetadata

import org.apache.cassandra.db.ColumnFamilyStore; //导入方法依赖的package包/类
public List<SSTableMetadata> getSSTableMetadata(String ksName, String cfName) {
    ColumnFamilyStore cfStore = getStore(ksName, cfName);
    Collection<SSTableReader> tables = cfStore.getSSTables();
    List<SSTableMetadata> metaData = new ArrayList<>(tables.size());
    for (SSTableReader table : tables) {
        SSTableMetadata tableMetadata = new SSTableMetadata();
        File dataFile = new File(table.descriptor.filenameFor(Component.DATA));
        tableMetadata.filename = dataFile.getName();
        tableMetadata.generation = table.descriptor.generation;
        try {
            tableMetadata.fileTimestamp = Files.getLastModifiedTime(dataFile.toPath()).toMillis();
        } catch (IOException e) {
            tableMetadata.fileTimestamp = 0;
        }
        tableMetadata.minTimestamp = table.getMinTimestamp();
        tableMetadata.maxTimestamp = table.getMaxTimestamp();
        tableMetadata.diskLength = table.onDiskLength();
        tableMetadata.uncompressedLength = table.uncompressedLength();
        tableMetadata.keys = table.estimatedKeys();
        EstimatedHistogram rowSizeHistogram = table.getEstimatedRowSize();
        tableMetadata.maxRowSize = rowSizeHistogram.max();
        tableMetadata.avgRowSize = rowSizeHistogram.mean();
        EstimatedHistogram columnCountHistogram = table.getEstimatedColumnCount();
        tableMetadata.maxColumnCount = columnCountHistogram.max();
        tableMetadata.avgColumnCount = columnCountHistogram.mean();
        tableMetadata.droppableTombstones = table.getDroppableTombstonesBefore(Util.NOW_SECONDS - table.metadata.getGcGraceSeconds());
        tableMetadata.level = table.getSSTableLevel();
        tableMetadata.isRepaired = false;
        metaData.add(tableMetadata);
    }
    return metaData;
}
 
开发者ID:instaclustr,项目名称:cassandra-sstable-tools,代码行数:33,代码来源:CassandraBackend.java

示例6: lookupSSTable

import org.apache.cassandra.db.ColumnFamilyStore; //导入方法依赖的package包/类
private SSTableReader lookupSSTable(final ColumnFamilyStore cfs, Descriptor descriptor)
{
    for (SSTableReader sstable : cfs.getSSTables())
    {
        if (sstable.descriptor.equals(descriptor))
            return sstable;
    }
    return null;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:10,代码来源:CompactionManager.java

示例7: testFilterOldSSTables

import org.apache.cassandra.db.ColumnFamilyStore; //导入方法依赖的package包/类
@Test
public void testFilterOldSSTables()
{
    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF_STANDARD1);
    cfs.truncateBlocking();
    cfs.disableAutoCompaction();

    ByteBuffer value = ByteBuffer.wrap(new byte[100]);

    // create 3 sstables
    int numSSTables = 3;
    for (int r = 0; r < numSSTables; r++)
    {
        DecoratedKey key = Util.dk(String.valueOf(r));
        Mutation rm = new Mutation(KEYSPACE1, key.getKey());
        rm.add(CF_STANDARD1, Util.cellname("column"), value, r);
        rm.apply();
        cfs.forceBlockingFlush();
    }
    cfs.forceBlockingFlush();

    Iterable<SSTableReader> filtered;
    List<SSTableReader> sstrs = new ArrayList<>(cfs.getSSTables());

    filtered = filterOldSSTables(sstrs, 0, 2);
    assertEquals("when maxSSTableAge is zero, no sstables should be filtered", sstrs.size(), Iterables.size(filtered));

    filtered = filterOldSSTables(sstrs, 1, 2);
    assertEquals("only the newest 2 sstables should remain", 2, Iterables.size(filtered));

    filtered = filterOldSSTables(sstrs, 1, 3);
    assertEquals("only the newest sstable should remain", 1, Iterables.size(filtered));

    filtered = filterOldSSTables(sstrs, 1, 4);
    assertEquals("no sstables should remain when all are too old", 0, Iterables.size(filtered));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:38,代码来源:DateTieredCompactionStrategyTest.java

示例8: testCanonicalSSTables

import org.apache.cassandra.db.ColumnFamilyStore; //导入方法依赖的package包/类
@Test
public void testCanonicalSSTables() throws ExecutionException, InterruptedException
{
    Keyspace keyspace = Keyspace.open(KEYSPACE);
    final ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
    truncate(cfs);

    cfs.addSSTable(writeFile(cfs, 100));
    Collection<SSTableReader> allSSTables = cfs.getLiveSSTables();
    assertEquals(1, allSSTables.size());
    final AtomicBoolean done = new AtomicBoolean(false);
    final AtomicBoolean failed = new AtomicBoolean(false);
    Runnable r = () -> {
        while (!done.get())
        {
            Iterable<SSTableReader> sstables = cfs.getSSTables(SSTableSet.CANONICAL);
            if (Iterables.size(sstables) != 1)
            {
                failed.set(true);
                return;
            }
        }
    };
    Thread t = new Thread(r);
    try
    {
        t.start();
        cfs.forceMajorCompaction();
    }
    finally
    {
        done.set(true);
        t.join(20);
    }
    assertFalse(failed.get());


}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:39,代码来源:SSTableRewriterTest.java

示例9: testPrepBucket

import org.apache.cassandra.db.ColumnFamilyStore; //导入方法依赖的package包/类
@Test
public void testPrepBucket()
{
    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF_STANDARD1);
    cfs.truncateBlocking();
    cfs.disableAutoCompaction();

    ByteBuffer value = ByteBuffer.wrap(new byte[100]);

    // create 3 sstables
    int numSSTables = 3;
    for (int r = 0; r < numSSTables; r++)
    {
        DecoratedKey key = Util.dk(String.valueOf(r));
        Mutation rm = new Mutation(KEYSPACE1, key.getKey());
        rm.add(CF_STANDARD1, Util.cellname("column"), value, r);
        rm.apply();
        cfs.forceBlockingFlush();
    }
    cfs.forceBlockingFlush();

    List<SSTableReader> sstrs = new ArrayList<>(cfs.getSSTables());

    List<SSTableReader> newBucket = newestBucket(Collections.singletonList(sstrs.subList(0, 2)), 4, 32, 9, 10);
    assertTrue("incoming bucket should not be accepted when it has below the min threshold SSTables", newBucket.isEmpty());

    newBucket = newestBucket(Collections.singletonList(sstrs.subList(0, 2)), 4, 32, 10, 10);
    assertFalse("non-incoming bucket should be accepted when it has at least 2 SSTables", newBucket.isEmpty());

    assertEquals("an sstable with a single value should have equal min/max timestamps", sstrs.get(0).getMinTimestamp(), sstrs.get(0).getMaxTimestamp());
    assertEquals("an sstable with a single value should have equal min/max timestamps", sstrs.get(1).getMinTimestamp(), sstrs.get(1).getMaxTimestamp());
    assertEquals("an sstable with a single value should have equal min/max timestamps", sstrs.get(2).getMinTimestamp(), sstrs.get(2).getMaxTimestamp());

    // if we have more than the max threshold, the oldest should be dropped
    Collections.sort(sstrs, Collections.reverseOrder(new Comparator<SSTableReader>() {
        public int compare(SSTableReader o1, SSTableReader o2) {
            return Long.compare(o1.getMinTimestamp(), o2.getMinTimestamp()) ;
        }
    }));

    List<SSTableReader> bucket = trimToThreshold(sstrs, 2);
    assertEquals("one bucket should have been dropped", 2, bucket.size());
    for (SSTableReader sstr : bucket)
        assertFalse("the oldest sstable should be dropped", sstr.getMinTimestamp() == 0);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:47,代码来源:DateTieredCompactionStrategyTest.java

示例10: testScheduleTimeout

import org.apache.cassandra.db.ColumnFamilyStore; //导入方法依赖的package包/类
@Test
public void testScheduleTimeout() throws Exception
{
    String ks = "Keyspace1";
    String cf = "Standard1";

    InetAddress peer = FBUtilities.getBroadcastAddress();
    StreamSession session = new StreamSession(peer, peer, null, 0);
    ColumnFamilyStore cfs = Keyspace.open(ks).getColumnFamilyStore(cf);

    // create two sstables
    for (int i = 0; i < 2; i++)
    {
        insertData(ks, cf, i, 1);
        cfs.forceBlockingFlush();
    }

    // create streaming task that streams those two sstables
    StreamTransferTask task = new StreamTransferTask(session, cfs.metadata.cfId);
    for (SSTableReader sstable : cfs.getSSTables())
    {
        List<Range<Token>> ranges = new ArrayList<>();
        ranges.add(new Range<>(sstable.first.getToken(), sstable.last.getToken()));
        task.addTransferFile(sstable, sstable.selfRef(), 1, sstable.getPositionsForRanges(ranges), 0);
    }
    assertEquals(2, task.getTotalNumberOfFiles());

    // if file sending completes before timeout then the task should be canceled.
    Future f = task.scheduleTimeout(0, 0, TimeUnit.NANOSECONDS);
    f.get();

    // when timeout runs on second file, task should be completed
    f = task.scheduleTimeout(1, 1, TimeUnit.MILLISECONDS);
    task.complete(1);
    try
    {
        f.get();
        Assert.assertTrue(false);
    }
    catch (CancellationException ex)
    {
    }
    assertEquals(StreamSession.State.WAIT_COMPLETE, session.state());

    // when all streaming are done, time out task should not be scheduled.
    assertNull(task.scheduleTimeout(1, 1, TimeUnit.SECONDS));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:48,代码来源:StreamTransferTaskTest.java


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