2 * Copyright (c) 2015 Cisco 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.openflowplugin.api.openflow.role;
10 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
11 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SalRoleService;
15 import javax.annotation.Nonnull;
18 * Rewrote whole role context to prevent errors to change role on cluster
20 public interface RoleContext extends RequestContextStack, AutoCloseable {
23 * Initialization method is responsible for a registration of
24 * {@link org.opendaylight.controller.md.sal.common.api.clustering.Entity} and listener
25 * for notification from service
26 * {@link org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService}
27 * returns Role which has to be applied for responsible Device Context suite. Any Exception
28 * state has to close Device connection channel.
29 * @return true if initialization done ok
31 boolean initialization();
34 * Termination method is responsible for an unregistration of
35 * {@link org.opendaylight.controller.md.sal.common.api.clustering.Entity} and listener
36 * for notification from service
37 * {@link org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService}
38 * returns notification "Someone else take Leadership" or "I'm last"
39 * and we need to clean Oper. DS.
41 void unregisterAllCandidates();
44 * Setter for sal role service
45 * @param salRoleService
47 void setSalRoleService(@Nonnull final SalRoleService salRoleService);
50 * Getter for sal role service
53 SalRoleService getSalRoleService();
56 * Getter for main entity
62 * Getter for tx entity
74 * Returns true if main entity is registered
77 boolean isMainCandidateRegistered();
80 * Returns true if tx entity is registered
83 boolean isTxCandidateRegistered();
86 * Register candidate depending on parameter
88 * @return true is registration was successful
90 boolean registerCandidate(final Entity entity);
93 * Unregister candidate depending on parameter
95 * @return true is registration was successful
97 boolean unregisterCandidate(final Entity entity);
100 * Returns true if we hold both registrations