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


Java RandomPartitioner类代码示例

本文整理汇总了Java中org.apache.cassandra.dht.RandomPartitioner的典型用法代码示例。如果您正苦于以下问题:Java RandomPartitioner类的具体用法?Java RandomPartitioner怎么用?Java RandomPartitioner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testAddEmptyKey

import org.apache.cassandra.dht.RandomPartitioner; //导入依赖的package包/类
@Test
public void testAddEmptyKey() throws Exception
{
    IPartitioner p = new RandomPartitioner();
    try (IndexSummaryBuilder builder = new IndexSummaryBuilder(1, 1, BASE_SAMPLING_LEVEL))
    {
        builder.maybeAddEntry(p.decorateKey(ByteBufferUtil.EMPTY_BYTE_BUFFER), 0);
        IndexSummary summary = builder.build(p);
        assertEquals(1, summary.size());
        assertEquals(0, summary.getPosition(0));
        assertArrayEquals(new byte[0], summary.getKey(0));

        DataOutputBuffer dos = new DataOutputBuffer();
        IndexSummary.serializer.serialize(summary, dos, false);
        DataInputStream dis = new DataInputStream(new ByteArrayInputStream(dos.toByteArray()));
        IndexSummary loaded = IndexSummary.serializer.deserialize(dis, p, false, 1, 1);

        assertEquals(1, loaded.size());
        assertEquals(summary.getPosition(0), loaded.getPosition(0));
        assertArrayEquals(summary.getKey(0), summary.getKey(0));
        summary.close();
        loaded.close();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:IndexSummaryTest.java

示例2: testValidationCompleteWrite

import org.apache.cassandra.dht.RandomPartitioner; //导入依赖的package包/类
private void testValidationCompleteWrite() throws IOException
{
    // empty validation
    Validator v0 = new Validator(DESC, FBUtilities.getBroadcastAddress(),  -1);
    ValidationComplete c0 = new ValidationComplete(DESC, v0.tree);

    // validation with a tree
    IPartitioner p = new RandomPartitioner();
    MerkleTree mt = new MerkleTree(p, FULL_RANGE, MerkleTree.RECOMMENDED_DEPTH, Integer.MAX_VALUE);
    for (int i = 0; i < 10; i++)
        mt.split(p.getRandomToken());
    Validator v1 = new Validator(DESC, FBUtilities.getBroadcastAddress(), mt, -1);
    ValidationComplete c1 = new ValidationComplete(DESC, v1.tree);

    // validation failed
    ValidationComplete c3 = new ValidationComplete(DESC);

    testRepairMessageWrite("service.ValidationComplete.bin", c0, c1, c3);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:20,代码来源:SerializationsTest.java

示例3: testAddEmptyKey

import org.apache.cassandra.dht.RandomPartitioner; //导入依赖的package包/类
@Test
public void testAddEmptyKey() throws Exception
{
    IPartitioner p = new RandomPartitioner();
    IndexSummaryBuilder builder = new IndexSummaryBuilder(1, 1);
    builder.maybeAddEntry(p.decorateKey(ByteBufferUtil.EMPTY_BYTE_BUFFER), 0);
    IndexSummary summary = builder.build(p);
    assertEquals(1, summary.size());
    assertEquals(0, summary.getPosition(0));
    assertArrayEquals(new byte[0], summary.getKey(0));

    ByteArrayOutputStream aos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(aos);
    IndexSummary.serializer.serialize(summary, dos);
    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(aos.toByteArray()));
    IndexSummary loaded = IndexSummary.serializer.deserialize(dis, p);

    assertEquals(1, loaded.size());
    assertEquals(summary.getPosition(0), loaded.getPosition(0));
    assertArrayEquals(summary.getKey(0), summary.getKey(0));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:22,代码来源:IndexSummaryTest.java

示例4: testValidationCompleteWrite

import org.apache.cassandra.dht.RandomPartitioner; //导入依赖的package包/类
private void testValidationCompleteWrite() throws IOException
{
    IPartitioner p = RandomPartitioner.instance;

    MerkleTrees mt = new MerkleTrees(p);

    // empty validation
    mt.addMerkleTree((int) Math.pow(2, 15), FULL_RANGE);
    Validator v0 = new Validator(DESC, FBUtilities.getBroadcastAddress(),  -1);
    ValidationComplete c0 = new ValidationComplete(DESC, mt);

    // validation with a tree
    mt = new MerkleTrees(p);
    mt.addMerkleTree(Integer.MAX_VALUE, FULL_RANGE);
    for (int i = 0; i < 10; i++)
        mt.split(p.getRandomToken());
    Validator v1 = new Validator(DESC, FBUtilities.getBroadcastAddress(), -1);
    ValidationComplete c1 = new ValidationComplete(DESC, mt);

    // validation failed
    ValidationComplete c3 = new ValidationComplete(DESC);

    testRepairMessageWrite("service.ValidationComplete.bin", c0, c1, c3);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:25,代码来源:SerializationsTest.java

示例5: testAddEmptyKey

import org.apache.cassandra.dht.RandomPartitioner; //导入依赖的package包/类
@Test
public void testAddEmptyKey() throws Exception
{
    IPartitioner p = new RandomPartitioner();
    IndexSummaryBuilder builder = new IndexSummaryBuilder(1, 1, BASE_SAMPLING_LEVEL);
    builder.maybeAddEntry(p.decorateKey(ByteBufferUtil.EMPTY_BYTE_BUFFER), 0);
    IndexSummary summary = builder.build(p);
    assertEquals(1, summary.size());
    assertEquals(0, summary.getPosition(0));
    assertArrayEquals(new byte[0], summary.getKey(0));

    DataOutputBuffer dos = new DataOutputBuffer();
    IndexSummary.serializer.serialize(summary, dos, false);
    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(dos.toByteArray()));
    IndexSummary loaded = IndexSummary.serializer.deserialize(dis, p, false, 1, 1);

    assertEquals(1, loaded.size());
    assertEquals(summary.getPosition(0), loaded.getPosition(0));
    assertArrayEquals(summary.getKey(0), summary.getKey(0));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:21,代码来源:IndexSummaryTest.java

示例6: testTreeResponseWrite

import org.apache.cassandra.dht.RandomPartitioner; //导入依赖的package包/类
private void testTreeResponseWrite() throws IOException
{
    // empty validation
    AntiEntropyService.Validator v0 = new AntiEntropyService.Validator(Statics.req);

    // validation with a tree
    IPartitioner p = new RandomPartitioner();
    MerkleTree mt = new MerkleTree(p, FULL_RANGE, MerkleTree.RECOMMENDED_DEPTH, Integer.MAX_VALUE);
    for (int i = 0; i < 10; i++)
        mt.split(p.getRandomToken());
    AntiEntropyService.Validator v1 = new AntiEntropyService.Validator(Statics.req, mt);

    DataOutputStream out = getOutput("service.TreeResponse.bin");
    AntiEntropyService.Validator.serializer.serialize(v0, out, getVersion());
    AntiEntropyService.Validator.serializer.serialize(v1, out, getVersion());
    v0.createMessage().serialize(out, getVersion());
    v1.createMessage().serialize(out, getVersion());
    out.close();

    // test serializedSize
    testSerializedSize(v0, AntiEntropyService.Validator.serializer);
    testSerializedSize(v1, AntiEntropyService.Validator.serializer);
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:24,代码来源:SerializationsTest.java

示例7: testAddEmptyKey

import org.apache.cassandra.dht.RandomPartitioner; //导入依赖的package包/类
@Test
public void testAddEmptyKey() throws Exception
{
    IPartitioner p = new RandomPartitioner();
    IndexSummaryBuilder builder = new IndexSummaryBuilder(1, 1, BASE_SAMPLING_LEVEL);
    builder.maybeAddEntry(p.decorateKey(ByteBufferUtil.EMPTY_BYTE_BUFFER), 0);
    IndexSummary summary = builder.build(p);
    assertEquals(1, summary.size());
    assertEquals(0, summary.getPosition(0));
    assertArrayEquals(new byte[0], summary.getKey(0));

    ByteArrayOutputStream aos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(aos);
    IndexSummary.serializer.serialize(summary, dos, false);
    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(aos.toByteArray()));
    IndexSummary loaded = IndexSummary.serializer.deserialize(dis, p, false, 1);

    assertEquals(1, loaded.size());
    assertEquals(summary.getPosition(0), loaded.getPosition(0));
    assertArrayEquals(summary.getKey(0), summary.getKey(0));
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:22,代码来源:IndexSummaryTest.java

示例8: testAddEmptyKey

import org.apache.cassandra.dht.RandomPartitioner; //导入依赖的package包/类
@Test
public void testAddEmptyKey() throws Exception
{
    IPartitioner p = new RandomPartitioner();
    IndexSummaryBuilder builder = new IndexSummaryBuilder(1);
    builder.maybeAddEntry(p.decorateKey(ByteBufferUtil.EMPTY_BYTE_BUFFER), 0);
    IndexSummary summary = builder.build(p);
    assertEquals(1, summary.size());
    assertEquals(0, summary.getPosition(0));
    assertArrayEquals(new byte[0], summary.getKey(0));

    ByteArrayDataOutput bout = ByteStreams.newDataOutput();
    IndexSummary.serializer.serialize(summary, bout);
    ByteArrayDataInput bin = ByteStreams.newDataInput(bout.toByteArray());
    IndexSummary loaded = IndexSummary.serializer.deserialize(bin, p);

    assertEquals(1, loaded.size());
    assertEquals(summary.getPosition(0), loaded.getPosition(0));
    assertArrayEquals(summary.getKey(0), summary.getKey(0));
}
 
开发者ID:wso2,项目名称:wso2-cassandra,代码行数:21,代码来源:IndexSummaryTest.java

示例9: getJobConf

import org.apache.cassandra.dht.RandomPartitioner; //导入依赖的package包/类
private static Job getJobConf(CommandLine cli)
        throws URISyntaxException, IOException {
    Configuration conf = new Configuration();
    Job job = Job.getInstance(conf);
    ClassLoader loader = SSTableMRExample.class.getClassLoader();
    URL url = loader.getResource("knewton-site.xml");
    conf.addResource(url);

    SSTableInputFormat.setPartitionerClass(RandomPartitioner.class.getName(), job);
    SSTableInputFormat.setComparatorClass(LongType.class.getName(), job);
    SSTableInputFormat.setColumnFamilyName("StudentEvents", job);
    SSTableInputFormat.setKeyspaceName("demoKeyspace", job);

    if (cli.hasOption('s')) {
        conf.set(PropertyConstants.START_DATE.txt, cli.getOptionValue('s'));
    }
    if (cli.hasOption('e')) {
        conf.set(PropertyConstants.END_DATE.txt, cli.getOptionValue('e'));
    }
    return job;
}
 
开发者ID:Knewton,项目名称:KassandraMRHelper,代码行数:22,代码来源:SSTableMRExample.java

示例10: getTaskAttemptContext

import org.apache.cassandra.dht.RandomPartitioner; //导入依赖的package包/类
private TaskAttemptContext getTaskAttemptContext(boolean setColumnComparator,
                                                 boolean setPartitioner,
                                                 boolean setSubComparator) throws Exception {

    if (setColumnComparator) {
        SSTableInputFormat.setComparatorClass(LongType.class.getName(), job);
    }
    if (setPartitioner) {
        SSTableInputFormat.setPartitionerClass(RandomPartitioner.class.getName(), job);
    }
    if (setSubComparator) {
        SSTableInputFormat.setSubComparatorClass(LongType.class.getName(), job);
    }

    return new TaskAttemptContextImpl(conf, attemptId);
}
 
开发者ID:Knewton,项目名称:KassandraMRHelper,代码行数:17,代码来源:SSTableRecordReaderTest.java

示例11: testTreeResponseWrite

import org.apache.cassandra.dht.RandomPartitioner; //导入依赖的package包/类
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());
    Message.serializer().serialize(AntiEntropyService.TreeResponseVerbHandler.makeVerb(FBUtilities.getLocalAddress(), v0), out, getVersion());
    Message.serializer().serialize(AntiEntropyService.TreeResponseVerbHandler.makeVerb(FBUtilities.getLocalAddress(), v1), out, getVersion());
    out.close();
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:21,代码来源:SerializationsTest.java

示例12: setup

import org.apache.cassandra.dht.RandomPartitioner; //导入依赖的package包/类
@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.getLocalAddress());
    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);
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:23,代码来源:RemoveTest.java

示例13: searchTokenForOldPendingRanges

import org.apache.cassandra.dht.RandomPartitioner; //导入依赖的package包/类
@Benchmark
public void searchTokenForOldPendingRanges(final Blackhole bh)
{
    int randomToken = ThreadLocalRandom.current().nextInt(maxToken * 10 + 5);
    Token searchToken = new RandomPartitioner.BigIntegerToken(Integer.toString(randomToken));
    Set<InetAddress> endpoints = new HashSet<>();
    for (Map.Entry<Range<Token>, Collection<InetAddress>> entry : oldPendingRanges.asMap().entrySet())
    {
        if (entry.getKey().contains(searchToken))
            endpoints.addAll(entry.getValue());
    }
    bh.consume(endpoints);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:14,代码来源:PendingRangesBench.java

示例14: setup

import org.apache.cassandra.dht.RandomPartitioner; //导入依赖的package包/类
@Before
public void setup() throws ConfigurationException, IOException
{
    String confFile = FBUtilities.resourceToFile(PropertyFileSnitch.SNITCH_PROPERTIES_FILENAME);
    effectiveFile = Paths.get(confFile);
    backupFile = Paths.get(confFile + ".bak");

    restoreOrigConfigFile();

    InetAddress[] hosts = {
        InetAddress.getByName("127.0.0.1"), // this exists in the config file
        InetAddress.getByName("127.0.0.2"), // this exists in the config file
        InetAddress.getByName("127.0.0.9"), // this does not exist in the config file
    };

    IPartitioner partitioner = new RandomPartitioner();
    valueFactory = new VersionedValue.VersionedValueFactory(partitioner);
    tokenMap = new HashMap<>();

    for (InetAddress host : hosts)
    {
        Set<Token> tokens = Collections.singleton(partitioner.getRandomToken());
        Gossiper.instance.initializeNodeUnsafe(host, UUID.randomUUID(), 1);
        Gossiper.instance.injectApplicationState(host, ApplicationState.TOKENS, valueFactory.tokens(tokens));

        setNodeShutdown(host);
        tokenMap.put(host, tokens);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:30,代码来源:PropertyFileSnitchTest.java

示例15: clear

import org.apache.cassandra.dht.RandomPartitioner; //导入依赖的package包/类
@Before
public void clear()
{
    TOKEN_SCALE = new BigInteger("8");
    partitioner = RandomPartitioner.instance;
    // TODO need to trickle TokenSerializer
    DatabaseDescriptor.setPartitionerUnsafe(partitioner);
    mt = new MerkleTree(partitioner, fullRange(), RECOMMENDED_DEPTH, Integer.MAX_VALUE);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:10,代码来源:MerkleTreeTest.java


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