All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.btrplace.model.constraint.NoDelayChecker Maven / Gradle / Ivy

/*
 * Copyright (c) 2016 University Nice Sophia Antipolis
 *
 * This file is part of btrplace.
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see .
 */

package org.btrplace.model.constraint;

import org.btrplace.plan.event.*;

/**
 * Checker for the {@link org.btrplace.model.constraint.NoDelay} constraint
 *
 * @author Vincent Kherbache
 * @see org.btrplace.model.constraint.NoDelay
 */
public class NoDelayChecker extends AllowAllConstraintChecker {

    /**
     * Make a new checker.
     *
     * @param nd the constraint associated to the checker.
     */
    public NoDelayChecker(NoDelay nd) {
        super(nd);
    }

    @Override
    public boolean start(MigrateVM a) {
        if (getVMs().contains(a.getVM())) {
            if (a.getStart() == 0) {
                return startRunningVMPlacement(a);
            }
            return false;
        }
        return true;
    }

    @Override
    public boolean start(BootVM a) {
        if (getVMs().contains(a.getVM())) {
            if (a.getStart() == 0) {
                return startRunningVMPlacement(a);
            }
            return false;
        }
        return true;
    }

    @Override
    public boolean start(ShutdownVM a) {
        if (getVMs().contains(a.getVM())) {
            return a.getStart() == 0;
        }
        return true;
    }

    @Override
    public boolean start(ResumeVM a) {
        if (getVMs().contains(a.getVM())) {
            if (a.getStart() == 0) {
                return startRunningVMPlacement(a);
            }
            return false;
        }
        return true;
    }

    @Override
    public boolean start(SuspendVM a) {
        if (getVMs().contains(a.getVM())) {
            return a.getStart() == 0;
        }
        return true;
    }

    @Override
    public boolean start(KillVM a) {
        if (getVMs().contains(a.getVM())) {
            return a.getStart() == 0;
        }
        return true;
    }

    @Override
    public boolean start(ForgeVM a) {
        if (getVMs().contains(a.getVM())) {
            return a.getStart() == 0;
        }
        return true;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy