Package com.netflix.genie.common.model

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


     * @throws GenieException
     */
    @Test(expected = GenieNotFoundException.class)
    public void testUpdateApplicationNoAppExists() throws GenieException {
        this.service.updateApplication(
                UUID.randomUUID().toString(), new Application());
    }
View Full Code Here


     *
     * @throws GenieException
     */
    @Test(expected = GenieBadRequestException.class)
    public void testUpdateApplicationIdsDontMatch() throws GenieException {
        final Application updateApp = new Application();
        updateApp.setId(UUID.randomUUID().toString());
        this.service.updateApplication(APP_1_ID, updateApp);
    }
View Full Code Here

        if (StringUtils.isBlank(id)) {
            //Messages will be logged by exception mapper at resource level
            throw new GeniePreconditionException("No id entered. Unable to get");
        }
        LOG.debug("Called with id " + id);
        final Application app = this.applicationRepo.findOne(id);
        if (app == null) {
            throw new GenieNotFoundException("No application with id " + id);
        }

        return app;
View Full Code Here

        //Set the id if it's not set so we can merge
        if (StringUtils.isBlank(updateApp.getId())) {
            updateApp.setId(id);
        }
        LOG.debug("Called with app " + updateApp.toString());
        final Application app = this.em.merge(updateApp);
        app.validate();
        return app;
    }
