Java Code Examples for org.apache.cassandra.config.KSMetaData#optsWithRF()
The following examples show how to use
org.apache.cassandra.config.KSMetaData#optsWithRF() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OldNetworkTopologyStrategyTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
/** * 4 same rack endpoints * * @throws UnknownHostException */ @Test public void testBigIntegerEndpointsA() throws UnknownHostException { RackInferringSnitch endpointSnitch = new RackInferringSnitch(); AbstractReplicationStrategy strategy = new OldNetworkTopologyStrategy("Keyspace1", tmd, endpointSnitch, KSMetaData.optsWithRF(1)); addEndpoint("0", "5", "254.0.0.1"); addEndpoint("10", "15", "254.0.0.2"); addEndpoint("20", "25", "254.0.0.3"); addEndpoint("30", "35", "254.0.0.4"); expectedResults.put("5", buildResult("254.0.0.2", "254.0.0.3", "254.0.0.4")); expectedResults.put("15", buildResult("254.0.0.3", "254.0.0.4", "254.0.0.1")); expectedResults.put("25", buildResult("254.0.0.4", "254.0.0.1", "254.0.0.2")); expectedResults.put("35", buildResult("254.0.0.1", "254.0.0.2", "254.0.0.3")); testGetEndpoints(strategy, keyTokens.toArray(new Token[0])); }
Example 2
Source File: OldNetworkTopologyStrategyTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
/** * 3 same rack endpoints * 1 external datacenter * * @throws UnknownHostException */ @Test public void testBigIntegerEndpointsB() throws UnknownHostException { RackInferringSnitch endpointSnitch = new RackInferringSnitch(); AbstractReplicationStrategy strategy = new OldNetworkTopologyStrategy("Keyspace1", tmd, endpointSnitch, KSMetaData.optsWithRF(1)); addEndpoint("0", "5", "254.0.0.1"); addEndpoint("10", "15", "254.0.0.2"); addEndpoint("20", "25", "254.1.0.3"); addEndpoint("30", "35", "254.0.0.4"); expectedResults.put("5", buildResult("254.0.0.2", "254.1.0.3", "254.0.0.4")); expectedResults.put("15", buildResult("254.1.0.3", "254.0.0.4", "254.0.0.1")); expectedResults.put("25", buildResult("254.0.0.4", "254.1.0.3", "254.0.0.1")); expectedResults.put("35", buildResult("254.0.0.1", "254.1.0.3", "254.0.0.2")); testGetEndpoints(strategy, keyTokens.toArray(new Token[0])); }
Example 3
Source File: OldNetworkTopologyStrategyTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
/** * 2 same rack endpoints * 1 same datacenter, different rack endpoints * 1 external datacenter * * @throws UnknownHostException */ @Test public void testBigIntegerEndpointsC() throws UnknownHostException { RackInferringSnitch endpointSnitch = new RackInferringSnitch(); AbstractReplicationStrategy strategy = new OldNetworkTopologyStrategy("Keyspace1", tmd, endpointSnitch, KSMetaData.optsWithRF(1)); addEndpoint("0", "5", "254.0.0.1"); addEndpoint("10", "15", "254.0.0.2"); addEndpoint("20", "25", "254.0.1.3"); addEndpoint("30", "35", "254.1.0.4"); expectedResults.put("5", buildResult("254.0.0.2", "254.0.1.3", "254.1.0.4")); expectedResults.put("15", buildResult("254.0.1.3", "254.1.0.4", "254.0.0.1")); expectedResults.put("25", buildResult("254.1.0.4", "254.0.0.1", "254.0.0.2")); expectedResults.put("35", buildResult("254.0.0.1", "254.0.1.3", "254.1.0.4")); testGetEndpoints(strategy, keyTokens.toArray(new Token[0])); }
Example 4
Source File: OldNetworkTopologyStrategyTest.java From stratio-cassandra with Apache License 2.0 | 4 votes |
private Pair<Set<Range<Token>>, Set<Range<Token>>> calculateStreamAndFetchRanges(BigIntegerToken[] tokens, BigIntegerToken[] tokensAfterMove, int movingNodeIdx) throws UnknownHostException { RackInferringSnitch endpointSnitch = new RackInferringSnitch(); InetAddress movingNode = InetAddress.getByName("254.0.0." + Integer.toString(movingNodeIdx + 1)); TokenMetadata tokenMetadataCurrent = initTokenMetadata(tokens); TokenMetadata tokenMetadataAfterMove = initTokenMetadata(tokensAfterMove); AbstractReplicationStrategy strategy = new OldNetworkTopologyStrategy("Keyspace1", tokenMetadataCurrent, endpointSnitch, KSMetaData.optsWithRF(2)); Collection<Range<Token>> currentRanges = strategy.getAddressRanges().get(movingNode); Collection<Range<Token>> updatedRanges = strategy.getPendingAddressRanges(tokenMetadataAfterMove, tokensAfterMove[movingNodeIdx], movingNode); Pair<Set<Range<Token>>, Set<Range<Token>>> ranges = StorageService.instance.calculateStreamAndFetchRanges(currentRanges, updatedRanges); return ranges; }