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 javax.annotation.Nonnull;
11 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
12 import org.opendaylight.openflowplugin.api.openflow.OFPContext;
13 import org.opendaylight.openflowplugin.api.openflow.OFPManager;
14 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
15 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
16 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcManager;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SalRoleService;
20 * Role context for change role on cluster
22 public interface RoleContext extends RequestContextStack, AutoCloseable, OFPContext {
25 * Initialization method is responsible for a registration of
26 * {@link org.opendaylight.controller.md.sal.common.api.clustering.Entity} and listener
27 * for notification from service
28 * {@link org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService}
29 * returns Role which has to be applied for responsible Device Context suite. Any Exception
30 * state has to close Device connection channel.
31 * @return true if initialization done ok
33 boolean initialization();
36 * Termination method is responsible for an unregistration of
37 * {@link org.opendaylight.controller.md.sal.common.api.clustering.Entity} and listener
38 * for notification from service
39 * {@link org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService}
40 * returns notification "Someone else take Leadership" or "I'm last"
41 * and we need to clean Oper. DS.
43 void unregisterAllCandidates();
46 * Setter for sal role service
47 * @param salRoleService
49 void setSalRoleService(@Nonnull final SalRoleService salRoleService);
52 * Getter for sal role service
55 SalRoleService getSalRoleService();
58 * Getter for main entity
64 * Getter for tx entity
70 * Returns true if main entity is registered
73 boolean isMainCandidateRegistered();
76 * Returns true if tx entity is registered
79 boolean isTxCandidateRegistered();
82 * Register candidate depending on parameter
84 * @return true is registration was successful
86 boolean registerCandidate(final Entity entity);
89 * Unregister candidate depending on parameter
91 * @return true is registration was successful
93 boolean unregisterCandidate(final Entity entity);
96 * Returns true if we hold both registrations