Package voldemort.client.protocol.admin

Examples of voldemort.client.protocol.admin.AdminClient$AdminStoreClient


    }

    public void setGetPutQuotasForEachServer() throws Exception {
        Properties adminProperties = new Properties();
        adminProperties.setProperty("max_connections", "2");
        adminClient = new AdminClient(cluster,
                                      new AdminClientConfig(adminProperties),
                                      new ClientConfig());

        Map<Pair<Integer, QuotaType>, Integer> throughPutMap = new HashMap<Pair<Integer, QuotaType>, Integer>();
        // Set Node0 Quota
View Full Code Here


                nodeIds = (List<Integer>) options.valuesOf(AdminParserUtils.OPT_NODE);
                allNodes = false;
            }

            // execute command
            AdminClient adminClient = AdminToolUtils.getAdminClient(url);

            if(allNodes) {
                nodeIds = AdminToolUtils.getAllNodeIds(adminClient);
            }
View Full Code Here

            }
            storeName = (String) options.valueOf(AdminParserUtils.OPT_STORE);
            url = (String) options.valueOf(AdminParserUtils.OPT_URL);

            // execute command
            AdminClient adminClient = AdminToolUtils.getAdminClient(url);

            doDebugRoute(adminClient, storeName, keyStrings, keyType);
        }
View Full Code Here

            ClusterTestUtils.RebalanceKit rebalanceKit = ClusterTestUtils.getRebalanceKit(bootstrapUrl,
                                                                                          finalCluster);

            try {
                populateData(currentCluster, rwStoreDefWithReplication);
                AdminClient admin = rebalanceKit.controller.getAdminClient();

                List<ByteArray> p6KeySamples = sampleKeysFromPartition(admin, 4, rwStoreDefWithReplication.getName(),
                                                                       Arrays.asList(6), 20);
                List<ByteArray> p1KeySamples = sampleKeysFromPartition(admin, 4, rwStoreDefWithReplication.getName(),
                                                                       Arrays.asList(1), 20);
View Full Code Here

            int maxParallel = 2;
            final ClusterTestUtils.RebalanceKit rebalanceKit = ClusterTestUtils.getRebalanceKit(bootstrapUrl,
                                                                                                maxParallel,
                                                                                                finalCluster);
            populateData(currentCluster, rwStoreDefWithReplication);
            final AdminClient adminClient = rebalanceKit.controller.getAdminClient();
            // the plan would cause these partitions to move:
            // Partition : Donor -> stealer
            //
            // p2 (Z-SEC) : s4 -> s3
            // p3-6 (Z-PRI) : s4 -> s5
            // p7 (Z-PRI) : s3 -> s5
            //
            // p5 (Z-SEC): s10 -> s9
            // p6 (Z-PRI): s10 -> s11
            //
            // Rebalancing will run on servers 3, 5, 9, & 11
            final List<ByteArray> movingKeysList = sampleKeysFromPartition(adminClient,
                                                                           4,
                                                                           rwStoreDefWithReplication.getName(),
                                                                           Arrays.asList(6),
                                                                           20);
            assertTrue("Empty list of moving keys...", movingKeysList.size() > 0);
            final AtomicBoolean rebalancingStarted = new AtomicBoolean(false);
            final AtomicBoolean proxyWritesDone = new AtomicBoolean(false);
            final HashMap<String, String> baselineTuples = new HashMap<String, String>(testEntries);
            final HashMap<String, VectorClock> baselineVersions = new HashMap<String, VectorClock>();
            for(String key: baselineTuples.keySet()) {
                baselineVersions.put(key, new VectorClock());
            }
            final CountDownLatch latch = new CountDownLatch(2);
            // start get operation.
            executors.execute(new Runnable() {
                @Override
                public void run() {
                    SocketStoreClientFactory factory = null;
                    try {
                        // wait for the rebalancing to begin
                        List<VoldemortServer> serverList = Lists.newArrayList(serverMap.get(3), serverMap.get(5),
                                                                              serverMap.get(9), serverMap.get(11));
                        while(!rebalancingComplete.get()) {
                            Iterator<VoldemortServer> serverIterator = serverList.iterator();
                            while(serverIterator.hasNext()) {
                                VoldemortServer server = serverIterator.next();
                                if(ByteUtils.getString(server.getMetadataStore()
                                                             .get(MetadataStore.SERVER_STATE_KEY, null)
                                                             .get(0)
                                                             .getValue(),
                                                       "UTF-8")
                                            .compareTo(VoldemortState.REBALANCING_MASTER_SERVER.toString()) == 0) {
                                    logger.info("Server " + server.getIdentityNode().getId()
                                                + " transitioned into REBALANCING MODE");
                                    serverIterator.remove();
                                }
                            }
                            if(serverList.size() == 0) {
                                rebalancingStarted.set(true);
                                break;
                            }
                        }
                        if(rebalancingStarted.get()) {
                            factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls
                                                                                      (getBootstrapUrl(updatedCurrentCluster, 3))
                                                                                     .setEnableLazy(false)
                                                                                     .setSocketTimeout(120, TimeUnit.SECONDS)
                                                                                     .setClientZoneId(3));

                            final StoreClient<String, String> storeClientRW = new DefaultStoreClient
                                                                                 <String, String>(testStoreNameRW,
                                                                                                  null,
                                                                                                  factory,
                                                                                                  3);
                            // Now perform some writes and determine the end state of the changed keys.
                            // Initially, all data now with zero vector clock
                            for(ByteArray movingKey: movingKeysList) {
                                try {
                                    String keyStr = ByteUtils.getString(movingKey.get(), "UTF-8");
                                    String valStr = "proxy_write";
                                    storeClientRW.put(keyStr, valStr);
                                    baselineTuples.put(keyStr, valStr);
                                    baselineVersions.get(keyStr)
                                                    .incrementVersion(11, System.currentTimeMillis());
                                    proxyWritesDone.set(true);
                                    if(rebalancingComplete.get()) {
                                        break;
                                    }
                                } catch(InvalidMetadataException e) {
                                    logger.error("Encountered an invalid metadata exception.. ", e);
                                }
                            }
                        }
                    } catch(Exception e) {
                        logger.error("Exception in proxy write thread..", e);
                        exceptions.add(e);
                    } finally {
                        if(factory != null)
                            factory.close();
                        latch.countDown();
                    }
                }
            });

            executors.execute(new Runnable() {

                @Override
                public void run() {
                    try {
                        rebalanceKit.rebalance();
                    } catch(Exception e) {
                        logger.error("Error in rebalancing... ", e);
                        exceptions.add(e);
                    } finally {
                        rebalancingComplete.set(true);
                        latch.countDown();
                    }
                }
            });
            latch.await();
            executors.shutdown();
            executors.awaitTermination(300, TimeUnit.SECONDS);

            assertEquals("Client did not see all server transition into rebalancing state",
                         rebalancingStarted.get(), true);
            assertEquals("Not enough time to begin proxy writing", proxyWritesDone.get(), true);
            checkEntriesPostRebalance(updatedCurrentCluster, finalCluster,
                                      Lists.newArrayList(rwStoreDefWithReplication),
                                      Arrays.asList(3, 4, 5, 9, 10, 11), baselineTuples, baselineVersions);
            checkConsistentMetadata(finalCluster, serverList);
            // check No Exception
            if(exceptions.size() > 0) {
                for(Exception e: exceptions) {
                    e.printStackTrace();
                }
                fail("Should not see any exceptions.");
            }
            // check that the proxy writes were made to the original donor, node 4
            List<ClockEntry> clockEntries = new ArrayList<ClockEntry>(serverList.size());
            for(Integer nodeid: serverList)
                clockEntries.add(new ClockEntry(nodeid.shortValue(), System.currentTimeMillis()));
            VectorClock clusterXmlClock = new VectorClock(clockEntries, System.currentTimeMillis());
            for(Integer nodeid: serverList)
                adminClient.metadataMgmtOps.updateRemoteCluster(nodeid, currentCluster, clusterXmlClock);
            adminClient.setAdminClientCluster(currentCluster);
            checkForTupleEquivalence(adminClient, 4, testStoreNameRW, movingKeysList, baselineTuples, baselineVersions);
            // stop servers
            try {
                stopServer(serverList);
            } catch(Exception e) {
View Full Code Here

            quotaTypes = AdminToolUtils.getQuotaTypes((List<String>) options.valuesOf(OPT_HEAD_QUOTA_GET));
            storeNames = (List<String>) options.valuesOf(AdminParserUtils.OPT_STORE);
            url = (String) options.valueOf(AdminParserUtils.OPT_URL);

            // execute command
            AdminClient adminClient = AdminToolUtils.getAdminClient(url);

            doQuotaGet(adminClient, storeNames, quotaTypes);
        }
