Package voldemort.client

Examples of voldemort.client.SocketStoreClientFactory


        System.out.println("==============Avro store example=================");
        // In production environment, the StoreClient instantiation should be done using factory pattern
        // through a Framework such as Spring
        String bootstrapUrl = "tcp://localhost:6666";
        StoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl));

        StoreClient<GenericRecord, GenericRecord> client = factory.getStoreClient("avro-example");


        // creating initial k-v pair
        System.out.println("Creating initial Key and Value");
        String keySchemaJson = "{ \"name\": \"key\", \"type\": \"record\", \"fields\": [{ \"name\": \"user_id\", \"type\": \"int\" }] }";
View Full Code Here


        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));
    }
View Full Code Here

                                                                               freePort);
        socketService.start();

        Thread.sleep(1000);

        SocketStoreClientFactory storeClientFactory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls("tcp://localhost:"
                                                                                                                       + freePort)
                                                                                                     .setMaxBootstrapRetries(10));
        StoreClient<String, String> storeClient = storeClientFactory.getStoreClient("test");
        storeClient.put("someKey", "someValue");
        assertEquals(storeClient.getValue("someKey"), "someValue");
        socketService.stop();
    }
View Full Code Here

        // Start another node for only this unit test
        HashMap<ByteArray, byte[]> entrySet =
                ServerTestUtils.createRandomKeyValuePairs(100);

        SocketStoreClientFactory factory = new SocketStoreClientFactory(new
                                                                        ClientConfig().setBootstrapUrls(Lists.newArrayList("tcp://"
                                                                                                                           + currentCluster.getNodeById(0)
                                                                                                                                           .getHost()
                                                                                                                           + ":"
                                                                                                                           + currentCluster.getNodeById(0)
                                                                                                                                           .getSocketPort())));
        StoreClient<Object, Object> storeClient = factory.getStoreClient("test");

        this.primaryEntriesMoved = Maps.newHashMap();
        this.secondaryEntriesMoved = Maps.newHashMap();
        this.proxyPutTestPrimaryEntries = Maps.newHashMap();
        this.proxyPutTestSecondaryEntries = Maps.newHashMap();
View Full Code Here

        StoreClientFactory factory = null;
        DefaultStoreClient<Object, Object> client = null;
        try {
            try {
                factory = new SocketStoreClientFactory(clientConfig);
                client = (DefaultStoreClient<Object, Object>) factory.getStoreClient(storeName);
            } catch(Exception e) {
                Utils.croak("Could not connect to server: " + e.getMessage());
            }
View Full Code Here

        for(int i = 0; i < numServers; ++i) {
            servers.add(voldemortServers[i]);
        }

        String bootstrapUrl = cluster.getNodeById(0).getSocketUrl().toString();
        storeClient = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl)).getStoreClient(STORE_NAME);

        Map<String, String> entries = Maps.newHashMap();
        entries.put("a", "1");
        entries.put("b", "2");
        for(Map.Entry<String, String> entry: entries.entrySet())
View Full Code Here

                thread.setName("stress-test");
                return thread;
            }
        });
        try {
            final SocketStoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(url)
                                                                                                    .setEnableLazy(false)
                                                                                                    .setConnectionTimeout(timeoutSecs,
                                                                                                                          TimeUnit.SECONDS)
                                                                                                    .setSocketTimeout(timeoutSecs,
                                                                                                                      TimeUnit.SECONDS)
                                                                                                    .setMaxThreads(numThreads)
                                                                                                    .setSelectors(numSelectors));
            for(int i = 0; i < numThreads; i++) {
                executor.submit(new Runnable() {

                    public void run() {
                        for(int j = 0; j < count; j++) {
                            try {
                                String clusterXml = factory.bootstrapMetadataWithRetries(MetadataStore.CLUSTER_KEY);
                                new ClusterMapper().readCluster(new StringReader(clusterXml));
                                String storesXml = factory.bootstrapMetadataWithRetries(MetadataStore.STORES_KEY);
                                new StoreDefinitionsMapper().readStoreList(new StringReader(storesXml));
                                if(logger.isTraceEnabled())
                                    logger.trace("ok " + j);
                            } catch(MappingException me) {
                                logger.fatal(me, me);
View Full Code Here

    public void setUp() throws Exception {
        deploy(hostNames, ec2FailureDetectorTestConfig);
        startClusterAsync(hostNames, ec2FailureDetectorTestConfig, nodeIds);

        String url = "tcp://" + getRandomHostName() + ":6666";
        StoreClientFactory scf = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(url));

        failureDetector = scf.getFailureDetector();
        store = scf.getStoreClient("test");
    }
View Full Code Here

        byte[] k3_bytes = { (byte) 'K', (byte) '3' };
        clientConfig = new ClientConfig();
        clientConfig.setBootstrapUrls(cluster.getNodes().iterator().next().getSocketUrl().toString());
        clientConfig.setClientZoneId(clientZoneId);
        setupZoneAffinitySettings();
        SocketStoreClientFactory socketStoreClientFactory = new SocketStoreClientFactory(clientConfig);
        for(Integer nodeId: cluster.getNodeIds()) {
            SocketStoreFactory socketStoreFactory = new ClientRequestExecutorPool(2,
                                                                                  10000,
                                                                                  100000,
                                                                                  1024);
            VoldemortConfig config = ServerTestUtils.createServerConfigWithDefs(true,
                                                                                nodeId,
                                                                                TestUtils.createTempDir()
                                                                                        .getAbsolutePath(),
                                                                                cluster,
                                                                                stores,
                                                                                new Properties());
            VoldemortServer vs = ServerTestUtils.startVoldemortServer(socketStoreFactory,
                                                                      config,
                                                                      cluster);
            vservers.put(nodeId, vs);
            socketStoreFactories.put(nodeId, socketStoreFactory);
            Store<ByteArray, byte[], byte[]> store = vs.getStoreRepository()
                    .getLocalStore(storeDef.getName());
            Node node = cluster.getNodeById(nodeId);

            VectorClock version1 = new VectorClock();
            version1.incrementVersion(0, System.currentTimeMillis());
            VectorClock version2 = version1.incremented(0, System.currentTimeMillis());

            if(node.getZoneId() == clientZoneId) {
                // local zone
                store.put(new ByteArray(k1_bytes), new Versioned<byte[]>(v1_bytes, version1), null);
                store.put(new ByteArray(k2_bytes), new Versioned<byte[]>(v1_bytes, version1), null);
            } else {
                // remote zone
                store.put(new ByteArray(k1_bytes), new Versioned<byte[]>(v2_bytes, version2), null);
                store.put(new ByteArray(k2_bytes), new Versioned<byte[]>(v1_bytes, version1), null);
                store.put(new ByteArray(k3_bytes), new Versioned<byte[]>(v1_bytes, version1), null);
            }
        }

        client = socketStoreClientFactory.getRawStore(storeDef.getName(), null);
    }
View Full Code Here

        conflict5 = getVersioned(0, 0, 0, 0, 0, 1, 1, 1, 1, 1);
        conflict6 = getVersioned(0, 0, 0, 0, 0, 0, 1, 1, 1, 1);

        Node node = cluster.getNodes().iterator().next();
        String bootstrapUrl = "tcp://" + node.getHost() + ":" + node.getSocketPort();
        StoreClientFactory storeClientFactory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl));

        defaultStoreClient = storeClientFactory.getStoreClient("test");
        socketStore = ServerTestUtils.getSocketStore(socketStoreFactory,
                                                     "test",
                                                     node.getSocketPort(),
                                                     RequestFormatType.VOLDEMORT_V1);
    }
View Full Code Here

TOP

Related Classes of voldemort.client.SocketStoreClientFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.