Package com.netflix.genie.common.exceptions

Examples of com.netflix.genie.common.exceptions.GeniePreconditionException


    //TODO: Shares a lot of code with the add, should be able to refactor
    public List<Command> updateCommandsForCluster(
            final String id,
            final List<Command> commands) throws GenieException {
        if (StringUtils.isBlank(id)) {
            throw new GeniePreconditionException("No cluster id entered. Unable to update commands.");
        }
        if (commands == null) {
            throw new GeniePreconditionException("No commands entered. Unable to add commands.");
        }
        final Cluster cluster = this.clusterRepo.findOne(id);
        if (cluster != null) {
            final List<Command> cmds = new ArrayList<>();
            for (final Command detached : commands) {
View Full Code Here


     */
    @Override
    public List<Command> removeAllCommandsForCluster(
            final String id) throws GenieException {
        if (StringUtils.isBlank(id)) {
            throw new GeniePreconditionException("No cluster id entered. Unable to remove commands.");
        }
        final Cluster cluster = this.clusterRepo.findOne(id);
        if (cluster != null) {
            final List<Command> cmdList = new ArrayList<>();
            cmdList.addAll(cluster.getCommands());
View Full Code Here

    @Override
    public List<Command> removeCommandForCluster(
            final String id,
            final String cmdId) throws GenieException {
        if (StringUtils.isBlank(id)) {
            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) {
View Full Code Here

    @Override
    public Set<String> addTagsForCluster(
            final String id,
            final Set<String> tags) throws GenieException {
        if (StringUtils.isBlank(id)) {
            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();
View Full Code Here

    public Set<String> getTagsForCluster(
            final String id)
            throws GenieException {

        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();
View Full Code Here

    @Override
    public Set<String> updateTagsForCluster(
            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();
View Full Code Here

     */
    @Override
    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();
View Full Code Here

     */
    @Override
    public Set<String> removeTagForCluster(final String id, final String tag)
            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)) {
View Full Code Here

        LOG.info("called");

        if (clusters == null || clusters.isEmpty()) {
            final String msg = "No cluster configuration found to match user params";
            LOG.error(msg);
            throw new GeniePreconditionException(msg);
        }

        // return a random one
        final Random rand = new Random();
        return clusters.get(Math.abs(rand.nextInt(clusters.size())));
View Full Code Here

        LOG.info("called");

        if (job == null) {
            final String msg = "No job entered. Unable to continue";
            LOG.error(msg);
            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) {
                final JobManager jobManager = (JobManager) instance;
                jobManager.init(job, cluster);
                return jobManager;
            } else {
                final String msg = className + " is not of type JobManager. Unable to continue.";
                LOG.error(msg);
                throw new GeniePreconditionException(msg);
            }
        } catch (final ClassNotFoundException | BeansException e) {
            final String msg = "Unable to create job manager for class name " + className;
            LOG.error(msg, e);
            throw new GenieBadRequestException(msg);
View Full Code Here

TOP

Related Classes of com.netflix.genie.common.exceptions.GeniePreconditionException

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.