public static void main(String[] args) { String bootstrapUrl = "tcp://localhost:6666"; StoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl)); // create a client that executes operations on a single store StoreClient store = factory.getStoreClient("kevoree"); store.put("pompier1", "capteurs"); Versioned<String> data = store.get("pompier1"); System.out.println(data.getValue() + " " + data.getVersion()); store.delete("pompier1", data.getVersion()); }
private void ensureNotThrottled() { for (int i = 0; i < 1000; i++) { try { // do a put storeClient.put("key", "value"); } catch (QuotaExceededException qee) { /** Occurs only when a serial put to master node fails due to exceeding quota */ fail("Put throttled when rate is :" + Integer.MAX_VALUE); } try { // do a get storeClient.get("key"); } catch (QuotaExceededException qee) { fail("Get throttled when rate is :" + Integer.MAX_VALUE); } } }
public long multiWrite(int count, String keyRoot) { StoreClient<String, Doc> client = _factory.getStoreClient("test"); long start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { Doc d = new Doc("name", "geir"); d.add("x", 1); Versioned<Doc> v = new Versioned<Doc>(d); client.put(keyRoot + i, v); } long end = System.currentTimeMillis(); return end - start; }
public void simple() { StoreClient<String, Doc> client = _factory.getStoreClient("test"); Versioned<Doc> v = client.get("key"); if (v == null) { Doc d = new Doc("name", "geir"); d.add("x", 1); v = new Versioned<Doc>(d); } // update the value client.put("key", v); v = client.get("key"); System.out.println("value : " + v.getValue()); System.out.println("clock : " + v.getVersion()); }
private void ensureThrottled() { int numGetExceptions = 0; int numPutExceptions = 0; for (int i = 0; i < 1000; i++) { try { // do a put storeClient.put("key", "value"); } catch (QuotaExceededException qee) { /** occurs only when a serial put to master node fails due to exceeding quota */ numPutExceptions++; } try { // do a get storeClient.get("key"); } catch (QuotaExceededException qee) { numGetExceptions++; } } assertTrue("No get operations rate limited", numGetExceptions > 0); assertTrue("No put operations rate limited", numPutExceptions > 0); }
public static void main(String[] args) { /* */ String bootstrapUrl = "tcp://localhost:6666"; StoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl)); String bootstrapUrl2 = "tcp://localhost:6667"; StoreClientFactory factory2 = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl2)); String bootstrapUrl3 = "tcp://localhost:6668"; StoreClientFactory factory3 = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl3)); // create a client that executes operations on a single store StoreClient client = factory.getStoreClient("kevoree"); StoreClient client2 = factory2.getStoreClient("kevoree"); StoreClient client3 = factory3.getStoreClient("kevoree"); /* AdminClientConfig config = new AdminClientConfig(); AdminClient t2 = new AdminClient(bootstrapUrl,config); Cluster current = t2.getAdminClientCluster(); System.out.println("Number of node "+current.getNodes().size()); Node newNode = new Node(11,"localhost",8081,6666,9000, new ArrayList<Integer>()); List<Node> nodes = Lists.newArrayList(); Cluster newCluster = new Cluster(current.getName(),nodes,Lists.newArrayList(current.getZones())); Cluster generatedCluster = RebalanceUtils.getClusterWithNewNodes(current, newCluster); RebalanceClientConfig config2 = new RebalanceClientConfig(); config2.setMaxParallelRebalancing(1); config2.setDeleteAfterRebalancingEnabled(false); config2.setEnableShowPlan(false); config2.setMaxTriesRebalancing(100); config2.setRebalancingClientTimeoutSeconds(500); config2.setPrimaryPartitionBatchSize(1000); config2.setStealerBasedRebalancing(false); RebalanceController rebalanceController = new RebalanceController(bootstrapUrl, config2); rebalanceController.rebalance(generatedCluster); rebalanceController.stop(); AdminClient t3 = new AdminClient(bootstrapUrl,config); Cluster current3 = t2.getAdminClientCluster(); System.out.println("Number of node "+current3.getNodes().size()); */ client2.put("pompier1", "jed2"); List<Node> t = client2.getResponsibleNodes("id2"); System.out.println(t); factory.close(); factory2.close(); factory3.close(); // System.out.println(client.get("some_key")); }