Package com.netflix.genie.common.model

Examples of com.netflix.genie.common.model.Cluster


            throw new GeniePreconditionException("No cluster id entered. Unable to remove command.");
        }
        if (StringUtils.isBlank(cmdId)) {
            throw new GeniePreconditionException("No command id entered. Unable to remove command.");
        }
        final Cluster cluster = this.clusterRepo.findOne(id);
        if (cluster != null) {
            final Command cmd = this.commandRepo.findOne(cmdId);
            if (cmd != null) {
                cluster.removeCommand(cmd);
            } else {
                throw new GenieNotFoundException("No command with id " + cmdId + " exists.");
            }
            return cluster.getCommands();
        } else {
            throw new GenieNotFoundException("No cluster with id " + id + " exists.");
        }
    }
View Full Code Here


            throw new GeniePreconditionException("No cluster id entered. Unable to add tags.");
        }
        if (tags == null) {
            throw new GeniePreconditionException("No tags entered.");
        }
        final Cluster cluster = this.clusterRepo.findOne(id);
        if (cluster != null) {
            cluster.getTags().addAll(tags);
            return cluster.getTags();
        } else {
            throw new GenieNotFoundException("No cluster with id " + id + " exists.");
        }
    }
View Full Code Here

        if (StringUtils.isBlank(id)) {
            throw new GeniePreconditionException("No cluster id sent. Cannot retrieve tags.");
        }

        final Cluster cluster = this.clusterRepo.findOne(id);
        if (cluster != null) {
            return cluster.getTags();
        } else {
            throw new GenieNotFoundException("No cluster with id " + id + " exists.");
        }
    }
View Full Code Here

            final String id,
            final Set<String> tags) throws GenieException {
        if (StringUtils.isBlank(id)) {
            throw new GeniePreconditionException("No cluster id entered. Unable to update tags.");
        }
        final Cluster cluster = this.clusterRepo.findOne(id);
        if (cluster != null) {
            cluster.setTags(tags);
            return cluster.getTags();
        } else {
            throw new GenieNotFoundException("No cluster with id " + id + " exists.");
        }
    }
View Full Code Here

    public Set<String> removeAllTagsForCluster(
            final String id) throws GenieException {
        if (StringUtils.isBlank(id)) {
            throw new GeniePreconditionException("No cluster id entered. Unable to remove tags.");
        }
        final Cluster cluster = this.clusterRepo.findOne(id);
        if (cluster != null) {
            cluster.getTags().clear();
            return cluster.getTags();
        } else {
            throw new GenieNotFoundException("No cluster with id " + id + " exists.");
        }
    }
View Full Code Here

            throws GenieException {
        if (StringUtils.isBlank(id)) {
            throw new GeniePreconditionException("No cluster id entered. Unable to remove tag.");
        }

        final Cluster cluster = this.clusterRepo.findOne(id);
        if (cluster != null) {
            if (StringUtils.isNotBlank(tag)) {
                cluster.getTags().remove(tag);
            }
            return cluster.getTags();
        } else {
            throw new GenieNotFoundException("No cluster with id " + id + " exists.");
        }
    }
View Full Code Here

            throw new GeniePreconditionException(msg);
        }

        // Figure out a cluster to run this job. Cluster selection is done based on
        // ClusterCriteria tags and Command tags specified in the job.
        final Cluster cluster = this.clb.selectCluster(this.ccs.chooseClusterForJob(job.getId()));
        final String className = ConfigurationManager.getConfigInstance()
                .getString("netflix.genie.server." + cluster.getClusterType() + ".JobManagerImpl");

        try {
            final Class jobManagerClass = Class.forName(className);
            final Object instance = this.context.getBean(jobManagerClass);
            if (instance instanceof JobManager) {
View Full Code Here

            @ApiParam(value = "The cluster to create.", required = true)
            final Cluster cluster,
            @Context UriInfo uriInfo)
            throws GenieException {
        LOG.info("Called to create new cluster " + cluster);
        final Cluster createdCluster = this.ccs.createCluster(cluster);
        return Response.created(
                uriInfo.getAbsolutePathBuilder().path(createdCluster.getId()).build()).
                entity(createdCluster).
                build();
    }
View Full Code Here

     */
    @Test
    public void testValidCluster() throws GenieException {
        final Set<String> configs = new HashSet<>();
        configs.add("SomeConfig");
        final Cluster cce = new Cluster("name", "tgianos", ClusterStatus.UP, "jobManager", configs, "2.4.0");
        assertNotNull(this.clb.selectCluster(Arrays.asList(cce, cce, cce)));
    }
View Full Code Here

        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());
        LOG.info("Deleted command config with id: " + command1.getId());
        LOG.info(command5.toString());
View Full Code Here

TOP

Related Classes of com.netflix.genie.common.model.Cluster

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.