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


Java DatabaseDescriptor.setDynamicBadnessThreshold方法代码示例

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


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

示例1: updateSnitch

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public void updateSnitch(String epSnitchClassName, Boolean dynamic, Integer dynamicUpdateInterval, Integer dynamicResetInterval, Double dynamicBadnessThreshold) throws ClassNotFoundException
{
    IEndpointSnitch oldSnitch = DatabaseDescriptor.getEndpointSnitch();

    // new snitch registers mbean during construction
    IEndpointSnitch newSnitch;
    try
    {
        newSnitch = FBUtilities.construct(epSnitchClassName, "snitch");
    }
    catch (ConfigurationException e)
    {
        throw new ClassNotFoundException(e.getMessage());
    }
    if (dynamic)
    {
        DatabaseDescriptor.setDynamicUpdateInterval(dynamicUpdateInterval);
        DatabaseDescriptor.setDynamicResetInterval(dynamicResetInterval);
        DatabaseDescriptor.setDynamicBadnessThreshold(dynamicBadnessThreshold);
        newSnitch = new DynamicEndpointSnitch(newSnitch);
    }

    // point snitch references to the new instance
    DatabaseDescriptor.setEndpointSnitch(newSnitch);
    for (String ks : Schema.instance.getKeyspaces())
    {
        Keyspace.open(ks).getReplicationStrategy().snitch = newSnitch;
    }

    if (oldSnitch instanceof DynamicEndpointSnitch)
        ((DynamicEndpointSnitch)oldSnitch).unregisterMBean();
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:33,代码来源:StorageService.java

示例2: updateSnitch

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public void updateSnitch(String epSnitchClassName, Boolean dynamic, Integer dynamicUpdateInterval, Integer dynamicResetInterval, Double dynamicBadnessThreshold) throws ClassNotFoundException
{
    IEndpointSnitch oldSnitch = DatabaseDescriptor.getEndpointSnitch();

    // new snitch registers mbean during construction
    IEndpointSnitch newSnitch;
    try
    {
        newSnitch = FBUtilities.construct(epSnitchClassName, "snitch");
    }
    catch (ConfigurationException e)
    {
        throw new ClassNotFoundException(e.getMessage());
    }
    if (dynamic)
    {
        DatabaseDescriptor.setDynamicUpdateInterval(dynamicUpdateInterval);
        DatabaseDescriptor.setDynamicResetInterval(dynamicResetInterval);
        DatabaseDescriptor.setDynamicBadnessThreshold(dynamicBadnessThreshold);
        newSnitch = new DynamicEndpointSnitch(newSnitch);
    }

    // point snitch references to the new instance
    DatabaseDescriptor.setEndpointSnitch(newSnitch);
    for (String ks : Schema.instance.getKeyspaces())
    {
        Keyspace.open(ks).getReplicationStrategy().snitch = newSnitch;
    }

    if (oldSnitch instanceof DynamicEndpointSnitch)
        ((DynamicEndpointSnitch)oldSnitch).unregisterMBean();

    updateTopology();
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:35,代码来源:StorageService.java

示例3: testConcurrency

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testConcurrency() throws InterruptedException, IOException, ConfigurationException
{
    // The goal of this test is to check for CASSANDRA-8448/CASSANDRA-9519
    double badness = DatabaseDescriptor.getDynamicBadnessThreshold();
    DatabaseDescriptor.setDynamicBadnessThreshold(0.0);

    try
    {
        final int ITERATIONS = 10000;

        // do this because SS needs to be initialized before DES can work properly.
        StorageService.instance.unsafeInitialize();
        SimpleSnitch ss = new SimpleSnitch();
        DynamicEndpointSnitch dsnitch = new DynamicEndpointSnitch(ss, String.valueOf(ss.hashCode()));
        InetAddress self = FBUtilities.getBroadcastAddress();

        List<InetAddress> hosts = new ArrayList<>();
        // We want a big list of hosts so  sorting takes time, making it much more likely to reproduce the
        // problem we're looking for.
        for (int i = 0; i < 100; i++)
            for (int j = 0; j < 256; j++)
                hosts.add(InetAddress.getByAddress(new byte[]{127, 0, (byte)i, (byte)j}));

        ScoreUpdater updater = new ScoreUpdater(dsnitch, hosts);
        updater.start();

        List<InetAddress> result = null;
        for (int i = 0; i < ITERATIONS; i++)
            result = dsnitch.getSortedListByProximity(self, hosts);

        updater.stopped = true;
        updater.join();
    }
    finally
    {
        DatabaseDescriptor.setDynamicBadnessThreshold(badness);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:40,代码来源:DynamicEndpointSnitchLongTest.java


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