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


Java OpOrder.Group方法代码示例

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


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

示例1: allocate

import org.apache.cassandra.utils.concurrent.OpOrder; //导入方法依赖的package包/类
public long allocate(int size, OpOrder.Group opGroup)
{
    assert size >= 0;
    offHeap().allocate(size, opGroup);
    // satisfy large allocations directly from JVM since they don't cause fragmentation
    // as badly, and fill up our regions quickly
    if (size > MAX_CLONED_SIZE)
        return allocateOversize(size);

    while (true)
    {
        Region region = currentRegion.get();
        long peer;
        if (region != null && (peer = region.allocate(size)) > 0)
            return peer;

        trySwapRegion(region, size);
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:20,代码来源:NativeAllocator.java

示例2: allocate

import org.apache.cassandra.utils.concurrent.OpOrder; //导入方法依赖的package包/类
public void allocate(long size, OpOrder.Group opGroup)
{
    while (true)
    {
        if (parent.tryAllocate(size))
        {
            acquired(size);
            return;
        }
        WaitQueue.Signal signal = opGroup.isBlockingSignal(parent.hasRoom().register());
        boolean allocated = parent.tryAllocate(size);
        if (allocated || opGroup.isBlocking())
        {
            signal.cancel();
            if (allocated) // if we allocated, take ownership
                acquired(size);
            else // otherwise we're blocking so we're permitted to overshoot our constraints, to just allocate without blocking
                allocated(size);
            return;
        }
        else
            signal.awaitUninterruptibly();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:MemtableAllocator.java

示例3: apply

import org.apache.cassandra.utils.concurrent.OpOrder; //导入方法依赖的package包/类
/**
 * Insert/Update the column family for this key.
 * Caller is responsible for acquiring Keyspace.switchLock
 * param @ lock - lock that needs to be used.
 * param @ key - key for update/insert
 * param @ columnFamily - columnFamily changes
 */
public void apply(PartitionUpdate update, UpdateTransaction indexer, OpOrder.Group opGroup, ReplayPosition replayPosition)

{
    long start = System.nanoTime();
    Memtable mt = data.getMemtableFor(opGroup, replayPosition);
    try
    {
        long timeDelta = mt.put(update, indexer, opGroup);
        DecoratedKey key = update.partitionKey();
        maybeUpdateRowCache(key);
        metric.samplers.get(Sampler.WRITES).addSample(key.getKey(), key.hashCode(), 1);
        metric.writeLatency.addNano(System.nanoTime() - start);
        if(timeDelta < Long.MAX_VALUE)
            metric.colUpdateTimeDeltaHistogram.update(timeDelta);
    }
    catch (RuntimeException e)
    {
        throw new RuntimeException(e.getMessage()
                                                 + " for ks: "
                                                 + keyspace.getName() + ", table: " + name, e);
    }

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

示例4: allocate

import org.apache.cassandra.utils.concurrent.OpOrder; //导入方法依赖的package包/类
/**
 * Allocate space in this buffer for the provided mutation, and return the allocated Allocation object.
 * Returns null if there is not enough space in this segment, and a new segment is needed.
 */
@SuppressWarnings("resource") //we pass the op order around
Allocation allocate(Mutation mutation, int size)
{
    final OpOrder.Group opGroup = appendOrder.start();
    try
    {
        int position = allocate(size);
        if (position < 0)
        {
            opGroup.close();
            return null;
        }
        markDirty(mutation, position);
        return new Allocation(this, opGroup, position, (ByteBuffer) buffer.duplicate().position(position).limit(position + size));
    }
    catch (Throwable t)
    {
        opGroup.close();
        throw t;
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:26,代码来源:CommitLogSegment.java

示例5: getMemtableFor

import org.apache.cassandra.utils.concurrent.OpOrder; //导入方法依赖的package包/类
public Memtable getMemtableFor(OpOrder.Group opGroup, ReplayPosition replayPosition)
{
    // since any new memtables appended to the list after we fetch it will be for operations started
    // after us, we can safely assume that we will always find the memtable that 'accepts' us;
    // if the barrier for any memtable is set whilst we are reading the list, it must accept us.

    // there may be multiple memtables in the list that would 'accept' us, however we only ever choose
    // the oldest such memtable, as accepts() only prevents us falling behind (i.e. ensures we don't
    // assign operations to a memtable that was retired/queued before we started)
    for (Memtable memtable : view.get().liveMemtables)
    {
        if (memtable.accepts(opGroup, replayPosition))
            return memtable;
    }
    throw new AssertionError(view.get().liveMemtables.toString());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:17,代码来源:DataTracker.java

示例6: adjust

import org.apache.cassandra.utils.concurrent.OpOrder; //导入方法依赖的package包/类
public void adjust(long size, OpOrder.Group opGroup)
{
    if (size <= 0)
        released(-size);
    else
        allocate(size, opGroup);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:8,代码来源:MemtableAllocator.java

示例7: allocate

import org.apache.cassandra.utils.concurrent.OpOrder; //导入方法依赖的package包/类
public ByteBuffer allocate(int size, OpOrder.Group opGroup)
{
    assert size >= 0;
    if (size == 0)
        return ByteBufferUtil.EMPTY_BYTE_BUFFER;

    (allocateOnHeapOnly ? onHeap() : offHeap()).allocate(size, opGroup);
    // satisfy large allocations directly from JVM since they don't cause fragmentation
    // as badly, and fill up our regions quickly
    if (size > MAX_CLONED_SIZE)
    {
        unslabbedSize.addAndGet(size);
        if (allocateOnHeapOnly)
            return ByteBuffer.allocate(size);
        Region region = new Region(ByteBuffer.allocateDirect(size));
        offHeapRegions.add(region);
        return region.allocate(size);
    }

    while (true)
    {
        Region region = getRegion();

        // Try to allocate from this region
        ByteBuffer cloned = region.allocate(size);
        if (cloned != null)
            return cloned;

        // not enough space!
        currentRegion.compareAndSet(region, null);
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:33,代码来源:SlabAllocator.java

示例8: RowUpdater

import org.apache.cassandra.utils.concurrent.OpOrder; //导入方法依赖的package包/类
private RowUpdater(AtomicBTreePartition updating, MemtableAllocator allocator, OpOrder.Group writeOp, UpdateTransaction indexer)
{
    this.updating = updating;
    this.allocator = allocator;
    this.writeOp = writeOp;
    this.indexer = indexer;
    this.nowInSec = FBUtilities.nowInSeconds();
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:9,代码来源:AtomicBTreePartition.java

示例9: NativeDecoratedKey

import org.apache.cassandra.utils.concurrent.OpOrder; //导入方法依赖的package包/类
public NativeDecoratedKey(Token token, NativeAllocator allocator, OpOrder.Group writeOp, ByteBuffer key)
{
    super(token);
    assert key != null;
    assert key.order() == ByteOrder.BIG_ENDIAN;

    int size = key.remaining();
    this.peer = allocator.allocate(4 + size, writeOp);
    MemoryUtil.setInt(peer, size);
    MemoryUtil.setBytes(peer + 4, key);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:12,代码来源:NativeDecoratedKey.java

示例10: NativeClustering

import org.apache.cassandra.utils.concurrent.OpOrder; //导入方法依赖的package包/类
public NativeClustering(NativeAllocator allocator, OpOrder.Group writeOp, Clustering clustering)
{
    int count = clustering.size();
    int metadataSize = (count * 2) + 4;
    int dataSize = clustering.dataSize();
    int bitmapSize = ((count + 7) >>> 3);

    assert count < 64 << 10;
    assert dataSize < 64 << 10;

    peer = allocator.allocate(metadataSize + dataSize + bitmapSize, writeOp);
    long bitmapStart = peer + metadataSize;
    MemoryUtil.setShort(peer, (short) count);
    MemoryUtil.setShort(peer + (metadataSize - 2), (short) dataSize); // goes at the end of the other offsets

    MemoryUtil.setByte(bitmapStart, bitmapSize, (byte) 0);
    long dataStart = peer + metadataSize + bitmapSize;
    int dataOffset = 0;
    for (int i = 0 ; i < count ; i++)
    {
        MemoryUtil.setShort(peer + 2 + i * 2, (short) dataOffset);

        ByteBuffer value = clustering.get(i);
        if (value == null)
        {
            long boffset = bitmapStart + (i >>> 3);
            int b = MemoryUtil.getByte(boffset);
            b |= 1 << (i & 7);
            MemoryUtil.setByte(boffset, (byte) b);
            continue;
        }

        assert value.order() == ByteOrder.BIG_ENDIAN;

        int size = value.remaining();
        MemoryUtil.setBytes(dataStart + dataOffset, value);
        dataOffset += size;
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:40,代码来源:NativeClustering.java

示例11: NativeCell

import org.apache.cassandra.utils.concurrent.OpOrder; //导入方法依赖的package包/类
public NativeCell(NativeAllocator allocator,
                  OpOrder.Group writeOp,
                  Cell cell)
{
    this(allocator,
         writeOp,
         cell.column(),
         cell.timestamp(),
         cell.ttl(),
         cell.localDeletionTime(),
         cell.value(),
         cell.path());
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:14,代码来源:NativeCell.java

示例12: readTypeTimestamp

import org.apache.cassandra.utils.concurrent.OpOrder; //导入方法依赖的package包/类
private static long readTypeTimestamp(String keyspaceName, String typeName)
{
    ColumnFamilyStore store = org.apache.cassandra.db.Keyspace.open(SystemKeyspace.NAME)
                                                              .getColumnFamilyStore(SystemKeyspace.LEGACY_USERTYPES);

    ClusteringComparator comparator = store.metadata.comparator;
    Slices slices = Slices.with(comparator, Slice.make(comparator, typeName));
    int nowInSec = FBUtilities.nowInSeconds();
    DecoratedKey key = store.metadata.decorateKey(AsciiType.instance.fromString(keyspaceName));
    SinglePartitionReadCommand command = SinglePartitionReadCommand.create(store.metadata, nowInSec, key, slices);

    try (OpOrder.Group op = store.readOrdering.start();
         RowIterator partition = UnfilteredRowIterators.filter(command.queryMemtableAndDisk(store, op), nowInSec))
    {
        long timestamp;
        do {
            Row row = partition.next();
            timestamp = row.primaryKeyLivenessInfo().timestamp();
            if (row.primaryKeyLivenessInfo().isEmpty() && nonPersistent) {
                // I don't think this is a scylla bug per se, but apparently we 
                // generate sstables slightly different from origin, thus though we get the 
                // data, the pk liveness/timestamp is not set. But returning NO_TIMESTAMP
                // here will lead to all mutations generated being empty (deletion deletes).
                // Work around this (only in tool/non-persistent mode) by saying "now" 
                timestamp = FBUtilities.timestampMicros();
                break;
            }
        } while (partition.hasNext());

        return timestamp;
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:33,代码来源:LegacySchemaMigrator.java

示例13: update

import org.apache.cassandra.utils.concurrent.OpOrder; //导入方法依赖的package包/类
public void update(ByteBuffer rowKey, Cell oldCol, Cell col, OpOrder.Group opGroup)
{
    // insert the new value before removing the old one, so we never have a period
    // where the row is invisible to both queries (the opposite seems preferable); see CASSANDRA-5540                    
    insert(rowKey, col, opGroup);
    if (SecondaryIndexManager.shouldCleanupOldValue(oldCol, col))
        delete(rowKey, oldCol, opGroup);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:9,代码来源:AbstractSimplePerColumnSecondaryIndex.java

示例14: getSSTablesForKey

import org.apache.cassandra.utils.concurrent.OpOrder; //导入方法依赖的package包/类
public List<String> getSSTablesForKey(String key)
{
    DecoratedKey dk = decorateKey(metadata.getKeyValidator().fromString(key));
    try (OpOrder.Group op = readOrdering.start())
    {
        List<String> files = new ArrayList<>();
        for (SSTableReader sstr : select(View.select(SSTableSet.LIVE, dk)).sstables)
        {
            // check if the key actually exists in this sstable, without updating cache and stats
            if (sstr.getPosition(dk, SSTableReader.Operator.EQ, false) != null)
                files.add(sstr.getFilename());
        }
        return files;
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:16,代码来源:ColumnFamilyStore.java

示例15: allocate

import org.apache.cassandra.utils.concurrent.OpOrder; //导入方法依赖的package包/类
public ByteBuffer allocate(int size, OpOrder.Group opGroup)
{
    super.onHeap().allocate(size, opGroup);
    return ByteBuffer.allocate(size);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:6,代码来源:HeapPool.java


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