Search in sources :

Example 46 with VoldemortServer

use of voldemort.server.VoldemortServer in project voldemort by voldemort.

the class SetMetadataTest method setup.

/**
     * This test is to partially test the functionality of SetMetadata feature
     * of the VoldemortAdminTool
     */
@Before
public void setup() throws IOException {
    // setup cluster
    cluster = ClusterTestUtils.getZZZCluster();
    oldStores = ClusterTestUtils.getZZZStoreDefsInMemory();
    bsURL = cluster.getNodes().iterator().next().getSocketUrl().toString();
    for (Node node : cluster.getNodes()) {
        SocketStoreFactory ssf = new ClientRequestExecutorPool(2, 10000, 100000, 1024);
        VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, node.getId(), TestUtils.createTempDir().getAbsolutePath(), cluster, oldStores, new Properties());
        VoldemortServer vs = ServerTestUtils.startVoldemortServer(ssf, config, cluster);
        vservers.put(node.getId(), vs);
        socketStoreFactories.put(node.getId(), ssf);
    }
}
Also used : ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) Node(voldemort.cluster.Node) SocketStoreFactory(voldemort.store.socket.SocketStoreFactory) Properties(java.util.Properties) VoldemortServer(voldemort.server.VoldemortServer) VoldemortConfig(voldemort.server.VoldemortConfig) Before(org.junit.Before)

Example 47 with VoldemortServer

use of voldemort.server.VoldemortServer in project voldemort by voldemort.

the class SetMetadataTest method testSetMetadataStoreXmlVerifyVersionUpdate.

@Test
public void testSetMetadataStoreXmlVerifyVersionUpdate() throws Exception {
    // setup new stores xml
    final String newStoreXMLFilePrefix = "updated.stores";
    final String newStoreXMLFileSuffix = "xml";
    List<StoreDefinition> newStores = new ArrayList<StoreDefinition>();
    for (StoreDefinition storeDef : ClusterTestUtils.getZZZStoreDefsInMemory()) {
        StoreDefinitionBuilder sb = storeDefToBuilder(storeDef);
        Map<Integer, Integer> zrf = sb.getZoneReplicationFactor();
        Integer zone0RepFactor = zrf.get(0);
        zrf.remove(0);
        sb.setReplicationFactor(sb.getReplicationFactor() - zone0RepFactor);
        newStores.add(sb.build());
    }
    File newStoresXMLFolder = TestUtils.createTempDir();
    File newStoreXMLFile = File.createTempFile(newStoreXMLFilePrefix, newStoreXMLFileSuffix, newStoresXMLFolder);
    FileWriter fwriter = new FileWriter(newStoreXMLFile);
    fwriter.write(new StoreDefinitionsMapper().writeStoreList(newStores));
    fwriter.close();
    // check version
    String sysStoreName = SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name();
    ByteArray metadataKey = new ByteArray(ByteUtils.getBytes(SystemStoreConstants.VERSIONS_METADATA_KEY, "utf-8"));
    for (VoldemortServer vs : vservers.values()) {
        List<Versioned<byte[]>> result = vs.getStoreRepository().getLocalStore(sysStoreName).get(metadataKey, null);
        String versionInfo = new String(result.get(0).getValue());
        System.out.format("[INITIAL]Version values on node [%d] is: \n %s\n", vs.getIdentityNode().getId(), versionInfo);
        Properties props = new Properties();
        props.load(new ByteArrayInputStream(versionInfo.getBytes()));
        for (StoreDefinition sd : oldStores) {
            if (!props.getProperty(sd.getName()).equals("0")) {
                Assert.fail("Initial version of key [" + sd.getName() + "] on node [" + vs.getIdentityNode().getId() + "] is expected to be 0 but not");
            }
        }
        if (!props.getProperty("cluster.xml").equals("0")) {
            Assert.fail("Final version of key [stores.xml] on node [" + vs.getIdentityNode().getId() + "] is expected to greater than 0 but not");
        }
    }
    // update the stores xml
    VoldemortAdminTool.main(new String[] { "--auto", "--set-metadata", MetadataStore.STORES_KEY, "--set-metadata-value", newStoreXMLFile.getAbsolutePath(), "--url", bsURL });
    // properly
    try {
        Thread.sleep(10000);
    } catch (Exception e) {
    }
    // check version
    for (VoldemortServer vs : vservers.values()) {
        List<Versioned<byte[]>> result = vs.getStoreRepository().getLocalStore(sysStoreName).get(metadataKey, null);
        String versionInfo = new String(result.get(0).getValue());
        System.out.format("[FINAL]Version values on node [%d] is: \n %s\n", vs.getIdentityNode().getId(), versionInfo);
        Properties props = new Properties();
        props.load(new ByteArrayInputStream(versionInfo.getBytes()));
        for (StoreDefinition sd : oldStores) {
            if (!(Long.parseLong(props.getProperty(sd.getName())) > 0)) {
                Assert.fail("Final version of key [" + sd.getName() + "] on node [" + vs.getIdentityNode().getId() + "] is expected to greater than 0 but not");
            }
        }
        if (!(Long.parseLong(props.getProperty("stores.xml")) > 0)) {
            Assert.fail("Final version of key [stores.xml] on node [" + vs.getIdentityNode().getId() + "] is expected to greater than 0 but not");
        }
    }
}
Also used : StoreDefinitionBuilder(voldemort.store.StoreDefinitionBuilder) Versioned(voldemort.versioning.Versioned) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) VoldemortServer(voldemort.server.VoldemortServer) Properties(java.util.Properties) IOException(java.io.IOException) ByteArrayInputStream(java.io.ByteArrayInputStream) StoreDefinition(voldemort.store.StoreDefinition) ByteArray(voldemort.utils.ByteArray) File(java.io.File) Test(org.junit.Test)

