Examples of AdminClientConfig


Examples of voldemort.client.protocol.admin.AdminClientConfig

             * reconcilation.
             */
            for(String hostname: newHostnames) {
                int nodeId = nodeIds.get(hostname);
                AdminClient adminClient = new AdminClient("tcp://" + hostname + ":6666",
                                                          new AdminClientConfig(),
                                                          new ClientConfig());

                Versioned<String> versioned = adminClient.metadataMgmtOps.getRemoteMetadata(nodeId,
                                                                                            MetadataStore.CLUSTER_KEY);
                Version version = versioned.getVersion();

                VectorClock vectorClock = (VectorClock) version;
                vectorClock.incrementVersion(nodeId, System.currentTimeMillis());

                try {
                    adminClient.metadataMgmtOps.updateRemoteMetadata(peerNodeId,
                                                                     MetadataStore.CLUSTER_KEY,
                                                                     versioned);
                    adminClient.metadataMgmtOps.updateRemoteMetadata(nodeId,
                                                                     MetadataStore.CLUSTER_KEY,
                                                                     versioned);
                } catch(VoldemortException e) {
                    logger.error(e);
                }
            }

            /**
             * Finally, verify that all of the nodes have been discovered
             */
            assertWithBackoff(1000, 60000, new Attempt() {

                private int count = 1;
                private AdminClient adminClient = new AdminClient("tcp://" + hostNames.get(0)
                                                                          + ":6666",
                                                                  new AdminClientConfig(),
                                                                  new ClientConfig());

                public void checkCondition() throws Exception, AssertionError {
                    logger.info("Attempt " + count++);

View Full Code Here

Examples of voldemort.client.protocol.admin.AdminClientConfig

                                                            "test/common/voldemort/config/single-store.xml");

            Properties adminProperties = new Properties();
            adminProperties.setProperty("max_connections", "2");
            adminClient = new AdminClient(servers[0].getMetadataStore().getCluster(),
                                          new AdminClientConfig(adminProperties),
                                          new ClientConfig());
        } catch(Exception e) {
            logger.error("Error in setup", e);
            throw e;
        }
View Full Code Here

Examples of voldemort.client.protocol.admin.AdminClientConfig

        return config;
    }

    public static AdminClient getAdminClient(Cluster cluster) {

        AdminClientConfig config = new AdminClientConfig();
        return new AdminClient(cluster, config, new ClientConfig());
    }
View Full Code Here

Examples of voldemort.client.protocol.admin.AdminClientConfig

        AdminClientConfig config = new AdminClientConfig();
        return new AdminClient(cluster, config, new ClientConfig());
    }

    public static AdminClient getAdminClient(String bootstrapURL) {
        AdminClientConfig config = new AdminClientConfig();
        return new AdminClient(bootstrapURL, config, new ClientConfig());
    }
View Full Code Here

