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


Java DatabaseDescriptor.getClusterName方法代码示例

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


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

示例1: doShadowRound

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
/**
 *  Do a single 'shadow' round of gossip, where we do not modify any state
 *  Only used when replacing a node, to get and assume its states
 */
public void doShadowRound()
{
    buildSeedsList();
    // send a completely empty syn
    List<GossipDigest> gDigests = new ArrayList<GossipDigest>();
    GossipDigestSyn digestSynMessage = new GossipDigestSyn(DatabaseDescriptor.getClusterName(),
            DatabaseDescriptor.getPartitionerName(),
            gDigests);
    MessageOut<GossipDigestSyn> message = new MessageOut<GossipDigestSyn>(MessagingService.Verb.GOSSIP_DIGEST_SYN,
            digestSynMessage,
            GossipDigestSyn.serializer);
    inShadowRound = true;
    for (InetAddress seed : seeds)
        MessagingService.instance().sendOneWay(message, seed);
    int slept = 0;
    try
    {
        while (true)
        {
            Thread.sleep(1000);
            if (!inShadowRound)
                break;
            slept += 1000;
            if (slept > StorageService.RING_DELAY)
                throw new RuntimeException("Unable to gossip with any seeds");
        }
    }
    catch (InterruptedException wtf)
    {
        throw new RuntimeException(wtf);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:37,代码来源:Gossiper.java

示例2: checkHealth

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的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

示例3: checkHealth

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的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

示例4: doShadowRound

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
/**
 *  Do a single 'shadow' round of gossip, where we do not modify any state
 *  Only used when replacing a node, to get and assume its states
 */
public void doShadowRound()
{
    buildSeedsList();
    // send a completely empty syn
    List<GossipDigest> gDigests = new ArrayList<GossipDigest>();
    GossipDigestSyn digestSynMessage = new GossipDigestSyn(DatabaseDescriptor.getClusterName(),
            DatabaseDescriptor.getPartitionerName(),
            gDigests);
    MessageOut<GossipDigestSyn> message = new MessageOut<GossipDigestSyn>(MessagingService.Verb.GOSSIP_DIGEST_SYN,
            digestSynMessage,
            GossipDigestSyn.serializer);

    inShadowRound = true;
    int slept = 0;
    try
    {
        while (true)
        {
            if (slept % 5000 == 0)
            { // CASSANDRA-8072, retry at the beginning and every 5 seconds
                logger.trace("Sending shadow round GOSSIP DIGEST SYN to seeds {}", seeds);
                for (InetAddress seed : seeds)
                    MessagingService.instance().sendOneWay(message, seed);
            }

            Thread.sleep(1000);
            if (!inShadowRound)
                break;

            slept += 1000;
            if (slept > StorageService.RING_DELAY)
                throw new RuntimeException("Unable to gossip with any seeds");
        }
    }
    catch (InterruptedException wtf)
    {
        throw new RuntimeException(wtf);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:44,代码来源:Gossiper.java

示例5: checkHealth

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的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(NAME);
    }
    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);

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

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

        // no system files.  this is a new node.
        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:scylladb,项目名称:scylla-tools-java,代码行数:41,代码来源:SystemKeyspace.java

示例6: getClusterName

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
/** Returns the name of the cluster */
public String getClusterName()
{
    return DatabaseDescriptor.getClusterName();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:6,代码来源:StorageService.java

示例7: run

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public void run()
{
    try
    {
        //wait on messaging service to start listening
        MessagingService.instance().waitUntilListening();

        taskLock.lock();

        /* Update the local heartbeat counter. */
        endpointStateMap.get(FBUtilities.getBroadcastAddress()).getHeartBeatState().updateHeartBeat();
        if (logger.isTraceEnabled())
            logger.trace("My heartbeat is now " + endpointStateMap.get(FBUtilities.getBroadcastAddress()).getHeartBeatState().getHeartBeatVersion());
        final List<GossipDigest> gDigests = new ArrayList<GossipDigest>();
        Gossiper.instance.makeRandomGossipDigest(gDigests);

        if (gDigests.size() > 0)
        {
            GossipDigestSyn digestSynMessage = new GossipDigestSyn(DatabaseDescriptor.getClusterName(),
                                                                   DatabaseDescriptor.getPartitionerName(),
                                                                   gDigests);
            MessageOut<GossipDigestSyn> message = new MessageOut<GossipDigestSyn>(MessagingService.Verb.GOSSIP_DIGEST_SYN,
                                                                                  digestSynMessage,
                                                                                  GossipDigestSyn.serializer);
            /* Gossip to some random live member */
            boolean gossipedToSeed = doGossipToLiveMember(message);

            /* Gossip to some unreachable member with some probability to check if he is back up */
            doGossipToUnreachableMember(message);

            /* Gossip to a seed if we did not do so above, or we have seen less nodes
               than there are seeds.  This prevents partitions where each group of nodes
               is only gossiping to a subset of the seeds.

               The most straightforward check would be to check that all the seeds have been
               verified either as live or unreachable.  To avoid that computation each round,
               we reason that:

               either all the live nodes are seeds, in which case non-seeds that come online
               will introduce themselves to a member of the ring by definition,

               or there is at least one non-seed node in the list, in which case eventually
               someone will gossip to it, and then do a gossip to a random seed from the
               gossipedToSeed check.

               See CASSANDRA-150 for more exposition. */
            if (!gossipedToSeed || liveEndpoints.size() < seeds.size())
                doGossipToSeed(message);

            doStatusCheck();
        }
    }
    catch (Exception e)
    {
        JVMStabilityInspector.inspectThrowable(e);
        logger.error("Gossip error", e);
    }
    finally
    {
        taskLock.unlock();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:63,代码来源:Gossiper.java

示例8: describe_cluster_name

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public String describe_cluster_name() throws TException
{
    return DatabaseDescriptor.getClusterName();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:5,代码来源:CassandraServer.java

示例9: run

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public void run()
{
    try
    {
        //wait on messaging service to start listening
        MessagingService.instance().waitUntilListening();

        /* Update the local heartbeat counter. */
        endpointStateMap.get(FBUtilities.getBroadcastAddress()).getHeartBeatState().updateHeartBeat();
        if (logger.isTraceEnabled())
            logger.trace("My heartbeat is now " + endpointStateMap.get(FBUtilities.getBroadcastAddress()).getHeartBeatState().getHeartBeatVersion());
        final List<GossipDigest> gDigests = new ArrayList<GossipDigest>();
        Gossiper.instance.makeRandomGossipDigest(gDigests);

        if (gDigests.size() > 0)
        {
            GossipDigestSyn digestSynMessage = new GossipDigestSyn(DatabaseDescriptor.getClusterName(),
                                                                   DatabaseDescriptor.getPartitionerName(),
                                                                   gDigests);
            MessageOut<GossipDigestSyn> message = new MessageOut<GossipDigestSyn>(MessagingService.Verb.GOSSIP_DIGEST_SYN,
                                                                                  digestSynMessage,
                                                                                  GossipDigestSyn.serializer);
            /* Gossip to some random live member */
            boolean gossipedToSeed = doGossipToLiveMember(message);

            /* Gossip to some unreachable member with some probability to check if he is back up */
            doGossipToUnreachableMember(message);

            /* Gossip to a seed if we did not do so above, or we have seen less nodes
               than there are seeds.  This prevents partitions where each group of nodes
               is only gossiping to a subset of the seeds.

               The most straightforward check would be to check that all the seeds have been
               verified either as live or unreachable.  To avoid that computation each round,
               we reason that:

               either all the live nodes are seeds, in which case non-seeds that come online
               will introduce themselves to a member of the ring by definition,

               or there is at least one non-seed node in the list, in which case eventually
               someone will gossip to it, and then do a gossip to a random seed from the
               gossipedToSeed check.

               See CASSANDRA-150 for more exposition. */
            if (!gossipedToSeed || liveEndpoints.size() < seeds.size())
                doGossipToSeed(message);

            if (logger.isTraceEnabled())
                logger.trace("Performing status check ...");
            doStatusCheck();
        }
    }
    catch (Exception e)
    {
        logger.error("Gossip error", e);
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:58,代码来源:Gossiper.java

示例10: run

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public void run()
{
    try
    {
        //wait on messaging service to start listening
        MessagingService.instance().waitUntilListening();

        taskLock.lock();

        /* Update the local heartbeat counter. */
        endpointStateMap.get(FBUtilities.getBroadcastAddress()).getHeartBeatState().updateHeartBeat();
        if (logger.isTraceEnabled())
            logger.trace("My heartbeat is now {}", endpointStateMap.get(FBUtilities.getBroadcastAddress()).getHeartBeatState().getHeartBeatVersion());
        final List<GossipDigest> gDigests = new ArrayList<GossipDigest>();
        Gossiper.instance.makeRandomGossipDigest(gDigests);

        if (gDigests.size() > 0)
        {
            GossipDigestSyn digestSynMessage = new GossipDigestSyn(DatabaseDescriptor.getClusterName(),
                                                                   DatabaseDescriptor.getPartitionerName(),
                                                                   gDigests);
            MessageOut<GossipDigestSyn> message = new MessageOut<GossipDigestSyn>(MessagingService.Verb.GOSSIP_DIGEST_SYN,
                                                                                  digestSynMessage,
                                                                                  GossipDigestSyn.serializer);
            /* Gossip to some random live member */
            boolean gossipedToSeed = doGossipToLiveMember(message);

            /* Gossip to some unreachable member with some probability to check if he is back up */
            maybeGossipToUnreachableMember(message);

            /* Gossip to a seed if we did not do so above, or we have seen less nodes
               than there are seeds.  This prevents partitions where each group of nodes
               is only gossiping to a subset of the seeds.

               The most straightforward check would be to check that all the seeds have been
               verified either as live or unreachable.  To avoid that computation each round,
               we reason that:

               either all the live nodes are seeds, in which case non-seeds that come online
               will introduce themselves to a member of the ring by definition,

               or there is at least one non-seed node in the list, in which case eventually
               someone will gossip to it, and then do a gossip to a random seed from the
               gossipedToSeed check.

               See CASSANDRA-150 for more exposition. */
            if (!gossipedToSeed || liveEndpoints.size() < seeds.size())
                maybeGossipToSeed(message);

            doStatusCheck();
        }
    }
    catch (Exception e)
    {
        JVMStabilityInspector.inspectThrowable(e);
        logger.error("Gossip error", e);
    }
    finally
    {
        taskLock.unlock();
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:63,代码来源:Gossiper.java

示例11: executeImpl

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
protected ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params)
{
    DatabaseDescriptor.getClusterName();
    return null;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:6,代码来源:CallOrgApache.java


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