Search in sources :

Example 11 with ClientConfig

use of voldemort.client.ClientConfig in project voldemort by voldemort.

the class DynamicTimeoutStoreClientTest method setUp.

/**
     * Setup a one node Voldemort cluster with a 'slow' store
     * (SlowStorageEngine) with a delay of 500 ms for get and put.
     * 
     * @throws java.lang.Exception
     */
@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", SLOW_STORE_DELAY);
    props.setProperty("testing.slow.queueing.put.ms", SLOW_STORE_DELAY);
    cluster = ServerTestUtils.startVoldemortCluster(numServers, servers, partitionMap, socketStoreFactory, // useNio
    true, null, STORES_XML, props);
    socketUrl = servers[0].getIdentityNode().getSocketUrl().toString();
    String bootstrapUrl = socketUrl;
    ClientConfig clientConfig = new ClientConfig().setBootstrapUrls(bootstrapUrl).setEnableCompressionLayer(false).setEnableSerializationLayer(false).enableDefaultClient(true).setEnableLazy(false);
    String storesXml = FileUtils.readFileToString(new File(STORES_XML), "UTF-8");
    ClusterMapper mapper = new ClusterMapper();
    this.dynamicTimeoutClient = new DynamicTimeoutStoreClient<ByteArray, byte[]>(STORE_NAME, new SocketStoreClientFactory(clientConfig), 1, storesXml, mapper.writeCluster(cluster));
}
Also used : SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) ByteArray(voldemort.utils.ByteArray) ClusterMapper(voldemort.xml.ClusterMapper) Properties(java.util.Properties) ClientConfig(voldemort.client.ClientConfig) File(java.io.File) Before(org.junit.Before)

Example 12 with ClientConfig

use of voldemort.client.ClientConfig in project voldemort by voldemort.

the class AbstractZonedRebalanceTest method testProxyGetDuringRebalancing.

@Test(timeout = 600000)
public void testProxyGetDuringRebalancing() throws Exception {
    logger.info("Starting testProxyGetDuringRebalancing");
    try {
        Cluster currentCluster = ServerTestUtils.getLocalZonedCluster(4, 2, new int[] { 0, 0, 1, 1 }, new int[][] { { 0, 2, 4 }, { 6 }, { 1, 3, 5 }, { 7 } });
        Cluster tmpfinalCluster = UpdateClusterUtils.createUpdatedCluster(currentCluster, 3, Lists.newArrayList(2));
        final Cluster finalCluster = UpdateClusterUtils.createUpdatedCluster(tmpfinalCluster, 1, Lists.newArrayList(3));
        final List<Integer> serverList = Arrays.asList(0, 1, 2, 3);
        Map<String, String> configProps = new HashMap<String, String>();
        configProps.put("admin.max.threads", "5");
        final Cluster updatedCurrentCluster = startServers(currentCluster, storeDefFileWithReplication, serverList, configProps);
        ExecutorService executors = Executors.newFixedThreadPool(2);
        final AtomicBoolean rebalancingComplete = new AtomicBoolean(false);
        final List<Exception> exceptions = Collections.synchronizedList(new ArrayList<Exception>());
        String bootstrapUrl = getBootstrapUrl(updatedCurrentCluster, 0);
        int maxParallel = 2;
        final ClusterTestUtils.RebalanceKit rebalanceKit = ClusterTestUtils.getRebalanceKit(bootstrapUrl, maxParallel, finalCluster);
        try {
            populateData(currentCluster, rwStoreDefWithReplication);
            final SocketStoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(getBootstrapUrl(currentCluster, 0)).setEnableLazy(false).setSocketTimeout(120, TimeUnit.SECONDS));
            final StoreClient<String, String> storeClientRW = new DefaultStoreClient<String, String>(rwStoreDefWithReplication.getName(), null, factory, 3);
            final CountDownLatch latch = new CountDownLatch(2);
            // start get operation.
            executors.execute(new Runnable() {

                @Override
                public void run() {
                    try {
                        List<String> keys = new ArrayList<String>(testEntries.keySet());
                        while (!rebalancingComplete.get()) {
                            // should always able to get values.
                            int index = (int) (Math.random() * keys.size());
                            // should get a valid value
                            try {
                                Versioned<String> value = storeClientRW.get(keys.get(index));
                                assertNotSame("StoreClient get() should not return null.", null, value);
                                assertEquals("Value returned should be good", new Versioned<String>(testEntries.get(keys.get(index))), value);
                            } catch (Exception e) {
                                logger.error("Exception in proxy get thread", e);
                                e.printStackTrace();
                                exceptions.add(e);
                            }
                        }
                    } catch (Exception e) {
                        logger.error("Exception in proxy get thread", e);
                        exceptions.add(e);
                    } finally {
                        factory.close();
                        latch.countDown();
                    }
                }
            });
            executors.execute(new Runnable() {

                @Override
                public void run() {
                    try {
                        Thread.sleep(500);
                        rebalanceAndCheck(rebalanceKit.plan, rebalanceKit.controller, Arrays.asList(0, 1, 2, 3));
                        Thread.sleep(500);
                        rebalancingComplete.set(true);
                        checkConsistentMetadata(finalCluster, serverList);
                    } catch (Exception e) {
                        exceptions.add(e);
                    } finally {
                        // stop servers
                        try {
                            stopServer(serverList);
                        } catch (Exception e) {
                            throw new RuntimeException(e);
                        }
                        latch.countDown();
                    }
                }
            });
            latch.await();
            executors.shutdown();
            executors.awaitTermination(300, TimeUnit.SECONDS);
            // check No Exception
            if (exceptions.size() > 0) {
                for (Exception e : exceptions) {
                    e.printStackTrace();
                }
                fail("Should not see any exceptions.");
            }
        } finally {
            // stop servers
            stopServer(serverList);
        }
    } catch (AssertionError ae) {
        logger.error("Assertion broken in testProxyGetDuringRebalancing ", ae);
        throw ae;
    }
}
Also used : Versioned(voldemort.versioning.Versioned) HashMap(java.util.HashMap) SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) List(java.util.List) ArrayList(java.util.ArrayList) ClientConfig(voldemort.client.ClientConfig) Cluster(voldemort.cluster.Cluster) CountDownLatch(java.util.concurrent.CountDownLatch) ObsoleteVersionException(voldemort.versioning.ObsoleteVersionException) IOException(java.io.IOException) InvalidMetadataException(voldemort.store.InvalidMetadataException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ClusterTestUtils(voldemort.ClusterTestUtils) ExecutorService(java.util.concurrent.ExecutorService) DefaultStoreClient(voldemort.client.DefaultStoreClient) Test(org.junit.Test)

Example 13 with ClientConfig

use of voldemort.client.ClientConfig in project voldemort by voldemort.

the class CoordinatorProxyService method getFatClientFactory.

/**
     * Create a @SocketStoreClientFactory from the given configPops
     * 
     * @param bootstrapURLs
     * @param configProps
     * @return
     */
private SocketStoreClientFactory getFatClientFactory(String[] bootstrapURLs, Properties configProps) {
    ClientConfig fatClientConfig = new ClientConfig(configProps);
    logger.info("Using config: " + fatClientConfig);
    fatClientConfig.setBootstrapUrls(bootstrapURLs).setEnableCompressionLayer(false).setEnableSerializationLayer(false).enableDefaultClient(true).setEnableLazy(false);
    return new SocketStoreClientFactory(fatClientConfig);
}
Also used : SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) ClientConfig(voldemort.client.ClientConfig)

Example 14 with ClientConfig

use of voldemort.client.ClientConfig in project voldemort by voldemort.

the class CoordinatorProxyService method initialize.

@Override
protected void initialize() {
    // Initialize the Voldemort Metadata
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setBootstrapUrls(this.coordinatorConfig.getBootstrapURLs());
    storeClientFactory = new SocketStoreClientFactory(clientConfig);
    try {
        initializeAllFatClients();
        // Setup the Async Metadata checker
        SystemStoreRepository sysRepository = new SystemStoreRepository(clientConfig);
        String clusterXml = storeClientFactory.bootstrapMetadataWithRetries(MetadataStore.CLUSTER_KEY);
        sysRepository.createSystemStores(clientConfig, clusterXml, storeClientFactory.getFailureDetector());
        // Create a callback for re-bootstrapping the client
        Callable<Void> rebootstrapCallback = new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                initializeAllFatClients();
                return null;
            }
        };
        asyncMetadataManager = new AsyncMetadataVersionManager(sysRepository, rebootstrapCallback, null);
        schedulerService = new SchedulerService(1, SystemTime.INSTANCE, true);
        schedulerService.schedule(asyncMetadataManager.getClass().getName(), asyncMetadataManager, new Date(), this.coordinatorConfig.getMetadataCheckIntervalInMs());
    } catch (BootstrapFailureException be) {
    /*
             * While testing, the cluster may not be up, but we may still need
             * to verify if the service deploys. Hence, catch a
             * BootstrapFailureException if any, but continue to register the
             * Netty service (and listener).
             * 
             * TODO: Modify the coordinator service to be more lazy. If it
             * cannot initialize the fat clients during initialization, do this
             * when we get an actual request.
             */
    }
}
Also used : SchedulerService(voldemort.common.service.SchedulerService) SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) BootstrapFailureException(voldemort.client.BootstrapFailureException) SystemStoreRepository(voldemort.client.SystemStoreRepository) AsyncMetadataVersionManager(voldemort.client.scheduler.AsyncMetadataVersionManager) ClientConfig(voldemort.client.ClientConfig) Callable(java.util.concurrent.Callable) Date(java.util.Date)

Example 15 with ClientConfig

use of voldemort.client.ClientConfig in project voldemort by voldemort.

the class AdminToolUtils method getAdminClient.

/**
     * Utility function that constructs AdminClient.
     * 
     * @param url URL pointing to the bootstrap node
     * @return Newly constructed AdminClient
     */
public static AdminClient getAdminClient(String url) {
    ClientConfig config = new ClientConfig().setBootstrapUrls(url).setConnectionTimeout(5, TimeUnit.SECONDS);
    AdminClientConfig adminConfig = new AdminClientConfig().setAdminSocketTimeoutSec(5);
    return new AdminClient(adminConfig, config);
}
Also used : AdminClientConfig(voldemort.client.protocol.admin.AdminClientConfig) AdminClientConfig(voldemort.client.protocol.admin.AdminClientConfig) ClientConfig(voldemort.client.ClientConfig) AdminClient(voldemort.client.protocol.admin.AdminClient)

Aggregations

ClientConfig (voldemort.client.ClientConfig)51 SocketStoreClientFactory (voldemort.client.SocketStoreClientFactory)37 VoldemortServer (voldemort.server.VoldemortServer)17 IOException (java.io.IOException)15 Properties (java.util.Properties)15 Test (org.junit.Test)15 Before (org.junit.Before)14 ByteArray (voldemort.utils.ByteArray)13 ArrayList (java.util.ArrayList)12 Cluster (voldemort.cluster.Cluster)12 ExecutorService (java.util.concurrent.ExecutorService)10 AdminClient (voldemort.client.protocol.admin.AdminClient)10 Node (voldemort.cluster.Node)10 StoreClientFactory (voldemort.client.StoreClientFactory)9 HashMap (java.util.HashMap)8 List (java.util.List)8 ClientRequestExecutorPool (voldemort.store.socket.clientrequest.ClientRequestExecutorPool)8 File (java.io.File)7 VoldemortException (voldemort.VoldemortException)7 CountDownLatch (java.util.concurrent.CountDownLatch)6