Package com.netflix.genie.client

Examples of com.netflix.genie.client.ClusterServiceClient


        LOG.info(command1.toString());
        final List<Command> commands = new ArrayList<>();
        commands.add(command1);

        LOG.info("Initializing ClusterConfigServiceClient");
        final ClusterServiceClient clusterClient = ClusterServiceClient.getInstance();

        LOG.info("Creating new cluster configuration");
        final Cluster cluster1 = clusterClient.createCluster(createSampleCluster(ID));
        clusterClient.addCommandsToCluster(cluster1.getId(), commands);

        LOG.info("Cluster config created with id: " + cluster1.getId());
        LOG.info(cluster1.toString());

        LOG.info("Getting cluster config by id");
        final Cluster cluster2 = clusterClient.getCluster(cluster1.getId());
        LOG.info(cluster2.toString());

        LOG.info("Getting clusterConfigs using specified filter criteria");
        final Multimap<String, String> params = ArrayListMultimap.create();
        params.put("name", NAME);
        params.put("adHoc", "false");
        params.put("test", "true");
        params.put("limit", "3");
        final List<Cluster> clusters = clusterClient.getClusters(params);
        if (clusters != null && !clusters.isEmpty()) {
            for (final Cluster cluster : clusters) {
                LOG.info(cluster.toString());
            }
        } else {
            LOG.info("No clusters found for parameters");
        }

        LOG.info("Configurations for cluster with id " + cluster1.getId());
        final Set<String> configs = clusterClient.getConfigsForCluster(cluster1.getId());
        for (final String config : configs) {
            LOG.info("Config = " + config);
        }

        LOG.info("Adding configurations to cluster with id " + cluster1.getId());
        final Set<String> newConfigs = new HashSet<>();
        newConfigs.add("someNewConfigFile");
        newConfigs.add("someOtherNewConfigFile");
        final Set<String> configs2 = clusterClient.addConfigsToCluster(cluster1.getId(), newConfigs);
        for (final String config : configs2) {
            LOG.info("Config = " + config);
        }

        LOG.info("Updating set of configuration files associated with id " + cluster1.getId());
        //This should remove the original config leaving only the two in this set
        final Set<String> configs3 = clusterClient.updateConfigsForCluster(cluster1.getId(), newConfigs);
        for (final String config : configs3) {
            LOG.info("Config = " + config);
        }

        /**************** Begin tests for tag Api's *********************/
        LOG.info("Get tags for cluster with id " + cluster1.getId());
        final Set<String> tags = cluster1.getTags();
        for (final String tag : tags) {
            LOG.info("Tag = " + tag);
        }

        LOG.info("Adding tags to cluster with id " + cluster1.getId());
        final Set<String> newTags = new HashSet<>();
        newTags.add("tag1");
        newTags.add("tag2");
        final Set<String> tags2 = clusterClient.addTagsToCluster(cluster1.getId(), newTags);
        for (final String tag : tags2) {
            LOG.info("Tag = " + tag);
        }

        LOG.info("Updating set of tags associated with id " + cluster1.getId());
        //This should remove the original config leaving only the two in this set
        final Set<String> tags3 = clusterClient.updateTagsForCluster(cluster1.getId(), newTags);
        for (final String tag : tags3) {
            LOG.info("Tag = " + tag);
        }

        LOG.info("Deleting one tag from the cluster with id " + cluster1.getId());
        //This should remove the "tag3" from the tags
        final Set<String> tags5 = clusterClient.removeTagForCluster(cluster1.getId(), "tag1");
        for (final String tag : tags5) {
            //Shouldn't print anything
            LOG.info("Tag = " + tag);
        }

        LOG.info("Deleting all the tags from the cluster with id " + cluster1.getId());
        //This should remove the original config leaving only the two in this set
        final Set<String> tags4 = clusterClient.removeAllTagsForCluster(cluster1.getId());
        for (final String tag : tags4) {
            //Shouldn't print anything
            LOG.info("Config = " + tag);
        }
        /********************** End tests for tag Api's **********************/

        LOG.info("Commands for cluster with id " + cluster1.getId());
        final List<Command> commands1 = clusterClient.getCommandsForCluster(cluster1.getId());
        for (final Command command : commands1) {
            LOG.info("Command = " + command);
        }

        LOG.info("Adding commands to cluster with id " + cluster1.getId());
        final List<Command> newCmds = new ArrayList<>();
        newCmds.add(commandClient.createCommand(CommandServiceSampleClient.createSampleCommand(ID + "something")));
        newCmds.add(commandClient.createCommand(CommandServiceSampleClient.createSampleCommand(null)));

        final List<Command> commands2 = clusterClient.addCommandsToCluster(cluster1.getId(), newCmds);
        for (final Command command : commands2) {
            LOG.info("Command = " + command);
        }

        LOG.info("Updating set of commands files associated with id " + cluster1.getId());
        //This should remove the original config leaving only the two in this set
        final List<Command> commands3 = clusterClient.updateCommandsForCluster(cluster1.getId(), newCmds);
        for (final Command command : commands3) {
            LOG.info("Command = " + command);
        }

        LOG.info("Deleting the command from the cluster with id " + ID + "something");
        final Set<Command> commands4 = clusterClient.removeCommandForCluster(cluster1.getId(), ID + "something");
        for (final Command command : commands4) {
            LOG.info("Command = " + command);
        }

        LOG.info("Deleting all the commands from the command with id " + command1.getId());
        final List<Command> commands5 = clusterClient.removeAllCommandsForCluster(cluster1.getId());
        for (final Command command : commands5) {
            //Shouldn't print anything
            LOG.info("Command = " + command);
        }

        LOG.info("Updating existing cluster config");
        cluster2.setStatus(ClusterStatus.TERMINATED);
        final Cluster cluster3 = clusterClient.updateCluster(cluster2.getId(), cluster2);
        LOG.info("Cluster updated:");
        LOG.info(cluster3.toString());

        LOG.info("Deleting cluster config using id");
        final Cluster cluster4 = clusterClient.deleteCluster(cluster1.getId());
        LOG.info("Deleted cluster config with id: " + cluster1.getId());
        LOG.info(cluster4.toString());

        LOG.info("Deleting command config using id");
        final Command command5 = commandClient.deleteCommand(command1.getId());
View Full Code Here

TOP

Related Classes of com.netflix.genie.client.ClusterServiceClient

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.