2 * Copyright (c) 2016 Pantheon Technologies s.r.o. 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.lifecycle;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import javax.annotation.Nonnull;
12 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
13 import org.opendaylight.openflowplugin.api.openflow.OFPContext;
14 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
17 * Chain of contexts, hold references to the contexts.
19 public interface ContextChain extends AutoCloseable {
22 * Add context to the chain, if reference already exist ignore it.
23 * @param context child of OFPContext
25 <T extends OFPContext> void addContext(T context);
27 void addLifecycleService(LifecycleService lifecycleService);
30 * Stop the working contexts, but not release them.
33 ListenableFuture<Void> stopChain();
39 * Method need to be called if connection is dropped to stop the chain.
42 ListenableFuture<Void> connectionDropped();
45 * Slave was successfully set.
47 void makeContextChainStateSlave();
50 * Registers context chain into cluster singleton service.
51 * @param clusterSingletonServiceProvider provider
53 void registerServices(ClusterSingletonServiceProvider clusterSingletonServiceProvider);
56 * After connect of device make this device SLAVE.
58 void makeDeviceSlave();
61 * Check all needed to be master.
62 * @param mastershipState - state master on device, initial gather, initial submit, initial registry fill
63 * @return true if everything done fine
65 boolean isMastered(@Nonnull ContextChainMastershipState mastershipState);
68 * Add new auxiliary connection if primary is ok.
69 * @param connectionContext new connection to the device.
70 * @return false if primary connection is broken
72 boolean addAuxiliaryConnection(@Nonnull ConnectionContext connectionContext);
75 * Check if connection is auxiliary and if yes then continue working.
76 * @param connectionContext connection to the device
77 * @return false if this is primary connection
79 boolean auxiliaryConnectionDropped(@Nonnull ConnectionContext connectionContext);