Examples of voldemort.client.protocol.admin.AdminClientConfig

                               List<String> storesList,
                               List<Integer> partitions,
                               ForkLiftTaskMode mode) {
        // set up AdminClient on source cluster
        this.srcAdminClient = new AdminClient(srcBootstrapUrl,
                                              new AdminClientConfig(),
                                              new ClientConfig());

        // set up streaming client to the destination cluster
        Props props = new Props();
        props.put("streaming.platform.bootstrapURL", dstBootstrapUrl);
View Full Code Here

Examples of voldemort.client.protocol.admin.AdminClientConfig

            dataDir = dataDir.replaceFirst(existingPort, this.hdfsFetcherPort);
        }

        // Create admin client
        AdminClient client = new AdminClient(cluster,
                                             new AdminClientConfig().setMaxConnectionsPerNode(cluster.getNumberOfNodes())
                                                                    .setAdminConnectionTimeoutSec(httpTimeoutMs / 1000)
                                                                    .setMaxBackoffDelayMs(swapConf.getMaxBackoffDelayMs()),
                                             new ClientConfig());

        if(pushVersion == -1L) {
View Full Code Here

Examples of voldemort.client.protocol.admin.AdminClientConfig

            AdminClient adminClient = null;
            ExecutorService service = null;
            try {
                service = Executors.newCachedThreadPool();
                adminClient = new AdminClient(clusterUrl,
                                              new AdminClientConfig(),
                                              new ClientConfig());
                Cluster cluster = adminClient.getAdminClientCluster();
                AdminStoreSwapper swapper = new AdminStoreSwapper(cluster,
                                                                  service,
                                                                  adminClient,
View Full Code Here

Examples of voldemort.client.protocol.admin.AdminClientConfig

        StoreSwapper swapper = null;
        AdminClient adminClient = null;

        DefaultHttpClient httpClient = null;
        if(useAdminServices) {
            adminClient = new AdminClient(cluster, new AdminClientConfig(), new ClientConfig());
            swapper = new AdminStoreSwapper(cluster, executor, adminClient, timeoutMs);
        } else {
            int numConnections = cluster.getNumberOfNodes() + 3;
            ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager();
            httpClient = new DefaultHttpClient(connectionManager);
View Full Code Here

Examples of voldemort.client.protocol.admin.AdminClientConfig

                                                             // Retrieve admin
                                                             // client for
                                                             // verification of
                                                             // schema + pushing
                                                             adminClient = new AdminClient(url,
                                                                                           new AdminClientConfig(),
                                                                                           new ClientConfig());

                                                             // Verify the store
                                                             // exists ( If not,
                                                             // add it
                                                             // the
                                                             // store )
                                                             Pair<StoreDefinition, Cluster> metadata = verifySchema(storeName,
                                                                                                                    url,
                                                                                                                    inputDirsPerStore.get(storeName),
                                                                                                                    adminClient);

                                                             // Populate the url
                                                             // to cluster
                                                             // metadata
                                                             urlToCluster.put(url,
                                                                              metadata.getSecond());

                                                             // Create output
                                                             // directory path
                                                             URI uri = new URI(url);

                                                             Path outputDirPath = new Path(outputDir
                                                                                                   + Path.SEPARATOR
                                                                                                   + storeName,
                                                                                           uri.getHost());

                                                             log.info("Running build phase for store '"
                                                                      + storeName
                                                                      + "' and url '"
                                                                      + url
                                                                      + "'. Reading from input directory '"
                                                                      + inputDirsPerStore.get(storeName)
                                                                      + "' and writing to "
                                                                      + outputDirPath);

                                                             runBuildStore(metadata.getSecond(),
                                                                           metadata.getFirst(),
                                                                           inputDirsPerStore.get(storeName),
                                                                           outputDirPath);

                                                             log.info("Finished running build phase for store "
                                                                      + storeName
                                                                      + " and url '"
                                                                      + url
                                                                      + "'. Written to directory "
                                                                      + outputDirPath);

                                                             long storePushVersion = pushVersion;
                                                             if(storePushVersion == -1L) {
                                                                 log.info("Retrieving version number for store '"
                                                                          + storeName
                                                                          + "' and cluster '"
                                                                          + url
                                                                          + "'");

                                                                 Map<String, Long> pushVersions = adminClient.readonlyOps.getROMaxVersion(Lists.newArrayList(storeName));

                                                                 if(pushVersions == null
                                                                    || !pushVersions.containsKey(storeName)) {
                                                                     throw new RuntimeException("Could not retrieve version for store '"
                                                                                                + storeName
                                                                                                + "'");
                                                                 }

                                                                 storePushVersion = pushVersions.get(storeName);
                                                                 storePushVersion++;

                                                                 log.info("Retrieved max version number for store '"
                                                                          + storeName
                                                                          + "' and cluster '"
                                                                          + url
                                                                          + "' = "
                                                                          + storePushVersion);
                                                             }

                                                             log.info("Running push for cluster url "
                                                                      + url);

                                                             // Used for
                                                             // parallel pushing
                                                             internalExecutor = Executors.newCachedThreadPool();

                                                             AdminStoreSwapper swapper = new AdminStoreSwapper(metadata.getSecond(),
                                                                                                               internalExecutor,
                                                                                                               adminClient,
                                                                                                               1000 * props.getInt("timeout.seconds",
                                                                                                                                   24 * 60 * 60),
                                                                                                               true,
                                                                                                               true);

                                                             // Convert to
                                                             // hadoop specific
                                                             // path
                                                             String outputDirPathString = outputDirPath.makeQualified(fs)
                                                                                                       .toString();

                                                             if(!fs.exists(outputDirPath)) {
                                                                 throw new RuntimeException("Output directory for store "
                                                                                            + storeName
                                                                                            + " and cluster '"
                                                                                            + url
                                                                                            + "' - "
                                                                                            + outputDirPathString
                                                                                            + " does not exist");
                                                             }

                                                             log.info("Pushing data to store '"
                                                                      + storeName + "' on cluster "
                                                                      + url + " from path  "
                                                                      + outputDirPathString
                                                                      + " with version "
                                                                      + storePushVersion);

                                                             List<String> nodeDirs = swapper.invokeFetch(storeName,
                                                                                                         outputDirPathString,
                                                                                                         storePushVersion);

                                                             log.info("Successfully pushed data to store '"
                                                                      + storeName
                                                                      + "' on cluster "
                                                                      + url
                                                                      + " from path  "
                                                                      + outputDirPathString
                                                                      + " with version "
                                                                      + storePushVersion);

                                                             return nodeDirs;
                                                         } finally {
                                                             if(internalExecutor != null) {
                                                                 internalExecutor.shutdownNow();
                                                                 internalExecutor.awaitTermination(10,
                                                                                                   TimeUnit.SECONDS);
                                                             }
                                                             if(adminClient != null) {
                                                                 adminClient.close();
                                                             }
                                                         }
                                                     }

                                                 }));

                }

            }

            for(final String storeName: storeNames) {
                for(int index = 0; index < clusterUrls.size(); index++) {
                    Pair<String, String> key = Pair.create(clusterUrls.get(index), storeName);
                    Future<List<String>> nodeDirs = fetchDirsPerStoreCluster.get(key);
                    try {
                        nodeDirPerClusterStore.put(key, nodeDirs.get());
                    } catch(Exception e) {
                        exceptions.put(key, e);
                    }
                }
            }

        } finally {
            if(executor != null) {
                executor.shutdownNow();
                executor.awaitTermination(10, TimeUnit.SECONDS);
            }
        }

        // ===== If we got exceptions during the build + push, delete data from
        // successful
        // nodes ======
        if(!exceptions.isEmpty()) {

            log.error("Got an exception during pushes. Deleting data already pushed on successful nodes");

            for(int index = 0; index < clusterUrls.size(); index++) {
                String clusterUrl = clusterUrls.get(index);
                Cluster cluster = urlToCluster.get(clusterUrl);

                AdminClient adminClient = null;
                try {
                    adminClient = new AdminClient(cluster,
                                                  new AdminClientConfig(),
                                                  new ClientConfig());
                    for(final String storeName: storeNames) {
                        // Check if the [ cluster , store name ] succeeded. We
                        // need to roll it back
                        Pair<String, String> key = Pair.create(clusterUrl, storeName);

                        if(nodeDirPerClusterStore.containsKey(key)) {
                            List<String> nodeDirs = nodeDirPerClusterStore.get(key);

                            log.info("Deleting data for successful pushes to " + clusterUrl
                                     + " and store " + storeName);
                            int nodeId = 0;
                            for(String nodeDir: nodeDirs) {
                                try {
                                    log.info("Deleting data ( " + nodeDir
                                             + " ) for successful pushes to '" + clusterUrl
                                             + "' and store '" + storeName + "' and node " + nodeId);
                                    adminClient.readonlyOps.failedFetchStore(nodeId,
                                                                             storeName,
                                                                             nodeDir);
                                    log.info("Successfully deleted data for successful pushes to '"
                                             + clusterUrl + "' and store '" + storeName
                                             + "' and node " + nodeId);

                                } catch(Exception e) {
                                    log.error("Failure while deleting data on node " + nodeId
                                              + " for store '" + storeName + "' and url '"
                                              + clusterUrl + "'");
                                }
                                nodeId++;
                            }
                        }
                    }
                } finally {
                    if(adminClient != null) {
                        adminClient.close();
                    }
                }
            }

            int errorNo = 1;
            for(Pair<String, String> key: exceptions.keySet()) {
                log.error("Error no " + errorNo + "] Error pushing for cluster '" + key.getFirst()
                          + "' and store '" + key.getSecond() + "' :", exceptions.get(key));
                errorNo++;
            }

            throw new VoldemortException("Exception during build + push");
        }

        // ====== Delete the temporary directory since we don't require it
        // ======
        if(!props.getBoolean("build.output.keep", false)) {
            JobConf jobConf = new JobConf();

            if(props.containsKey("hadoop.job.ugi")) {
                jobConf.set("hadoop.job.ugi", props.getString("hadoop.job.ugi"));
            }

            log.info("Deleting output directory since we have finished the pushes " + outputDir);
            HadoopUtils.deletePathIfExists(jobConf, outputDir.toString());
            log.info("Successfully deleted output directory since we have finished the pushes"
                     + outputDir);
        }

        // ====== Time to swap the stores one node at a time ========
        try {
            for(int index = 0; index < clusterUrls.size(); index++) {
                String url = clusterUrls.get(index);
                Cluster cluster = urlToCluster.get(url);

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

                log.info("Swapping all stores on cluster " + url);
                try {
                    // Go over every node and swap
                    for(Node node: cluster.getNodes()) {

                        log.info("Swapping all stores on cluster " + url + " and node "
                                 + node.getId());

                        // Go over every store and swap
                        for(String storeName: storeNames) {

                            Pair<String, String> key = Pair.create(url, storeName);
                            log.info("Swapping '" + storeName + "' store on cluster " + url
                                     + " and node " + node.getId() + " - "
                                     + nodeDirPerClusterStore.get(key).get(node.getId()));

                            previousNodeDirPerClusterStore.put(key,
                                                               Pair.create(node.getId(),
                                                                           adminClient.readonlyOps.swapStore(node.getId(),
                                                                                                             storeName,
                                                                                                             nodeDirPerClusterStore.get(key)
                                                                                                                                   .get(node.getId()))));
                            log.info("Successfully swapped '" + storeName + "' store on cluster "
                                     + url + " and node " + node.getId());

                        }

                    }
                } finally {
                    adminClient.close();

                }
            }
        } catch(Exception e) {

            log.error("Got an exception during swaps. Rolling back data already pushed on successful nodes");

            for(Pair<String, String> clusterStoreTuple: previousNodeDirPerClusterStore.keySet()) {
                Collection<Pair<Integer, String>> nodeToPreviousDirs = previousNodeDirPerClusterStore.get(clusterStoreTuple);
                String url = clusterStoreTuple.getFirst();
                Cluster cluster = urlToCluster.get(url);

                log.info("Rolling back for cluster " + url + " and store  "
                         + clusterStoreTuple.getSecond());

                AdminClient adminClient = new AdminClient(cluster,
                                                          new AdminClientConfig(),
                                                          new ClientConfig());
                try {
                    for(Pair<Integer, String> nodeToPreviousDir: nodeToPreviousDirs) {
                        log.info("Rolling back for cluster " + url + " and store "
                                 + clusterStoreTuple.getSecond() + " and node "
View Full Code Here

Examples of voldemort.client.protocol.admin.AdminClientConfig

                                              sourceCluster);

        Properties adminProperties = new Properties();
        adminProperties.setProperty("max_connections", "2");
        adminClient = new AdminClient(servers[0].getMetadataStore().getCluster(),
                                      new AdminClientConfig(adminProperties),
                                      new ClientConfig());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.