Search in sources :

Example 1 with RESTClientConfig

use of voldemort.restclient.RESTClientConfig 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)

Example 2 with RESTClientConfig

use of voldemort.restclient.RESTClientConfig in project voldemort by voldemort.

the class CoordinatorAdminToolTest 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)

Example 3 with RESTClientConfig

use of voldemort.restclient.RESTClientConfig in project voldemort by voldemort.

the class RestServerAPITest method oneTimeSetUp.

@BeforeClass
public static void oneTimeSetUp() {
    voldemortConfig = VoldemortConfig.loadFromVoldemortHome("config/single_node_rest_server/");
    key = new ByteArray("key1".getBytes());
    vectorClock = new VectorClock();
    vectorClock.incrementVersion(voldemortConfig.getNodeId(), System.currentTimeMillis());
    value = new Versioned<byte[]>("value1".getBytes(), vectorClock);
    server = new VoldemortServer(voldemortConfig);
    if (!server.isStarted())
        server.start();
    logger.info("********************Starting REST Server********************");
    restClientConfig = new RESTClientConfig();
    restClientConfig.setHttpBootstrapURL("http://localhost:8085").setTimeoutMs(1500, TimeUnit.MILLISECONDS).setMaxR2ConnectionPoolSize(100);
    clientFactory = new HttpClientFactory();
    Map<String, String> properties = new HashMap<String, String>();
    properties.put(HttpClientFactory.HTTP_POOL_SIZE, Integer.toString(restClientConfig.getMaxR2ConnectionPoolSize()));
    transportClient = clientFactory.getClient(properties);
    r2store = new R2Store("test", restClientConfig.getHttpBootstrapURL(), "2", transportClient, restClientConfig, 0);
    store = r2store;
    deleteCreatedKeys(key);
}
Also used : RESTClientConfig(voldemort.restclient.RESTClientConfig) HashMap(java.util.HashMap) VectorClock(voldemort.versioning.VectorClock) R2Store(voldemort.restclient.R2Store) ByteArray(voldemort.utils.ByteArray) VoldemortServer(voldemort.server.VoldemortServer) HttpClientFactory(com.linkedin.r2.transport.http.client.HttpClientFactory) BeforeClass(org.junit.BeforeClass)

Example 4 with RESTClientConfig

use of voldemort.restclient.RESTClientConfig in project voldemort by voldemort.

the class RestServiceR2StoreTest method setUp.

@Override
@Before
public void setUp() throws IOException {
    logger.info(" Initial SEED used for random number generator: " + TestUtils.SEED);
    final int numServers = 1;
    this.nodeId = 0;
    servers = new VoldemortServer[numServers];
    // Setup the cluster
    Properties props = new Properties();
    props.setProperty("rest.enable", "true");
    props.setProperty("http.enable", "true");
    Cluster customCluster = clusterMapper.readCluster(new FileReader(clusterXmlFile), false);
    logger.info(" Node " + customCluster.getNodes().iterator().next().getStateString());
    cluster = ServerTestUtils.startVoldemortCluster(servers, null, clusterXmlFile, storesXmlfile, props, customCluster);
    // Creating R2Store
    RESTClientConfig restClientConfig = new RESTClientConfig();
    restClientConfig.setHttpBootstrapURL("http://localhost:" + cluster.getNodeById(0).getRestPort()).setTimeoutMs(10000, TimeUnit.MILLISECONDS).setMaxR2ConnectionPoolSize(100);
    clientFactory = new HttpClientFactory();
    Map<String, String> properties = new HashMap<String, String>();
    properties.put(HttpClientFactory.HTTP_POOL_SIZE, Integer.toString(restClientConfig.getMaxR2ConnectionPoolSize()));
    TransportClient transportClient = clientFactory.getClient(properties);
    R2Store r2Store = new R2Store(STORE_NAME, restClientConfig.getHttpBootstrapURL(), "0", transportClient, restClientConfig, 0);
    store = r2Store;
}
Also used : TransportClient(com.linkedin.r2.transport.common.bridge.client.TransportClient) RESTClientConfig(voldemort.restclient.RESTClientConfig) HashMap(java.util.HashMap) R2Store(voldemort.restclient.R2Store) Cluster(voldemort.cluster.Cluster) FileReader(java.io.FileReader) Properties(java.util.Properties) HttpClientFactory(com.linkedin.r2.transport.http.client.HttpClientFactory) Before(org.junit.Before)

Aggregations

RESTClientConfig (voldemort.restclient.RESTClientConfig)4 Properties (java.util.Properties)3 Before (org.junit.Before)3 HttpClientFactory (com.linkedin.r2.transport.http.client.HttpClientFactory)2 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 CoordinatorServer (voldemort.rest.coordinator.CoordinatorServer)2 CoordinatorConfig (voldemort.rest.coordinator.config.CoordinatorConfig)2 R2Store (voldemort.restclient.R2Store)2 CoordinatorAdminClient (voldemort.restclient.admin.CoordinatorAdminClient)2 TransportClient (com.linkedin.r2.transport.common.bridge.client.TransportClient)1 FileReader (java.io.FileReader)1 BeforeClass (org.junit.BeforeClass)1 Cluster (voldemort.cluster.Cluster)1 VoldemortServer (voldemort.server.VoldemortServer)1 ByteArray (voldemort.utils.ByteArray)1 VectorClock (voldemort.versioning.VectorClock)1