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

org.btrplace.model.constraint.Quarantine 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.Node;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * A constraint to put a node into quarantine.
 * Running VMs in the quarantine zone can not leave their node
 * while no VMs outside the quarantine zone can be hosted on
 * the node in quarantine.
 * 

* The restriction provided by the constraint is only continuous. * * @author Fabien Hermenier */ @SideConstraint(args = {"n : nodes"}, inv = "(!(v : hosted(n)) Root(v)) & (!(v2 /: hosted(n)) Ban(v2, {n}))") public class Quarantine implements SatConstraint { private Node node; /** * Make a new constraint. * * @param n the node to put into quarantine */ public Quarantine(Node n) { this.node = n; } @Override public SatConstraintChecker getChecker() { return new QuarantineChecker(this); } @Override public String toString() { return "quarantine(" + "node=" + node + ", continuous" + ")"; } @Override public boolean setContinuous(boolean b) { return b; } /** * Instantiate constraints for a collection of nodes. * * @param nodes the nodes to integrate * @return the associated list of constraints */ public static List newQuarantine(Collection nodes) { return nodes.stream().map(Quarantine::new).collect(Collectors.toList()); } @Override public Collection getInvolvedNodes() { return Collections.singleton(node); } @Override public boolean isContinuous() { return true; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Quarantine that = (Quarantine) o; return Objects.equals(node, that.node); } @Override public int hashCode() { return Objects.hash(node); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy