Search in sources :

Example 1 with CLUSTER_EVENT

use of org.onosproject.security.AppPermission.Type.CLUSTER_EVENT in project onos by opennetworkinglab.

the class UpgradeManager method handleClusterEvent.

/**
 * Handles a cluster event.
 *
 * @param event the cluster event
 */
protected void handleClusterEvent(ClusterEvent event) {
    checkPermission(CLUSTER_EVENT);
    // If an instance was deactivated, check whether we need to roll back the upgrade.
    if (event.type() == ClusterEvent.Type.INSTANCE_DEACTIVATED) {
        Upgrade upgrade = getState();
        if (upgrade.status().upgraded()) {
            // Get the upgraded subset of the cluster and check whether the down node is a member
            // of the upgraded subset. If so, roll back the upgrade to tolerate the failure.
            Set<NodeId> upgradedNodes = clusterService.getNodes().stream().map(ControllerNode::id).filter(id -> clusterService.getVersion(id).equals(upgrade.target())).collect(Collectors.toSet());
            if (upgradedNodes.contains(event.subject().id())) {
                log.warn("Upgrade failure detected: rolling back upgrade");
                rollback();
            }
        }
    }
}
Also used : AtomicValueEvent(org.onosproject.store.service.AtomicValueEvent) AppGuard.checkPermission(org.onosproject.security.AppGuard.checkPermission) CLUSTER_EVENT(org.onosproject.security.AppPermission.Type.CLUSTER_EVENT) CoordinationService(org.onosproject.store.service.CoordinationService) AtomicReference(java.util.concurrent.atomic.AtomicReference) ControllerNode(org.onosproject.cluster.ControllerNode) AtomicValue(org.onosproject.store.service.AtomicValue) Component(org.osgi.service.component.annotations.Component) Upgrade(org.onosproject.upgrade.Upgrade) VersionService(org.onosproject.core.VersionService) Version(org.onosproject.core.Version) Activate(org.osgi.service.component.annotations.Activate) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) NodeId(org.onosproject.cluster.NodeId) UpgradeEventListener(org.onosproject.upgrade.UpgradeEventListener) Serializer(org.onosproject.store.service.Serializer) ClusterEventListener(org.onosproject.cluster.ClusterEventListener) UpgradeService(org.onosproject.upgrade.UpgradeService) Logger(org.slf4j.Logger) UPGRADE_EVENT(org.onosproject.security.AppPermission.Type.UPGRADE_EVENT) UPGRADE_READ(org.onosproject.security.AppPermission.Type.UPGRADE_READ) ClusterEvent(org.onosproject.cluster.ClusterEvent) AbstractListenerManager(org.onosproject.event.AbstractListenerManager) Deactivate(org.osgi.service.component.annotations.Deactivate) Set(java.util.Set) Collectors(java.util.stream.Collectors) AtomicValueEventListener(org.onosproject.store.service.AtomicValueEventListener) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Objects(java.util.Objects) UpgradeEvent(org.onosproject.upgrade.UpgradeEvent) UpgradeAdminService(org.onosproject.upgrade.UpgradeAdminService) MembershipService(org.onosproject.cluster.MembershipService) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) ClusterService(org.onosproject.cluster.ClusterService) UPGRADE_WRITE(org.onosproject.security.AppPermission.Type.UPGRADE_WRITE) Reference(org.osgi.service.component.annotations.Reference) NodeId(org.onosproject.cluster.NodeId) ControllerNode(org.onosproject.cluster.ControllerNode) Upgrade(org.onosproject.upgrade.Upgrade)

Aggregations

Objects (java.util.Objects)1 Set (java.util.Set)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Collectors (java.util.stream.Collectors)1 ClusterEvent (org.onosproject.cluster.ClusterEvent)1 ClusterEventListener (org.onosproject.cluster.ClusterEventListener)1 ClusterService (org.onosproject.cluster.ClusterService)1 ControllerNode (org.onosproject.cluster.ControllerNode)1 MembershipService (org.onosproject.cluster.MembershipService)1 NodeId (org.onosproject.cluster.NodeId)1 Version (org.onosproject.core.Version)1 VersionService (org.onosproject.core.VersionService)1 AbstractListenerManager (org.onosproject.event.AbstractListenerManager)1 AppGuard.checkPermission (org.onosproject.security.AppGuard.checkPermission)1 CLUSTER_EVENT (org.onosproject.security.AppPermission.Type.CLUSTER_EVENT)1 UPGRADE_EVENT (org.onosproject.security.AppPermission.Type.UPGRADE_EVENT)1 UPGRADE_READ (org.onosproject.security.AppPermission.Type.UPGRADE_READ)1 UPGRADE_WRITE (org.onosproject.security.AppPermission.Type.UPGRADE_WRITE)1 KryoNamespaces (org.onosproject.store.serializers.KryoNamespaces)1 AtomicValue (org.onosproject.store.service.AtomicValue)1