Search in sources :

Example 1 with CoordinatorConfig

use of voldemort.rest.coordinator.config.CoordinatorConfig in project voldemort by voldemort.

the class RestClientTest method setUp.

@Override
@Before
public void setUp() throws IOException {
    final int numServers = 1;
    this.nodeId = 0;
    this.time = SystemTime.INSTANCE;
    servers = new VoldemortServer[numServers];
    int[][] partitionMap = { { 0, 1, 2, 3, 4, 5, 6, 7 } };
    try {
        // Setup the cluster
        cluster = ServerTestUtils.startVoldemortCluster(numServers, servers, partitionMap, socketStoreFactory, true, null, storesXmlfile, new Properties());
    } catch (IOException e) {
        fail("Failure to setup the cluster");
    }
    socketUrl = servers[0].getIdentityNode().getSocketUrl().toString();
    List<String> bootstrapUrls = new ArrayList<String>();
    bootstrapUrls.add(socketUrl);
    // create a copy of the config file in a temp directory and work on that
    File src = new File(FAT_CLIENT_CONFIG_PATH_ORIGINAL);
    COPY_OF_FAT_CLIENT_CONFIG_FILE = new File(TestUtils.createTempDir(), "clientConfigs" + System.currentTimeMillis() + ".avro");
    FileUtils.copyFile(src, COPY_OF_FAT_CLIENT_CONFIG_FILE);
    // Setup the Coordinator
    CoordinatorConfig coordinatorConfig = new CoordinatorConfig();
    coordinatorConfig.setBootstrapURLs(bootstrapUrls).setCoordinatorCoreThreads(100).setCoordinatorMaxThreads(100).setFatClientConfigPath(COPY_OF_FAT_CLIENT_CONFIG_FILE.getAbsolutePath()).setServerPort(9999);
    try {
        StoreClientConfigService storeClientConfigs = null;
        switch(coordinatorConfig.getFatClientConfigSource()) {
            case FILE:
                storeClientConfigs = new FileBasedStoreClientConfigService(coordinatorConfig);
                break;
            case ZOOKEEPER:
                throw new UnsupportedOperationException("Zookeeper-based configs are not implemented yet!");
            default:
                storeClientConfigs = null;
        }
        coordinator = new CoordinatorProxyService(coordinatorConfig, storeClientConfigs);
        coordinator.start();
    } catch (Exception e) {
        e.printStackTrace();
        fail("Failure to start the Coordinator");
    }
    Properties props = new Properties();
    props.setProperty(ClientConfig.BOOTSTRAP_URLS_PROPERTY, "http://localhost:9999");
    props.setProperty(ClientConfig.ROUTING_TIMEOUT_MS_PROPERTY, "1500");
    RESTClientFactoryConfig mainConfig = new RESTClientFactoryConfig(props, null);
    RESTClientFactory factory = new RESTClientFactory(mainConfig);
    this.client = factory.getStoreClient(STORE_NAME);
}
Also used : FileBasedStoreClientConfigService(voldemort.rest.coordinator.config.FileBasedStoreClientConfigService) ArrayList(java.util.ArrayList) RESTClientFactoryConfig(voldemort.restclient.RESTClientFactoryConfig) IOException(java.io.IOException) Properties(java.util.Properties) ObsoleteVersionException(voldemort.versioning.ObsoleteVersionException) IOException(java.io.IOException) RESTClientFactory(voldemort.restclient.RESTClientFactory) CoordinatorProxyService(voldemort.rest.coordinator.CoordinatorProxyService) StoreClientConfigService(voldemort.rest.coordinator.config.StoreClientConfigService) FileBasedStoreClientConfigService(voldemort.rest.coordinator.config.FileBasedStoreClientConfigService) CoordinatorConfig(voldemort.rest.coordinator.config.CoordinatorConfig) File(java.io.File) Before(org.junit.Before)

Example 2 with CoordinatorConfig

use of voldemort.rest.coordinator.config.CoordinatorConfig in project voldemort by voldemort.

the class CoordinatorRestAPITest method setUp.

