2 * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.sal.common.api.clustering;
10 import com.google.common.base.Preconditions;
11 import javax.annotation.Nonnull;
14 * A DTO that encapsulates an ownership change for an entity.
16 * @author Thomas Pantelis
18 public class EntityOwnershipChange {
19 private final Entity entity;
20 private final boolean wasOwner;
21 private final boolean isOwner;
22 private final boolean hasOwner;
23 private final boolean inJeopardy;
25 public EntityOwnershipChange(@Nonnull Entity entity, boolean wasOwner, boolean isOwner, boolean hasOwner) {
26 this(entity, wasOwner, isOwner, hasOwner, false);
29 public EntityOwnershipChange(@Nonnull Entity entity, boolean wasOwner, boolean isOwner, boolean hasOwner,
31 this.entity = Preconditions.checkNotNull(entity, "entity can't be null");
32 this.wasOwner = wasOwner;
33 this.isOwner = isOwner;
34 this.hasOwner = hasOwner;
35 this.inJeopardy = inJeopardy;
39 * Returns the entity whose ownership status changed.
42 @Nonnull public Entity getEntity() {
47 * Returns the previous ownership status of the entity for this process instance.
48 * @return true if this process was the owner of the entity at the time this notification was generated
50 public boolean wasOwner() {
55 * Returns the current ownership status of the entity for this process instance.
56 * @return true if this process is now the owner of the entity
58 public boolean isOwner() {
63 * Returns the current ownership status of the entity across all process instances.
64 * @return true if the entity has an owner which may or may not be this process. If false, then
65 * the entity has no candidates and thus no owner.
67 public boolean hasOwner() {
72 * Returns the current jeopardy state. When in a jeopardy state, the values from other methods may potentially
75 * @return true if the local node is in a jeopardy state. If false, the reported information is accurate.
77 public boolean inJeopardy() {
82 public String toString() {
83 return "EntityOwnershipChanged [entity=" + entity + ", wasOwner=" + wasOwner + ", isOwner=" + isOwner
84 + ", hasOwner=" + hasOwner + ", inJeopardy=" + inJeopardy + "]";