Bug 4957: OF Role processing changes
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / role / RoleContext.java
1 /**
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowplugin.api.openflow.role;
9
10 import java.util.concurrent.Future;
11 import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException;
12 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
13 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
14
15 /**
16  * Created by kramesha on 9/12/15.
17  */
18 public interface RoleContext extends RoleChangeListener, RequestContextStack {
19
20     void setTxLockOwned(boolean txLockOwned);
21
22     /**
23      * Initialization method is responsible for a registration of
24      * {@link org.opendaylight.controller.md.sal.common.api.clustering.Entity} and listen for notification from service.
25      * {@link Future} returned object is used primary
26      * for new connection initialization phase where we have to wait for actual Role.
27      * The {@link Future} has to be canceled if device is in disconnected state or when
28      * {@link org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService} returns
29      * {@link org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException}
30      */
31     void initialization() throws CandidateAlreadyRegisteredException;
32
33     /**
34      * Transaction Candidate will provide safe way to correctly finish TxChainManager from
35      * last Node Master. It means only Master of TxEntity could hold TxChainFactory and
36      * active TransactionChain to write Data to Distributed DataStore.
37      */
38     void setupTxCandidate() throws CandidateAlreadyRegisteredException;
39
40     /**
41      * UnregistrationTxCandidate from OwnershipService
42      */
43     void suspendTxCandidate();
44
45     @Override
46     void close();
47
48     DeviceContext getDeviceContext();
49
50     boolean isTxLockOwned();
51 }