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


Java Directories类代码示例

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


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

示例1: MaxSSTableSizeWriter

import org.apache.cassandra.db.Directories; //导入依赖的package包/类
@SuppressWarnings("resource")
public MaxSSTableSizeWriter(ColumnFamilyStore cfs,
                            Directories directories,
                            LifecycleTransaction txn,
                            Set<SSTableReader> nonExpiredSSTables,
                            long maxSSTableSize,
                            int level,
                            boolean offline,
                            boolean keepOriginals)
{
    super(cfs, directories, txn, nonExpiredSSTables, offline, keepOriginals);
    this.allSSTables = txn.originals();
    this.level = level;
    this.maxSSTableSize = maxSSTableSize;

    long totalSize = getTotalWriteSize(nonExpiredSSTables, estimatedTotalKeys, cfs, txn.opType());
    expectedWriteSize = Math.min(maxSSTableSize, totalSize);
    estimatedSSTables = Math.max(1, totalSize / maxSSTableSize);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:20,代码来源:MaxSSTableSizeWriter.java

示例2: CompactionAwareWriter

import org.apache.cassandra.db.Directories; //导入依赖的package包/类
public CompactionAwareWriter(ColumnFamilyStore cfs,
                             Directories directories,
                             LifecycleTransaction txn,
                             Set<SSTableReader> nonExpiredSSTables,
                             boolean offline,
                             boolean keepOriginals)
{
    this.cfs = cfs;
    this.directories = directories;
    this.nonExpiredSSTables = nonExpiredSSTables;
    this.estimatedTotalKeys = SSTableReader.getApproximateKeyCount(nonExpiredSSTables);
    this.maxAge = CompactionTask.getMaxDataAge(nonExpiredSSTables);
    this.minRepairedAt = CompactionTask.getMinRepairedAt(nonExpiredSSTables);
    this.txn = txn;
    this.sstableWriter = SSTableRewriter.construct(cfs, txn, keepOriginals, maxAge, offline);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:CompactionAwareWriter.java

示例3: getFilter

import org.apache.cassandra.db.Directories; //导入依赖的package包/类
private static BiFunction<File, Directories.FileType, Boolean> getFilter(Options options)
{
    return (file, type) ->
    {
        switch(type)
        {
            case FINAL:
                return options.type != Options.FileType.TMP;
            case TEMPORARY:
                return options.type != Options.FileType.FINAL;
            case TXN_LOG:
                return options.oplogs;
            default:
                throw new AssertionError();
        }
    };
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:18,代码来源:StandaloneSSTableUtil.java

示例4: Transaction

import org.apache.cassandra.db.Directories; //导入依赖的package包/类
Transaction(ColumnFamilyStore cfs, LogTransaction txnLogs) throws IOException
{
    this.cfs = cfs;
    this.txnLogs = txnLogs;
    this.dataFolder = new Directories(cfs.metadata).getDirectoryForNewSSTables();
    this.sstableOld = sstable(dataFolder, cfs, 0, 128);
    this.sstableNew = sstable(dataFolder, cfs, 1, 128);

    assertNotNull(txnLogs);
    assertNotNull(txnLogs.id());
    Assert.assertEquals(OperationType.COMPACTION, txnLogs.type());

    txnLogs.trackNew(sstableNew);
    tidier = txnLogs.obsoleted(sstableOld);
    assertNotNull(tidier);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:LogTransactionTest.java

示例5: testUntrack

import org.apache.cassandra.db.Directories; //导入依赖的package包/类
@Test
public void testUntrack() throws Throwable
{
    ColumnFamilyStore cfs = MockSchema.newCFS(KEYSPACE);
    File dataFolder = new Directories(cfs.metadata).getDirectoryForNewSSTables();
    SSTableReader sstableNew = sstable(dataFolder, cfs, 1, 128);

    // complete a transaction without keep the new files since they were untracked
    LogTransaction log = new LogTransaction(OperationType.COMPACTION);
    assertNotNull(log);

    log.trackNew(sstableNew);
    log.untrackNew(sstableNew);

    log.finish();

    sstableNew.selfRef().release();
    Thread.sleep(1);
    LogTransaction.waitForDeletions();

    assertFiles(dataFolder.getPath(), Collections.<String>emptySet());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:23,代码来源:LogTransactionTest.java

示例6: testCommitOnlyNew

import org.apache.cassandra.db.Directories; //导入依赖的package包/类
@Test
public void testCommitOnlyNew() throws Throwable
{
    ColumnFamilyStore cfs = MockSchema.newCFS(KEYSPACE);
    File dataFolder = new Directories(cfs.metadata).getDirectoryForNewSSTables();
    SSTableReader sstable = sstable(dataFolder, cfs, 0, 128);

    LogTransaction log = new LogTransaction(OperationType.COMPACTION);
    assertNotNull(log);

    log.trackNew(sstable);
    log.finish();

    assertFiles(dataFolder.getPath(), new HashSet<>(sstable.getAllFilePaths()));

    sstable.selfRef().release();
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:18,代码来源:LogTransactionTest.java

示例7: testCommitOnlyOld

import org.apache.cassandra.db.Directories; //导入依赖的package包/类
@Test
public void testCommitOnlyOld() throws Throwable
{
    ColumnFamilyStore cfs = MockSchema.newCFS(KEYSPACE);
    File dataFolder = new Directories(cfs.metadata).getDirectoryForNewSSTables();
    SSTableReader sstable = sstable(dataFolder, cfs, 0, 128);

    LogTransaction log = new LogTransaction(OperationType.COMPACTION);
    assertNotNull(log);

    LogTransaction.SSTableTidier tidier = log.obsoleted(sstable);
    assertNotNull(tidier);

    log.finish();
    sstable.markObsolete(tidier);
    sstable.selfRef().release();

    assertFiles(dataFolder.getPath(), new HashSet<>());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:20,代码来源:LogTransactionTest.java

示例8: testAbortOnlyNew

import org.apache.cassandra.db.Directories; //导入依赖的package包/类
@Test
public void testAbortOnlyNew() throws Throwable
{
    ColumnFamilyStore cfs = MockSchema.newCFS(KEYSPACE);
    File dataFolder = new Directories(cfs.metadata).getDirectoryForNewSSTables();
    SSTableReader sstable = sstable(dataFolder, cfs, 0, 128);

    LogTransaction log = new LogTransaction(OperationType.COMPACTION);
    assertNotNull(log);

    log.trackNew(sstable);
    log.abort();

    sstable.selfRef().release();

    assertFiles(dataFolder.getPath(), new HashSet<>());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:18,代码来源:LogTransactionTest.java

示例9: testAbortOnlyOld

import org.apache.cassandra.db.Directories; //导入依赖的package包/类
@Test
public void testAbortOnlyOld() throws Throwable
{
    ColumnFamilyStore cfs = MockSchema.newCFS(KEYSPACE);
    File dataFolder = new Directories(cfs.metadata).getDirectoryForNewSSTables();
    SSTableReader sstable = sstable(dataFolder, cfs, 0, 128);

    LogTransaction log = new LogTransaction(OperationType.COMPACTION);
    assertNotNull(log);

    LogTransaction.SSTableTidier tidier = log.obsoleted(sstable);
    assertNotNull(tidier);

    tidier.abort();
    log.abort();

    sstable.selfRef().release();

    assertFiles(dataFolder.getPath(), new HashSet<>(sstable.getAllFilePaths()));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:LogTransactionTest.java

示例10: testGetTemporaryFilesSafeAfterObsoletion

import org.apache.cassandra.db.Directories; //导入依赖的package包/类
@Test
public void testGetTemporaryFilesSafeAfterObsoletion() throws Throwable
{
    ColumnFamilyStore cfs = MockSchema.newCFS(KEYSPACE);
    File dataFolder = new Directories(cfs.metadata).getDirectoryForNewSSTables();
    SSTableReader sstable = sstable(dataFolder, cfs, 0, 128);

    LogTransaction logs = new LogTransaction(OperationType.COMPACTION);
    assertNotNull(logs);

    LogTransaction.SSTableTidier tidier = logs.obsoleted(sstable);

    logs.finish();

    sstable.markObsolete(tidier);
    sstable.selfRef().release();

    // This should race with the asynchronous deletion of txn log files
    // It doesn't matter what it returns but it should not throw because the txn
    // was completed before deleting files (i.e. releasing sstables)
    for (int i = 0; i < 200; i++)
        getTemporaryFiles(dataFolder);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:24,代码来源:LogTransactionTest.java

示例11: listFiles

import org.apache.cassandra.db.Directories; //导入依赖的package包/类
static Set<File> listFiles(File folder, Directories.FileType... types)
{
    Collection<Directories.FileType> match = Arrays.asList(types);
    return new LogAwareFileLister(folder.toPath(),
                                  (file, type) -> match.contains(type),
                                  Directories.OnTxnErr.IGNORE).list()
                   .stream()
                   .map(f -> {
                       try
                       {
                           return f.getCanonicalFile();
                       }
                       catch (IOException e)
                       {
                           throw new IOError(e);
                       }
                   })
                   .collect(Collectors.toSet());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:20,代码来源:LogTransactionTest.java

示例12: testFromFilenameFor

import org.apache.cassandra.db.Directories; //导入依赖的package包/类
private void testFromFilenameFor(File dir)
{
    // normal
    checkFromFilename(new Descriptor(dir, ksname, cfname, 1), false);
    // skip component (for streaming lock file)
    checkFromFilename(new Descriptor(dir, ksname, cfname, 2), true);

    // secondary index
    String idxName = "myidx";
    File idxDir = new File(dir.getAbsolutePath() + File.separator + Directories.SECONDARY_INDEX_NAME_SEPARATOR + idxName);
    checkFromFilename(new Descriptor(idxDir, ksname, cfname + Directories.SECONDARY_INDEX_NAME_SEPARATOR + idxName, 4), false);

    // legacy version
    checkFromFilename(new Descriptor("ja", dir, ksname, cfname, 1, SSTableFormat.Type.LEGACY), false);
    // legacy secondary index
    checkFromFilename(new Descriptor("ja", dir, ksname, cfname + Directories.SECONDARY_INDEX_NAME_SEPARATOR + idxName, 3, SSTableFormat.Type.LEGACY), false);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:18,代码来源:DescriptorTest.java

示例13: testFromFilenameFor

import org.apache.cassandra.db.Directories; //导入依赖的package包/类
private void testFromFilenameFor(File dir)
{
    // normal
    checkFromFilename(new Descriptor(dir, ksname, cfname, 1, Descriptor.Type.FINAL), false);
    // skip component (for streaming lock file)
    checkFromFilename(new Descriptor(dir, ksname, cfname, 2, Descriptor.Type.FINAL), true);
    // tmp
    checkFromFilename(new Descriptor(dir, ksname, cfname, 3, Descriptor.Type.TEMP), false);
    // secondary index
    String idxName = "myidx";
    File idxDir = new File(dir.getAbsolutePath() + File.separator + Directories.SECONDARY_INDEX_NAME_SEPARATOR + idxName);
    checkFromFilename(new Descriptor(idxDir, ksname, cfname + Directories.SECONDARY_INDEX_NAME_SEPARATOR + idxName, 4, Descriptor.Type.FINAL), false);
    // secondary index tmp
    checkFromFilename(new Descriptor(idxDir, ksname, cfname + Directories.SECONDARY_INDEX_NAME_SEPARATOR + idxName, 5, Descriptor.Type.TEMP), false);

    // legacy version
    checkFromFilename(new Descriptor("ja", dir, ksname, cfname, 1, Descriptor.Type.FINAL), false);
    // legacy tmp
    checkFromFilename(new Descriptor("ja", dir, ksname, cfname, 2, Descriptor.Type.TEMP), false);
    // legacy secondary index
    checkFromFilename(new Descriptor("ja", dir, ksname, cfname + Directories.SECONDARY_INDEX_NAME_SEPARATOR + idxName, 3, Descriptor.Type.FINAL), false);
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:23,代码来源:DescriptorTest.java

示例14: getContextMapping

import org.apache.cassandra.db.Directories; //导入依赖的package包/类
/** Translates remote files to local files by creating a local sstable per remote sstable. */
public static PendingFile getContextMapping(PendingFile remote) throws IOException
{
    /* Create a local sstable for each remote sstable */
    Descriptor remotedesc = remote.desc;
    if (!remotedesc.isStreamCompatible())
        throw new UnsupportedOperationException(String.format("SSTable %s is not compatible with current version %s",
                                                              remote.getFilename(), Descriptor.Version.CURRENT));

    // new local sstable
    Table table = Table.open(remotedesc.ksname);
    ColumnFamilyStore cfStore = table.getColumnFamilyStore(remotedesc.cfname);
    Directories.DataDirectory localDir = cfStore.directories.getLocationCapableOfSize(remote.size);
    if (localDir == null)
        throw new RuntimeException("Insufficient disk space to store " + remote.size + " bytes");
    Descriptor localdesc = Descriptor.fromFilename(cfStore.getTempSSTablePath(cfStore.directories.getLocationForDisk(localDir)));

    return new PendingFile(localdesc, remote);
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:20,代码来源:StreamIn.java

示例15: getContextMapping

import org.apache.cassandra.db.Directories; //导入依赖的package包/类
/** Translates remote files to local files by creating a local sstable per remote sstable. */
public static PendingFile getContextMapping(PendingFile remote) throws IOException
{
    /* Create a local sstable for each remote sstable */
    Descriptor remotedesc = remote.desc;
    if (!remotedesc.isStreamCompatible())
        throw new UnsupportedOperationException(String.format("SSTable %s is not compatible with current version %s",
                                                              remote.getFilename(), Descriptor.Version.CURRENT));

    // new local sstable
    Table table = Table.open(remotedesc.ksname);
    ColumnFamilyStore cfStore = table.getColumnFamilyStore(remotedesc.cfname);
    Directories.DataDirectory localDir = cfStore.directories.getWriteableLocation();
    if (localDir == null)
        throw new RuntimeException("Insufficient disk space to store " + remote.size + " bytes");
    Descriptor localdesc = Descriptor.fromFilename(cfStore.getTempSSTablePath(cfStore.directories.getLocationForDisk(localDir)));

    return new PendingFile(localdesc, remote);
}
 
开发者ID:wso2,项目名称:wso2-cassandra,代码行数:20,代码来源:StreamIn.java


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