@Before
public void setUp() throws Exception {
    int numServers = 1;
    servers = new VoldemortServer[numServers];
    int[][] partitionMap = { { 0, 2, 4, 6, 1, 3, 5, 7 } };
    Properties props = new Properties();
    props.setProperty("storage.configs", "voldemort.store.bdb.BdbStorageConfiguration,voldemort.store.slow.SlowStorageConfiguration");
    props.setProperty("testing.slow.queueing.get.ms", "4");
    props.setProperty("testing.slow.queueing.getall.ms", "4");
    props.setProperty("testing.slow.queueing.put.ms", "4");
    props.setProperty("testing.slow.queueing.delete.ms", "4");
    ServerTestUtils.startVoldemortCluster(numServers, servers, partitionMap, socketStoreFactory, // useNio
    true, null, STORES_XML, props);
    // create a copy of the config file in a temp directory and work on that
    File src = new File(FAT_CLIENT_CONFIG_FILE_PATH_ORIGINAL);
    COPY_OF_FAT_CLIENT_CONFIG_FILE = new File(TestUtils.createTempDir(), "fat-client-config" + System.currentTimeMillis() + ".avro");
    FileUtils.copyFile(src, COPY_OF_FAT_CLIENT_CONFIG_FILE);
    CoordinatorConfig config = new CoordinatorConfig();
    List<String> bootstrapUrls = new ArrayList<String>();
    socketUrl = servers[0].getIdentityNode().getSocketUrl().toString();
    bootstrapUrls.add(socketUrl);
    System.out.println("\n\n************************ Starting the Coordinator *************************");
    config.setBootstrapURLs(bootstrapUrls);
    config.setFatClientConfigPath(COPY_OF_FAT_CLIENT_CONFIG_FILE.getAbsolutePath());
    StoreClientConfigService storeClientConfigs = null;
    switch(config.getFatClientConfigSource()) {
        case FILE:
            storeClientConfigs = new FileBasedStoreClientConfigService(config);
            break;
        case ZOOKEEPER:
            throw new UnsupportedOperationException("Zookeeper-based configs are not implemented yet!");
        default:
            storeClientConfigs = null;
    }
    this.coordinator = new CoordinatorProxyService(config, storeClientConfigs);
    if (!this.coordinator.isStarted()) {
        this.coordinator.start();
    }
}
Also used : FileBasedStoreClientConfigService(voldemort.rest.coordinator.config.FileBasedStoreClientConfigService) CoordinatorProxyService(voldemort.rest.coordinator.CoordinatorProxyService) StoreClientConfigService(voldemort.rest.coordinator.config.StoreClientConfigService) FileBasedStoreClientConfigService(voldemort.rest.coordinator.config.FileBasedStoreClientConfigService) ArrayList(java.util.ArrayList) Properties(java.util.Properties) CoordinatorConfig(voldemort.rest.coordinator.config.CoordinatorConfig) File(java.io.File) Before(org.junit.Before)

Example 3 with CoordinatorConfig

use of voldemort.rest.coordinator.config.CoordinatorConfig in project voldemort by voldemort.

the class CoordinatorServer method main.

public static void main(String[] args) throws Exception {
    CoordinatorConfig config = null;
    try {
        if (args.length != 1) {
            croak("USAGE: java " + CoordinatorProxyService.class.getName() + " <coordinator_config_file>");
            System.exit(-1);
        }
        config = new CoordinatorConfig(new File(args[0]));
    } catch (Exception e) {
        logger.error(e);
        Utils.croak("Error while loading configuration: " + e.getMessage());
    }
    final CoordinatorServer coordinatorServer = new CoordinatorServer(config);
    if (!coordinatorServer.isStarted()) {
        coordinatorServer.start();
    }
}
Also used : CoordinatorConfig(voldemort.rest.coordinator.config.CoordinatorConfig) File(java.io.File) VoldemortException(voldemort.VoldemortException)

Example 4 with CoordinatorConfig

use of voldemort.rest.coordinator.config.CoordinatorConfig in project voldemort by voldemort.

the class CoordinatorRestAPITest method testLargeValueSizeVersionedPut.

@Test
public void testLargeValueSizeVersionedPut() {
    String key = "amigo";
    String payload = generateRandomString(new CoordinatorConfig().getHttpMessageDecoderMaxChunkSize() * 10, ValueType.ALPHA);
    String newPayload = generateRandomString(new CoordinatorConfig().getHttpMessageDecoderMaxChunkSize() * 10, ValueType.ALPHA);
    // 1. Do a put
    doPut(key, payload, null);
    // 2. Do a get on the same key
    TestVersionedValue response = doGet(key, null);
    if (response == null) {
        fail("key does not exist after a put. ");
    }
    System.out.println("Received value: " + response.getValue());
    // 3. Do a versioned put based on the version received previously
    doPut(key, newPayload, response.getVc());
    // 4. Do a get again on the same key
    TestVersionedValue newResponse = doGet(key);
    if (newResponse == null) {
        fail("key does not exist after the versioned put. ");
    }
    assertEquals("Returned response does not have a higer version", Occurred.AFTER, newResponse.getVc().compare(response.getVc()));
    assertEquals("Returned response does not have a higer version", Occurred.BEFORE, response.getVc().compare(newResponse.getVc()));
    System.out.println("Received value after the Versioned put: " + newResponse.getValue());
    if (!newResponse.getValue().equals(newPayload)) {
        fail("Received value is incorrect ! Expected : " + newPayload + " but got : " + newResponse.getValue());
    }
}
Also used : CoordinatorConfig(voldemort.rest.coordinator.config.CoordinatorConfig) Test(org.junit.Test)