View Full Code Here

            // execute command
            if(!AdminToolUtils.askConfirm(confirm, "reserve memory")) {
                return;
            }

            AdminClient adminClient = AdminToolUtils.getAdminClient(url);

            if(allNodes) {
                nodeIds = AdminToolUtils.getAllNodeIds(adminClient);
            }
View Full Code Here

            // execute command
            if(!AdminToolUtils.askConfirm(confirm, "set quota")) {
                return;
            }

            AdminClient adminClient = AdminToolUtils.getAdminClient(url);
            Map<String, String> quotaMap = AdminToolUtils.convertListToMap(quota);

            AdminToolUtils.assertServerNotInRebalancingState(adminClient);

            doQuotaSet(adminClient, storeNames, quotaMap);
View Full Code Here

            // execute command
            if(!AdminToolUtils.askConfirm(confirm, "unset quota")) {
                return;
            }

            AdminClient adminClient = AdminToolUtils.getAdminClient(url);

            AdminToolUtils.assertServerNotInRebalancingState(adminClient);

            doQuotaUnset(adminClient, storeNames, quotaTypes);
        }
View Full Code Here

                nodeIds = (List<Integer>) options.valuesOf(AdminParserUtils.OPT_NODE);
                allNodes = false;
            }

            // execute command
            AdminClient adminClient = AdminToolUtils.getAdminClient(url);

            if(allNodes) {
                nodeIds = AdminToolUtils.getAllNodeIds(adminClient);
            }
View Full Code Here

TOP

Related Classes of voldemort.client.protocol.admin.AdminClient$AdminStoreClient

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.