use of voldemort.store.socket.SocketStoreFactory in project voldemort by voldemort.
the class ZoneCountWriteTest method setup.
@Before
public void setup() throws IOException {
storeDef = storeDefs.get(0);
Integer zoneCountWrite = 1;
// override
storeDef = new StoreDefinition(storeDef.getName(), storeDef.getType(), storeDef.getDescription(), storeDef.getKeySerializer(), storeDef.getValueSerializer(), storeDef.getTransformsSerializer(), storeDef.getRoutingPolicy(), storeDef.getRoutingStrategyType(), storeDef.getReplicationFactor(), storeDef.getPreferredReads(), storeDef.getRequiredReads(), storeDef.getPreferredWrites(), storeDef.getRequiredWrites(), storeDef.getViewTargetStoreName(), storeDef.getValueTransformation(), storeDef.getZoneReplicationFactor(), storeDef.getZoneCountReads(), zoneCountWrite, storeDef.getRetentionDays(), storeDef.getRetentionScanThrottleRate(), storeDef.getRetentionFrequencyDays(), storeDef.getSerializerFactory(), storeDef.getHintedHandoffStrategyType(), storeDef.getHintPrefListSize(), storeDef.getOwners(), storeDef.getMemoryFootprintMB());
storeDefs.set(0, storeDef);
SocketStoreClientFactory socketStoreClientFactory = new SocketStoreClientFactory(clientConfig);
for (Integer nodeId : cluster.getNodeIds()) {
SocketStoreFactory socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 1024);
VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, nodeId, TestUtils.createTempDir().getAbsolutePath(), cluster, storeDefs, new Properties());
VoldemortServer vs = ServerTestUtils.startVoldemortServer(socketStoreFactory, config, cluster);
vservers.put(nodeId, vs);
}
client = socketStoreClientFactory.getRawStore(storeDef.getName(), null);
}
use of voldemort.store.socket.SocketStoreFactory in project voldemort by voldemort.
the class RebootstrappingStoreTest method setUp.
@Before
public void setUp() throws Exception {
SocketStoreFactory socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 32 * 1024);
int numServers = 2;
VoldemortServer[] voldemortServers = new VoldemortServer[numServers];
int[][] partitionMap = { { 0, 1 }, {} };
cluster = ServerTestUtils.startVoldemortCluster(numServers, voldemortServers, partitionMap, socketStoreFactory, false, null, STORES_XML, new Properties());
servers = Lists.newArrayList();
for (int i = 0; i < numServers; ++i) {
servers.add(voldemortServers[i]);
}
String bootstrapUrl = cluster.getNodeById(0).getSocketUrl().toString();
storeClient = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl)).getStoreClient(STORE_NAME);
Map<String, String> entries = Maps.newHashMap();
entries.put("a", "1");
entries.put("b", "2");
for (Map.Entry<String, String> entry : entries.entrySet()) storeClient.put(entry.getKey(), entry.getValue());
}
use of voldemort.store.socket.SocketStoreFactory in project voldemort by voldemort.
the class HintedHandoffSendHintTest method setUp.
@Before
public void setUp() throws Exception {
if (logger.isDebugEnabled()) {
logger.debug("Test Started: replication[" + REPLICATION_FACTOR + "], preferredW[" + P_WRITES + "], requiredW[" + R_WRITES + "]");
}
cluster = getNineNodeCluster();
storeDef = getStoreDef();
// create voldemort servers
for (Integer nodeId = 0; nodeId < NUM_NODES_TOTAL; nodeId++) {
SocketStoreFactory socketStoreFactory;
socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 1024);
List<StoreDefinition> stores = new ArrayList<StoreDefinition>();
stores.add(storeDef);
VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, nodeId, TestUtils.createTempDir().getAbsolutePath(), cluster, stores, new Properties());
config.setNioAdminConnectorSelectors(1);
config.setNioConnectorSelectors(2);
VoldemortServer vs = ServerTestUtils.startVoldemortServer(socketStoreFactory, config);
VoldemortService vsrv = vs.getService(ServiceType.STORAGE);
StorageService ss = (StorageService) vsrv;
voldemortServers.put(nodeId, vs);
slopStorageEngines.put(nodeId, ss.getStoreRepository().getSlopStore());
slopStores.put(nodeId, SerializingStore.wrap(ss.getStoreRepository().getSlopStore(), new ByteArraySerializer(), new SlopSerializer(), new IdentitySerializer()));
// wrap original store with force fail store
Store<ByteArray, byte[], byte[]> store = ss.getStoreRepository().removeLocalStore(STORE_NAME);
UnreachableStoreException exception = new UnreachableStoreException("Force failed");
ForceFailStore<ByteArray, byte[], byte[]> forceFailStore = new ForceFailStore<ByteArray, byte[], byte[]>(store, exception);
forceFailStores.put(nodeId, forceFailStore);
ss.getStoreRepository().addLocalStore(forceFailStore);
}
strategy = new RoutingStrategyFactory().updateRoutingStrategy(storeDef, cluster);
// create client socket stores and slop stores
SocketStoreClientFactoryForTest clientSocketStoreFactory = new SocketStoreClientFactoryForTest(STORE_NAME, SLOP_STORE_NAME);
Serializer<ByteArray> slopKeySerializer = new ByteArraySerializer();
Serializer<Slop> slopValueSerializer = new SlopSerializer();
Map<Integer, Store<ByteArray, byte[], byte[]>> testStores = subStores;
Map<Integer, Store<ByteArray, Slop, byte[]>> slopStores = new HashMap<Integer, Store<ByteArray, Slop, byte[]>>();
for (Node node : cluster.getNodes()) {
// test store
SocketStore socketTestStore = clientSocketStoreFactory.getSocketTestStoreByNode(node);
socketTestStores.put(node.getId(), socketTestStore);
testStores.put(node.getId(), socketTestStore);
// slop store
SocketStore socketSlopStore = clientSocketStoreFactory.getSocketSlopStoreByNode(node);
Store<ByteArray, Slop, byte[]> slopStore = SerializingStore.wrap(socketSlopStore, slopKeySerializer, slopValueSerializer, new IdentitySerializer());
socketSlopStores.put(node.getId(), socketSlopStore);
slopStores.put(node.getId(), slopStore);
}
// set failure detector
if (failureDetector != null)
failureDetector.destroy();
FailureDetectorConfig failureDetectorConfig = new FailureDetectorConfig();
failureDetectorConfig.setImplementationClassName(failureDetectorCls.getName());
failureDetectorConfig.setThreshold(50);
failureDetectorConfig.setCluster(cluster);
failureDetectorConfig.setConnectionVerifier(MutableStoreConnectionVerifier.create(subStores));
failureDetector = FailureDetectorUtils.create(failureDetectorConfig, false);
// make routedStore
RoutedStoreFactory factory = new RoutedStoreFactory();
routedStore = factory.create(cluster, storeDef, testStores, socketTestStores, slopStores, socketSlopStores, failureDetector, new RoutedStoreConfig().setTimeoutConfig(new TimeoutConfig(1500L, false)));
// generate the keys
for (int i = 0; i < 5; i++) {
Set<Integer> nodesCovered = Sets.newHashSet();
while (nodesCovered.size() < NUM_NODES_TOTAL) {
ByteArray randomKey = new ByteArray(TestUtils.randomBytes(KEY_LENGTH));
byte[] randomValue = TestUtils.randomBytes(VALUE_LENGTH);
if (randomKey.length() > 0 && randomValue.length > 0) {
if (!keyList.contains(randomKey)) {
for (Node node : strategy.routeRequest(randomKey.get())) {
keysToNodes.put(randomKey, node.getId());
nodesCovered.add(node.getId());
}
logger.info("Inserting key [" + randomKey + "] to key list as id:" + keyList.size());
keyList.add(randomKey);
keyValues.put(randomKey, new ByteArray(randomValue));
}
}
}
}
}
use of voldemort.store.socket.SocketStoreFactory in project voldemort by voldemort.
the class ZoneShrinkageEndToEndTest method setup.
@Before
public void setup() throws IOException {
// setup and start servers
for (Node node : cluster.getNodes()) {
String tempFolderPath = TestUtils.createTempDir().getAbsolutePath();
// setup servers
SocketStoreFactory ssf = new TestSocketStoreFactory();
VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, node.getId(), tempFolderPath, cluster, storeDefs, new Properties());
Assert.assertTrue(config.isSlopEnabled());
Assert.assertTrue(config.isSlopPusherJobEnabled());
Assert.assertTrue(config.getAutoPurgeDeadSlops());
config.setSlopFrequencyMs(10000L);
VoldemortServer vs = ServerTestUtils.startVoldemortServer(ssf, config, cluster);
vservers.put(node.getId(), vs);
socketStoreFactories.put(node.getId(), ssf);
voldemortConfigs.put(node.getId(), config);
}
for (Node node : cluster.getNodes()) {
if (node.getZoneId() != droppingZoneId) {
survivingNodes.add(node);
}
}
bootstrapURL = survivingNodes.get(0).getSocketUrl().toString();
}
use of voldemort.store.socket.SocketStoreFactory in project voldemort by voldemort.
the class ReplaceNodeTest method testNodeDownReplacement.
@Test
public void testNodeDownReplacement() throws Exception {
final int REPLACEMENT_NODE = 0;
// This is to simulate the case where a machine failed but hard disk was intact
// In this case we will move the hard disk to another machine, edit the cluster.xml
// to point to this host and start this machine.
// The case is simulated by remembering the cluster of node A.
// Replace this node with node B. Now create a new server with cluster of
// node A ( this is to simulate the cluster.xml edit) and data directory of B
// ( this is to simulate the hard disk move). Now try replacing the node B with
// newly created node after shutting down the node B.
Cluster cluster = originalServers[nodeToBeReplaced].getMetadataStore().getCluster();
List<StoreDefinition> storeDefs = originalServers[nodeToBeReplaced].getMetadataStore().getStoreDefList();
Node node = originalServers[nodeToBeReplaced].getIdentityNode();
// Verify the node down scenario first
final boolean DO_RESTORE = false;
final boolean STOP_OLD_NODE = true;
verifyNodeReplacement(nodeToBeReplaced, otherServers, REPLACEMENT_NODE, STOP_OLD_NODE, DO_RESTORE);
// Now the replacement node is part of the original cluster.
// Stop the replacement node, assume you moved the hard disk
// to a new node ( This is done by starting another node)
// that points to the data directory of the replacement node.
String baseDirPath = otherServers[REPLACEMENT_NODE].getVoldemortConfig().getVoldemortHome();
// Using ServerTestUtils stopVoldemortServer also deletes the data
// directory so using the stop, to simulate the hard disk move.
otherServers[REPLACEMENT_NODE].stop();
VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, node.getId(), baseDirPath, cluster, storeDefs, new Properties());
Assert.assertTrue(config.isSlopEnabled());
Assert.assertTrue(config.isSlopPusherJobEnabled());
Assert.assertTrue(config.getAutoPurgeDeadSlops());
config.setSlopFrequencyMs(8000L);
config.setEnableNodeIdDetection(this.autoDetectNodeId);
if (this.autoDetectNodeId) {
config.setNodeIdImplementation(new NodeIdHostMatcher(nodeToBeReplaced));
}
// Though baseDir is used as part of Config, TestUtils, always appends
// it with node- (nodeId). So forcefully overwriting it here to point to
// the old directory.
config.setVoldemortHome(baseDirPath);
SocketStoreFactory ssf = new TestSocketStoreFactory();
VoldemortServer hardDiskMovedServer = ServerTestUtils.startVoldemortServer(ssf, config, cluster);
ssf.close();
otherServers[REPLACEMENT_NODE] = hardDiskMovedServer;
final boolean SKIP_RESTORE = true;
final boolean DONOT_STOP_OLD_NODE = true;
verifyNodeReplacement(nodeToBeReplaced, otherServers, REPLACEMENT_NODE, DONOT_STOP_OLD_NODE, SKIP_RESTORE);
}
Aggregations