Prevent ConfigPusher from killing its thread
[controller.git] / opendaylight / connectionmanager / implementation / src / main / java / org / opendaylight / controller / connectionmanager / scheme / AnyControllerScheme.java
1 package org.opendaylight.controller.connectionmanager.scheme;
2
3 import java.net.InetAddress;
4 import java.util.Set;
5
6 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
7 import org.opendaylight.controller.connectionmanager.ConnectionMgmtScheme;
8 import org.opendaylight.controller.sal.core.Node;
9
10 class AnyControllerScheme extends AbstractScheme {
11     private static AbstractScheme myScheme= null;
12
13     protected AnyControllerScheme(IClusterGlobalServices clusterServices) {
14         super(clusterServices, ConnectionMgmtScheme.ANY_CONTROLLER_ONE_MASTER);
15     }
16
17     public static AbstractScheme getScheme(IClusterGlobalServices clusterServices) {
18         if (myScheme == null) {
19             myScheme = new AnyControllerScheme(clusterServices);
20         }
21         return myScheme;
22     }
23
24     @Override
25     public boolean isConnectionAllowedInternal(Node node) {
26         Set <InetAddress> controllers = nodeConnections.get(node);
27         if (controllers == null || controllers.size() == 0) return true;
28         return (controllers.size() == 1 && controllers.contains(clusterServices.getMyAddress()));
29     }
30 }