Example usage for java.util.concurrent ConcurrentSkipListMap ConcurrentSkipListMap

List of usage examples for java.util.concurrent ConcurrentSkipListMap ConcurrentSkipListMap

Introduction

In this page you can find the example usage for java.util.concurrent ConcurrentSkipListMap ConcurrentSkipListMap.

Prototype

public ConcurrentSkipListMap(SortedMap<K, ? extends V> m) 

Source Link

Document

Constructs a new map containing the same mappings and using the same ordering as the specified sorted map.

Usage

From source file:org.apache.blur.kvs.HdfsKeyValueStore.java

private NavigableMap<BytesRef, Value> createSnapshot() {
    _writeLock.lock();/*www.  jav a2s. c o m*/
    try {
        return new ConcurrentSkipListMap<BytesRef, Value>(_pointers);
    } finally {
        _writeLock.unlock();
    }
}

From source file:org.apache.cassandra.db.ColumnFamilyStore.java

private ColumnFamilyStore(Table table, String columnFamilyName, IPartitioner partitioner, int generation,
        CFMetaData metadata) {//from w  w  w.ja va  2  s.co  m
    assert metadata != null : "null metadata for " + table + ":" + columnFamilyName;
    this.table = table;
    columnFamily = columnFamilyName;
    this.metadata = metadata;
    this.minCompactionThreshold = new DefaultInteger(metadata.getMinCompactionThreshold());
    this.maxCompactionThreshold = new DefaultInteger(metadata.getMaxCompactionThreshold());
    this.memtime = new DefaultInteger(metadata.getMemtableFlushAfterMins());
    this.memsize = new DefaultInteger(metadata.getMemtableThroughputInMb());
    this.memops = new DefaultDouble(metadata.getMemtableOperationsInMillions());
    this.rowCacheSaveInSeconds = new DefaultInteger(metadata.getRowCacheSavePeriodInSeconds());
    this.keyCacheSaveInSeconds = new DefaultInteger(metadata.getKeyCacheSavePeriodInSeconds());
    this.partitioner = partitioner;
    fileIndexGenerator.set(generation);
    binaryMemtable = new AtomicReference<BinaryMemtable>(new BinaryMemtable(this));

    if (logger.isDebugEnabled())
        logger.debug("Starting CFS {}", columnFamily);

    ICache<Pair<Descriptor, DecoratedKey>, Long> kc = ConcurrentLinkedHashCache.create(0);
    keyCache = new AutoSavingKeyCache<Pair<Descriptor, DecoratedKey>, Long>(kc, table.name, columnFamilyName);
    ICache<DecoratedKey, ColumnFamily> rc = metadata.getRowCacheProvider().create(0);
    rowCache = new AutoSavingRowCache<DecoratedKey, ColumnFamily>(rc, table.name, columnFamilyName);

    // scan for sstables corresponding to this cf and load them
    data = new DataTracker(this);
    Set<DecoratedKey> savedKeys = keyCache.readSaved();
    List<SSTableReader> sstables = new ArrayList<SSTableReader>();
    for (Map.Entry<Descriptor, Set<Component>> sstableFiles : files(table.name, columnFamilyName, false)
            .entrySet()) {
        SSTableReader sstable;
        try {
            sstable = SSTableReader.open(sstableFiles.getKey(), sstableFiles.getValue(), savedKeys, data,
                    metadata, this.partitioner);
        } catch (FileNotFoundException ex) {
            logger.error(
                    "Missing sstable component in " + sstableFiles + "; skipped because of " + ex.getMessage());
            continue;
        } catch (IOException ex) {
            logger.error("Corrupt sstable " + sstableFiles + "; skipped", ex);
            continue;
        }
        sstables.add(sstable);
    }
    data.addSSTables(sstables);

    // create the private ColumnFamilyStores for the secondary column indexes
    indexedColumns = new ConcurrentSkipListMap<ByteBuffer, ColumnFamilyStore>(getComparator());
    for (ColumnDefinition info : metadata.getColumn_metadata().values()) {
        if (info.getIndexType() != null)
            addIndex(info);
    }

    // register the mbean
    String type = this.partitioner instanceof LocalPartitioner ? "IndexColumnFamilies" : "ColumnFamilies";
    mbeanName = "org.apache.cassandra.db:type=" + type + ",keyspace=" + this.table.name + ",columnfamily="
            + columnFamily;
    try {
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        ObjectName nameObj = new ObjectName(mbeanName);
        mbs.registerMBean(this, nameObj);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:org.apache.hadoop.hbase.client.TestClientNoCluster.java

/**
 * Create up a map that is keyed by meta row name and whose value is the HRegionInfo and
 * ServerName to return for this row.//from  w  w w.  ja  va 2s  . co m
 * @return Map with faked hbase:meta content in it.
 */
static SortedMap<byte[], Pair<HRegionInfo, ServerName>> makeMeta(final byte[] tableName, final int regionCount,
        final long namespaceSpan, final int serverCount) {
    // I need a comparator for meta rows so we sort properly.
    SortedMap<byte[], Pair<HRegionInfo, ServerName>> meta = new ConcurrentSkipListMap<byte[], Pair<HRegionInfo, ServerName>>(
            new MetaRowsComparator());
    HRegionInfo[] hris = makeHRegionInfos(tableName, regionCount, namespaceSpan);
    ServerName[] serverNames = makeServerNames(serverCount);
    int per = regionCount / serverCount;
    int count = 0;
    for (HRegionInfo hri : hris) {
        Pair<HRegionInfo, ServerName> p = new Pair<HRegionInfo, ServerName>(hri, serverNames[count++ / per]);
        meta.put(hri.getRegionName(), p);
    }
    return meta;
}