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


Java UntypedResultSet.isEmpty方法代码示例

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


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

示例1: getPreviousVersionString

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
/**
 * Try to determine what the previous version, if any, was installed on this node.
 * Primary source of truth is the release version in system.local. If the previous
 * version cannot be determined by looking there then either:
 * * the node never had a C* install before
 * * the was a very old version (pre 1.2) installed, which did not include system.local
 *
 * @return either a version read from the system.local table or one of two special values
 * indicating either no previous version (SystemUpgrade.NULL_VERSION) or an unreadable,
 * legacy version (SystemUpgrade.UNREADABLE_VERSION).
 */
private static String getPreviousVersionString()
{
    String req = "SELECT release_version FROM system.%s WHERE key='%s'";
    UntypedResultSet result = executeInternal(String.format(req, SystemKeyspace.LOCAL, SystemKeyspace.LOCAL));
    if (result.isEmpty() || !result.one().has("release_version"))
    {
        // it isn't inconceivable that one might try to upgrade a node straight from <= 1.1 to whatever
        // the current version is. If we couldn't read a previous version from system.local we check for
        // the existence of the legacy system.Versions table. We don't actually attempt to read a version
        // from there, but it informs us that this isn't a completely new node.
        for (File dataDirectory : Directories.getKSChildDirectories(SystemKeyspace.NAME))
        {
            if (dataDirectory.getName().equals("Versions") && dataDirectory.listFiles().length > 0)
            {
                logger.trace("Found unreadable versions info in pre 1.2 system.Versions table");
                return UNREADABLE_VERSION.toString();
            }
        }

        // no previous version information found, we can assume that this is a new node
        return NULL_VERSION.toString();
    }
    // report back whatever we found in the system table
    return result.one().getString("release_version");
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:37,代码来源:SystemKeyspace.java

示例2: getSSTableReadMeter

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
/**
 * Returns a RestorableMeter tracking the average read rate of a particular SSTable, restoring the last-seen rate
 * from values in system.sstable_activity if present.
 * @param keyspace the keyspace the sstable belongs to
 * @param table the table the sstable belongs to
 * @param generation the generation number for the sstable
 */
public static RestorableMeter getSSTableReadMeter(String keyspace, String table, int generation)
{
    String cql = "SELECT * FROM %s WHERE keyspace_name='%s' and columnfamily_name='%s' and generation=%d";
    UntypedResultSet results = processInternal(String.format(cql,
                                                             SSTABLE_ACTIVITY_CF,
                                                             keyspace,
                                                             table,
                                                             generation));

    if (results.isEmpty())
        return new RestorableMeter();

    UntypedResultSet.Row row = results.one();
    double m15rate = row.getDouble("rate_15m");
    double m120rate = row.getDouble("rate_120m");
    return new RestorableMeter(m15rate, m120rate);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:25,代码来源:SystemKeyspace.java

示例3: getTruncationRecords

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
public static Map<UUID, Pair<ReplayPosition, Long>> getTruncationRecords()
{
    String req = "SELECT truncated_at FROM system.%s WHERE key = '%s'";
    UntypedResultSet rows = processInternal(String.format(req, LOCAL_CF, LOCAL_KEY));
    if (rows.isEmpty())
        return Collections.emptyMap();

    UntypedResultSet.Row row = rows.one();
    Map<UUID, ByteBuffer> rawMap = row.getMap("truncated_at", UUIDType.instance, BytesType.instance);
    if (rawMap == null)
        return Collections.emptyMap();

    Map<UUID, Pair<ReplayPosition, Long>> positions = new HashMap<UUID, Pair<ReplayPosition, Long>>();
    for (Map.Entry<UUID, ByteBuffer> entry : rawMap.entrySet())
        positions.put(entry.getKey(), truncationRecordFromBlob(entry.getValue()));
    return positions;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:18,代码来源:SystemKeyspace.java

示例4: getViewBuildStatus

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
public static Pair<Integer, Token> getViewBuildStatus(String ksname, String viewName)
{
    String req = "SELECT generation_number, last_token FROM system.%s WHERE keyspace_name = ? AND view_name = ?";
    UntypedResultSet queryResultSet = executeInternal(String.format(req, VIEWS_BUILDS_IN_PROGRESS), ksname, viewName);
    if (queryResultSet == null || queryResultSet.isEmpty())
        return null;

    UntypedResultSet.Row row = queryResultSet.one();

    Integer generation = null;
    Token lastKey = null;
    if (row.has("generation_number"))
        generation = row.getInt("generation_number");
    if (row.has("last_key"))
    {
        Token.TokenFactory factory = ViewsBuildsInProgress.partitioner.getTokenFactory();
        lastKey = factory.fromString(row.getString("last_key"));
    }

    return Pair.create(generation, lastKey);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:SystemKeyspace.java

示例5: loadPaxosState

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
public static PaxosState loadPaxosState(ByteBuffer key, CFMetaData metadata)
{
    String req = "SELECT * FROM system.%s WHERE row_key = 0x%s AND cf_id = %s";
    UntypedResultSet results = processInternal(String.format(req, PAXOS_CF, ByteBufferUtil.bytesToHex(key), metadata.cfId));
    if (results.isEmpty())
        return new PaxosState(key, metadata);
    UntypedResultSet.Row row = results.one();
    Commit promised = new Commit(key, row.getUUID("in_progress_ballot"), EmptyColumns.factory.create(metadata));
    // either we have both a recently accepted ballot and update or we have neither
    Commit accepted = row.has("proposal")
                    ? new Commit(key, row.getUUID("proposal_ballot"), ColumnFamily.fromBytes(row.getBytes("proposal")))
                    : Commit.emptyCommit(key, metadata);
    // either most_recent_commit and most_recent_commit_at will both be set, or neither
    Commit mostRecent = row.has("most_recent_commit")
                      ? new Commit(key, row.getUUID("most_recent_commit_at"), ColumnFamily.fromBytes(row.getBytes("most_recent_commit")))
                      : Commit.emptyCommit(key, metadata);
    return new PaxosState(promised, accepted, mostRecent);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:19,代码来源:SystemKeyspace.java

示例6: doAuthenticate

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
private AuthenticatedUser doAuthenticate(String username, String password, SelectStatement authenticationStatement)
throws RequestExecutionException, AuthenticationException
{
    ResultMessage.Rows rows = authenticationStatement.execute(QueryState.forInternalCalls(),
                                                              QueryOptions.forInternalCalls(consistencyForRole(username),
                                                                                            Lists.newArrayList(ByteBufferUtil.bytes(username))));
    UntypedResultSet result = UntypedResultSet.create(rows.result);

    if ((result.isEmpty() || !result.one().has(SALTED_HASH)) || !BCrypt.checkpw(password, result.one().getString(SALTED_HASH)))
        throw new AuthenticationException("Username and/or password are incorrect");

    return new AuthenticatedUser(username);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:14,代码来源:PasswordAuthenticator.java

示例7: getPreferredIP

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
/**
 * Get preferred IP for given endpoint if it is known. Otherwise this returns given endpoint itself.
 *
 * @param ep endpoint address to check
 * @return Preferred IP for given endpoint if present, otherwise returns given ep
 */
public static InetAddress getPreferredIP(InetAddress ep)
{
    String req = "SELECT preferred_ip FROM system.%s WHERE peer=?";
    UntypedResultSet result = executeInternal(String.format(req, PEERS_CF), ep);
    if (!result.isEmpty() && result.one().has("preferred_ip"))
        return result.one().getInetAddress("preferred_ip");
    return ep;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:15,代码来源:SystemKeyspace.java

示例8: checkHealth

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
/**
 * One of three things will happen if you try to read the system keyspace:
 * 1. files are present and you can read them: great
 * 2. no files are there: great (new node is assumed)
 * 3. files are present but you can't read them: bad
 * @throws ConfigurationException
 */
public static void checkHealth() throws ConfigurationException
{
    Keyspace keyspace;
    try
    {
        keyspace = Keyspace.open(Keyspace.SYSTEM_KS);
    }
    catch (AssertionError err)
    {
        // this happens when a user switches from OPP to RP.
        ConfigurationException ex = new ConfigurationException("Could not read system keyspace!");
        ex.initCause(err);
        throw ex;
    }
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(LOCAL_CF);

    String req = "SELECT cluster_name FROM system.%s WHERE key='%s'";
    UntypedResultSet result = executeInternal(String.format(req, LOCAL_CF, LOCAL_KEY));

    if (result.isEmpty() || !result.one().has("cluster_name"))
    {
        // this is a brand new node
        if (!cfs.getSSTables().isEmpty())
            throw new ConfigurationException("Found system keyspace files, but they couldn't be loaded!");

        // no system files.  this is a new node.
        req = "INSERT INTO system.%s (key, cluster_name) VALUES ('%s', ?)";
        executeInternal(String.format(req, LOCAL_CF, LOCAL_KEY), DatabaseDescriptor.getClusterName());
        return;
    }

    String savedClusterName = result.one().getString("cluster_name");
    if (!DatabaseDescriptor.getClusterName().equals(savedClusterName))
        throw new ConfigurationException("Saved cluster name " + savedClusterName + " != configured name " + DatabaseDescriptor.getClusterName());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:43,代码来源:SystemKeyspace.java

示例9: getSavedTokens

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
public static Collection<Token> getSavedTokens()
{
    String req = "SELECT tokens FROM system.%s WHERE key='%s'";
    UntypedResultSet result = executeInternal(String.format(req, LOCAL, LOCAL));
    return result.isEmpty() || !result.one().has("tokens")
         ? Collections.<Token>emptyList()
         : deserializeTokens(result.one().getSet("tokens", UTF8Type.instance));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:9,代码来源:SystemKeyspace.java

示例10: getBootstrapState

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
public static BootstrapState getBootstrapState()
{
    String req = "SELECT bootstrapped FROM system.%s WHERE key='%s'";
    UntypedResultSet result = executeInternal(String.format(req, LOCAL, LOCAL));

    if (result.isEmpty() || !result.one().has("bootstrapped"))
        return BootstrapState.NEEDS_BOOTSTRAP;

    return BootstrapState.valueOf(result.one().getString("bootstrapped"));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:11,代码来源:SystemKeyspace.java

示例11: getSSTableReadMeter

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
/**
 * Returns a RestorableMeter tracking the average read rate of a particular SSTable, restoring the last-seen rate
 * from values in system.sstable_activity if present.
 * @param keyspace the keyspace the sstable belongs to
 * @param table the table the sstable belongs to
 * @param generation the generation number for the sstable
 */
public static RestorableMeter getSSTableReadMeter(String keyspace, String table, int generation)
{
    String cql = "SELECT * FROM system.%s WHERE keyspace_name=? and columnfamily_name=? and generation=?";
    UntypedResultSet results = executeInternal(String.format(cql, SSTABLE_ACTIVITY), keyspace, table, generation);

    if (results.isEmpty())
        return new RestorableMeter();

    UntypedResultSet.Row row = results.one();
    double m15rate = row.getDouble("rate_15m");
    double m120rate = row.getDouble("rate_120m");
    return new RestorableMeter(m15rate, m120rate);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:SystemKeyspace.java

示例12: replayAllFailedBatches

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
private void replayAllFailedBatches() throws ExecutionException, InterruptedException
{
    logger.debug("Started replayAllFailedBatches");

    // rate limit is in bytes per second. Uses Double.MAX_VALUE if disabled (set to 0 in cassandra.yaml).
    // max rate is scaled by the number of nodes in the cluster (same as for HHOM - see CASSANDRA-5272).
    int throttleInKB = DatabaseDescriptor.getBatchlogReplayThrottleInKB() / StorageService.instance.getTokenMetadata().getAllEndpoints().size();
    RateLimiter rateLimiter = RateLimiter.create(throttleInKB == 0 ? Double.MAX_VALUE : throttleInKB * 1024);

    UntypedResultSet page = executeInternal(String.format("SELECT id, data, written_at, version FROM %s.%s LIMIT %d",
                                                          Keyspace.SYSTEM_KS,
                                                          SystemKeyspace.BATCHLOG_CF,
                                                          PAGE_SIZE));

    while (!page.isEmpty())
    {
        UUID id = processBatchlogPage(page, rateLimiter);

        if (page.size() < PAGE_SIZE)
            break; // we've exhausted the batchlog, next query would be empty.

        page = executeInternal(String.format("SELECT id, data, written_at, version FROM %s.%s WHERE token(id) > token(?) LIMIT %d",
                                             Keyspace.SYSTEM_KS,
                                             SystemKeyspace.BATCHLOG_CF,
                                             PAGE_SIZE),
                               id);
    }

    cleanup();

    logger.debug("Finished replayAllFailedBatches");
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:33,代码来源:BatchlogManager.java

示例13: checkHealth

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
/**
 * One of three things will happen if you try to read the system keyspace:
 * 1. files are present and you can read them: great
 * 2. no files are there: great (new node is assumed)
 * 3. files are present but you can't read them: bad
 * @throws ConfigurationException
 */
public static void checkHealth() throws ConfigurationException
{
    Keyspace keyspace;
    try
    {
        keyspace = Keyspace.open(Keyspace.SYSTEM_KS);
    }
    catch (AssertionError err)
    {
        // this happens when a user switches from OPP to RP.
        ConfigurationException ex = new ConfigurationException("Could not read system keyspace!");
        ex.initCause(err);
        throw ex;
    }
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(LOCAL_CF);

    String req = "SELECT cluster_name FROM system.%s WHERE key='%s'";
    UntypedResultSet result = processInternal(String.format(req, LOCAL_CF, LOCAL_KEY));

    if (result.isEmpty() || !result.one().has("cluster_name"))
    {
        // this is a brand new node
        if (!cfs.getSSTables().isEmpty())
            throw new ConfigurationException("Found system keyspace files, but they couldn't be loaded!");

        // no system files.  this is a new node.
        req = "INSERT INTO system.%s (key, cluster_name) VALUES ('%s', '%s')";
        processInternal(String.format(req, LOCAL_CF, LOCAL_KEY, DatabaseDescriptor.getClusterName()));
        return;
    }

    String savedClusterName = result.one().getString("cluster_name");
    if (!DatabaseDescriptor.getClusterName().equals(savedClusterName))
        throw new ConfigurationException("Saved cluster name " + savedClusterName + " != configured name " + DatabaseDescriptor.getClusterName());
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:43,代码来源:SystemKeyspace.java

示例14: getSavedTokens

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
public static Collection<Token> getSavedTokens()
{
    String req = "SELECT tokens FROM system.%s WHERE key='%s'";
    UntypedResultSet result = processInternal(String.format(req, LOCAL_CF, LOCAL_KEY));
    return result.isEmpty() || !result.one().has("tokens")
         ? Collections.<Token>emptyList()
         : deserializeTokens(result.one().<String>getSet("tokens", UTF8Type.instance));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:9,代码来源:SystemKeyspace.java

示例15: incrementAndGetGeneration

import org.apache.cassandra.cql3.UntypedResultSet; //导入方法依赖的package包/类
public static int incrementAndGetGeneration()
{
    String req = "SELECT gossip_generation FROM system.%s WHERE key='%s'";
    UntypedResultSet result = processInternal(String.format(req, LOCAL_CF, LOCAL_KEY));

    int generation;
    if (result.isEmpty() || !result.one().has("gossip_generation"))
    {
        // seconds-since-epoch isn't a foolproof new generation
        // (where foolproof is "guaranteed to be larger than the last one seen at this ip address"),
        // but it's as close as sanely possible
        generation = (int) (System.currentTimeMillis() / 1000);
    }
    else
    {
        // Other nodes will ignore gossip messages about a node that have a lower generation than previously seen.
        final int storedGeneration = result.one().getInt("gossip_generation") + 1;
        final int now = (int) (System.currentTimeMillis() / 1000);
        if (storedGeneration >= now)
        {
            logger.warn("Using stored Gossip Generation {} as it is greater than current system time {}.  See CASSANDRA-3654 if you experience problems",
                        storedGeneration, now);
            generation = storedGeneration;
        }
        else
        {
            generation = now;
        }
    }

    req = "INSERT INTO system.%s (key, gossip_generation) VALUES ('%s', %d)";
    processInternal(String.format(req, LOCAL_CF, LOCAL_KEY, generation));
    forceBlockingFlush(LOCAL_CF);

    return generation;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:37,代码来源:SystemKeyspace.java


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