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


Java Descriptor类代码示例

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


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

示例1: deserialize

import org.apache.cassandra.io.sstable.Descriptor; //导入依赖的package包/类
public Map<MetadataType, MetadataComponent> deserialize(Descriptor descriptor, EnumSet<MetadataType> types) throws IOException
{
    Map<MetadataType, MetadataComponent> components;
    logger.trace("Load metadata for {}", descriptor);
    String statsFile = descriptor.filenameFor(Component.STATS);

    if (!HadoopFileUtils.exists(statsFile, descriptor.getConfiguration()))
    {
        logger.trace("No sstable stats for {}", descriptor);
        components = Maps.newHashMap();
        components.put(MetadataType.STATS, MetadataCollector.defaultStatsMetadata());
    }
    else
    {
        try (RandomAccessReader r = RandomAccessReader.open(statsFile, descriptor.getConfiguration()))
        {
            components = deserialize(descriptor, r, types);
        }
    }

    return components;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:23,代码来源:MetadataSerializer.java

示例2: internalOpen

import org.apache.cassandra.io.sstable.Descriptor; //导入依赖的package包/类
/**
 * Open a RowIndexedReader which already has its state initialized (by SSTableWriter).
 */
public static SSTableReader internalOpen(Descriptor desc,
                                  Set<Component> components,
                                  CFMetaData metadata,
                                  FileHandle ifile,
                                  FileHandle dfile,
                                  IndexSummary isummary,
                                  IFilter bf,
                                  long maxDataAge,
                                  StatsMetadata sstableMetadata,
                                  OpenReason openReason,
                                  SerializationHeader header)
{
    assert desc != null && ifile != null && dfile != null && isummary != null && bf != null && sstableMetadata != null;

    SSTableReader reader = internalOpen(desc, components, metadata, maxDataAge, sstableMetadata, openReason, header);

    reader.bf = bf;
    reader.ifile = ifile;
    reader.dfile = dfile;
    reader.indexSummary = isummary;
    reader.setup(true);

    return reader;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:28,代码来源:SSTableReader.java

示例3: get

import org.apache.cassandra.io.sstable.Descriptor; //导入依赖的package包/类
@SuppressWarnings("resource")
public static Ref<GlobalTidy> get(SSTableReader sstable)
{
    Descriptor descriptor = sstable.descriptor;
    Ref<GlobalTidy> refc = lookup.get(descriptor);
    if (refc != null)
        return refc.ref();
    final GlobalTidy tidy = new GlobalTidy(sstable);
    refc = new Ref<>(tidy, tidy);
    Ref<?> ex = lookup.putIfAbsent(descriptor, refc);
    if (ex != null)
    {
        refc.close();
        //throw new AssertionError();
    }
    return refc;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:18,代码来源:SSTableReader.java

示例4: onDiskIterator

import org.apache.cassandra.io.sstable.Descriptor; //导入依赖的package包/类
public static Iterator<OnDiskAtom> onDiskIterator(final DataInput in,
                                                  final ColumnSerializer.Flag flag,
                                                  final int expireBefore,
                                                  final Descriptor.Version version,
                                                  final CellNameType type)
{
    return new AbstractIterator<OnDiskAtom>()
    {
        protected OnDiskAtom computeNext()
        {
            OnDiskAtom atom;
            try
            {
                atom = type.onDiskAtomSerializer().deserializeFromSSTable(in, flag, expireBefore, version);
            }
            catch (IOException e)
            {
                throw new IOError(e);
            }
            if (atom == null)
                return endOfData();

            return atom;
        }
    };
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:AbstractCell.java

示例5: compact

import org.apache.cassandra.io.sstable.Descriptor; //导入依赖的package包/类
@VisibleForTesting
protected synchronized void compact()
{
    ArrayList<Descriptor> descriptors = new ArrayList<>();
    for (SSTable sstable : hintStore.getDataTracker().getUncompactingSSTables())
        descriptors.add(sstable.descriptor);

    if (descriptors.isEmpty())
        return;

    try
    {
        CompactionManager.instance.submitUserDefined(hintStore, descriptors, (int) (System.currentTimeMillis() / 1000)).get();
    }
    catch (InterruptedException | ExecutionException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:20,代码来源:HintedHandOffManager.java

示例6: testMTSnapshots

import org.apache.cassandra.io.sstable.Descriptor; //导入依赖的package包/类
@Test
public void testMTSnapshots() throws Exception
{
    for (final CFMetaData cfm : CFM)
    {
        final Directories directories = new Directories(cfm);
        assertEquals(cfDir(cfm), directories.getDirectoryForNewSSTables());
        final String n = Long.toString(System.nanoTime());
        Callable<File> directoryGetter = new Callable<File>() {
            public File call() throws Exception {
                Descriptor desc = new Descriptor(cfDir(cfm), KS, cfm.cfName, 1);
                return Directories.getSnapshotDirectory(desc, n);
            }
        };
        List<Future<File>> invoked = Executors.newFixedThreadPool(2).invokeAll(Arrays.asList(directoryGetter, directoryGetter));
        for(Future<File> fut:invoked) {
            assertTrue(fut.get().exists());
        }
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:DirectoriesTest.java

示例7: create

import org.apache.cassandra.io.sstable.Descriptor; //导入依赖的package包/类
public void create(Collection<SSTableWriter> sstables)
{
    List<String> sstablePaths = new ArrayList<>(sstables.size());
    for (SSTableWriter writer : sstables)
    {
        /* write out the file names *without* the 'tmp-file' flag in the file name.
           this class will not need to clean up tmp files (on restart), CassandraDaemon does that already,
           just make sure we delete the fully-formed SSTRs. */
        sstablePaths.add(writer.descriptor.asType(Descriptor.Type.FINAL).baseFilename());
    }

    try
    {
        Files.write(lockfile.toPath(), sstablePaths, Charsets.UTF_8,
                StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE, StandardOpenOption.DSYNC);
    }
    catch (IOException e)
    {
        logger.warn(String.format("Could not create lockfile %s for stream session, nothing to worry too much about", lockfile), e);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:StreamLockfile.java

示例8: testBackupAfterFlush

import org.apache.cassandra.io.sstable.Descriptor; //导入依赖的package包/类
@Test
public void testBackupAfterFlush() throws Throwable
{
    ColumnFamilyStore cfs = Keyspace.open(KEYSPACE2).getColumnFamilyStore(CF_STANDARD1);
    new RowUpdateBuilder(cfs.metadata, 0, ByteBufferUtil.bytes("key1")).clustering("Column1").add("val", "asdf").build().applyUnsafe();
    cfs.forceBlockingFlush();
    new RowUpdateBuilder(cfs.metadata, 0, ByteBufferUtil.bytes("key2")).clustering("Column1").add("val", "asdf").build().applyUnsafe();
    cfs.forceBlockingFlush();

    for (int version = 1; version <= 2; ++version)
    {
        Descriptor existing = new Descriptor(cfs.getDirectories().getDirectoryForNewSSTables(), KEYSPACE2, CF_STANDARD1, version);
        Descriptor desc = new Descriptor(Directories.getBackupsDirectory(existing), KEYSPACE2, CF_STANDARD1, version);
        for (Component c : new Component[]{ Component.DATA, Component.PRIMARY_INDEX, Component.FILTER, Component.STATS })
            assertTrue("Cannot find backed-up file:" + desc.filenameFor(c), new File(desc.filenameFor(c)).exists());
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:18,代码来源:ColumnFamilyStoreTest.java

示例9: deserialize

import org.apache.cassandra.io.sstable.Descriptor; //导入依赖的package包/类
public Map<MetadataType, MetadataComponent> deserialize(Descriptor descriptor, FileDataInput in, EnumSet<MetadataType> types) throws IOException
{
    Map<MetadataType, MetadataComponent> components = Maps.newHashMap();
    // read number of components
    int numComponents = in.readInt();
    // read toc
    Map<MetadataType, Integer> toc = new HashMap<>(numComponents);
    for (int i = 0; i < numComponents; i++)
    {
        toc.put(MetadataType.values()[in.readInt()], in.readInt());
    }
    for (MetadataType type : types)
    {
        MetadataComponent component = null;
        if (toc.containsKey(type))
        {
            in.seek(toc.get(type));
            component = type.serializer.deserialize(descriptor.version, in);
        }
        components.put(type, component);
    }
    return components;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:24,代码来源:MetadataSerializer.java

示例10: createColumnFamilyStore

import org.apache.cassandra.io.sstable.Descriptor; //导入依赖的package包/类
public static synchronized ColumnFamilyStore createColumnFamilyStore(Keyspace keyspace,
                                                                     String columnFamily,
                                                                     CFMetaData metadata,
                                                                     boolean loadSSTables)
{
    // get the max generation number, to prevent generation conflicts
    Directories directories = new Directories(metadata, initialDirectories);
    Directories.SSTableLister lister = directories.sstableLister(Directories.OnTxnErr.IGNORE).includeBackups(true);
    List<Integer> generations = new ArrayList<Integer>();
    for (Map.Entry<Descriptor, Set<Component>> entry : lister.list().entrySet())
    {
        Descriptor desc = entry.getKey();
        generations.add(desc.generation);
        if (!desc.isCompatible())
            throw new RuntimeException(String.format("Incompatible SSTable found. Current version %s is unable to read file: %s. Please run upgradesstables.",
                    desc.getFormat().getLatestVersion(), desc));
    }
    Collections.sort(generations);
    int value = (generations.size() > 0) ? (generations.get(generations.size() - 1)) : 0;

    return new ColumnFamilyStore(keyspace, columnFamily, value, metadata, directories, loadSSTables);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:23,代码来源:ColumnFamilyStore.java

示例11: numLegacyFiles

import org.apache.cassandra.io.sstable.Descriptor; //导入依赖的package包/类
private static int numLegacyFiles()
{
    int ret = 0;
    Iterable<String> dirs = Arrays.asList(DatabaseDescriptor.getAllDataFileLocations());
    for (String dataDir : dirs)
    {
        File dir = new File(dataDir);
        for (File ksdir : dir.listFiles((d, n) -> new File(d, n).isDirectory()))
        {
            for (File cfdir : ksdir.listFiles((d, n) -> new File(d, n).isDirectory()))
            {
                if (Descriptor.isLegacyFile(cfdir))
                {
                    ret++;
                }
                else
                {
                    File[] legacyFiles = cfdir.listFiles((d, n) -> Descriptor.isLegacyFile(new File(d, n)));
                    ret += legacyFiles.length;
                }
            }
        }
    }
    return ret;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:26,代码来源:SystemKeyspaceTest.java

示例12: testMTSnapshots

import org.apache.cassandra.io.sstable.Descriptor; //导入依赖的package包/类
@Test
public void testMTSnapshots() throws Exception
{
    for (final CFMetaData cfm : CFM)
    {
        final Directories directories = new Directories(cfm);
        assertEquals(cfDir(cfm), directories.getDirectoryForNewSSTables());
        final String n = Long.toString(System.nanoTime());
        Callable<File> directoryGetter = new Callable<File>() {
            public File call() throws Exception {
                Descriptor desc = new Descriptor(cfDir(cfm), KS, cfm.cfName, 1, Descriptor.Type.FINAL);
                return Directories.getSnapshotDirectory(desc, n);
            }
        };
        List<Future<File>> invoked = Executors.newFixedThreadPool(2).invokeAll(Arrays.asList(directoryGetter, directoryGetter));
        for(Future<File> fut:invoked) {
            assertTrue(fut.get().exists());
        }
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:21,代码来源:DirectoriesTest.java

示例13: shouldImportCqlTable

import org.apache.cassandra.io.sstable.Descriptor; //导入依赖的package包/类
@Test
/* 
 *  The schema is 
 *      CREATE TABLE cql_keyspace.table1 (k int PRIMARY KEY, v1 text, v2 int)
 * */
public void shouldImportCqlTable() throws IOException, URISyntaxException
{
    String cql_keyspace = "cql_keyspace";
    String cql_table = "table1";
    String jsonUrl = resourcePath("CQLTable.json");
    File tempSS = tempSSTableFile(cql_keyspace, cql_table);
    new SSTableImport(true).importJson(jsonUrl, cql_keyspace, cql_table, tempSS.getPath());
    SSTableReader reader = SSTableReader.open(Descriptor.fromFilename(tempSS.getPath()));
    Keyspace.open(cql_keyspace).getColumnFamilyStore(cql_table).addSSTable(reader);
    
    UntypedResultSet result = QueryProcessor.executeOnceInternal(String.format("SELECT * FROM %s.%s", cql_keyspace, cql_table));
    assertThat(result.size(), is(2));
    assertThat(result, hasItem(withElements(1, "NY", 1980)));
    assertThat(result, hasItem(withElements(2, "CA", 2014)));
    reader.selfRef().release();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:SSTableImportTest.java

示例14: testSerialization

import org.apache.cassandra.io.sstable.Descriptor; //导入依赖的package包/类
@Test
public void testSerialization() throws IOException
{
    Map<MetadataType, MetadataComponent> originalMetadata = constructMetadata();

    MetadataSerializer serializer = new MetadataSerializer();
    File statsFile = serialize(originalMetadata, serializer, BigFormat.latestVersion);

    Descriptor desc = new Descriptor( statsFile.getParentFile(), "", "", 0);
    try (RandomAccessReader in = RandomAccessReader.open(statsFile))
    {
        Map<MetadataType, MetadataComponent> deserialized = serializer.deserialize(desc, in, EnumSet.allOf(MetadataType.class));

        for (MetadataType type : MetadataType.values())
        {
            assertEquals(originalMetadata.get(type), deserialized.get(type));
        }
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:20,代码来源:MetadataSerializerTest.java

示例15: deserialize

import org.apache.cassandra.io.sstable.Descriptor; //导入依赖的package包/类
public RowIndexEntry deserialize(DataInput in, Descriptor.Version version) throws IOException
{
    long position = in.readLong();

    int size = in.readInt();
    if (size > 0)
    {
        DeletionTime deletionTime = DeletionTime.serializer.deserialize(in);

        int entries = in.readInt();
        List<IndexHelper.IndexInfo> columnsIndex = new ArrayList<IndexHelper.IndexInfo>(entries);
        for (int i = 0; i < entries; i++)
            columnsIndex.add(IndexHelper.IndexInfo.deserialize(in));

        return new IndexedEntry(position, deletionTime, columnsIndex);
    }
    else
    {
        return new RowIndexEntry(position);
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:22,代码来源:RowIndexEntry.java


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