Search in sources :

Example 51 with IPartitioner

use of org.apache.cassandra.dht.IPartitioner in project eiger by wlloyd.

the class RemoveTest method setup.

@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);
    MessagingService.instance().listen(FBUtilities.getBroadcastAddress());
    Gossiper.instance.start(1);
    for (int i = 0; i < 6; i++) {
        Gossiper.instance.initializeNodeUnsafe(hosts.get(i), 1);
    }
    removalhost = hosts.get(5);
    hosts.remove(removalhost);
    removaltoken = endpointTokens.get(5);
    endpointTokens.remove(removaltoken);
}
Also used : RandomPartitioner(org.apache.cassandra.dht.RandomPartitioner) IPartitioner(org.apache.cassandra.dht.IPartitioner) Before(org.junit.Before)

Example 52 with IPartitioner

use of org.apache.cassandra.dht.IPartitioner in project eiger by wlloyd.

the class SerializationsTest method testTreeResponseWrite.

private void testTreeResponseWrite() throws IOException {
    AntiEntropyService.Validator v0 = new AntiEntropyService.Validator(Statics.req);
    IPartitioner part = new RandomPartitioner();
    MerkleTree mt = new MerkleTree(part, FULL_RANGE, 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");
    AntiEntropyService.TreeResponseVerbHandler.SERIALIZER.serialize(v0, out, getVersion());
    AntiEntropyService.TreeResponseVerbHandler.SERIALIZER.serialize(v1, out, getVersion());
    messageSerializer.serialize(AntiEntropyService.TreeResponseVerbHandler.makeVerb(FBUtilities.getBroadcastAddress(), v0), out, getVersion());
    messageSerializer.serialize(AntiEntropyService.TreeResponseVerbHandler.makeVerb(FBUtilities.getBroadcastAddress(), v1), out, getVersion());
    out.close();
}
Also used : RandomPartitioner(org.apache.cassandra.dht.RandomPartitioner) MerkleTree(org.apache.cassandra.utils.MerkleTree) DataOutputStream(java.io.DataOutputStream) ArrayList(java.util.ArrayList) Token(org.apache.cassandra.dht.Token) IPartitioner(org.apache.cassandra.dht.IPartitioner)

Example 53 with IPartitioner

use of org.apache.cassandra.dht.IPartitioner in project eiger by wlloyd.

the class SerializationsTest method testRangeSliceCommandWrite.

private void testRangeSliceCommandWrite() throws IOException {
    ByteBuffer startCol = ByteBufferUtil.bytes("Start");
    ByteBuffer stopCol = ByteBufferUtil.bytes("Stop");
    ByteBuffer emptyCol = ByteBufferUtil.bytes("");
    SlicePredicate namesPred = new SlicePredicate();
    namesPred.column_names = Statics.NamedCols;
    SliceRange emptySliceRange = new SliceRange(emptyCol, emptyCol, false, 100);
    SliceRange nonEmptySliceRange = new SliceRange(startCol, stopCol, true, 100);
    SlicePredicate emptyRangePred = new SlicePredicate();
    emptyRangePred.slice_range = emptySliceRange;
    SlicePredicate nonEmptyRangePred = new SlicePredicate();
    nonEmptyRangePred.slice_range = nonEmptySliceRange;
    IPartitioner part = StorageService.getPartitioner();
    AbstractBounds<RowPosition> bounds = new Range<Token>(part.getRandomToken(), part.getRandomToken()).toRowBounds();
    Message namesCmd = new RangeSliceCommand(Statics.KS, "Standard1", null, namesPred, bounds, 100).getMessage(MessagingService.version_);
    Message emptyRangeCmd = new RangeSliceCommand(Statics.KS, "Standard1", null, emptyRangePred, bounds, 100).getMessage(MessagingService.version_);
    Message regRangeCmd = new RangeSliceCommand(Statics.KS, "Standard1", null, nonEmptyRangePred, bounds, 100).getMessage(MessagingService.version_);
    Message namesCmdSup = new RangeSliceCommand(Statics.KS, "Super1", Statics.SC, namesPred, bounds, 100).getMessage(MessagingService.version_);
    Message emptyRangeCmdSup = new RangeSliceCommand(Statics.KS, "Super1", Statics.SC, emptyRangePred, bounds, 100).getMessage(MessagingService.version_);
    Message regRangeCmdSup = new RangeSliceCommand(Statics.KS, "Super1", Statics.SC, nonEmptyRangePred, bounds, 100).getMessage(MessagingService.version_);
    DataOutputStream dout = getOutput("db.RangeSliceCommand.bin");
    messageSerializer.serialize(namesCmd, dout, getVersion());
    messageSerializer.serialize(emptyRangeCmd, dout, getVersion());
    messageSerializer.serialize(regRangeCmd, dout, getVersion());
    messageSerializer.serialize(namesCmdSup, dout, getVersion());
    messageSerializer.serialize(emptyRangeCmdSup, dout, getVersion());
    messageSerializer.serialize(regRangeCmdSup, dout, getVersion());
    dout.close();
}
Also used : Message(org.apache.cassandra.net.Message) SliceRange(org.apache.cassandra.thrift.SliceRange) DataOutputStream(java.io.DataOutputStream) SlicePredicate(org.apache.cassandra.thrift.SlicePredicate) Token(org.apache.cassandra.dht.Token) ByteBuffer(java.nio.ByteBuffer) IPartitioner(org.apache.cassandra.dht.IPartitioner)

Aggregations

IPartitioner (org.apache.cassandra.dht.IPartitioner)53 Token (org.apache.cassandra.dht.Token)27 Test (org.junit.Test)27 InetAddress (java.net.InetAddress)15 Range (org.apache.cassandra.dht.Range)14 TokenMetadata (org.apache.cassandra.locator.TokenMetadata)10 IdentityQueryFilter (org.apache.cassandra.db.columniterator.IdentityQueryFilter)9 BigIntegerToken (org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken)9 VersionedValue (org.apache.cassandra.gms.VersionedValue)9 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)6 RandomPartitioner (org.apache.cassandra.dht.RandomPartitioner)6 IOError (java.io.IOError)4 ByteBuffer (java.nio.ByteBuffer)4 IFilter (org.apache.cassandra.db.filter.IFilter)3 QueryPath (org.apache.cassandra.db.filter.QueryPath)3 AbstractReplicationStrategy (org.apache.cassandra.locator.AbstractReplicationStrategy)3 IndexExpression (org.apache.cassandra.thrift.IndexExpression)3 HashMultimap (com.google.common.collect.HashMultimap)2 Multimap (com.google.common.collect.Multimap)2