Example 48 with VoldemortServer

use of voldemort.server.VoldemortServer in project voldemort by voldemort.

the class StoreOperationsTest method setup.

@Before
public void setup() throws IOException {
    // setup cluster
    cluster = ServerTestUtils.getLocalCluster(2);
    stores = ServerTestUtils.getStoreDefs(2);
    bsURL = cluster.getNodes().iterator().next().getSocketUrl().toString();
    for (Node node : cluster.getNodes()) {
        SocketStoreFactory ssf = new ClientRequestExecutorPool(2, 10000, 100000, 1024);
        VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, node.getId(), TestUtils.createTempDir().getAbsolutePath(), cluster, stores, new Properties());
        VoldemortServer vs = ServerTestUtils.startVoldemortServer(ssf, config, cluster);
        vservers.put(node.getId(), vs);
        socketStoreFactories.put(node.getId(), ssf);
    }
    adminClient = new AdminClient(cluster);
}
Also used : ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) Node(voldemort.cluster.Node) SocketStoreFactory(voldemort.store.socket.SocketStoreFactory) Properties(java.util.Properties) VoldemortServer(voldemort.server.VoldemortServer) VoldemortConfig(voldemort.server.VoldemortConfig) AdminClient(voldemort.client.protocol.admin.AdminClient) Before(org.junit.Before)

Example 49 with VoldemortServer

use of voldemort.server.VoldemortServer 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 50 with VoldemortServer

use of voldemort.server.VoldemortServer in project voldemort by voldemort.

the class SystemStoreTest 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();
    ClientConfig clientConfig = new ClientConfig().setMaxTotalConnections(4).setMaxConnectionsPerNode(4).setBootstrapUrls(socketUrl);
    SocketStoreClientFactory socketFactory = new SocketStoreClientFactory(clientConfig);
    bootStrapUrls = new String[1];
    bootStrapUrls[0] = socketUrl;
    clusterXml = ((AbstractStoreClientFactory) socketFactory).bootstrapMetadataWithRetries(MetadataStore.CLUSTER_KEY);
}
Also used : SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) Properties(java.util.Properties) VoldemortServer(voldemort.server.VoldemortServer) ClientConfig(voldemort.client.ClientConfig) VoldemortConfig(voldemort.server.VoldemortConfig) Before(org.junit.Before)

Aggregations

VoldemortServer (voldemort.server.VoldemortServer)86 Properties (java.util.Properties)36 VoldemortConfig (voldemort.server.VoldemortConfig)24 Test (org.junit.Test)23 Node (voldemort.cluster.Node)23 Before (org.junit.Before)21 SocketStoreFactory (voldemort.store.socket.SocketStoreFactory)20 ClientRequestExecutorPool (voldemort.store.socket.clientrequest.ClientRequestExecutorPool)18 ClientConfig (voldemort.client.ClientConfig)17 ByteArray (voldemort.utils.ByteArray)17 ArrayList (java.util.ArrayList)16 After (org.junit.After)15 StoreDefinition (voldemort.store.StoreDefinition)15 SocketStoreClientFactory (voldemort.client.SocketStoreClientFactory)14 Cluster (voldemort.cluster.Cluster)14 IOException (java.io.IOException)11 HashMap (java.util.HashMap)11 AdminClient (voldemort.client.protocol.admin.AdminClient)11 VectorClock (voldemort.versioning.VectorClock)10 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)9