Search in sources :

Example 51 with VoldemortConfig

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

the class ServerTestUtils method restartServer.

public static VoldemortServer restartServer(VoldemortServer oldServer, int nodeId, Cluster cluster, Properties serverProps) throws Exception {
    ServerTestUtils.stopVoldemortServer(oldServer);
    String baseDirPath = oldServer.getVoldemortConfig().getVoldemortHome();
    String parentDirPath = Paths.get(baseDirPath).getParent().toString();
    List<StoreDefinition> storeDefs = oldServer.getMetadataStore().getStoreDefList();
    final boolean ENABLE_NIO = true;
    VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(ENABLE_NIO, nodeId, parentDirPath, cluster, storeDefs, serverProps);
    SocketStoreFactory socketStoreFactory = getSocketStoreFactory();
    try {
        return startVoldemortServer(socketStoreFactory, config, cluster);
    } finally {
        socketStoreFactory.close();
    }
}
Also used : StoreDefinition(voldemort.store.StoreDefinition) SocketStoreFactory(voldemort.store.socket.SocketStoreFactory) VoldemortConfig(voldemort.server.VoldemortConfig)

Example 52 with VoldemortConfig

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

the class ServerJVMTestUtils method createAndInitializeVoldemortHome.

public static String createAndInitializeVoldemortHome(boolean useNio, int node, String storesXmlfile, Cluster cluster) throws IOException {
    VoldemortConfig config = ServerTestUtils.createServerConfig(useNio, node, TestUtils.createTempDir().getAbsolutePath(), null, storesXmlfile, new Properties());
    // Initialize voldemort config dir with all required files.
    // cluster.xml
    File clusterXml = new File(config.getMetadataDirectory() + File.separator + "cluster.xml");
    FileUtils.writeStringToFile(clusterXml, new ClusterMapper().writeCluster(cluster));
    // stores.xml
    File storesXml = new File(config.getMetadataDirectory() + File.separator + "stores.xml");
    FileUtils.copyFile(new File(storesXmlfile), storesXml);
    // server.properties
    File serverProperties = new File(config.getMetadataDirectory() + File.separator + "server.properties");
    FileUtils.writeLines(serverProperties, Arrays.asList("node.id=" + node, "bdb.cache.size=" + 1024 * 1024, "enable.metadata.checking=" + false, "enable.network.classloader=" + false));
    return config.getVoldemortHome();
}
Also used : ClusterMapper(voldemort.xml.ClusterMapper) Properties(java.util.Properties) File(java.io.File) VoldemortConfig(voldemort.server.VoldemortConfig)

Example 53 with VoldemortConfig

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

the class HintedHandoffTestEnvironment method startServer.

/**
     * Start a server How it works:
     * 
     * 1. create a server using test utilities
     * 
     * 2.Inject prepared test store and storage engine
     * 
     * 3. Inject prepared slop store and storage engine
     * 
     * @param nodeId The node of server to start
     * @throws IOException
     */
public void startServer(int nodeId) throws IOException {
    if (logger.isInfoEnabled())
        logger.info("Starting server of node [" + nodeId + "]");
    SocketStoreFactory socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 1024);
    List<StoreDefinition> stores = new ArrayList<StoreDefinition>();
    stores.add(storeDef);
    // start a voldemort server
    VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true, nodeId, TestUtils.createTempDir().getAbsolutePath(), cluster, stores, new Properties());
    config.setNioAdminConnectorSelectors(1);
    config.setNioConnectorSelectors(5);
    config.setSlopFrequencyMs(DEFAULT_SLOP_PUSH_INTERVAL_S * 1000);
    config.setSlopStoreType("memory");
    config.setFailureDetectorAsyncRecoveryInterval(DEFAULT_ASYNC_RECOVERY_INTERVAL_S * 1000);
    VoldemortServer vs = ServerTestUtils.startVoldemortServer(socketStoreFactory, config);
    socketStoreFactory.close();
    voldemortServers.put(nodeId, vs);
    VoldemortService vsrv = vs.getService(ServiceType.STORAGE);
    StoreRepository sr = ((StorageService) vsrv).getStoreRepository();
    // storage engine injection
    sr.removeLocalStore(STORE_NAME);
    sr.addLocalStore(sleepyStores.get(nodeId));
    sr.removeStorageEngine(STORE_NAME);
    sr.addStorageEngine((StorageEngine<ByteArray, byte[], byte[]>) realStores.get(nodeId));
    // slop stores caching and injection
    if (!slopStorageEngines.containsKey(nodeId)) {
        SlopStorageEngine slopStorageEngine = sr.getSlopStore();
        slopStorageEngines.put(nodeId, slopStorageEngine);
    } else {
        sr.removeStorageEngine("slop");
        sr.removeLocalStore("slop");
        sr.addStorageEngine(slopStorageEngines.get(nodeId));
        sr.addLocalStore(slopStorageEngines.get(nodeId));
        sr.setSlopStore(slopStorageEngines.get(nodeId));
    }
}
Also used : ArrayList(java.util.ArrayList) SocketStoreFactory(voldemort.store.socket.SocketStoreFactory) StoreRepository(voldemort.server.StoreRepository) Properties(java.util.Properties) VoldemortServer(voldemort.server.VoldemortServer) VoldemortConfig(voldemort.server.VoldemortConfig) StorageService(voldemort.server.storage.StorageService) VoldemortService(voldemort.common.service.VoldemortService) ClientRequestExecutorPool(voldemort.store.socket.clientrequest.ClientRequestExecutorPool) StoreDefinition(voldemort.store.StoreDefinition) ByteArray(voldemort.utils.ByteArray)

Aggregations

VoldemortConfig (voldemort.server.VoldemortConfig)53 Properties (java.util.Properties)29 VoldemortServer (voldemort.server.VoldemortServer)24 Before (org.junit.Before)18 Node (voldemort.cluster.Node)16 StoreDefinition (voldemort.store.StoreDefinition)16 File (java.io.File)15 Props (voldemort.utils.Props)14 SocketStoreFactory (voldemort.store.socket.SocketStoreFactory)13 ByteArray (voldemort.utils.ByteArray)12 ClientRequestExecutorPool (voldemort.store.socket.clientrequest.ClientRequestExecutorPool)11 Cluster (voldemort.cluster.Cluster)7 Test (org.junit.Test)6 ClientConfig (voldemort.client.ClientConfig)6 SocketStoreClientFactory (voldemort.client.SocketStoreClientFactory)6 BdbStorageConfiguration (voldemort.store.bdb.BdbStorageConfiguration)6 AdminClient (voldemort.client.protocol.admin.AdminClient)5 OptionParser (joptsimple.OptionParser)4 OptionSet (joptsimple.OptionSet)4 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)4