Package voldemort.client.protocol.admin

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


                                                                                new Properties());
            VoldemortServer vs = ServerTestUtils.startVoldemortServer(ssf, config, cluster);
            vservers.put(node.getId(), vs);
            socketStoreFactories.put(node.getId(), ssf);
        }
        adminClient = new AdminClient(cluster, new AdminClientConfig(), new ClientConfig());
    }
View Full Code Here


                                                                                new Properties());
            VoldemortServer vs = ServerTestUtils.startVoldemortServer(ssf, config, cluster);
            vservers.put(node.getId(), vs);
            socketStoreFactories.put(node.getId(), ssf);
        }
        adminClient = new AdminClient(cluster, new AdminClientConfig(), new ClientConfig());
        storeName = stores.iterator().next().getName();
        quotaType = QuotaUtils.validQuotaTypes().iterator().next();
    }
View Full Code Here

    protected Cluster getCurrentCluster(int nodeId) {
        String hostName = nodeIdsInv.get(nodeId);
        if(hostName == null) {
            throw new VoldemortException("Node id " + nodeId + " does not exist");
        } else {
            AdminClient adminClient = new AdminClient(hostName,
                                                      new AdminClientConfig(),
                                                      new ClientConfig());
            return adminClient.getAdminClientCluster();
        }
    }
View Full Code Here

    protected VoldemortState getCurrentState(int nodeId) {
        String hostName = nodeIdsInv.get(nodeId);
        if(hostName == null) {
            throw new VoldemortException("Node id " + nodeId + " does not exist");
        } else {
            AdminClient adminClient = new AdminClient(hostName,
                                                      new AdminClientConfig(),
                                                      new ClientConfig());
            return adminClient.rebalanceOps.getRemoteServerState(nodeId).getValue();
        }
    }
