use of voldemort.xml.StoreDefinitionsMapper in project voldemort by voldemort.
the class AdminFetchTest method setUp.
@Before
public void setUp() throws IOException {
partitionToKeysMap = new HashMap<Integer, Set<String>>();
SocketStoreFactory socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 32 * 1024);
final int numServers = 2;
servers = new VoldemortServer[numServers];
int[][] partitionMap = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 } };
cluster = ServerTestUtils.startVoldemortCluster(numServers, servers, partitionMap, socketStoreFactory, this.useNio, null, storesXmlfile, properties);
List<StoreDefinition> storeDefs = new StoreDefinitionsMapper().readStoreList(new File(storesXmlfile));
for (StoreDefinition storeDef : storeDefs) if (storeDef.getName().equals(testStoreName))
testStoreDef = storeDef;
routingStrategy = new RoutingStrategyFactory().updateRoutingStrategy(testStoreDef, cluster);
adminClient = ServerTestUtils.getAdminClient(cluster);
// load data into the servers
Node firstServer = cluster.getNodes().iterator().next();
String bootstrapUrl = "tcp://" + firstServer.getHost() + ":" + firstServer.getSocketPort();
StoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl).setSelectors(2));
// create a client that executes operations on a single store
StoreClient<String, String> voldClient = factory.getStoreClient("users");
for (int i = 0; i < TEST_STREAM_KEYS_SIZE; i++) {
String key = "key" + i;
byte[] bkey = key.getBytes("UTF-8");
int partition = routingStrategy.getPartitionList(bkey).get(0);
if (!partitionToKeysMap.containsKey(partition))
partitionToKeysMap.put(partition, new HashSet<String>());
partitionToKeysMap.get(partition).add(key);
voldClient.put(key, "value" + i);
}
}
use of voldemort.xml.StoreDefinitionsMapper in project voldemort by voldemort.
the class AdminServiceBasicTest method testFetchAllStoresFromMetadataStore.
@Test
public void testFetchAllStoresFromMetadataStore() throws Exception {
String storeName = MetadataStore.STORES_KEY;
String storeDefStr = bootstrapMetadata(storeName);
StoreDefinitionsMapper mapper = new StoreDefinitionsMapper();
List<StoreDefinition> storeDefList = mapper.readStoreList(new StringReader(storeDefStr));
assertEquals(storeDefList.size(), this.storeDefs.size());
Set<String> receivedStoreNames = getStoreNames(storeDefList);
Set<String> originalStoreNames = getStoreNames(this.storeDefs);
assertEquals(receivedStoreNames, originalStoreNames);
}
use of voldemort.xml.StoreDefinitionsMapper in project voldemort by voldemort.
the class AdminServiceBasicTest method setUp.
@Before
public void setUp() throws IOException {
int numServers = 2;
servers = new VoldemortServer[numServers];
int[][] partitionMap = { { 0, 1, 2, 3 }, { 4, 5, 6, 7 } };
Properties serverProperties = new Properties();
serverProperties.setProperty("client.max.connections.per.node", "20");
serverProperties.setProperty("enforce.retention.policy.on.read", Boolean.toString(onlineRetention));
serverProperties.setProperty(VoldemortConfig.DEFAULT_STORAGE_SPACE_QUOTA_IN_KB, Long.toString(defaultStoreQuota));
cluster = ServerTestUtils.startVoldemortCluster(numServers, servers, partitionMap, socketStoreFactory, useNio, null, storesXmlfile, serverProperties);
storeDefs = new StoreDefinitionsMapper().readStoreList(new File(storesXmlfile));
Properties adminProperties = new Properties();
adminProperties.setProperty("max_connections", "20");
adminClient = new AdminClient(cluster, new AdminClientConfig(adminProperties));
Node node = cluster.getNodeById(0);
String bootstrapUrl = "tcp://" + node.getHost() + ":" + node.getSocketPort();
StoreClientFactory storeClientFactory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl));
storeClient = storeClientFactory.getStoreClient(STORE_NAME);
}
use of voldemort.xml.StoreDefinitionsMapper in project voldemort by voldemort.
the class AdminServiceFilterTest method setUp.
@Override
@Before
public void setUp() throws IOException {
cluster = ServerTestUtils.getLocalCluster(2);
VoldemortConfig config = ServerTestUtils.createServerConfig(useNio, 0, TestUtils.createTempDir().getAbsolutePath(), null, storesXmlfile, new Properties());
config.setEnableNetworkClassLoader(true);
List<StoreDefinition> storeDefs = new StoreDefinitionsMapper().readStoreList(new File(storesXmlfile));
storeDef = StoreDefinitionUtils.getStoreDefinitionWithName(storeDefs, testStoreName);
server = new VoldemortServer(config, cluster);
server.start();
adminClient = ServerTestUtils.getAdminClient(cluster);
}
use of voldemort.xml.StoreDefinitionsMapper in project voldemort by voldemort.
the class AbstractStoreBuilderConfigurable method configure.
public void configure(JobConf conf) {
this.cluster = new ClusterMapper().readCluster(new StringReader(conf.get("cluster.xml")));
List<StoreDefinition> storeDefs = new StoreDefinitionsMapper().readStoreList(new StringReader(conf.get("stores.xml")));
if (storeDefs.size() != 1)
throw new IllegalStateException("Expected to find only a single store, but found multiple!");
this.storeDef = storeDefs.get(0);
this.numChunks = conf.getInt(NUM_CHUNKS, -1);
if (this.numChunks < 1) {
// be overridden by the user.
throw new VoldemortException(NUM_CHUNKS + " not specified in the MapReduce JobConf (should NEVER happen)");
}
this.saveKeys = conf.getBoolean(VoldemortBuildAndPushJob.SAVE_KEYS, true);
this.reducerPerBucket = conf.getBoolean(VoldemortBuildAndPushJob.REDUCER_PER_BUCKET, true);
this.buildPrimaryReplicasOnly = conf.getBoolean(VoldemortBuildAndPushJob.BUILD_PRIMARY_REPLICAS_ONLY, false);
if (buildPrimaryReplicasOnly && !saveKeys) {
throw new IllegalStateException(VoldemortBuildAndPushJob.BUILD_PRIMARY_REPLICAS_ONLY + " can only be true if " + VoldemortBuildAndPushJob.SAVE_KEYS + " is also true.");
}
}
Aggregations