Example 5 with CoordinatorConfig

use of voldemort.rest.coordinator.config.CoordinatorConfig in project voldemort by voldemort.

the class CoordinatorAdminClientTest method setUp.

@Before
public void setUp() throws Exception {
    final int numServers = 1;
    servers = new VoldemortServer[numServers];
    int[][] partitionMap = { { 0, 1, 2, 3, 4, 5, 6, 7 } };
    try {
        // Setup the cluster
        cluster = ServerTestUtils.startVoldemortCluster(numServers, servers, partitionMap, socketStoreFactory, true, null, storesXmlfile, new Properties());
    } catch (IOException e) {
        fail("Failure to setup the cluster");
    }
    socketUrl = servers[0].getIdentityNode().getSocketUrl().toString();
    List<String> bootstrapUrls = new ArrayList<String>();
    bootstrapUrls.add(socketUrl);
    // create a copy of the config file in a temp directory and work on that
    File src = new File(FAT_CLIENT_CONFIG_PATH_ORIGINAL);
    COPY_Of_FAT_CLIENT_CONFIG_FILE = new File(TestUtils.createTempDir(), "clientConfigs_" + System.currentTimeMillis() + ".avro");
    FileUtils.copyFile(src, COPY_Of_FAT_CLIENT_CONFIG_FILE);
    // Setup the Coordinator
    CoordinatorConfig coordinatorConfig = new CoordinatorConfig();
    coordinatorConfig.setBootstrapURLs(bootstrapUrls).setCoordinatorCoreThreads(100).setCoordinatorMaxThreads(100).setFatClientConfigPath(COPY_Of_FAT_CLIENT_CONFIG_FILE.getAbsolutePath()).setServerPort(SERVER_PORT).setAdminPort(ADMIN_PORT);
    try {
        coordinator = new CoordinatorServer(coordinatorConfig);
        coordinator.start();
    } catch (Exception e) {
        e.printStackTrace();
        fail("Failure to start the Coordinator");
    }
    Properties props = new Properties();
    props.setProperty(ClientConfig.BOOTSTRAP_URLS_PROPERTY, BOOTSTRAP_URL);
    props.setProperty(ClientConfig.ROUTING_TIMEOUT_MS_PROPERTY, "1500");
    this.adminClient = new CoordinatorAdminClient(new RESTClientConfig(props));
}
Also used : CoordinatorServer(voldemort.rest.coordinator.CoordinatorServer) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Properties(java.util.Properties) CoordinatorAdminClient(voldemort.restclient.admin.CoordinatorAdminClient) IOException(java.io.IOException) RESTClientConfig(voldemort.restclient.RESTClientConfig) CoordinatorConfig(voldemort.rest.coordinator.config.CoordinatorConfig) File(java.io.File) Before(org.junit.Before)

Aggregations

CoordinatorConfig (voldemort.rest.coordinator.config.CoordinatorConfig)6 File (java.io.File)5 ArrayList (java.util.ArrayList)4 Properties (java.util.Properties)4 Before (org.junit.Before)4 IOException (java.io.IOException)3 CoordinatorProxyService (voldemort.rest.coordinator.CoordinatorProxyService)2 CoordinatorServer (voldemort.rest.coordinator.CoordinatorServer)2 FileBasedStoreClientConfigService (voldemort.rest.coordinator.config.FileBasedStoreClientConfigService)2 StoreClientConfigService (voldemort.rest.coordinator.config.StoreClientConfigService)2 RESTClientConfig (voldemort.restclient.RESTClientConfig)2 CoordinatorAdminClient (voldemort.restclient.admin.CoordinatorAdminClient)2 Test (org.junit.Test)1 VoldemortException (voldemort.VoldemortException)1 RESTClientFactory (voldemort.restclient.RESTClientFactory)1 RESTClientFactoryConfig (voldemort.restclient.RESTClientFactoryConfig)1 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)1