本文整理汇总了Java中org.apache.cassandra.dht.Murmur3Partitioner类的典型用法代码示例。如果您正苦于以下问题:Java Murmur3Partitioner类的具体用法?Java Murmur3Partitioner怎么用?Java Murmur3Partitioner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Murmur3Partitioner类属于org.apache.cassandra.dht包,在下文中一共展示了Murmur3Partitioner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testParsingCQLOnCompoundedTable
import org.apache.cassandra.dht.Murmur3Partitioner; //导入依赖的package包/类
@Test
public void testParsingCQLOnCompoundedTable() {
String cql = "CREATE TABLE keyspace1.compressed_bills (" +
" user text," +
" email text," +
" account_id text static," +
" balance int static," +
" expense_id int," +
" item_id int," +
" amount int," +
" name text," +
" PRIMARY KEY ((user, email), expense_id, item_id))";
ParsedStatement stmt = QueryProcessor.parseStatement(cql);
stmt.properties.properties.addProperty(CFProperties.KEYSPACE_NAME, "keyspace1");
stmt.properties.properties.addProperty(CFProperties.PARTITIONER_CLASS,
"org.apache.cassandra.dht.Murmur3Partitioner");
ParsedStatement.Prepared preparedStmt = stmt.prepare();
CFMetaData cfMetaData = ((CreateTableStatement) preparedStmt.statement).getCFMetaData();
Assert.assertEquals(cfMetaData.ksName, "keyspace1");
Assert.assertEquals(cfMetaData.partitioner, Murmur3Partitioner.instance);
}
示例2: testMurmur3FilterHash
import org.apache.cassandra.dht.Murmur3Partitioner; //导入依赖的package包/类
@Test
public void testMurmur3FilterHash()
{
IPartitioner partitioner = new Murmur3Partitioner();
Iterator<ByteBuffer> gen = new KeyGenerator.RandomStringGenerator(new Random().nextInt(), FilterTestHelper.ELEMENTS);
long[] expected = new long[2];
long[] actual = new long[2];
while (gen.hasNext())
{
expected[0] = 1;
expected[1] = 2;
actual[0] = 3;
actual[1] = 4;
ByteBuffer key = gen.next();
FilterKey expectedKey = FilterTestHelper.wrap(key);
FilterKey actualKey = partitioner.decorateKey(key);
actualKey.filterHash(actual);
expectedKey.filterHash(expected);
Assert.assertArrayEquals(expected, actual);
}
}
示例3: testShouldHint
import org.apache.cassandra.dht.Murmur3Partitioner; //导入依赖的package包/类
private void testShouldHint(Verb verb, ConsistencyLevel cl, boolean allowHints, boolean expectHint) throws Exception
{
Object payload = verb == Verb.PAXOS_COMMIT
? new Commit(UUID.randomUUID(), new PartitionUpdate(MockSchema.newCFMetaData("", ""), ByteBufferUtil.EMPTY_BYTE_BUFFER, PartitionColumns.NONE, 1))
: new Mutation("", new BufferDecoratedKey(new Murmur3Partitioner.LongToken(0), ByteBufferUtil.EMPTY_BYTE_BUFFER));
WriteCallbackInfo wcbi = new WriteCallbackInfo(InetAddress.getByName("192.168.1.1"), null, new MessageOut(verb, payload, null), null, cl, allowHints);
Assert.assertEquals(expectHint, wcbi.shouldHint());
if (expectHint)
{
Assert.assertNotNull(wcbi.mutation());
}
else
{
boolean fail = false;
try
{
wcbi.mutation();
}
catch (Throwable t)
{
fail = true;
}
Assert.assertTrue(fail);
}
}
示例4: compareMurmur3Partitioner
import org.apache.cassandra.dht.Murmur3Partitioner; //导入依赖的package包/类
@Test
public void compareMurmur3Partitioner() throws IOException {
conf.set(CassandraParams.SCRUB_CASSANDRACLUSTER_PARTITIONER_CONFIG,
Murmur3Partitioner.class.getName());
comparator.setConf(conf);
// murmur3_128("foo")[0] = -2129773440516405919
// murmur3_128("bar")[0] = -7911037993560119804
// murmur3_128("baz")[0] = 8295379539955784970
checkOrder("bar", "foo");
checkOrder("foo", "baz");
checkOrder("bar", "baz");
// Murmur3Partitioner maps empty string to Long.MIN_VALUE
checkOrder("", "foo");
checkOrder("", "bar");
}
示例5: init
import org.apache.cassandra.dht.Murmur3Partitioner; //导入依赖的package包/类
public void init()
{
if (!(StorageService.getPartitioner() instanceof Murmur3Partitioner))
throw new UnsupportedOperationException("SASI supported only with Murmur3Partitioner.");
isInitialized = true;
metrics = new IndexMetrics(baseCfs);
// init() is called by SIM only on the instance that it will keep around, but will call addColumnDef on any instance
// that it happens to create (and subsequently/immediately throw away)
track(columnDefs);
baseCfs.getDataTracker().subscribe(this);
}
示例6: beforeTest
import org.apache.cassandra.dht.Murmur3Partitioner; //导入依赖的package包/类
@Before
public void beforeTest()
{
ExtendedFilter filter = ExtendedFilter.create(BACKEND.getBaseCfs(),
DataRange.allData(new Murmur3Partitioner()),
null,
Integer.MAX_VALUE,
false,
System.currentTimeMillis());
controller = new QueryController(BACKEND, filter, TimeUnit.SECONDS.toMillis(10));
}
示例7: setUpClass
import org.apache.cassandra.dht.Murmur3Partitioner; //导入依赖的package包/类
@BeforeClass
public static void setUpClass()
{
if (ROW_CACHE_SIZE_IN_MB > 0)
DatabaseDescriptor.setRowCacheSizeInMB(ROW_CACHE_SIZE_IN_MB);
StorageService.instance.setPartitionerUnsafe(Murmur3Partitioner.instance);
}
示例8: newCFMetaData
import org.apache.cassandra.dht.Murmur3Partitioner; //导入依赖的package包/类
public static CFMetaData newCFMetaData(String ksname, String cfname)
{
CFMetaData metadata = CFMetaData.Builder.create(ksname, cfname)
.addPartitionKey("key", UTF8Type.instance)
.addClusteringColumn("col", UTF8Type.instance)
.addRegularColumn("value", UTF8Type.instance)
.withPartitioner(Murmur3Partitioner.instance)
.build();
metadata.caching(CachingParams.CACHE_NOTHING);
return metadata;
}
示例9: testSessionSuccess
import org.apache.cassandra.dht.Murmur3Partitioner; //导入依赖的package包/类
@Test
public void testSessionSuccess()
{
int cmd = 321;
String message = String.format("Repair session %s for range %s finished", UUID.randomUUID(),
new Range<Token>(new Murmur3Partitioner.LongToken(3), new Murmur3Partitioner.LongToken(4)));
Optional<int[]> result = LegacyJMXProgressSupport.getLegacyUserdata(String.format("repair:%d", cmd),
new ProgressEvent(ProgressEventType.PROGRESS, 2, 10, message));
assertTrue(result.isPresent());
assertArrayEquals(new int[]{ cmd, ActiveRepairService.Status.SESSION_SUCCESS.ordinal() }, result.get());
}
示例10: testSessionFailed
import org.apache.cassandra.dht.Murmur3Partitioner; //导入依赖的package包/类
@Test
public void testSessionFailed()
{
int cmd = 321;
String message = String.format("Repair session %s for range %s failed with error %s", UUID.randomUUID(),
new Range<Token>(new Murmur3Partitioner.LongToken(3), new Murmur3Partitioner.LongToken(4)).toString(),
new RuntimeException("error"));
Optional<int[]> result = LegacyJMXProgressSupport.getLegacyUserdata(String.format("repair:%d", cmd),
new ProgressEvent(ProgressEventType.PROGRESS, 2, 10, message));
assertTrue(result.isPresent());
assertArrayEquals(new int[]{ cmd, ActiveRepairService.Status.SESSION_FAILED.ordinal() }, result.get());
}
示例11: testConviction
import org.apache.cassandra.dht.Murmur3Partitioner; //导入依赖的package包/类
@Test
public void testConviction() throws Exception
{
InetAddress remote = InetAddress.getByName("127.0.0.2");
Gossiper.instance.initializeNodeUnsafe(remote, UUID.randomUUID(), 1);
// Set up RepairSession
UUID parentSessionId = UUIDGen.getTimeUUID();
UUID sessionId = UUID.randomUUID();
IPartitioner p = Murmur3Partitioner.instance;
Range<Token> repairRange = new Range<>(p.getToken(ByteBufferUtil.bytes(0)), p.getToken(ByteBufferUtil.bytes(100)));
Set<InetAddress> endpoints = Sets.newHashSet(remote);
RepairSession session = new RepairSession(parentSessionId, sessionId, Arrays.asList(repairRange), "Keyspace1", RepairParallelism.SEQUENTIAL, endpoints, ActiveRepairService.UNREPAIRED_SSTABLE, "Standard1");
// perform convict
session.convict(remote, Double.MAX_VALUE);
// RepairSession should throw ExecutorException with the cause of IOException when getting its value
try
{
session.get();
fail();
}
catch (ExecutionException ex)
{
assertEquals(IOException.class, ex.getCause().getClass());
}
}
示例12: testIncrementalRepairWithSubrangesIsNotGlobal
import org.apache.cassandra.dht.Murmur3Partitioner; //导入依赖的package包/类
@Test
public void testIncrementalRepairWithSubrangesIsNotGlobal() throws Exception
{
RepairOption ro = RepairOption.parse(ImmutableMap.of(RepairOption.INCREMENTAL_KEY, "true", RepairOption.RANGES_KEY, "42:42"),
Murmur3Partitioner.instance);
assertFalse(ro.isGlobal());
ro = RepairOption.parse(ImmutableMap.of(RepairOption.INCREMENTAL_KEY, "true", RepairOption.RANGES_KEY, ""),
Murmur3Partitioner.instance);
assertTrue(ro.isGlobal());
}
示例13: defineSchema
import org.apache.cassandra.dht.Murmur3Partitioner; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
sw = Util.switchPartitioner(Murmur3Partitioner.instance);
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE1,
KeyspaceParams.simple(1),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1, 1, BytesType.instance),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD2, 1, BytesType.instance),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD3, 1, BytesType.instance),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD4, 1, BytesType.instance),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD5, 1, BytesType.instance));
}
示例14: instance
import org.apache.cassandra.dht.Murmur3Partitioner; //导入依赖的package包/类
/**
* Returns a new {@link TokenMapper} instance for the current partitioner using the specified column family
* metadata.
*
* @param metadata The column family metadata.
* @return A new {@link TokenMapper} instance for the current partitioner.
*/
public static TokenMapper instance(CFMetaData metadata) {
IPartitioner partitioner = DatabaseDescriptor.getPartitioner();
if (partitioner instanceof Murmur3Partitioner) {
return new TokenMapperMurmur(metadata);
} else {
return new TokenMapperGeneric(metadata);
}
}
示例15: setup
import org.apache.cassandra.dht.Murmur3Partitioner; //导入依赖的package包/类
@Before
public void setup() {
partitioner = new Murmur3Partitioner();
rateLimiter = RateLimiter.create(1.0d * 1024.0d * 1024.0d);
metadata = new ColumnFamilyMetadata(keyspace, columnFamily, keyAliasesString, columnAliasesString, keyValidatorString, comparatorString);
sstableFile = new File(this.getClass().getResource(sstableFilePath).getPath());
}