Examples of RandomPartitioner


Examples of org.apache.cassandra.dht.RandomPartitioner

    public void testStateJumpToLeft() throws UnknownHostException
    {
        StorageService ss = StorageService.instance;
        TokenMetadata tmd = ss.getTokenMetadata();
        tmd.clearUnsafe();
        IPartitioner partitioner = new RandomPartitioner();
        AbstractReplicationStrategy testStrategy = new RackUnawareStrategy(tmd, null);

        IPartitioner oldPartitioner = ss.setPartitionerUnsafe(partitioner);
        Map<String, AbstractReplicationStrategy> oldStrategy = ss.setReplicationStrategyUnsafe(createReplacements(testStrategy));

        ArrayList<Token> endPointTokens = new ArrayList<Token>();
        ArrayList<Token> keyTokens = new ArrayList<Token>();
        List<InetAddress> hosts = new ArrayList<InetAddress>();

        // create a ring or 5 nodes
        createInitialRing(ss, partitioner, endPointTokens, keyTokens, hosts, 5);

        // node hosts.get(2) goes jumps to left
        ss.onChange(hosts.get(2), StorageService.MOVE_STATE, new ApplicationState(StorageService.STATE_LEFT + StorageService.Delimiter + StorageService.LEFT_NORMALLY + StorageService.Delimiter + partitioner.getTokenFactory().toString(endPointTokens.get(2))));

        assertFalse(tmd.isMember(hosts.get(2)));

        // node hosts.get(4) goes to bootstrap
        ss.onChange(hosts.get(3), StorageService.MOVE_STATE, new ApplicationState(StorageService.STATE_BOOTSTRAPPING + StorageService.Delimiter + partitioner.getTokenFactory().toString(keyTokens.get(1))));

        assertFalse(tmd.isMember(hosts.get(3)));
        assertTrue(tmd.getBootstrapTokens().size() == 1);
        assertTrue(tmd.getBootstrapTokens().get(keyTokens.get(1)).equals(hosts.get(3)));

        // and then directly to 'left'
        ss.onChange(hosts.get(2), StorageService.MOVE_STATE, new ApplicationState(StorageService.STATE_LEFT + StorageService.Delimiter + StorageService.LEFT_NORMALLY + StorageService.Delimiter + partitioner.getTokenFactory().toString(keyTokens.get(1))));

        assertTrue(tmd.getBootstrapTokens().size() == 0);
        assertFalse(tmd.isMember(hosts.get(2)));
        assertFalse(tmd.isLeaving(hosts.get(2)));
View Full Code Here

Examples of org.apache.cassandra.dht.RandomPartitioner

    @Before
    public void setup() throws IOException, ConfigurationException
    {
        tmd.clearUnsafe();
        IPartitioner partitioner = new RandomPartitioner();

        oldPartitioner = ss.setPartitionerUnsafe(partitioner);

        // create a ring of 5 nodes
        Util.createInitialRing(ss, partitioner, endpointTokens, keyTokens, hosts, 6);
View Full Code Here

Examples of org.apache.cassandra.dht.RandomPartitioner

    }
   
    private void testTreeResponseWrite() throws IOException
    {
        AntiEntropyService.Validator v0 = new AntiEntropyService.Validator(Statics.req);
        IPartitioner part = new RandomPartitioner();
        MerkleTree mt = new MerkleTree(part, MerkleTree.RECOMMENDED_DEPTH, Integer.MAX_VALUE);
        List<Token> tokens = new ArrayList<Token>();
        for (int i = 0; i < 10; i++)
        {
            Token t = part.getRandomToken();
            tokens.add(t);
            mt.split(t);
        }
        AntiEntropyService.Validator v1 = new AntiEntropyService.Validator(Statics.req, mt);
        DataOutputStream out = getOutput("service.TreeResponse.bin");
View Full Code Here

Examples of org.apache.cassandra.dht.RandomPartitioner

    }

    protected List<InetAddress> endpointsForKey(InetAddress seed, ByteBuffer key, String keyspace)
        throws IOException
    {
        RingCache ring = new RingCache(keyspace, new RandomPartitioner(), seed.getHostAddress(), 9160);
        List<InetAddress> privateendpoints = ring.getEndpoint(key);
        List<InetAddress> endpoints = new ArrayList<InetAddress>();
        for (InetAddress endpoint : privateendpoints)
        {
            endpoints.add(controller.getPublicHost(endpoint));
View Full Code Here

Examples of org.apache.cassandra.dht.RandomPartitioner

{
    @Test
    public void testBigIntegerEndpoints() throws UnknownHostException
    {
        TokenMetadata tmd = new TokenMetadata();
        IPartitioner partitioner = new RandomPartitioner();
        AbstractReplicationStrategy strategy = new RackUnawareStrategy(tmd, partitioner, 3);

        List<Token> endPointTokens = new ArrayList<Token>();
        List<Token> keyTokens = new ArrayList<Token>();
        for (int i = 0; i < 5; i++) {
View Full Code Here

Examples of org.apache.cassandra.dht.RandomPartitioner

   
    @Test
    public void testGetEndpointsDuringBootstrap() throws UnknownHostException
    {
        TokenMetadata tmd = new TokenMetadata();
        IPartitioner partitioner = new RandomPartitioner();
        AbstractReplicationStrategy strategy = new RackUnawareStrategy(tmd, partitioner, 3);

        Token[] endPointTokens = new Token[5];
        Token[] keyTokens = new Token[5];
       
View Full Code Here

Examples of org.apache.cassandra.dht.RandomPartitioner

        StorageService ss = StorageService.instance;
        final int RING_SIZE = 3;

        TokenMetadata tmd = ss.getTokenMetadata();
        tmd.clearUnsafe();
        IPartitioner partitioner = new RandomPartitioner();

        ss.setPartitionerUnsafe(partitioner);

        ArrayList<Token> endpointTokens = new ArrayList<Token>();
        ArrayList<Token> keyTokens = new ArrayList<Token>();
View Full Code Here

Examples of org.apache.cassandra.dht.RandomPartitioner

    }

    protected List<InetAddress> endpointsForKey(InetAddress seed, ByteBuffer key, String keyspace)
        throws IOException
    {
        RingCache ring = new RingCache(keyspace, new RandomPartitioner(), seed.getHostAddress(), 9160);
        List<InetAddress> privateendpoints = ring.getEndpoint(key);
        List<InetAddress> endpoints = new ArrayList<InetAddress>();
        for (InetAddress endpoint : privateendpoints)
        {
            endpoints.add(controller.getPublicHost(endpoint));
View Full Code Here

Examples of org.apache.cassandra.dht.RandomPartitioner

    @Before
    public void setup() throws IOException, ConfigurationException
    {
        tmd.clearUnsafe();
        IPartitioner partitioner = new RandomPartitioner();

        oldPartitioner = ss.setPartitionerUnsafe(partitioner);

        // create a ring of 5 nodes
        Util.createInitialRing(ss, partitioner, endpointTokens, keyTokens, hosts, 6);
View Full Code Here

Examples of org.apache.cassandra.dht.RandomPartitioner

    @Before
    public void clear()
    {
        TOKEN_SCALE = new BigInteger("8");
        partitioner = new RandomPartitioner();
        mt = new MerkleTree(partitioner, fullRange(), RECOMMENDED_DEPTH, Integer.MAX_VALUE);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.