BUG 2302 : odl-clustering-test-app should not be part of the odl-restconf-all feature set
[controller.git] / opendaylight / connectionmanager / implementation / src / main / java / org / opendaylight / controller / connectionmanager / scheme / SingleControllerScheme.java
1 /*
2  * Copyright (c) 2014 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.controller.connectionmanager.scheme;
9
10 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
11 import org.opendaylight.controller.connectionmanager.ConnectionMgmtScheme;
12 import org.opendaylight.controller.sal.core.Node;
13
14 class SingleControllerScheme extends AbstractScheme {
15
16     private static AbstractScheme myScheme = null;
17
18     protected SingleControllerScheme(IClusterGlobalServices clusterServices) {
19         super(clusterServices, ConnectionMgmtScheme.SINGLE_CONTROLLER);
20     }
21
22     public static AbstractScheme getScheme(IClusterGlobalServices clusterServices) {
23         if (myScheme == null) {
24             myScheme = new SingleControllerScheme(clusterServices);
25         }
26         return myScheme;
27     }
28
29     @Override
30     public boolean isConnectionAllowedInternal(Node node) {
31         // Lets make it simple. The Cluster Coordinator is the master
32         return clusterServices.amICoordinator();
33     }
34 }