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


Java FBUtilities类代码示例

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


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

示例1: UpdateParameters

import org.apache.cassandra.utils.FBUtilities; //导入依赖的package包/类
public UpdateParameters(CFMetaData metadata,
                        PartitionColumns updatedColumns,
                        QueryOptions options,
                        long timestamp,
                        int ttl,
                        Map<DecoratedKey, Partition> prefetchedRows)
throws InvalidRequestException
{
    this.metadata = metadata;
    this.updatedColumns = updatedColumns;
    this.options = options;

    this.nowInSec = FBUtilities.nowInSeconds();
    this.timestamp = timestamp;
    this.ttl = ttl;

    this.deletionTime = new DeletionTime(timestamp, nowInSec);

    this.prefetchedRows = prefetchedRows;

    // We use MIN_VALUE internally to mean the absence of of timestamp (in Selection, in sstable stats, ...), so exclude
    // it to avoid potential confusion.
    if (timestamp == Long.MIN_VALUE)
        throw new InvalidRequestException(String.format("Out of bound timestamp, must be in [%d, %d]", Long.MIN_VALUE + 1, Long.MAX_VALUE));
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:26,代码来源:UpdateParameters.java

示例2: maybeTakeFromPool

import org.apache.cassandra.utils.FBUtilities; //导入依赖的package包/类
private static ByteBuffer maybeTakeFromPool(int size, boolean allocateOnHeapWhenExhausted)
{
    if (size < 0)
        throw new IllegalArgumentException("Size must be positive (" + size + ")");

    if (size == 0)
        return EMPTY_BUFFER;

    if (size > CHUNK_SIZE)
    {
        if (logger.isTraceEnabled())
            logger.trace("Requested buffer size {} is bigger than {}, allocating directly",
                         FBUtilities.prettyPrintMemory(size),
                         FBUtilities.prettyPrintMemory(CHUNK_SIZE));

        return localPool.get().allocate(size, allocateOnHeapWhenExhausted);
    }

    return localPool.get().get(size);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:21,代码来源:BufferPool.java

示例3: create

import org.apache.cassandra.utils.FBUtilities; //导入依赖的package包/类
private static UnfilteredRowMergeIterator create(List<UnfilteredRowIterator> iterators, int nowInSec, MergeListener listener)
{
    try
    {
        //checkForInvalidInput(iterators);
        return new UnfilteredRowMergeIterator(iterators.get(0).metadata(),
                                              iterators,
                                              collectColumns(iterators),
                                              collectPartitionLevelDeletion(iterators, listener),
                                              nowInSec,
                                              iterators.get(0).isReverseOrder(),
                                              listener);
    }
    catch (RuntimeException | Error e)
    {
        try
        {
            FBUtilities.closeAll(iterators);
        }
        catch (Exception suppressed)
        {
            e.addSuppressed(suppressed);
        }
        throw e;
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:27,代码来源:UnfilteredRowIterators.java

示例4: getLocation

import org.apache.cassandra.utils.FBUtilities; //导入依赖的package包/类
private String getLocation()
{
    Collection<InetAddress> localAddresses = FBUtilities.getAllLocalAddresses();

    for (InetAddress address : localAddresses)
    {
        for (String location : split.getLocations())
        {
            InetAddress locationAddress = null;
            try
            {
                locationAddress = InetAddress.getByName(location);
            }
            catch (UnknownHostException e)
            {
                throw new AssertionError(e);
            }
            if (address.equals(locationAddress))
            {
                return location;
            }
        }
    }
    return split.getLocations()[0];
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:26,代码来源:ColumnFamilyRecordReader.java

示例5: validateDeletion

import org.apache.cassandra.utils.FBUtilities; //导入依赖的package包/类
public static void validateDeletion(CFMetaData metadata, Deletion del) throws org.apache.cassandra.exceptions.InvalidRequestException
{

    if (del.super_column != null)
        validateColumnNames(metadata, (ByteBuffer)null, Arrays.asList(del.super_column));

    if (del.predicate != null)
        validateSlicePredicate(metadata, del.super_column, del.predicate);

    if (!metadata.isSuper() && del.super_column != null)
    {
        String msg = String.format("Deletion of super columns is not possible on a standard table (KeySpace=%s Table=%s Deletion=%s)", metadata.ksName, metadata.cfName, del);
        throw new org.apache.cassandra.exceptions.InvalidRequestException(msg);
    }

    if (metadata.isCounter())
    {
        // forcing server timestamp even if a timestamp was set for coherence with other counter operation
        del.timestamp = FBUtilities.timestampMicros();
    }
    else if (!del.isSetTimestamp())
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException("Deletion timestamp is not optional for non commutative table " + metadata.cfName);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:26,代码来源:ThriftValidation.java

示例6: NetworkTopologyStrategy

import org.apache.cassandra.utils.FBUtilities; //导入依赖的package包/类
public NetworkTopologyStrategy(String keyspaceName, TokenMetadata tokenMetadata, IEndpointSnitch snitch, Map<String, String> configOptions) throws ConfigurationException
{
    super(keyspaceName, tokenMetadata, snitch, configOptions);
    this.snitch = snitch;

    Map<String, Integer> newDatacenters = new HashMap<String, Integer>();
    if (configOptions != null)
    {
        for (Entry<String, String> entry : configOptions.entrySet())
        {
            String dc = entry.getKey();
            if (dc.equalsIgnoreCase("replication_factor"))
                throw new ConfigurationException("replication_factor is an option for SimpleStrategy, not NetworkTopologyStrategy");
            Integer replicas = Integer.valueOf(entry.getValue());
            newDatacenters.put(dc, replicas);
        }
    }

    datacenters = Collections.unmodifiableMap(newDatacenters);
    logger.trace("Configured datacenter replicas are {}", FBUtilities.toString(datacenters));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:NetworkTopologyStrategy.java

示例7: testGetNeighborsPlusOneInLocalDC

import org.apache.cassandra.utils.FBUtilities; //导入依赖的package包/类
@Test
public void testGetNeighborsPlusOneInLocalDC() throws Throwable
{
    TokenMetadata tmd = StorageService.instance.getTokenMetadata();
    
    // generate rf+1 nodes, and ensure that all nodes are returned
    Set<InetAddress> expected = addTokens(1 + Keyspace.open(keyspaceName).getReplicationStrategy().getReplicationFactor());
    expected.remove(FBUtilities.getBroadcastAddress());
    // remove remote endpoints
    TokenMetadata.Topology topology = tmd.cloneOnlyTokenMap().getTopology();
    HashSet<InetAddress> localEndpoints = Sets.newHashSet(topology.getDatacenterEndpoints().get(DatabaseDescriptor.getLocalDataCenter()));
    expected = Sets.intersection(expected, localEndpoints);

    Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(keyspaceName);
    Set<InetAddress> neighbors = new HashSet<InetAddress>();
    for (Range<Token> range : ranges)
    {
        neighbors.addAll(ActiveRepairService.getNeighbors(keyspaceName, range, Arrays.asList(DatabaseDescriptor.getLocalDataCenter()), null));
    }
    assertEquals(expected, neighbors);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:AntiEntropyServiceTestAbstract.java

示例8: maybeBuildSecondaryIndexes

import org.apache.cassandra.utils.FBUtilities; //导入依赖的package包/类
/**
 * Does a full, blocking rebuild of the indexes specified by columns from the sstables.
 * Does nothing if columns is empty.
 *
 * Caller must acquire and release references to the sstables used here.
 *
 * @param sstables the data to build from
 * @param idxNames the list of columns to index, ordered by comparator
 */
public void maybeBuildSecondaryIndexes(Collection<SSTableReader> sstables, Set<String> idxNames)
{
    if (idxNames.isEmpty())
        return;

    logger.info(String.format("Submitting index build of %s for data in %s",
                              idxNames, StringUtils.join(sstables, ", ")));

    SecondaryIndexBuilder builder = new SecondaryIndexBuilder(baseCfs, idxNames, new ReducingKeyIterator(sstables));
    Future<?> future = CompactionManager.instance.submitIndexBuild(builder);
    FBUtilities.waitOnFuture(future);

    flushIndexesBlocking();

    logger.info("Index build of {} complete", idxNames);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:26,代码来源:SecondaryIndexManager.java

示例9: maybeSetApplicationState

import org.apache.cassandra.utils.FBUtilities; //导入依赖的package包/类
/**
 * be careful about just blindly updating ApplicationState.INTERNAL_IP everytime we read the yaml file,
 * as that can cause connections to get unnecessarily reset (via IESCS.onChange()).
 */
private void maybeSetApplicationState()
{
    if (localNodeData.dcLocalAddress == null)
        return;
    final EndpointState es = Gossiper.instance.getEndpointStateForEndpoint(FBUtilities.getBroadcastAddress());
    if (es == null)
        return;
    final VersionedValue vv = es.getApplicationState(ApplicationState.INTERNAL_IP);
    if ((vv != null && !vv.value.equals(localNodeData.dcLocalAddress.getHostAddress()))
        || vv == null)
    {
        Gossiper.instance.addLocalApplicationState(ApplicationState.INTERNAL_IP,
            StorageService.instance.valueFactory.internalIP(localNodeData.dcLocalAddress.getHostAddress()));
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:20,代码来源:YamlFileNetworkTopologySnitch.java

示例10: CqlRecordWriter

import org.apache.cassandra.utils.FBUtilities; //导入依赖的package包/类
CqlRecordWriter(Configuration conf)
{
    this.conf = conf;
    this.queueSize = conf.getInt(CqlOutputFormat.QUEUE_SIZE, 32 * FBUtilities.getAvailableProcessors());
    batchThreshold = conf.getLong(CqlOutputFormat.BATCH_THRESHOLD, 32);
    this.clients = new HashMap<>();
    String keyspace = ConfigHelper.getOutputKeyspace(conf);

    try (Cluster cluster = CqlConfigHelper.getOutputCluster(ConfigHelper.getOutputInitialAddress(conf), conf))
    {
        Metadata metadata = cluster.getMetadata();
        ringCache = new NativeRingCache(conf, metadata);
        TableMetadata tableMetadata = metadata.getKeyspace(Metadata.quote(keyspace)).getTable(ConfigHelper.getOutputColumnFamily(conf));
        clusterColumns = tableMetadata.getClusteringColumns();
        partitionKeyColumns = tableMetadata.getPartitionKey();

        String cqlQuery = CqlConfigHelper.getOutputCql(conf).trim();
        if (cqlQuery.toLowerCase().startsWith("insert"))
            throw new UnsupportedOperationException("INSERT with CqlRecordWriter is not supported, please use UPDATE/DELETE statement");
        cql = appendKeyWhereClauses(cqlQuery);
    }
    catch (Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:27,代码来源:CqlRecordWriter.java

示例11: testGetColumn

import org.apache.cassandra.utils.FBUtilities; //导入依赖的package包/类
@Test
public void testGetColumn()
{
    Keyspace keyspace = Keyspace.open("Keyspace1");
    CellNameType type = keyspace.getColumnFamilyStore("Standard1").getComparator();
    Mutation rm;
    DecoratedKey dk = Util.dk("key1");

    // add data
    rm = new Mutation("Keyspace1", dk.getKey());
    rm.add("Standard1", Util.cellname("Column1"), ByteBufferUtil.bytes("abcd"), 0);
    rm.apply();

    ReadCommand command = new SliceByNamesReadCommand("Keyspace1", dk.getKey(), "Standard1", System.currentTimeMillis(), new NamesQueryFilter(FBUtilities.singleton(Util.cellname("Column1"), type)));
    Row row = command.getRow(keyspace);
    Cell col = row.cf.getColumn(Util.cellname("Column1"));
    assertEquals(col.value(), ByteBuffer.wrap("abcd".getBytes()));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:19,代码来源:ReadMessageTest.java

示例12: PropertyFileSnitch

import org.apache.cassandra.utils.FBUtilities; //导入依赖的package包/类
public PropertyFileSnitch() throws ConfigurationException
{
    reloadConfiguration();

    try
    {
        FBUtilities.resourceToFile(SNITCH_PROPERTIES_FILENAME);
        Runnable runnable = new WrappedRunnable()
        {
            protected void runMayThrow() throws ConfigurationException
            {
                reloadConfiguration();
            }
        };
        ResourceWatcher.watch(SNITCH_PROPERTIES_FILENAME, runnable, 60 * 1000);
    }
    catch (ConfigurationException ex)
    {
        logger.error("{} found, but does not look like a plain file. Will not watch it for changes", SNITCH_PROPERTIES_FILENAME);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:PropertyFileSnitch.java

示例13: sendTreeRequests

import org.apache.cassandra.utils.FBUtilities; //导入依赖的package包/类
/**
 * Send merkle tree request to every involved neighbor.
 */
public void sendTreeRequests(Collection<InetAddress> endpoints)
{
    // send requests to all nodes
    List<InetAddress> allEndpoints = new ArrayList<>(endpoints);
    allEndpoints.add(FBUtilities.getBroadcastAddress());

    if (isSequential)
        makeSnapshots(endpoints);

    this.gcBefore = Keyspace.open(desc.keyspace).getColumnFamilyStore(desc.columnFamily).gcBefore(System.currentTimeMillis());

    for (InetAddress endpoint : allEndpoints)
        treeRequests.add(endpoint);

    logger.info(String.format("[repair #%s] requesting merkle trees for %s (to %s)", desc.sessionId, desc.columnFamily, allEndpoints));
    treeRequests.start();
    requestsSent.signalAll();
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:22,代码来源:RepairJob.java

示例14: validateKey

import org.apache.cassandra.utils.FBUtilities; //导入依赖的package包/类
public static void validateKey(CFMetaData metadata, ByteBuffer key) throws org.apache.cassandra.exceptions.InvalidRequestException
{
    if (key == null || key.remaining() == 0)
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException("Key may not be empty");
    }

    // check that key can be handled by FBUtilities.writeShortByteArray
    if (key.remaining() > FBUtilities.MAX_UNSIGNED_SHORT)
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException("Key length of " + key.remaining() +
                                                                          " is longer than maximum of " +
                                                                          FBUtilities.MAX_UNSIGNED_SHORT);
    }

    try
    {
        metadata.getKeyValidator().validate(key);
    }
    catch (MarshalException e)
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:25,代码来源:ThriftValidation.java

示例15: deserialize

import org.apache.cassandra.utils.FBUtilities; //导入依赖的package包/类
public Future<Pair<KeyCacheKey, RowIndexEntry>> deserialize(DataInputStream input, ColumnFamilyStore cfs) throws IOException
{
    int keyLength = input.readInt();
    if (keyLength > FBUtilities.MAX_UNSIGNED_SHORT)
    {
        throw new IOException(String.format("Corrupted key cache. Key length of %d is longer than maximum of %d",
                                            keyLength, FBUtilities.MAX_UNSIGNED_SHORT));
    }
    ByteBuffer key = ByteBufferUtil.read(input, keyLength);
    int generation = input.readInt();
    SSTableReader reader = findDesc(generation, cfs.getSSTables());
    input.readBoolean(); // backwards compatibility for "promoted indexes" boolean
    if (reader == null)
    {
        RowIndexEntry.Serializer.skipPromotedIndex(input);
        return null;
    }
    RowIndexEntry entry = reader.metadata.comparator.rowIndexEntrySerializer().deserialize(input, reader.descriptor.version);
    return Futures.immediateFuture(Pair.create(new KeyCacheKey(cfs.metadata.cfId, reader.descriptor, key), entry));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:21,代码来源:CacheService.java


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