use of voldemort.xml.StoreDefinitionsMapper in project voldemort by voldemort.
the class NonZonedRebalanceBatchPlanTest method setUp.
@Before
public void setUp() {
try {
storeDefList = new StoreDefinitionsMapper().readStoreList(new FileReader(new File(storeDefFile)));
storeDefList2 = new StoreDefinitionsMapper().readStoreList(new StringReader(VoldemortTestConstants.getSingleStore322Xml()));
test211StoreDef = Lists.newArrayList(ServerTestUtils.getStoreDef("test", 2, 1, 1, 1, 1, RoutingStrategyType.CONSISTENT_STRATEGY));
} catch (FileNotFoundException e) {
throw new RuntimeException("Failed to find storeDefFile:" + storeDefFile, e);
}
}
use of voldemort.xml.StoreDefinitionsMapper in project voldemort by voldemort.
the class RebalanceRebootstrapConsistencyTest method setUp.
@Before
public void setUp() throws Exception {
SocketStoreFactory socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 32 * 1024);
int numServers = 2;
rwStoreDefWithReplication = new StoreDefinitionBuilder().setName(testStoreNameRW).setType(BdbStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(2).setPreferredReads(1).setRequiredReads(1).setPreferredWrites(1).setRequiredWrites(1).build();
/*
* Bug fix: The old code was trying to rename a store during rebalance !
* God knows why Renaming it back to the original store name and
* changing other preferences (required reads = 2)
*/
rwStoreDefWithReplication2 = new StoreDefinitionBuilder().setName(testStoreNameRW).setType(BdbStorageConfiguration.TYPE_NAME).setKeySerializer(new SerializerDefinition("string")).setValueSerializer(new SerializerDefinition("string")).setRoutingPolicy(RoutingTier.CLIENT).setRoutingStrategyType(RoutingStrategyType.CONSISTENT_STRATEGY).setReplicationFactor(2).setPreferredReads(2).setRequiredReads(2).setPreferredWrites(1).setRequiredWrites(1).build();
List<StoreDefinition> storedefs = new ArrayList<StoreDefinition>();
storedefs.add(rwStoreDefWithReplication);
String storesXmlStr = new StoreDefinitionsMapper().writeStoreList(storedefs);
// create a temp file
File tempStoresXml = ServerTestUtils.createTempFile("tempfile", ".tmp");
BufferedWriter bw = new BufferedWriter(new FileWriter(tempStoresXml));
bw.write(storesXmlStr);
bw.close();
VoldemortServer[] voldemortServers = new VoldemortServer[numServers];
int[][] partitionMap = { { 0, 1 }, {} };
cluster = ServerTestUtils.startVoldemortCluster(numServers, voldemortServers, partitionMap, socketStoreFactory, false, null, tempStoresXml.getAbsolutePath(), new Properties());
servers = Lists.newArrayList();
for (int i = 0; i < numServers; ++i) {
servers.add(voldemortServers[i]);
}
socketUrl = voldemortServers[0].getIdentityNode().getSocketUrl().toString();
bootStrapUrls = new String[1];
bootStrapUrls[0] = socketUrl;
ClientConfig clientConfig = new ClientConfig();
clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(this.CLIENT_ZONE_ID);
SystemStoreClientFactory<String, String> systemStoreFactory = new SystemStoreClientFactory<String, String>(clientConfig);
sysVersionStore = systemStoreFactory.createSystemStore(SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name());
repository = new SystemStoreRepository(clientConfig);
repository.addSystemStore(sysVersionStore, SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name());
this.scheduler = new SchedulerService(2, SystemTime.INSTANCE, true);
Callable<Void> rebootstrapCallback = new Callable<Void>() {
@Override
public Void call() throws Exception {
// callbackForClusterChange();
checkConsistentMetadata();
return null;
}
};
// Starting the Version Metadata Manager
this.asyncCheckMetadata = new AsyncMetadataVersionManager(this.repository, rebootstrapCallback, null);
scheduler.schedule(asyncCheckMetadata.getClass().getName(), asyncCheckMetadata, new Date(), 500);
while (maxRetries < 3 && !asyncCheckMetadata.isActive) {
Thread.sleep(500);
maxRetries++;
}
}
use of voldemort.xml.StoreDefinitionsMapper in project voldemort by voldemort.
the class DataCleanupJobTest method runRetentionEnforcingStoreTest.
private void runRetentionEnforcingStoreTest(boolean onlineDeletes) throws InterruptedException {
time.setTime(System.currentTimeMillis());
StoreDefinition retentionStoreDef = new StoreDefinitionsMapper().readStoreList(new StringReader(VoldemortTestConstants.getStoreDefinitionsWithRetentionXml())).get(0);
RetentionEnforcingStore store = new RetentionEnforcingStore(engine, retentionStoreDef, onlineDeletes, time);
// do a bunch of puts
store.put(new ByteArray("k1".getBytes()), new Versioned<byte[]>("v1".getBytes()), null);
store.put(new ByteArray("k2".getBytes()), new Versioned<byte[]>("v2".getBytes()), null);
long writeMs = System.currentTimeMillis();
// wait for a bit and then do more puts
Thread.sleep(2000);
store.put(new ByteArray("k3".getBytes()), new Versioned<byte[]>("v3".getBytes()), null);
store.put(new ByteArray("k4".getBytes()), new Versioned<byte[]>("v4".getBytes()), null);
// move time forward just enough such that some keys will have expired.
time.setTime(writeMs + retentionStoreDef.getRetentionDays() * Time.MS_PER_DAY + 1);
assertEquals("k1 should have expired", 0, store.get(new ByteArray("k1".getBytes()), null).size());
assertEquals("k2 should have expired", 0, store.get(new ByteArray("k2".getBytes()), null).size());
assertTrue("k3 should not have expired", store.get(new ByteArray("k3".getBytes()), null).size() > 0);
assertTrue("k4 should not have expired", store.get(new ByteArray("k4".getBytes()), null).size() > 0);
// get all with k1, k4 should return a map with k4 alone
Map<ByteArray, List<Versioned<byte[]>>> getAllResult = store.getAll(Arrays.asList(new ByteArray("k1".getBytes()), new ByteArray("k4".getBytes())), null);
assertEquals("map should contain one element only", 1, getAllResult.size());
assertEquals("k1 should not be present", false, getAllResult.containsKey(new ByteArray("k1".getBytes())));
assertEquals("k4 should be present", true, getAllResult.containsKey(new ByteArray("k4".getBytes())));
// if online deletes are not configured, we should see the deleted keys
// in the base bdb store, so the datacleanup job can go and delete them
assertEquals("k1 should be present", !onlineDeletes, engine.get(new ByteArray("k1".getBytes()), null).size() > 0);
assertEquals("k2 should be present", !onlineDeletes, engine.get(new ByteArray("k2".getBytes()), null).size() > 0);
// delete everything for next run
engine.truncate();
}
use of voldemort.xml.StoreDefinitionsMapper in project voldemort by voldemort.
the class ReplaceNodeCLI method getStoresXML.
private String getStoresXML() {
StoreDefinitionsMapper storeMapper = new StoreDefinitionsMapper();
Map<Integer, String> storeXMLInNodes = getMetadataXML(MetadataStore.STORES_KEY);
List<StoreDefinition> storeList = null;
String storeXML = null;
for (Map.Entry<Integer, String> storeNodeId : storeXMLInNodes.entrySet()) {
String xml = storeNodeId.getValue();
List<StoreDefinition> storeDefinitions = storeMapper.readStoreList(new StringReader(xml), false);
if (storeList == null) {
storeList = storeDefinitions;
storeXML = xml;
} else if (storeList.equals(storeDefinitions) == false) {
throw new VoldemortApplicationException("Store XMLs are different across nodes, fix that before the node swap...aborting " + storeNodeId.getKey());
}
}
return storeXML;
}
use of voldemort.xml.StoreDefinitionsMapper in project voldemort by voldemort.
the class ZoneShrinkageCLI method shrinkStoresXml.
protected static String shrinkStoresXml(String storesXml, int droppingZoneId) {
List<StoreDefinition> initialStoreDefs = new StoreDefinitionsMapper().readStoreList(new StringReader(storesXml));
List<StoreDefinition> finalStoreDefs = RebalanceUtils.dropZone(initialStoreDefs, droppingZoneId);
String newStoresXml = new StoreDefinitionsMapper().writeStoreList(finalStoreDefs);
return newStoresXml;
}
Aggregations