Search in sources :

Example 1 with RESTClientFactoryConfig

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

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Before (org.junit.Before)1 CoordinatorProxyService (voldemort.rest.coordinator.CoordinatorProxyService)1 CoordinatorConfig (voldemort.rest.coordinator.config.CoordinatorConfig)1 FileBasedStoreClientConfigService (voldemort.rest.coordinator.config.FileBasedStoreClientConfigService)1 StoreClientConfigService (voldemort.rest.coordinator.config.StoreClientConfigService)1 RESTClientFactory (voldemort.restclient.RESTClientFactory)1 RESTClientFactoryConfig (voldemort.restclient.RESTClientFactoryConfig)1 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)1