2 * Copyright (c) 2014 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.controller.connectionmanager.scheme;
10 import java.net.InetAddress;
13 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
14 import org.opendaylight.controller.connectionmanager.ConnectionMgmtScheme;
15 import org.opendaylight.controller.sal.core.Node;
17 class AnyControllerScheme extends AbstractScheme {
18 private static AbstractScheme myScheme= null;
20 protected AnyControllerScheme(IClusterGlobalServices clusterServices) {
21 super(clusterServices, ConnectionMgmtScheme.ANY_CONTROLLER_ONE_MASTER);
24 public static AbstractScheme getScheme(IClusterGlobalServices clusterServices) {
25 if (myScheme == null) {
26 myScheme = new AnyControllerScheme(clusterServices);
32 public boolean isConnectionAllowedInternal(Node node) {
33 Set <InetAddress> controllers = nodeConnections.get(node);
34 if (controllers == null || controllers.size() == 0) return true;
35 return (controllers.size() == 1 && controllers.contains(clusterServices.getMyAddress()));