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


Java DatabaseDescriptor.setEndpointSnitch方法代码示例

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


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

示例1: testAllocateTokensNetworkStrategy

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
public void testAllocateTokensNetworkStrategy(int rackCount, int replicas) throws UnknownHostException
{
    IEndpointSnitch oldSnitch = DatabaseDescriptor.getEndpointSnitch();
    try
    {
        DatabaseDescriptor.setEndpointSnitch(new RackInferringSnitch());
        int vn = 16;
        String ks = "BootStrapperTestNTSKeyspace" + rackCount + replicas;
        String dc = "1";
        SchemaLoader.createKeyspace(ks, KeyspaceParams.nts(dc, replicas, "15", 15), SchemaLoader.standardCFMD(ks, "Standard1"));
        TokenMetadata tm = new TokenMetadata();
        tm.clearUnsafe();
        for (int i = 0; i < rackCount; ++i)
            generateFakeEndpoints(tm, 10, vn, dc, Integer.toString(i));
        InetAddress addr = InetAddress.getByName("127." + dc + ".0.99");
        allocateTokensForNode(vn, ks, tm, addr);
        // Note: Not matching replication factor in second datacentre, but this should not affect us.
    } finally {
        DatabaseDescriptor.setEndpointSnitch(oldSnitch);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:BootStrapperTest.java

示例2: setUp

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws ConfigurationException
{
    IEndpointSnitch snitch = new PropertyFileSnitch();
    DatabaseDescriptor.setEndpointSnitch(snitch);
    Keyspace.setInitialized();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:StorageServiceServerTest.java

示例3: 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

示例4: 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

示例5: testLargeCluster

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testLargeCluster() throws UnknownHostException, ConfigurationException
{
    int[] dcRacks = new int[]{2, 4, 8};
    int[] dcEndpoints = new int[]{128, 256, 512};
    int[] dcReplication = new int[]{2, 6, 6};

    IEndpointSnitch snitch = new RackInferringSnitch();
    DatabaseDescriptor.setEndpointSnitch(snitch);
    TokenMetadata metadata = new TokenMetadata();
    Map<String, String> configOptions = new HashMap<String, String>();
    Multimap<InetAddress, Token> tokens = HashMultimap.create();

    int totalRF = 0;
    for (int dc = 0; dc < dcRacks.length; ++dc)
    {
        totalRF += dcReplication[dc];
        configOptions.put(Integer.toString(dc), Integer.toString(dcReplication[dc]));
        for (int rack = 0; rack < dcRacks[dc]; ++rack)
        {
            for (int ep = 1; ep <= dcEndpoints[dc]/dcRacks[dc]; ++ep)
            {
                byte[] ipBytes = new byte[]{10, (byte)dc, (byte)rack, (byte)ep};
                InetAddress address = InetAddress.getByAddress(ipBytes);
                StringToken token = new StringToken(String.format("%02x%02x%02x", ep, rack, dc));
                logger.debug("adding node " + address + " at " + token);
                tokens.put(address, token);
            }
        }
    }
    metadata.updateNormalTokens(tokens);

    NetworkTopologyStrategy strategy = new NetworkTopologyStrategy(keyspaceName, metadata, snitch, configOptions);

    for (String testToken : new String[]{"123456", "200000", "000402", "ffffff", "400200"})
    {
        List<InetAddress> endpoints = strategy.calculateNaturalEndpoints(new StringToken(testToken), metadata);
        Set<InetAddress> epSet = new HashSet<InetAddress>(endpoints);

        Assert.assertEquals(totalRF, endpoints.size());
        Assert.assertEquals(totalRF, epSet.size());
        logger.debug(testToken + ": " + endpoints.toString());
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:45,代码来源:NetworkTopologyStrategyTest.java

示例6: setUp

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws ConfigurationException
{
    IEndpointSnitch snitch = new PropertyFileSnitch();
    DatabaseDescriptor.setEndpointSnitch(snitch);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:7,代码来源:StorageServiceServerTest.java

示例7: testLargeCluster

import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testLargeCluster() throws UnknownHostException, ConfigurationException
{
    int[] dcRacks = new int[]{2, 4, 8};
    int[] dcEndpoints = new int[]{128, 256, 512};
    int[] dcReplication = new int[]{2, 6, 6};

    IEndpointSnitch snitch = new RackInferringSnitch();
    DatabaseDescriptor.setEndpointSnitch(snitch);
    TokenMetadata metadata = new TokenMetadata();
    Map<String, String> configOptions = new HashMap<String, String>();
    Multimap<InetAddress, Token> tokens = HashMultimap.create();

    int totalRF = 0;
    for (int dc = 0; dc < dcRacks.length; ++dc)
    {
        totalRF += dcReplication[dc];
        configOptions.put(Integer.toString(dc), Integer.toString(dcReplication[dc]));
        for (int rack = 0; rack < dcRacks[dc]; ++rack)
        {
            for (int ep = 1; ep <= dcEndpoints[dc]/dcRacks[dc]; ++ep)
            {
                byte[] ipBytes = new byte[]{10, (byte)dc, (byte)rack, (byte)ep};
                InetAddress address = InetAddress.getByAddress(ipBytes);
                StringToken token = new StringToken(String.format("%02x%02x%02x", ep, rack, dc));
                logger.debug("adding node {} at {}", address, token);
                tokens.put(address, token);
            }
        }
    }
    metadata.updateNormalTokens(tokens);

    NetworkTopologyStrategy strategy = new NetworkTopologyStrategy(keyspaceName, metadata, snitch, configOptions);

    for (String testToken : new String[]{"123456", "200000", "000402", "ffffff", "400200"})
    {
        List<InetAddress> endpoints = strategy.calculateNaturalEndpoints(new StringToken(testToken), metadata);
        Set<InetAddress> epSet = new HashSet<InetAddress>(endpoints);

        Assert.assertEquals(totalRF, endpoints.size());
        Assert.assertEquals(totalRF, epSet.size());
        logger.debug("{}: {}", testToken, endpoints);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:45,代码来源:NetworkTopologyStrategyTest.java


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