use of org.apache.cassandra.locator.TokenMetadata in project cassandra by apache.
the class BootStrapperTest method testAllocateTokens.
@Test
public void testAllocateTokens() throws UnknownHostException {
int vn = 16;
String ks = "BootStrapperTestKeyspace3";
TokenMetadata tm = new TokenMetadata();
generateFakeEndpoints(tm, 10, vn);
InetAddress addr = FBUtilities.getBroadcastAddress();
allocateTokensForNode(vn, ks, tm, addr);
}
use of org.apache.cassandra.locator.TokenMetadata in project cassandra by apache.
the class BootStrapperTest method testAllocateTokensNetworkStrategy.
public void testAllocateTokensNetworkStrategy(int rackCount, int replicas) throws UnknownHostException {
IEndpointSnitch oldSnitch = DatabaseDescriptor.getEndpointSnitch();
try {
DatabaseDescriptor.setEndpointSnitch(new RackInferringSnitch());
int vn = 16;
String ks = "BootStrapperTestNTSKeyspace" + rackCount + replicas;
String dc = "1";
// Register peers with expected DC for NetworkTopologyStrategy.
TokenMetadata metadata = StorageService.instance.getTokenMetadata();
metadata.clearUnsafe();
metadata.updateHostId(UUID.randomUUID(), InetAddress.getByName("127.1.0.99"));
metadata.updateHostId(UUID.randomUUID(), InetAddress.getByName("127.15.0.99"));
SchemaLoader.createKeyspace(ks, KeyspaceParams.nts(dc, replicas, "15", 15), SchemaLoader.standardCFMD(ks, "Standard1"));
TokenMetadata tm = StorageService.instance.getTokenMetadata();
tm.clearUnsafe();
for (int i = 0; i < rackCount; ++i) generateFakeEndpoints(tm, 10, vn, dc, Integer.toString(i));
InetAddress addr = InetAddress.getByName("127." + dc + ".0.99");
allocateTokensForNode(vn, ks, tm, addr);
// Note: Not matching replication factor in second datacentre, but this should not affect us.
} finally {
DatabaseDescriptor.setEndpointSnitch(oldSnitch);
}
}
use of org.apache.cassandra.locator.TokenMetadata in project cassandra by apache.
the class DiskBoundaryManagerTest method setup.
@Before
public void setup() {
DisallowedDirectories.clearUnwritableUnsafe();
TokenMetadata metadata = StorageService.instance.getTokenMetadata();
metadata.updateNormalTokens(BootStrapper.getRandomTokens(metadata, 10), FBUtilities.getBroadcastAddressAndPort());
createTable("create table %s (id int primary key, x text)");
dirs = new Directories(getCurrentColumnFamilyStore().metadata(), Lists.newArrayList(new Directories.DataDirectory(new File("/tmp/1")), new Directories.DataDirectory(new File("/tmp/2")), new Directories.DataDirectory(new File("/tmp/3"))));
mock = new MockCFS(getCurrentColumnFamilyStore(), dirs);
dbm = mock.diskBoundaryManager;
}
use of org.apache.cassandra.locator.TokenMetadata in project cassandra by apache.
the class RowCacheTest method testRowCacheCleanup.
@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.size(), 100);
store.cleanupCache();
assertEquals(CacheService.instance.rowCache.size(), 100);
TokenMetadata tmd = StorageService.instance.getTokenMetadata();
byte[] tk1, tk2;
tk1 = "key1000".getBytes();
tk2 = "key1050".getBytes();
tmd.updateNormalToken(new BytesToken(tk1), InetAddressAndPort.getByName("127.0.0.1"));
tmd.updateNormalToken(new BytesToken(tk2), InetAddressAndPort.getByName("127.0.0.2"));
store.cleanupCache();
assertEquals(50, CacheService.instance.rowCache.size());
CacheService.instance.setRowCacheCapacityInMB(0);
}
use of org.apache.cassandra.locator.TokenMetadata in project cassandra by apache.
the class ReadCommandVerbHandlerTest method init.
@BeforeClass
public static void init() throws Throwable {
SchemaLoader.loadSchema();
SchemaLoader.schemaDefinition(TEST_NAME);
metadata = Schema.instance.getTableMetadata(KEYSPACE, TABLE);
metadata_with_transient = Schema.instance.getTableMetadata(KEYSPACE_WITH_TRANSIENT, TABLE);
KEY = key(metadata, 1);
TokenMetadata tmd = StorageService.instance.getTokenMetadata();
tmd.updateNormalToken(KEY.getToken(), InetAddressAndPort.getByName("127.0.0.2"));
tmd.updateNormalToken(key(metadata, 2).getToken(), InetAddressAndPort.getByName("127.0.0.3"));
tmd.updateNormalToken(key(metadata, 3).getToken(), FBUtilities.getBroadcastAddressAndPort());
}
Aggregations