Moved pure ONOS code in net.floodlightcontroller.core.internal to onos package namespace
diff --git a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
deleted file mode 100644
index 275dc21..0000000
--- a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
+++ /dev/null
@@ -1,228 +0,0 @@
-package net.floodlightcontroller.core.internal;
-
-import java.util.Collection;
-
-import net.onrc.onos.ofcontroller.core.ISwitchStorage;
-import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
-import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
-import net.onrc.onos.util.GraphDBConnection;
-import net.onrc.onos.util.GraphDBConnection.GenerateEvent;
-import net.onrc.onos.util.GraphDBConnection.Transaction;
-
-import org.openflow.protocol.OFPhysicalPort;
-import org.openflow.protocol.OFPhysicalPort.OFPortConfig;
-import org.openflow.protocol.OFPhysicalPort.OFPortState;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SwitchStorageImpl implements ISwitchStorage {
- protected GraphDBConnection conn;
- protected static Logger log = LoggerFactory.getLogger(SwitchStorageImpl.class);
-
- @Override
- public void update(String dpid, SwitchState state, DM_OPERATION op) {
- // TODO Auto-generated method stub
- log.info("SwitchStorage:update dpid:{} state: {} ", dpid, state);
- switch(op) {
-
- case UPDATE:
- case INSERT:
- case CREATE:
- addSwitch(dpid);
- if (state != SwitchState.ACTIVE) {
- setStatus(dpid, state);
- }
- break;
- case DELETE:
- deleteSwitch(dpid);
- break;
- default:
- }
- }
-
- private void setStatus(String dpid, SwitchState state) {
- ISwitchObject sw = conn.utils().searchSwitch(conn, dpid);
- if (sw != null) {
- sw.setState(state.toString());
- conn.endTx(Transaction.COMMIT);
- log.info("SwitchStorage:setStatus dpid:{} state: {} done", dpid, state);
- } else {
- conn.endTx(Transaction.ROLLBACK);
- log.info("SwitchStorage:setStatus dpid:{} state: {} failed: switch not found", dpid, state);
- }
- }
-
- @Override
- public void addPort(String dpid, OFPhysicalPort port) {
- // TODO Auto-generated method stub
-
- boolean portDown = ((OFPortConfig.OFPPC_PORT_DOWN.getValue() & port.getConfig()) > 0) ||
- ((OFPortState.OFPPS_LINK_DOWN.getValue() & port.getState()) > 0);
- if (portDown) {
- deletePort(dpid, port.getPortNumber());
- return;
- }
-
- try {
- ISwitchObject sw = conn.utils().searchSwitch(conn, dpid);
-
- if (sw != null) {
- IPortObject p = conn.utils().searchPort(conn, dpid, port.getPortNumber());
- log.info("SwitchStorage:addPort dpid:{} port:{}", dpid, port.getPortNumber());
- if (p != null) {
- log.error("SwitchStorage:addPort dpid:{} port:{} exists", dpid, port.getPortNumber());
- } else {
- p = conn.utils().newPort(conn);
-
- p.setType("port");
- p.setNumber(port.getPortNumber());
- p.setState("ACTIVE");
- p.setPortState(port.getState());
- p.setDesc(port.getName());
- sw.addPort(p);
- conn.endTx(Transaction.COMMIT);
-
- }
- } else {
- log.error("SwitchStorage:addPort dpid:{} port:{} : failed switch does not exist", dpid, port.getPortNumber());
- }
- } catch (Exception e) {
- // TODO: handle exceptions
- e.printStackTrace();
- conn.endTx(Transaction.ROLLBACK);
- log.error("SwitchStorage:addPort dpid:{} port:{} failed", dpid, port.getPortNumber());
- }
-
- }
-
- @Override
- public Collection<OFPhysicalPort> getPorts(long dpid) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public OFPhysicalPort getPort(String dpid, short portnum) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public OFPhysicalPort getPort(String dpid, String portName) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void addSwitch(String dpid) {
-
- log.info("SwitchStorage:addSwitch(): dpid {} ", dpid);
-
- try {
- ISwitchObject sw = conn.utils().searchSwitch(conn, dpid);
- if (sw != null) {
- /*
- * Do nothing or throw exception?
- */
-
- log.info("SwitchStorage:addSwitch dpid:{} already exists", dpid);
- sw.setState(SwitchState.ACTIVE.toString());
- conn.endTx(Transaction.COMMIT);
- } else {
- sw = conn.utils().newSwitch(conn);
-
- if (sw != null) {
- sw.setType("switch");
- sw.setDPID(dpid);
- sw.setState(SwitchState.ACTIVE.toString());
- conn.endTx(Transaction.COMMIT);
- log.info("SwitchStorage:addSwitch dpid:{} added", dpid);
- } else {
- log.error("switchStorage:addSwitch dpid:{} failed -> newSwitch failed", dpid);
- }
- }
- } catch (Exception e) {
- /*
- * retry?
- */
- e.printStackTrace();
- conn.endTx(Transaction.ROLLBACK);
- log.info("SwitchStorage:addSwitch dpid:{} failed", dpid);
- }
-
-
- }
-
- @Override
- public void deleteSwitch(String dpid) {
- // TODO Setting inactive but we need to eventually remove data
-
- try {
-
- ISwitchObject sw = conn.utils().searchSwitch(conn, dpid);
- if (sw != null) {
- conn.utils().removeSwitch(conn, sw);
-
- conn.endTx(Transaction.COMMIT);
- log.info("SwitchStorage:DeleteSwitch dpid:{} done", dpid);
- }
- } catch (Exception e) {
- // TODO: handle exceptions
- e.printStackTrace();
- conn.endTx(Transaction.ROLLBACK);
- log.error("SwitchStorage:deleteSwitch {} failed", dpid);
- }
-
- }
-
- @Override
- public void deletePort(String dpid, short port) {
- // TODO Auto-generated method stub
- try {
- ISwitchObject sw = conn.utils().searchSwitch(conn, dpid);
-
- if (sw != null) {
- IPortObject p = conn.utils().searchPort(conn, dpid, port);
- if (p != null) {
- log.info("SwitchStorage:deletePort dpid:{} port:{} found and deleted", dpid, port);
- sw.removePort(p);
- conn.utils().removePort(conn, p);
- conn.endTx(Transaction.COMMIT);
- }
- }
- } catch (Exception e) {
- // TODO: handle exceptions
- e.printStackTrace();
- conn.endTx(Transaction.ROLLBACK);
- log.info("SwitchStorage:deletePort dpid:{} port:{} failed", dpid, port);
- }
- }
-
- @Override
- public void deletePort(String dpid, String portName) {
- // TODO Auto-generated method stub
-
- }
-
-
-
- @Override
- public void init(String conf) {
-
- conn = GraphDBConnection.getInstance(conf);
-
- }
-
-
-
- public void finalize() {
- close();
- }
-
- @Override
- public void close() {
- conn.close();
- }
-
-
-}
diff --git a/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java b/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
deleted file mode 100644
index 5110957..0000000
--- a/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package net.floodlightcontroller.core.internal;
-
-import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
-import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
-import net.onrc.onos.ofcontroller.core.INetMapTopologyService.ITopoSwitchService;
-import net.onrc.onos.util.GraphDBConnection;
-import net.onrc.onos.util.GraphDBConnection.Transaction;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TopoSwitchServiceImpl implements ITopoSwitchService {
-
- private GraphDBConnection conn;
- protected static Logger log = LoggerFactory.getLogger(TopoSwitchServiceImpl.class);
-
-
- public void finalize() {
- close();
- }
-
- @Override
- public void close() {
-
- conn.close();
- }
-
- @Override
- public Iterable<ISwitchObject> getActiveSwitches() {
- // TODO Auto-generated method stub
- conn = GraphDBConnection.getInstance("/tmp/cassandra.titan");
- conn.close(); //Commit to ensure we see latest data
- return conn.utils().getActiveSwitches(conn);
- }
-
- @Override
- public Iterable<ISwitchObject> getAllSwitches() {
- // TODO Auto-generated method stub
- conn = GraphDBConnection.getInstance("/tmp/cassandra.titan");
- conn.close(); //Commit to ensure we see latest data
- return conn.utils().getAllSwitches(conn);
- }
-
- @Override
- public Iterable<ISwitchObject> getInactiveSwitches() {
- // TODO Auto-generated method stub
- conn = GraphDBConnection.getInstance("/tmp/cassandra.titan");
- conn.close(); //Commit to ensure we see latest data
- return conn.utils().getInactiveSwitches(conn);
- }
-
- @Override
- public Iterable<IPortObject> getPortsOnSwitch(String dpid) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public IPortObject getPortOnSwitch(String dpid, short port_num) {
- // TODO Auto-generated method stub
- return null;
- }
-}
diff --git a/src/main/java/net/floodlightcontroller/core/web/TopoSwitchesResource.java b/src/main/java/net/floodlightcontroller/core/web/TopoSwitchesResource.java
index f431524..a4e991f 100644
--- a/src/main/java/net/floodlightcontroller/core/web/TopoSwitchesResource.java
+++ b/src/main/java/net/floodlightcontroller/core/web/TopoSwitchesResource.java
@@ -2,8 +2,8 @@
import java.util.Iterator;
-import net.floodlightcontroller.core.internal.TopoSwitchServiceImpl;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
+import net.onrc.onos.ofcontroller.core.internal.TopoSwitchServiceImpl;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
diff --git a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceStorageImpl.java b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceStorageImpl.java
index 0fbd2dc..1a47b41 100644
--- a/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceStorageImpl.java
+++ b/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceStorageImpl.java
@@ -7,12 +7,12 @@
import com.google.common.collect.Lists;
import com.thinkaurelius.titan.core.TitanException;
-import net.floodlightcontroller.core.internal.SwitchStorageImpl;
import net.floodlightcontroller.devicemanager.IDevice;
import net.floodlightcontroller.devicemanager.IDeviceStorage;
import net.floodlightcontroller.devicemanager.SwitchPort;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IDeviceObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
+import net.onrc.onos.ofcontroller.core.internal.SwitchStorageImpl;
import net.onrc.onos.util.GraphDBConnection;
import net.onrc.onos.util.GraphDBConnection.Transaction;
diff --git a/src/main/java/net/floodlightcontroller/onoslistener/OnosPublisher.java b/src/main/java/net/floodlightcontroller/onoslistener/OnosPublisher.java
index da7461c..e8cf82c 100644
--- a/src/main/java/net/floodlightcontroller/onoslistener/OnosPublisher.java
+++ b/src/main/java/net/floodlightcontroller/onoslistener/OnosPublisher.java
@@ -14,8 +14,6 @@
import net.floodlightcontroller.core.IFloodlightProviderService;
import net.floodlightcontroller.core.IOFSwitch;
import net.floodlightcontroller.core.IOFSwitchListener;
-import net.floodlightcontroller.core.internal.SwitchStorageImpl;
-import net.floodlightcontroller.core.internal.TopoSwitchServiceImpl;
import net.floodlightcontroller.core.module.FloodlightModuleContext;
import net.floodlightcontroller.core.module.FloodlightModuleException;
import net.floodlightcontroller.core.module.IFloodlightModule;
@@ -37,6 +35,8 @@
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IPortObject;
import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.ISwitchObject;
import net.onrc.onos.ofcontroller.core.ISwitchStorage.SwitchState;
+import net.onrc.onos.ofcontroller.core.internal.SwitchStorageImpl;
+import net.onrc.onos.ofcontroller.core.internal.TopoSwitchServiceImpl;
import net.onrc.onos.registry.controller.IControllerRegistryService;
import net.onrc.onos.registry.controller.IControllerRegistryService.ControlChangeCallback;
import net.onrc.onos.registry.controller.RegistryException;