Package com.netflix.genie.common.model

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


            throw new GeniePreconditionException("No commands entered. Unable to add commands.");
        }
        final Cluster cluster = this.clusterRepo.findOne(id);
        if (cluster != null) {
            for (final Command detached : commands) {
                final Command cmd = this.commandRepo.findOne(detached.getId());
                if (cmd != null) {
                    cluster.addCommand(cmd);
                } else {
                    throw new GenieNotFoundException("No command with id " + detached.getId() + " exists.");
                }
View Full Code Here


        }
        final Cluster cluster = this.clusterRepo.findOne(id);
        if (cluster != null) {
            final List<Command> cmds = new ArrayList<>();
            for (final Command detached : commands) {
                final Command cmd = this.commandRepo.findOne(detached.getId());
                if (cmd != null) {
                    cmds.add(cmd);
                } else {
                    throw new GenieNotFoundException("No command with id " + detached.getId() + " exists.");
                }
View Full Code Here

        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.");
            }
View Full Code Here

        // save the cluster name and id
        this.jobService.setClusterInfoForJob(this.job.getId(), this.cluster.getId(), this.cluster.getName());

        // Find the command for the job
        Command command = null;
        for (final Command cmd : this.cluster.getCommands()) {
            if (cmd.getTags().containsAll(this.job.getCommandCriteria())) {
                command = cmd;
                break;
            }
        }

        //Avoiding NPE
        if (command == null) {
            final String msg = "No command found for params. Unable to continue.";
            LOG.error(msg);
            throw new GeniePreconditionException(msg);
        }

        // save the command name, application id and application name
        this.jobService.setCommandInfoForJob(this.job.getId(), command.getId(), command.getName());

        final Application application = command.getApplication();
        if (application != null) {
            this.jobService.setApplicationInfoForJob(this.job.getId(), application.getId(), application.getName());
        }

        // Refresh the job in memory to get the changes
View Full Code Here

     *
     * @param processBuilder The process builder to use.
     * @throws GenieException On an error interacting with database.
     */
    private void setCommandAndApplicationForJob(final ProcessBuilder processBuilder) throws GenieException {
        final Command command = this.commandService.getCommand(this.job.getCommandId());

        if (command.getConfigs() != null && !command.getConfigs().isEmpty()) {
            processBuilder.environment()
                    .put("S3_COMMAND_CONF_FILES", convertCollectionToCSV(command.getConfigs()));
        }

        if (StringUtils.isNotBlank(command.getEnvPropFile())) {
            processBuilder.environment().put("COMMAND_ENV_FILE", command.getEnvPropFile());
        }

        final Application application = command.getApplication();
        if (application != null) {
            if (application.getConfigs() != null && !application.getConfigs().isEmpty()) {
                processBuilder.environment()
                        .put("S3_APPLICATION_CONF_FILES", convertCollectionToCSV(application.getConfigs()));
            }
View Full Code Here

                    required = true
            )
            final Command command,
            @Context final UriInfo uriInfo) throws GenieException {
        LOG.info("called to create new command configuration " + command.toString());
        final Command createdCommand = this.ccs.createCommand(command);
        return Response.created(
                uriInfo.getAbsolutePathBuilder().path(createdCommand.getId()).build()).
                entity(createdCommand).
                build();
    }
View Full Code Here

        LOG.info("Initializing CommandServiceClient");
        final CommandServiceClient commandClient = CommandServiceClient.getInstance();

        LOG.info("Creating command pig13_mr2");
        final Command command1 = commandClient.createCommand(
                CommandServiceSampleClient.createSampleCommand(
                        CommandServiceSampleClient.ID));

        commandClient.setApplicationForCommand(command1.getId(), app1);

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

        LOG.info("Deleting commands in newCmd");
        for (final Command cmd : newCmds) {
            commandClient.deleteCommand(cmd.getId());
        }
View Full Code Here

        LOG.info(app2.toString());
        LOG.info("Initializing CommandServiceClient");
        final CommandServiceClient commandClient = CommandServiceClient.getInstance();

        LOG.info("Creating command pig13_mr2");
        final Command command1 = commandClient.createCommand(createSampleCommand(ID));
        commandClient.setApplicationForCommand(command1.getId(), app1);
        LOG.info("Created command:");
        LOG.info(command1.toString());

        LOG.info("Getting Commands using specified filter criteria name =  " + CMD_NAME);
        final Multimap<String, String> params = ArrayListMultimap.create();
        params.put("name", CMD_NAME);
        final List<Command> commands = commandClient.getCommands(params);
        if (commands.isEmpty()) {
            LOG.info("No commands found for specified criteria.");
        } else {
            LOG.info("Commands found:");
            for (final Command command : commands) {
                LOG.info(command.toString());
            }
        }

        LOG.info("Getting command config by id");
        final Command command3 = commandClient.getCommand(ID);
        LOG.info(command3.toString());

        LOG.info("Updating existing command config");
        command3.setStatus(CommandStatus.INACTIVE);
        final Command command4 = commandClient.updateCommand(ID, command3);
        LOG.info(command4.toString());

        LOG.info("Configurations for command with id " + command1.getId());
        final Set<String> configs = commandClient.getConfigsForCommand(command1.getId());
        for (final String config : configs) {
            LOG.info("Config = " + config);
        }

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

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

        LOG.info("Deleting all the configuration files from the command with id " + command1.getId());
        //This should remove the original config leaving only the two in this set
        final Set<String> configs4 = commandClient.removeAllConfigsForCommand(command1.getId());
        for (final String config : configs4) {
            //Shouldn't print anything
            LOG.info("Config = " + config);
        }

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

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

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

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

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

        LOG.info("Application for command with id " + command1.getId());
        final Application application = commandClient.getApplicationForCommand(command1.getId());
        LOG.info("Application = " + application);

        LOG.info("Removing Application for command with id " + command1.getId());
        final Application application2 = commandClient.removeApplicationForCommand(command1.getId());
        LOG.info("Application = " + application2);

        LOG.info("Getting all the clusters for command with id  " + command1.getId());
        final Set<Cluster> clusters = commandClient.getClustersForCommand(command1.getId());
        for (final Cluster cluster : clusters) {
            LOG.info("Cluster = " + cluster);
        }

        LOG.info("Deleting command config using id");
        final Command command5 = commandClient.deleteCommand(ID);
        LOG.info("Deleted command config with id: " + ID);
        LOG.info(command5.toString());

        LOG.info("Deleting all applications");
        final List<Application> deletedApps = appClient.deleteAllApplications();
        LOG.info("Deleted all applications");
        LOG.info(deletedApps.toString());
View Full Code Here

     * @return The pig example command
     * @throws GenieException On configuration issue.
     */
    public static Command createSampleCommand(
            final String id) throws GenieException {
        final Command command = new Command(
                CMD_NAME,
                "tgianos",
                CommandStatus.ACTIVE,
                "/apps/pig/0.13/bin/pig",
                CMD_VERSION);
        if (StringUtils.isNotBlank(id)) {
            command.setId(id);
        }
        command.setEnvPropFile("s3:/mybucket/envFile.sh");
        command.setVersion("0.13");

        final Set<String> tags = new HashSet<>();
        tags.add("tag0");
        command.setTags(tags);
        return command;
    }
View Full Code Here

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

TOP

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

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.