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

org.btrplace.model.constraint.Gather 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.model.VM;

import java.util.Collection;
import java.util.Objects;

/**
 * A constraint to force a set of VMs, if running, to be
 * hosted on the same node.
 * 

* If the restriction is discrete, VMs may then be temporary not co-located during the reconfiguration process but they * are ensure of being co-located at the end of the reconfiguration. *

* If the restriction is continuous, VMs will always be co-located. In practice, if the VMs are all running, they * have to already be co-located and it will not possible to relocate them to avoid a potential temporary separation. * * @author Fabien Hermenier */ public class Gather extends SimpleConstraint { private Collection vms; /** * Make a new constraint with a discrete restriction. * * @param vms the VMs to group */ public Gather(Collection vms) { this(vms, false); } /** * Make a new constraint. * * @param vms the VMs to group * @param continuous {@code true} for a continuous restriction */ public Gather(Collection vms, boolean continuous) { super(continuous); this.vms = vms; } @Override public String toString() { return "gather(" + "vms=" + vms + ", " + (isContinuous() ? "continuous" : "discrete") + ')'; } @Override public SatConstraintChecker getChecker() { return new GatherChecker(this); } @Override public Collection getInvolvedVMs() { return vms; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Gather gather = (Gather) o; return isContinuous() == gather.isContinuous() && Objects.equals(vms, gather.vms); } @Override public int hashCode() { return Objects.hash(vms, isContinuous()); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy