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


Java BytesToken类代码示例

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


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

示例1: antiCompactionSizeTest

import org.apache.cassandra.dht.BytesToken; //导入依赖的package包/类
@Test
public void antiCompactionSizeTest() throws ExecutionException, InterruptedException, IOException
{
    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
    cfs.disableAutoCompaction();
    SSTableReader s = writeFile(cfs, 1000);
    cfs.addSSTable(s);
    long origSize = s.bytesOnDisk();
    Range<Token> range = new Range<Token>(new BytesToken(ByteBufferUtil.bytes(0)), new BytesToken(ByteBufferUtil.bytes(500)));
    Collection<SSTableReader> sstables = cfs.getSSTables();
    CompactionManager.instance.performAnticompaction(cfs, Arrays.asList(range), Refs.tryRef(sstables), 12345);
    long sum = 0;
    for (SSTableReader x : cfs.getSSTables())
        sum += x.bytesOnDisk();
    assertEquals(sum, cfs.metric.liveDiskSpaceUsed.count());
    assertEquals(origSize, cfs.metric.liveDiskSpaceUsed.count(), 100000);

}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:20,代码来源:AntiCompactionTest.java

示例2: shouldSkipAntiCompactionForNonIntersectingRange

import org.apache.cassandra.dht.BytesToken; //导入依赖的package包/类
@Test
public void shouldSkipAntiCompactionForNonIntersectingRange() throws InterruptedException, ExecutionException, IOException
{
    ColumnFamilyStore store = prepareColumnFamilyStore();
    Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
    assertEquals(store.getSSTables().size(), sstables.size());
    Range<Token> range = new Range<Token>(new BytesToken("-10".getBytes()), new BytesToken("-1".getBytes()));
    List<Range<Token>> ranges = Arrays.asList(range);

    Refs<SSTableReader> refs = Refs.tryRef(sstables);
    if (refs == null)
        throw new IllegalStateException();
    CompactionManager.instance.performAnticompaction(store, ranges, refs, 1);
    assertThat(store.getSSTables().size(), is(1));
    assertThat(Iterables.get(store.getSSTables(), 0).isRepaired(), is(false));
    assertThat(Iterables.get(store.getSSTables(), 0).selfRef().globalCount(), is(1));
    assertThat(store.getDataTracker().getCompacting().size(), is(0));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:19,代码来源:AntiCompactionTest.java

示例3: shouldMutateRepairedAt

import org.apache.cassandra.dht.BytesToken; //导入依赖的package包/类
@Test
public void shouldMutateRepairedAt() throws InterruptedException, ExecutionException, IOException
{
    ColumnFamilyStore store = prepareColumnFamilyStore();
    Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
    assertEquals(store.getSSTables().size(), sstables.size());
    Range<Token> range = new Range<Token>(new BytesToken("0".getBytes()), new BytesToken("9999".getBytes()));
    List<Range<Token>> ranges = Arrays.asList(range);

    CompactionManager.instance.performAnticompaction(store, ranges, Refs.tryRef(sstables), 1);

    assertThat(store.getSSTables().size(), is(1));
    assertThat(Iterables.get(store.getSSTables(), 0).isRepaired(), is(true));
    assertThat(Iterables.get(store.getSSTables(), 0).selfRef().globalCount(), is(1));
    assertThat(store.getDataTracker().getCompacting().size(), is(0));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:17,代码来源:AntiCompactionTest.java

示例4: testRowCacheCleanup

import org.apache.cassandra.dht.BytesToken; //导入依赖的package包/类
@Test
public void testRowCacheCleanup() throws Exception
{
    StorageService.instance.initServer(0);
    CacheService.instance.setRowCacheCapacityInMB(1);
    rowCacheLoad(100, Integer.MAX_VALUE, 1000);

    ColumnFamilyStore store = Keyspace.open(KEYSPACE).getColumnFamilyStore(COLUMN_FAMILY);
    assertEquals(CacheService.instance.rowCache.getKeySet().size(), 100);
    store.cleanupCache();
    assertEquals(CacheService.instance.rowCache.getKeySet().size(), 100);
    TokenMetadata tmd = StorageService.instance.getTokenMetadata();
    byte[] tk1, tk2;
    tk1 = "key1000".getBytes();
    tk2 = "key1050".getBytes();
    tmd.updateNormalToken(new BytesToken(tk1), InetAddress.getByName("127.0.0.1"));
    tmd.updateNormalToken(new BytesToken(tk2), InetAddress.getByName("127.0.0.2"));
    store.cleanupCache();
    assertEquals(CacheService.instance.rowCache.getKeySet().size(), 50);
    CacheService.instance.setRowCacheCapacityInMB(0);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:RowCacheTest.java

示例5: shouldSkipAntiCompactionForNonIntersectingRange

import org.apache.cassandra.dht.BytesToken; //导入依赖的package包/类
@Test
public void shouldSkipAntiCompactionForNonIntersectingRange() throws InterruptedException, ExecutionException, IOException
{
    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF);
    store.disableAutoCompaction();

    for (int table = 0; table < 10; table++)
    {
        generateSStable(store,Integer.toString(table));
    }
    Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
    assertEquals(store.getSSTables().size(), sstables.size());
    
    Range<Token> range = new Range<Token>(new BytesToken("-10".getBytes()), new BytesToken("-1".getBytes()));
    List<Range<Token>> ranges = Arrays.asList(range);

    SSTableReader.acquireReferences(sstables);
    CompactionManager.instance.performAnticompaction(store, ranges, sstables, 0);

    assertThat(store.getSSTables().size(), is(10));
    assertThat(Iterables.get(store.getSSTables(), 0).isRepaired(), is(false));
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:24,代码来源:AntiCompactionTest.java

示例6: testRowCacheCleanup

import org.apache.cassandra.dht.BytesToken; //导入依赖的package包/类
@Test
public void testRowCacheCleanup() throws Exception
{
    StorageService.instance.initServer(0);
    CacheService.instance.setRowCacheCapacityInMB(1);
    rowCacheLoad(100, Integer.MAX_VALUE, 1000);

    ColumnFamilyStore store = Keyspace.open(KEYSPACE_CACHED).getColumnFamilyStore(CF_CACHED);
    assertEquals(CacheService.instance.rowCache.getKeySet().size(), 100);
    store.cleanupCache();
    assertEquals(CacheService.instance.rowCache.getKeySet().size(), 100);
    TokenMetadata tmd = StorageService.instance.getTokenMetadata();
    byte[] tk1, tk2;
    tk1 = "key1000".getBytes();
    tk2 = "key1050".getBytes();
    tmd.updateNormalToken(new BytesToken(tk1), InetAddress.getByName("127.0.0.1"));
    tmd.updateNormalToken(new BytesToken(tk2), InetAddress.getByName("127.0.0.2"));
    store.cleanupCache();
    assertEquals(CacheService.instance.rowCache.getKeySet().size(), 50);
    CacheService.instance.setRowCacheCapacityInMB(0);
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:22,代码来源:RowCacheTest.java

示例7: testStreamRequestMessageWrite

import org.apache.cassandra.dht.BytesToken; //导入依赖的package包/类
private void testStreamRequestMessageWrite() throws IOException
{
    UUID sessionId = UUIDGen.getTimeUUID();
    Collection<Range<Token>> ranges = new ArrayList<Range<Token>>();
    for (int i = 0; i < 5; i++)
        ranges.add(new Range<Token>(new BytesToken(ByteBufferUtil.bytes(Integer.toString(10*i))), new BytesToken(ByteBufferUtil.bytes(Integer.toString(10*i+5)))));
    List<ColumnFamilyStore> stores = Collections.singletonList(Table.open("Keyspace1").getColumnFamilyStore("Standard1"));
    StreamRequest msg0 = new StreamRequest(FBUtilities.getBroadcastAddress(), ranges, "Keyspace1", stores, sessionId, OperationType.RESTORE_REPLICA_COUNT);
    StreamRequest msg1 = new StreamRequest(FBUtilities.getBroadcastAddress(), makePendingFile(true, 100, OperationType.BOOTSTRAP), sessionId);
    StreamRequest msg2 = new StreamRequest(FBUtilities.getBroadcastAddress(), makePendingFile(false, 100, OperationType.BOOTSTRAP), sessionId);

    DataOutputStream out = getOutput("streaming.StreamRequestMessage.bin");
    StreamRequest.serializer.serialize(msg0, out, getVersion());
    StreamRequest.serializer.serialize(msg1, out, getVersion());
    StreamRequest.serializer.serialize(msg2, out, getVersion());
    msg0.createMessage().serialize(out, getVersion());
    msg1.createMessage().serialize(out, getVersion());
    msg2.createMessage().serialize(out, getVersion());
    out.close();

    // test serializedSize
    testSerializedSize(msg0, StreamRequest.serializer);
    testSerializedSize(msg1, StreamRequest.serializer);
    testSerializedSize(msg2, StreamRequest.serializer);
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:26,代码来源:SerializationsTest.java

示例8: testStreamRequestMessageWrite

import org.apache.cassandra.dht.BytesToken; //导入依赖的package包/类
private void testStreamRequestMessageWrite() throws IOException
{
    Collection<Range> ranges = new ArrayList<Range>();
    for (int i = 0; i < 5; i++)
        ranges.add(new Range(new BytesToken(ByteBufferUtil.bytes(Integer.toString(10*i))), new BytesToken(ByteBufferUtil.bytes(Integer.toString(10*i+5)))));
    StreamRequestMessage msg0 = new StreamRequestMessage(FBUtilities.getLocalAddress(), ranges, "Keyspace1", 123L, OperationType.RESTORE_REPLICA_COUNT);
    StreamRequestMessage msg1 = new StreamRequestMessage(FBUtilities.getLocalAddress(), makePendingFile(true, 100, OperationType.BOOTSTRAP), 124L);
    StreamRequestMessage msg2 = new StreamRequestMessage(FBUtilities.getLocalAddress(), makePendingFile(false, 100, OperationType.BOOTSTRAP), 124L);

    DataOutputStream out = getOutput("streaming.StreamRequestMessage.bin");
    StreamRequestMessage.serializer().serialize(msg0, out, getVersion());
    StreamRequestMessage.serializer().serialize(msg1, out, getVersion());
    StreamRequestMessage.serializer().serialize(msg2, out, getVersion());
    Message.serializer().serialize(msg0.getMessage(getVersion()), out, getVersion());
    Message.serializer().serialize(msg1.getMessage(getVersion()), out, getVersion());
    Message.serializer().serialize(msg2.getMessage(getVersion()), out, getVersion());
    out.close();
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:19,代码来源:SerializationsTest.java

示例9: testCleanupWithNewToken

import org.apache.cassandra.dht.BytesToken; //导入依赖的package包/类
@Test
public void testCleanupWithNewToken() throws ExecutionException, InterruptedException, UnknownHostException
{
    StorageService.instance.getTokenMetadata().clearUnsafe();

    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF2);

    List<Row> rows;

    // insert data and verify we get it back w/ range query
    fillCF(cfs, LOOPS);

    rows = Util.getRangeSlice(cfs);

    assertEquals(LOOPS, rows.size());
    TokenMetadata tmd = StorageService.instance.getTokenMetadata();

    byte[] tk1 = new byte[1], tk2 = new byte[1];
    tk1[0] = 2;
    tk2[0] = 1;
    tmd.updateNormalToken(new BytesToken(tk1), InetAddress.getByName("127.0.0.1"));
    tmd.updateNormalToken(new BytesToken(tk2), InetAddress.getByName("127.0.0.2"));
    CompactionManager.instance.performCleanup(cfs);

    rows = Util.getRangeSlice(cfs);
    assertEquals(0, rows.size());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:29,代码来源:CleanupTest.java

示例10: rangeFor

import org.apache.cassandra.dht.BytesToken; //导入依赖的package包/类
private static Range<Token> rangeFor(int start, int end)
{
    return new Range<Token>(new BytesToken(String.format("%03d", start).getBytes()),
                            new BytesToken(String.format("%03d", end).getBytes()));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:6,代码来源:CompactionsTest.java

示例11: boundsFor

import org.apache.cassandra.dht.BytesToken; //导入依赖的package包/类
private static Bounds<RowPosition> boundsFor(int start, int end)
{
    return new Bounds<RowPosition>(new BytesToken(toKey(start).getBytes()).minKeyBound(),
                                   new BytesToken(toKey(end).getBytes()).maxKeyBound());
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:6,代码来源:SSTableScannerTest.java

示例12: rangeFor

import org.apache.cassandra.dht.BytesToken; //导入依赖的package包/类
private static Range<Token> rangeFor(int start, int end)
{
    return new Range<Token>(new BytesToken(toKey(start).getBytes()),
                            new BytesToken(toKey(end).getBytes()));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:6,代码来源:SSTableScannerTest.java

示例13: antiCompactOne

import org.apache.cassandra.dht.BytesToken; //导入依赖的package包/类
@Test
public void antiCompactOne() throws InterruptedException, ExecutionException, IOException
{
    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF);
    store.disableAutoCompaction();
    long timestamp = System.currentTimeMillis();
    for (int i = 0; i < 10; i++)
    {
        DecoratedKey key = Util.dk(Integer.toString(i));
        Mutation rm = new Mutation(KEYSPACE1, key.getKey());
        for (int j = 0; j < 10; j++)
            rm.add(CF, Util.cellname(Integer.toString(j)),
                   ByteBufferUtil.EMPTY_BYTE_BUFFER,
                   timestamp,
                   0);
        rm.applyUnsafe();
    }
    store.forceBlockingFlush();
    Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
    assertEquals(store.getSSTables().size(), sstables.size());
    Range<Token> range = new Range<Token>(new BytesToken("0".getBytes()), new BytesToken("4".getBytes()));
    List<Range<Token>> ranges = Arrays.asList(range);

    SSTableReader.acquireReferences(sstables);
    long repairedAt = 1000;
    CompactionManager.instance.performAnticompaction(store, ranges, sstables, repairedAt);

    assertEquals(2, store.getSSTables().size());
    int repairedKeys = 0;
    int nonRepairedKeys = 0;
    for (SSTableReader sstable : store.getSSTables())
    {
        SSTableScanner scanner = sstable.getScanner();
        while (scanner.hasNext())
        {
            SSTableIdentityIterator row = (SSTableIdentityIterator) scanner.next();
            if (sstable.isRepaired())
            {
                assertTrue(range.contains(row.getKey().getToken()));
                repairedKeys++;
            }
            else
            {
                assertFalse(range.contains(row.getKey().getToken()));
                nonRepairedKeys++;
            }
        }
    }
    assertEquals(repairedKeys, 4);
    assertEquals(nonRepairedKeys, 6);
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:53,代码来源:AntiCompactionTest.java

示例14: antiCompactTen

import org.apache.cassandra.dht.BytesToken; //导入依赖的package包/类
public void antiCompactTen(String compactionStrategy) throws InterruptedException, ExecutionException, IOException
{
    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF);
    store.setCompactionStrategyClass(compactionStrategy);
    store.disableAutoCompaction();

    for (int table = 0; table < 10; table++)
    {
        generateSStable(store,Integer.toString(table));
    }
    Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
    assertEquals(store.getSSTables().size(), sstables.size());

    Range<Token> range = new Range<Token>(new BytesToken("0".getBytes()), new BytesToken("4".getBytes()));
    List<Range<Token>> ranges = Arrays.asList(range);

    SSTableReader.acquireReferences(sstables);
    long repairedAt = 1000;
    CompactionManager.instance.performAnticompaction(store, ranges, sstables, repairedAt);
    /*
    Anticompaction will be anti-compacting 10 SSTables but will be doing this two at a time
    so there will be no net change in the number of sstables
     */
    assertEquals(10, store.getSSTables().size());
    int repairedKeys = 0;
    int nonRepairedKeys = 0;
    for (SSTableReader sstable : store.getSSTables())
    {
        SSTableScanner scanner = sstable.getScanner();
        while (scanner.hasNext())
        {
            SSTableIdentityIterator row = (SSTableIdentityIterator) scanner.next();
            if (sstable.isRepaired())
            {
                assertTrue(range.contains(row.getKey().getToken()));
                assertEquals(repairedAt, sstable.getSSTableMetadata().repairedAt);
                repairedKeys++;
            }
            else
            {
                assertFalse(range.contains(row.getKey().getToken()));
                assertEquals(ActiveRepairService.UNREPAIRED_SSTABLE, sstable.getSSTableMetadata().repairedAt);
                nonRepairedKeys++;
            }
        }
    }
    assertEquals(repairedKeys, 40);
    assertEquals(nonRepairedKeys, 60);
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:51,代码来源:AntiCompactionTest.java

示例15: antiCompactOne

import org.apache.cassandra.dht.BytesToken; //导入依赖的package包/类
@Test
public void antiCompactOne() throws InterruptedException, ExecutionException, IOException
{
    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF);
    store.disableAutoCompaction();
    long timestamp = System.currentTimeMillis();
    for (int i = 0; i < 10; i++)
    {
        DecoratedKey key = Util.dk(Integer.toString(i));
        Mutation rm = new Mutation(KEYSPACE1, key.key);
        for (int j = 0; j < 10; j++)
            rm.add("Standard1", Util.cellname(Integer.toString(j)),
                   ByteBufferUtil.EMPTY_BYTE_BUFFER,
                   timestamp,
                   0);
        rm.apply();
    }
    store.forceBlockingFlush();
    Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
    assertEquals(store.getSSTables().size(), sstables.size());
    Range<Token> range = new Range<Token>(new BytesToken("0".getBytes()), new BytesToken("4".getBytes()));
    List<Range<Token>> ranges = Arrays.asList(range);

    SSTableReader.acquireReferences(sstables);
    long repairedAt = 1000;
    CompactionManager.instance.performAnticompaction(store, ranges, sstables, repairedAt);

    assertEquals(2, store.getSSTables().size());
    int repairedKeys = 0;
    int nonRepairedKeys = 0;
    for (SSTableReader sstable : store.getSSTables())
    {
        SSTableScanner scanner = sstable.getScanner();
        while (scanner.hasNext())
        {
            SSTableIdentityIterator row = (SSTableIdentityIterator) scanner.next();
            if (sstable.isRepaired())
            {
                assertTrue(range.contains(row.getKey().token));
                repairedKeys++;
            }
            else
            {
                assertFalse(range.contains(row.getKey().token));
                nonRepairedKeys++;
            }
        }
    }
    assertEquals(repairedKeys, 4);
    assertEquals(nonRepairedKeys, 6);
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:53,代码来源:AntiCompactionTest.java


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