Revert "Merge branch 'reginfo'"
This reverts commit 555b2c9bc95217a6c0e74c4cbbfa4da923291143, reversing
changes made to 7171a069fe3ee98e924e0e05ff1ae779d1de8e18.
diff --git a/src/main/java/net/onrc/onos/registry/controller/ControllerRegistryResource.java b/src/main/java/net/onrc/onos/registry/controller/ControllerRegistryResource.java
index a68c187..51f1d32 100644
--- a/src/main/java/net/onrc/onos/registry/controller/ControllerRegistryResource.java
+++ b/src/main/java/net/onrc/onos/registry/controller/ControllerRegistryResource.java
@@ -3,10 +3,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import org.restlet.Response;
-import org.restlet.data.Status;
-import org.restlet.representation.Representation;
-import org.restlet.representation.StringRepresentation;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
@@ -31,13 +27,8 @@
if (controllers == null){
controllers = new ArrayList<String>();
- Response response = getResponse();
- response.setStatus(Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY);
- Representation error = new StringRepresentation("Null data returned. Zookeeper connection may be down");
- response.setEntity(error);
- return null;
}
-
+
return controllers;
}
diff --git a/src/main/java/net/onrc/onos/registry/controller/ZookeeperRegistry.java b/src/main/java/net/onrc/onos/registry/controller/ZookeeperRegistry.java
index acc94f9..b666db7 100644
--- a/src/main/java/net/onrc/onos/registry/controller/ZookeeperRegistry.java
+++ b/src/main/java/net/onrc/onos/registry/controller/ZookeeperRegistry.java
@@ -36,8 +36,6 @@
import com.netflix.curator.framework.recipes.leader.LeaderLatchEvent;
import com.netflix.curator.framework.recipes.leader.LeaderLatchListener;
import com.netflix.curator.framework.recipes.leader.Participant;
-import com.netflix.curator.framework.state.ConnectionState;
-import com.netflix.curator.framework.state.ConnectionStateListener;
import com.netflix.curator.retry.ExponentialBackoffRetry;
import com.netflix.curator.utils.ZKPaths;
@@ -73,17 +71,6 @@
protected static final int sessionTimeout = 5000;
protected static final int connectionTimeout = 7000;
- //We can cache the connection state here whenever we get a connection state event.
- //Not 100% accurate but it's good enough to decide whether we can return data
- //via the REST API or not.
- protected volatile ConnectionState connectionState = ConnectionState.LOST;
-
- protected ConnectionStateListener connectionStateListener = new ConnectionStateListener(){
- @Override
- public void stateChanged(CuratorFramework client, ConnectionState state) {
- connectionState = state;
- }
- };
protected class SwitchLeaderListener implements LeaderLatchListener{
String dpid;
@@ -250,23 +237,7 @@
public Collection<String> getAllControllers() throws RegistryException {
log.debug("Getting all controllers");
- //Rebuild the cache to make sure we have the latest data
- //If we don't have ZK connection this will hang until we do. Undesirable.
- //try {
- //controllerCache.rebuild();
- //} catch (Exception e1) {
- //return null;
- //}
- ConnectionState currentConnectionState = connectionState;
- //if (currentConnectionState != ConnectionState.CONNECTED &&
- // currentConnectionState != ConnectionState.RECONNECTED){
- if (currentConnectionState == ConnectionState.LOST ||
- currentConnectionState == ConnectionState.SUSPENDED){
- return null;
- }
-
List<String> controllers = new ArrayList<String>();
-
for (ChildData data : controllerCache.getCurrentData()){
String d = null;
@@ -283,7 +254,6 @@
@Override
public void registerController(String id) throws RegistryException {
- //TODO this isn't replaced if we lose Zookeeper connection
if (controllerId != null) {
throw new RegistryException(
"Controller already registered with id " + controllerId);
@@ -456,7 +426,7 @@
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
client = CuratorFrameworkFactory.newClient(this.connectionString,
sessionTimeout, connectionTimeout, retryPolicy);
- client.getConnectionStateListenable().addListener(connectionStateListener);
+
client.start();
client = client.usingNamespace(namespace);