View Full Code Here

            final String id) throws GenieException {
        if (StringUtils.isBlank(id)) {
            throw new GeniePreconditionException("No application id entered. Unable to delete.");
        }
        LOG.debug("Called with id " + id);
        final Application app = this.applicationRepo.findOne(id);
        if (app == null) {
            throw new GenieNotFoundException("No application with id " + id + " exists.");
        }

        if (app.getCommands() != null) {
            final Set<Command> commands = new HashSet<>();
            commands.addAll(app.getCommands());
            for (final Command command : commands) {
                command.setApplication(null);
            }
        }
        this.applicationRepo.delete(app);
View Full Code Here

        LOG.info("Initializing ApplicationServiceClient");
        final ApplicationServiceClient appClient = ApplicationServiceClient.getInstance();

        LOG.info("Creating new application config");
        final Application app1 = appClient.createApplication(getSampleApplication(null));
        LOG.info("Application configuration created with id: " + app1.getId());
        LOG.info(app1.toString());

        LOG.info("Getting Applications using specified filter criteria name =  " + APP_NAME);
        final Multimap<String, String> params = ArrayListMultimap.create();
        params.put("name", APP_NAME);
        final List<Application> appResponses = appClient.getApplications(params);
        if (appResponses.isEmpty()) {
            LOG.info("No applications found for specified criteria.");
        } else {
            LOG.info("Applications found:");
            for (final Application appResponse : appResponses) {
                LOG.info(appResponse.toString());
            }
        }

        LOG.info("Getting application config by id");
        final Application app2 = appClient.getApplication(app1.getId());
        LOG.info(app2.toString());

        LOG.info("Updating existing application config");
        app2.setStatus(ApplicationStatus.INACTIVE);
        final Application app3 = appClient.updateApplication(app1.getId(), app2);
        LOG.info(app3.toString());

        LOG.info("Configurations for application with id " + app1.getId());
        final Set<String> configs = appClient.getConfigsForApplication(app1.getId());
        for (final String config : configs) {
            LOG.info("Config = " + config);
        }

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

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

        LOG.info("Deleting all the configuration files from the application with id " + app1.getId());
        //This should remove the original config leaving only the two in this set
        final Set<String> configs4 = appClient.removeAllConfigsForApplication(app1.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 application with id " + app1.getId());
        final Set<String> tags = app1.getTags();
        for (final String tag : tags) {
            LOG.info("Tag = " + tag);
        }

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

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

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

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

        LOG.info("Jars for application with id " + app1.getId());
        final Set<String> jars = appClient.getJarsForApplication(app1.getId());
        for (final String jar : jars) {
            LOG.info("jar = " + jar);
        }

        LOG.info("Adding jars to application with id " + app1.getId());
        final Set<String> newJars = new HashSet<>();
        newJars.add("someNewJarFile.jar");
        newJars.add("someOtherNewJarFile.jar");
        final Set<String> jars2 = appClient.addJarsToApplication(app1.getId(), newJars);
        for (final String jar : jars2) {
            LOG.info("jar = " + jar);
        }

        LOG.info("Updating set of jars associated with id " + app1.getId());
        //This should remove the original jar leaving only the two in this set
        final Set<String> jars3 = appClient.updateJarsForApplication(app1.getId(), newJars);
        for (final String jar : jars3) {
            LOG.info("jar = " + jar);
        }

        LOG.info("Deleting all the jars from the application with id " + app1.getId());
        //This should remove the original jar leaving only the two in this set
        final Set<String> jars4 = appClient.removeAllJarsForApplication(app1.getId());
        for (final String jar : jars4) {
            //Shouldn't print anything
            LOG.info("jar = " + jar);
        }

        LOG.info("Getting the commands associated with id " + app1.getId());
        final Set<Command> commands = appClient.getCommandsForApplication(app1.getId());
        for (final Command command : commands) {
            LOG.info("Command: " + command.toString());
        }

        LOG.info("Deleting application using id");
        final Application app4 = appClient.deleteApplication(app1.getId());
        LOG.info("Deleted application with id: " + app4.getId());
        LOG.info(app4.toString());

        LOG.info("Done");
    }
View Full Code Here

     * @param id The id to use or null/empty if want one created.
     * @return A sample application with id MR2
     * @throws GenieException For any issue
     */
    public static Application getSampleApplication(final String id) throws GenieException {
        final Application app = new Application(APP_NAME, "tgianos", ApplicationStatus.ACTIVE, APP_VERSION);
        if (StringUtils.isNotBlank(id)) {
            app.setId(id);
        }
        app.setVersion("2.4.0");
        final Set<String> configs = new HashSet<>();
        configs.add("s3://mybucket/mapred-site.xml");
        app.setConfigs(configs);

        final Set<String> jars = new HashSet<>();
        jars.add("s3://mybucket/foo.jar");
        app.setJars(jars);

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

                "localhost:7001");

        LOG.info("Initializing ApplicationServiceClient");
        final ApplicationServiceClient appClient = ApplicationServiceClient.getInstance();

        final Application app1 = appClient.createApplication(
                ApplicationServiceSampleClient.getSampleApplication(
                        ApplicationServiceSampleClient.ID
                ));
        LOG.info("Created application:");
        LOG.info(app1.toString());

        final Application app2 = appClient.createApplication(
                ApplicationServiceSampleClient.getSampleApplication(
                        ApplicationServiceSampleClient.ID + "2"
                ));
        LOG.info("Created application:");
        LOG.info(app2.toString());

        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());
        }

        LOG.info("Deleting application config using id");
        final Application app3 = appClient.deleteApplication(app1.getId());
        LOG.info("Deleted application config with id: " + app1.getId());
        LOG.info(app3.toString());

        LOG.info("Deleting application config using id");
        final Application app4 = appClient.deleteApplication(app2.getId());
        LOG.info("Deleted application config with id: " + app2.getId());
        LOG.info(app4.toString());

        LOG.info("Done");
    }
View Full Code Here

                "localhost:7001");

        LOG.info("Initializing ApplicationServiceClient");
        final ApplicationServiceClient appClient = ApplicationServiceClient.getInstance();

        final Application app1 = appClient.createApplication(
                ApplicationServiceSampleClient.getSampleApplication(
                        ApplicationServiceSampleClient.ID
                ));
        LOG.info("Created application:");
        LOG.info(app1.toString());

        final Application app2 = appClient.createApplication(
                ApplicationServiceSampleClient.getSampleApplication(
                        ApplicationServiceSampleClient.ID + "2"
                ));
        LOG.info("Created application:");
        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) {
View Full Code Here

            throw new GeniePreconditionException("No application id entered. Unable to add configurations.");
        }
        if (configs == null) {
            throw new GeniePreconditionException("No configuration files entered.");
        }
        final Application app = this.applicationRepo.findOne(id);
        if (app != null) {
            app.getConfigs().addAll(configs);
            return app.getConfigs();
        } else {
            throw new GenieNotFoundException("No application with id " + id + " exists.");
        }
    }
View Full Code Here

TOP

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

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.