Search in sources :

Example 1 with SystemStoreClientFactory

use of voldemort.client.SystemStoreClientFactory in project voldemort by voldemort.

the class AsyncMetadataVersionManagerTest method setUp.

@Before
public void setUp() throws Exception {
    servers = new VoldemortServer[cluster.getNodeIds().size()];
    int i = 0;
    for (Integer nodeId : cluster.getNodeIds()) {
        VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, nodeId, TestUtils.createTempDir().getAbsolutePath(), cluster, storeDefs, new Properties());
        VoldemortServer server = ServerTestUtils.startVoldemortServer(socketStoreFactory, config);
        servers[i++] = server;
    }
    socketUrl = servers[0].getIdentityNode().getSocketUrl().toString();
    bootStrapUrls = new String[1];
    bootStrapUrls[0] = socketUrl;
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(clientZoneId);
    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);
}
Also used : SchedulerService(voldemort.common.service.SchedulerService) SystemStoreClientFactory(voldemort.client.SystemStoreClientFactory) SystemStoreRepository(voldemort.client.SystemStoreRepository) Properties(java.util.Properties) VoldemortServer(voldemort.server.VoldemortServer) ClientConfig(voldemort.client.ClientConfig) VoldemortConfig(voldemort.server.VoldemortConfig) Before(org.junit.Before)

Example 2 with SystemStoreClientFactory

use of voldemort.client.SystemStoreClientFactory in project voldemort by voldemort.

the class SystemStoreTest method testCustomClusterXmlStore.

@Test
public void testCustomClusterXmlStore() {
    try {
        ClientConfig clientConfig = new ClientConfig();
        clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(this.clientZoneId);
        SystemStoreClientFactory<String, String> systemStoreFactory = new SystemStoreClientFactory<String, String>(clientConfig);
        SystemStoreClient<String, String> sysVersionStore = systemStoreFactory.createSystemStore(SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name(), this.clusterXml, null);
        long storesVersion = 1;
        sysVersionStore.putSysStore("stores.xml", Long.toString(storesVersion));
        long version = Long.parseLong(sysVersionStore.getValueSysStore("stores.xml"));
        assertEquals("Received incorrect version from the voldsys$_metadata_version system store", storesVersion, version);
    } catch (Exception e) {
        fail("Failed to create System Store with custom cluster Xml: " + e.getMessage());
    }
}
Also used : SystemStoreClientFactory(voldemort.client.SystemStoreClientFactory) ClientConfig(voldemort.client.ClientConfig) Test(org.junit.Test)

Example 3 with SystemStoreClientFactory

use of voldemort.client.SystemStoreClientFactory 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++;
    }
}
Also used : SchedulerService(voldemort.common.service.SchedulerService) SystemStoreClientFactory(voldemort.client.SystemStoreClientFactory) FileWriter(java.io.FileWriter) SystemStoreRepository(voldemort.client.SystemStoreRepository) ArrayList(java.util.ArrayList) AsyncMetadataVersionManager(voldemort.client.scheduler.AsyncMetadataVersionManager) VoldemortServer(voldemort.server.VoldemortServer) Properties(java.util.Properties) Callable(java.util.concurrent.Callable) BufferedWriter(java.io.BufferedWriter) StoreDefinition(voldemort.store.StoreDefinition) ClientConfig(voldemort.client.ClientConfig) StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) SocketStoreFactory(voldemort.store.socket.SocketStoreFactory) Date(java.util.Date) ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) File(java.io.File) SerializerDefinition(voldemort.serialization.SerializerDefinition) Before(org.junit.Before)

Example 4 with SystemStoreClientFactory

use of voldemort.client.SystemStoreClientFactory in project voldemort by voldemort.

the class SystemStoreTest method testBasicStore.

@Test
public void testBasicStore() {
    try {
        ClientConfig clientConfig = new ClientConfig();
        clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(this.clientZoneId);
        SystemStoreClientFactory<String, String> systemStoreFactory = new SystemStoreClientFactory<String, String>(clientConfig);
        SystemStoreClient<String, String> sysVersionStore = systemStoreFactory.createSystemStore(SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name());
        long storesVersion = 1;
        sysVersionStore.putSysStore("stores.xml", Long.toString(storesVersion));
        long version = Long.parseLong(sysVersionStore.getValueSysStore("stores.xml"));
        assertEquals("Received incorrect version from the voldsys$_metadata_version system store", storesVersion, version);
    } catch (Exception e) {
        fail("Failed to create the default System Store : " + e.getMessage());
    }
}
Also used : SystemStoreClientFactory(voldemort.client.SystemStoreClientFactory) ClientConfig(voldemort.client.ClientConfig) Test(org.junit.Test)

Example 5 with SystemStoreClientFactory

use of voldemort.client.SystemStoreClientFactory in project voldemort by voldemort.

the class SystemStoreTest method testIllegalSystemStore.

@Test
public void testIllegalSystemStore() {
    try {
        ClientConfig clientConfig = new ClientConfig();
        clientConfig.setBootstrapUrls(bootStrapUrls).setClientZoneId(this.clientZoneId);
        SystemStoreClientFactory<String, String> systemStoreFactory = new SystemStoreClientFactory<String, String>(clientConfig);
        SystemStoreClient sysVersionStore = systemStoreFactory.createSystemStore("test-store", this.clusterXml, null);
        fail("Should not execute this. We can only connect to system store with a 'voldsys$' prefix.");
    } catch (Exception e) {
    // This is fine.
    }
}
Also used : SystemStoreClientFactory(voldemort.client.SystemStoreClientFactory) SystemStoreClient(voldemort.client.SystemStoreClient) ClientConfig(voldemort.client.ClientConfig) Test(org.junit.Test)

Aggregations

ClientConfig (voldemort.client.ClientConfig)5 SystemStoreClientFactory (voldemort.client.SystemStoreClientFactory)5 Test (org.junit.Test)3 Properties (java.util.Properties)2 Before (org.junit.Before)2 SystemStoreRepository (voldemort.client.SystemStoreRepository)2 SchedulerService (voldemort.common.service.SchedulerService)2 VoldemortServer (voldemort.server.VoldemortServer)2 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Callable (java.util.concurrent.Callable)1 SystemStoreClient (voldemort.client.SystemStoreClient)1 AsyncMetadataVersionManager (voldemort.client.scheduler.AsyncMetadataVersionManager)1 SerializerDefinition (voldemort.serialization.SerializerDefinition)1 VoldemortConfig (voldemort.server.VoldemortConfig)1 StoreDefinition (voldemort.store.StoreDefinition)1 StoreDefinitionBuilder (voldemort.store.StoreDefinitionBuilder)1