doClientOperation();
// Try to add a store whose replication factor is greater than the
// number of nodes
StoreDefinition definition = new StoreDefinitionBuilder().setName("updateTest")
.setType(InMemoryStorageConfiguration.TYPE_NAME)
.setKeySerializer(new SerializerDefinition("string"))
.setValueSerializer(new SerializerDefinition("string"))
.setRoutingPolicy(RoutingTier.CLIENT)
.setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY)
.setReplicationFactor(3)
.setPreferredReads(1)
.setRequiredReads(1)
.setPreferredWrites(1)
.setRequiredWrites(1)
.build();
try {
adminClient.storeMgmtOps.addStore(definition);
fail("Should have thrown an exception because we cannot add a store with a replication factor greater than number of nodes");
} catch(Exception e) {}
// Try adding a legit store using inmemorystorage engine
definition = new StoreDefinitionBuilder().setName("updateTest")
.setType(InMemoryStorageConfiguration.TYPE_NAME)
.setKeySerializer(new SerializerDefinition("string"))
.setValueSerializer(new SerializerDefinition("string"))
.setRoutingPolicy(RoutingTier.CLIENT)
.setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY)
.setReplicationFactor(1)
.setPreferredReads(1)
.setRequiredReads(1)
.setPreferredWrites(1)
.setRequiredWrites(1)
.build();
adminClient.storeMgmtOps.addStore(definition);
// now test the store
StoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(cluster.getNodeById(0)
.getSocketUrl()
.toString()));
StoreClient<Object, Object> client = factory.getStoreClient("updateTest");
client.put("abc", "123");
String s = (String) client.get("abc").getValue();
assertEquals(s, "123");
// test again with a unknown store
try {
client = factory.getStoreClient("updateTest2");
client.put("abc", "123");
s = (String) client.get("abc").getValue();
assertEquals(s, "123");
fail("Should have received bootstrap failure exception");
} catch(Exception e) {
if(!(e instanceof BootstrapFailureException))
throw e;
}
// make sure that the store list we get back from AdminClient
Versioned<List<StoreDefinition>> list = adminClient.metadataMgmtOps.getRemoteStoreDefList(0);
assertTrue(list.getValue().contains(definition));
// Now add a RO store
definition = new StoreDefinitionBuilder().setName("addStoreROFormatTest")
.setType(ReadOnlyStorageConfiguration.TYPE_NAME)
.setKeySerializer(new SerializerDefinition("string"))
.setValueSerializer(new SerializerDefinition("string"))
.setRoutingPolicy(RoutingTier.CLIENT)
.setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY)