Package voldemort.client

Examples of voldemort.client.StoreClientFactory


        AdminClient adminClient = new AdminClient(bsURL, new AdminClientConfig(), new ClientConfig());
        assertEquals(2, adminClient.getAdminClientCluster().getZoneIds().size());


        String bootstrapUrl = adminClient.getAdminClientCluster().getNodes().iterator().next().getSocketUrl().toString();
        StoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl));
        StoreClient<String, String> client = factory.getStoreClient(oldStores.get(0).getName());
        client.put("k1", "v1" );
        assertEquals("v1", client.get("k1").getValue());
    }
View Full Code Here


     * @param keySize Size (in bytes) of the key
     * @param valueSize Size (in bytes) of the value
     * @param postfix Postfix to append (for uniqueness)
     */
    public void generateData(int requests, int keySize, int valueSize, String postfix) {
        StoreClientFactory storeClientFactory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(url)
                                                                                               .setMaxThreads(workers));
        StoreClient<String, String> client = storeClientFactory.getStoreClient(storeName);

        for(int i = 0; i < requests; i++) {
            StringBuilder keyBuilder = new StringBuilder(makeString(keySize)).append(i);
            StringBuilder valueBuilder = new StringBuilder(makeString(valueSize)).append(i);
            if(postfix != null) {
View Full Code Here

            Utils.croak("USAGE: java VoldemortClientShell store_name bootstrap_url [command_file]");

        String storeName = args[0];
        String bootstrapUrl = args[1];

        StoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setEnableLazy(false)
                                                                                    .setBootstrapUrls(bootstrapUrl));
        DefaultStoreClient<Object, Object> client = null;
        try {
            client = (DefaultStoreClient<Object, Object>) factory.getStoreClient(storeName);
        } catch(Exception e) {
            Utils.croak("Could not connect to server: " + e.getMessage());
        }

        System.out.println("Established connection to " + storeName + " via " + bootstrapUrl);
View Full Code Here

        System.out.println("==============String 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<String, String> client = factory.getStoreClient("test");

        // put initial value
        System.out.println("Putting an initial value");
        client.put("some_key", "initial value");
View Full Code Here

        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

        ClientConfig clientConfig = new ClientConfig().setBootstrapUrls(bootstrapUrl)
                                                      .setEnableLazy(false)
                                                      .setRequestFormatType(RequestFormatType.VOLDEMORT_V3);

        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());
            }

            System.out.println("Established connection to " + storeName + " via " + bootstrapUrl);
            System.out.print(PROMPT);

            Pair<Schema, Schema> keyValueSchemaPair = getLatestKeyValueSchema(bootstrapUrl,
                                                                              storeName);
            Schema latestKeySchema = keyValueSchemaPair.getFirst();
            if(latestKeySchema == null) {
                Utils.croak("Could not parse latest key schema for store name " + storeName);
            }

            Schema latestValueSchema = keyValueSchemaPair.getSecond();

            if(latestValueSchema == null) {
                Utils.croak("Could not parse latest value schema for store name " + storeName);
            }

            if(fileReader != null) {
                processCommands(client, fileReader, latestKeySchema, latestValueSchema, true);
            } else {
                processCommands(client, inputReader, latestKeySchema, latestValueSchema, false);
            }
        } finally {
            if(factory != null)
                factory.close();
            if(fileReader != null)
                fileReader.close();
        }
    }
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

        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

                                                                STORES_XML,
                                                                new Properties());

        Node node = cluster.getNodeById(0);
        String bootstrapUrl = "tcp://" + node.getHost() + ":" + node.getSocketPort();
        StoreClientFactory storeClientFactory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl));
        storeClient = storeClientFactory.getStoreClient(STORE_NAME);
    }
View Full Code Here

//        VoldemortServer server = new VoldemortServer(config);
//        server.start();

        // bootstrap
        String bootstrapUrl = "tcp://localhost:6666";
        StoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl));

        // create a client that executes operations on a single store
        client = factory.getStoreClient("test");
    }
View Full Code Here

TOP

Related Classes of voldemort.client.StoreClientFactory

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.