View Full Code Here

            String url = (String) options.valueOf("url");
            Integer nodeId = CmdUtils.valueOf(options, "node", -1);
            int parallelism = CmdUtils.valueOf(options, "restore", 5);
            Integer zoneId = CmdUtils.valueOf(options, "zone", -1);

            AdminClient adminClient = new AdminClient(url,
                                                      new AdminClientConfig(),
                                                      new ClientConfig());

            List<String> storeNames = null;
            if(options.has("store") && options.has("stores")) {
                throw new VoldemortException("Must not specify both --stores and --store options");
            } else if(options.has("stores")) {
                storeNames = (List<String>) options.valuesOf("stores");
            } else if(options.has("store")) {
                storeNames = Arrays.asList((String) options.valueOf("store"));
            }

            String outputDir = null;
            if(options.has("outdir")) {
                outputDir = (String) options.valueOf("outdir");
            }

            if(options.has("add-stores")) {
                String storesXml = (String) options.valueOf("add-stores");
                executeAddStores(adminClient, storesXml, nodeId);
            } else if(options.has("async")) {
                String asyncKey = (String) options.valueOf("async");
                List<Integer> asyncIds = null;
                if(options.hasArgument("async-id"))
                    asyncIds = (List<Integer>) options.valuesOf("async-id");
                executeAsync(nodeId, adminClient, asyncKey, asyncIds);
            } else if(options.has("check-metadata")) {
                String metadataKey = (String) options.valueOf("check-metadata");
                executeCheckMetadata(adminClient, metadataKey);
            } else if(options.has("delete-partitions")) {
                System.out.println("Starting delete-partitions");
                List<Integer> partitionIdList = (List<Integer>) options.valuesOf("delete-partitions");
                executeDeletePartitions(nodeId, adminClient, partitionIdList, storeNames);
                System.out.println("Finished delete-partitions");
            } else if(options.has("ro-metadata")) {
                String type = (String) options.valueOf("ro-metadata");
                executeROMetadata(nodeId, adminClient, storeNames, type);
            } else if(options.has("reserve-memory")) {
                if(!options.has("stores")) {
                    Utils.croak("Specify the list of stores to reserve memory");
                }
                long reserveMB = (Long) options.valueOf("reserve-memory");
                adminClient.quotaMgmtOps.reserveMemory(nodeId, storeNames, reserveMB);
            } else if(options.has("get-metadata")) {
                String metadataKey = ALL_METADATA;
                if(options.hasArgument("get-metadata")) {
                    metadataKey = (String) options.valueOf("get-metadata");
                }
                executeGetMetadata(nodeId, adminClient, metadataKey, outputDir);
            } else if(options.has("mirror-from-url")) {
                if(!options.has("mirror-node")) {
                    Utils.croak("Specify the mirror node to fetch from");
                }

                if(nodeId == -1) {
                    System.err.println("Cannot run mirroring without node id");
                    System.exit(1);
                }
                Integer mirrorNodeId = CmdUtils.valueOf(options, "mirror-node", -1);
                if(mirrorNodeId == -1) {
                    System.err.println("Cannot run mirroring without mirror node id");
                    System.exit(1);
                }
                adminClient.restoreOps.mirrorData(nodeId,
                                                  mirrorNodeId,
                                                  (String) options.valueOf("mirror-from-url"),
                                                  storeNames);
            } else if(options.has("clear-rebalancing-metadata")) {
                executeClearRebalancing(nodeId, adminClient);
            } else if(options.has("prune-job")) {
                if(storeNames == null) {
                    Utils.croak("Must specify --stores to run the prune job");
                }
                executePruneJob(nodeId, adminClient, storeNames);
            } else if(options.has("fetch-keys")) {
                boolean useAscii = options.has("ascii");
                System.out.println("Starting fetch keys");
                List<Integer> partitionIdList = null;
                if(options.hasArgument("fetch-keys"))
                    partitionIdList = (List<Integer>) options.valuesOf("fetch-keys");
                executeFetchKeys(nodeId,
                                 adminClient,
                                 partitionIdList,
                                 outputDir,
                                 storeNames,
                                 useAscii,
                                 options.has("fetch-orphaned"));
            } else if(options.has("repair-job")) {
                executeRepairJob(nodeId, adminClient);
            } else if(options.has("set-metadata-pair")) {
                List<String> metadataKeyPair = (List<String>) options.valuesOf("set-metadata-pair");
                if(metadataKeyPair.size() != 2) {
                    throw new VoldemortException("Missing set-metadata-pair keys (only two keys are needed and allowed)");
                }
                if(!options.has("set-metadata-value-pair")) {
                    throw new VoldemortException("Missing set-metadata-value-pair");
                } else {

                    List<String> metadataValuePair = (List<String>) options.valuesOf("set-metadata-value-pair");
                    if(metadataValuePair.size() != 2) {
                        throw new VoldemortException("Missing set-metadata--value-pair values (only two values are needed and allowed)");
                    }
                    if(metadataKeyPair.contains(MetadataStore.CLUSTER_KEY)
                       && metadataKeyPair.contains(MetadataStore.STORES_KEY)) {
                        ClusterMapper clusterMapper = new ClusterMapper();
                        StoreDefinitionsMapper storeDefsMapper = new StoreDefinitionsMapper();
                        // original metadata
                        Integer nodeIdToGetStoreXMLFrom = nodeId;
                        if(nodeId < 0) {
                            Collection<Node> nodes = adminClient.getAdminClientCluster().getNodes();
                            if(nodes.isEmpty()) {
                                throw new VoldemortException("No nodes in this cluster");
                            } else {
                                nodeIdToGetStoreXMLFrom = nodes.iterator().next().getId();
                            }
                        }
                        Versioned<String> storesXML = adminClient.metadataMgmtOps.getRemoteMetadata(nodeIdToGetStoreXMLFrom,
                                                                                                    MetadataStore.STORES_KEY);
                        List<StoreDefinition> oldStoreDefs = storeDefsMapper.readStoreList(new StringReader(storesXML.getValue()));

                        String clusterXMLPath = metadataValuePair.get(metadataKeyPair.indexOf(MetadataStore.CLUSTER_KEY));
                        clusterXMLPath = clusterXMLPath.replace("~",
                                                                System.getProperty("user.home"));
                        if(!Utils.isReadableFile(clusterXMLPath))
                            throw new VoldemortException("Cluster xml file path incorrect");
                        Cluster cluster = clusterMapper.readCluster(new File(clusterXMLPath));

                        String storesXMLPath = metadataValuePair.get(metadataKeyPair.indexOf(MetadataStore.STORES_KEY));
                        storesXMLPath = storesXMLPath.replace("~", System.getProperty("user.home"));
                        if(!Utils.isReadableFile(storesXMLPath))
                            throw new VoldemortException("Stores definition xml file path incorrect");
                        List<StoreDefinition> newStoreDefs = storeDefsMapper.readStoreList(new File(storesXMLPath));
                        StoreDefinitionUtils.validateSchemasAsNeeded(newStoreDefs);

                        executeSetMetadataPair(nodeId,
                                               adminClient,
                                               MetadataStore.CLUSTER_KEY,
                                               clusterMapper.writeCluster(cluster),
                                               MetadataStore.STORES_KEY,
                                               storeDefsMapper.writeStoreList(newStoreDefs));
                        executeUpdateMetadataVersionsOnStores(adminClient,
                                                              oldStoreDefs,
                                                              newStoreDefs);
                    } else {
                        throw new VoldemortException("set-metadata-pair keys should be <cluster.xml, stores.xml>");
                    }
                }
            } else if(options.has("set-metadata")) {

                String metadataKey = (String) options.valueOf("set-metadata");
                if(!options.has("set-metadata-value")) {
                    throw new VoldemortException("Missing set-metadata-value");
                } else {
                    String metadataValue = (String) options.valueOf("set-metadata-value");
                    if(metadataKey.compareTo(MetadataStore.CLUSTER_KEY) == 0
                       || metadataKey.compareTo(MetadataStore.REBALANCING_SOURCE_CLUSTER_XML) == 0) {
                        if(!Utils.isReadableFile(metadataValue))
                            throw new VoldemortException("Cluster xml file path incorrect");
                        ClusterMapper mapper = new ClusterMapper();
                        Cluster newCluster = mapper.readCluster(new File(metadataValue));
                        if(options.has("auto")) {
                            executeSetMetadata(nodeId,
                                               adminClient,
                                               metadataKey,
                                               mapper.writeCluster(newCluster));
                        } else {
                            if(confirmMetadataUpdate(nodeId,
                                                     adminClient,
                                                     mapper.writeCluster(newCluster))) {
                                executeSetMetadata(nodeId,
                                                   adminClient,
                                                   metadataKey,
                                                   mapper.writeCluster(newCluster));
                            } else {
                                System.out.println("New metadata has not been set");
                            }
                        }
                    } else if(metadataKey.compareTo(MetadataStore.SERVER_STATE_KEY) == 0) {
                        VoldemortState newState = VoldemortState.valueOf(metadataValue);
                        executeSetMetadata(nodeId,
                                           adminClient,
                                           MetadataStore.SERVER_STATE_KEY,
                                           newState.toString());
                    } else if(metadataKey.compareTo(MetadataStore.STORES_KEY) == 0) {
                        if(!Utils.isReadableFile(metadataValue))
                            throw new VoldemortException("Stores definition xml file path incorrect");
                        StoreDefinitionsMapper mapper = new StoreDefinitionsMapper();
                        List<StoreDefinition> newStoreDefs = mapper.readStoreList(new File(metadataValue));
                        StoreDefinitionUtils.validateSchemasAsNeeded(newStoreDefs);

                        // original metadata
                        Integer nodeIdToGetStoreXMLFrom = nodeId;
                        if(nodeId < 0) {
                            Collection<Node> nodes = adminClient.getAdminClientCluster().getNodes();
                            if(nodes.isEmpty()) {
                                throw new VoldemortException("No nodes in this cluster");
                            } else {
                                nodeIdToGetStoreXMLFrom = nodes.iterator().next().getId();
                            }
View Full Code Here

                if(keyCount == kvPairs.size() / 2)
                    conflictKey = key;
                keyCount++;
            }

            srcAdminClient = new AdminClient(srcCluster,
                                             new AdminClientConfig(),
                                             new ClientConfig());

            List<StoreDefinition> storeDefs = new StoreDefinitionsMapper().readStoreList(new File(STORES_XML));
View Full Code Here

                                                                   Lists.newArrayList(MULTIPLE_VERSIONS_STORE_NAME),
                                                                   null,
                                                                   ClusterForkLiftTool.ForkLiftTaskMode.no_resolution);
        forkLiftTool.run();

        AdminClient dstAdminClient = new AdminClient(dstBootStrapUrl,
                                                     new AdminClientConfig(),
                                                     new ClientConfig());

        for(Node node: dstAdminClient.getAdminClientCluster().getNodes()) {

            Iterator<Pair<ByteArray, Versioned<byte[]>>> entryItr = dstAdminClient.bulkFetchOps.fetchEntries(node.getId(),
                                                                                                             MULTIPLE_VERSIONS_STORE_NAME,
                                                                                                             node.getPartitionIds(),
                                                                                                             null,
View Full Code Here

                                                           100,
                                                           100,
                                                           false,
                                                           false);

        AdminClient adminClient = consistencyFix.getAdminClient();

        System.out.println("Initial get");
        for(int i = 0; i < 4; ++i) {
            List<Versioned<byte[]>> results;
            results = adminClient.storeOps.getNodeKey(ConsistencyFixTest.STORE_NAME, i, baKey);
View Full Code Here

        String bootstrapUrl = clientConfig.getBootstrapUrls()[0];

        try {
            factory = new SocketStoreClientFactory(clientConfig);
            client = factory.getStoreClient(storeName);
            adminClient = new AdminClient(bootstrapUrl, new AdminClientConfig(), new ClientConfig());

            storeDef = StoreUtils.getStoreDef(factory.getStoreDefs(), storeName);

            commandOutput.println("Established connection to " + storeName + " via " + bootstrapUrl);
            commandOutput.print(PROMPT);
View Full Code Here

                                                                STORES_XML,
                                                                new Properties());

        Node node = cluster.getNodeById(0);
        String bootstrapUrl = "tcp://" + node.getHost() + ":" + node.getSocketPort();
        AdminClient adminClient = new AdminClient(bootstrapUrl,
                                                  new AdminClientConfig(),
                                                  new ClientConfig());

        byte[] value = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
        byte[] value2 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
View Full Code Here

TOP

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

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.