Merge remote-tracking branch 'origin/master'
diff --git a/apps/foo/src/main/java/org/onlab/onos/foo/package-info.java b/apps/foo/src/main/java/org/onlab/onos/foo/package-info.java
index 6372772..af9506e 100644
--- a/apps/foo/src/main/java/org/onlab/onos/foo/package-info.java
+++ b/apps/foo/src/main/java/org/onlab/onos/foo/package-info.java
@@ -1,4 +1,4 @@
/**
* Sample application for use in various experiments.
*/
-package org.onlab.onos.foo;
\ No newline at end of file
+package org.onlab.onos.foo;
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
index 4c4af1a..41f30a7 100644
--- a/cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
@@ -103,4 +103,4 @@
}
-}
\ No newline at end of file
+}
diff --git a/core/api/src/main/java/org/onlab/onos/net/proxyarp/ProxyArpService.java b/core/api/src/main/java/org/onlab/onos/net/proxyarp/ProxyArpService.java
new file mode 100644
index 0000000..e6fe43b
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/net/proxyarp/ProxyArpService.java
@@ -0,0 +1,29 @@
+package org.onlab.onos.net.proxyarp;
+
+import org.onlab.packet.Ethernet;
+import org.onlab.packet.IpPrefix;
+
+/**
+ * Service for processing arp requests on behalf of applications.
+ */
+public interface ProxyArpService {
+
+ /**
+ * Returns whether this particular ip address is known to the system.
+ *
+ * @param addr
+ * a ip address
+ * @return true if know, false otherwise
+ */
+ boolean known(IpPrefix addr);
+
+ /**
+ * Sends a reply for a given request. If the host is not known then the arp
+ * will be flooded at all edge ports.
+ *
+ * @param request
+ * an arp request
+ */
+ void reply(Ethernet request);
+
+}
diff --git a/core/api/src/main/java/org/onlab/onos/net/proxyarp/package-info.java b/core/api/src/main/java/org/onlab/onos/net/proxyarp/package-info.java
new file mode 100644
index 0000000..4917c6e
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/net/proxyarp/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Base abstractions related to the proxy arp service.
+ */
+package org.onlab.onos.net.proxyarp;
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onlab/onos/store/ClockService.java b/core/api/src/main/java/org/onlab/onos/store/ClockService.java
new file mode 100644
index 0000000..2446ab7
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/store/ClockService.java
@@ -0,0 +1,26 @@
+package org.onlab.onos.store;
+
+import org.onlab.onos.cluster.MastershipTerm;
+import org.onlab.onos.net.DeviceId;
+
+// TODO: Consider renaming to DeviceClockService?
+/**
+ * Interface for a logical clock service that vends per device timestamps.
+ */
+public interface ClockService {
+
+ /**
+ * Returns a new timestamp for the specified deviceId.
+ * @param deviceId device identifier.
+ * @return timestamp.
+ */
+ public Timestamp getTimestamp(DeviceId deviceId);
+
+ // TODO: Should this be here or separate as Admin service, etc.?
+ /**
+ * Updates the mastership term for the specified deviceId.
+ * @param deviceId device identifier.
+ * @param term mastership term.
+ */
+ public void setMastershipTerm(DeviceId deviceId, MastershipTerm term);
+}
diff --git a/core/api/src/main/java/org/onlab/onos/store/package-info.java b/core/api/src/main/java/org/onlab/onos/store/package-info.java
index 7e767f0..b8203ce 100644
--- a/core/api/src/main/java/org/onlab/onos/store/package-info.java
+++ b/core/api/src/main/java/org/onlab/onos/store/package-info.java
@@ -1,4 +1,4 @@
/**
* Abstractions for creating and interacting with distributed stores.
*/
-package org.onlab.onos.store;
\ No newline at end of file
+package org.onlab.onos.store;
diff --git a/core/net/pom.xml b/core/net/pom.xml
index e2703b2..c075147 100644
--- a/core/net/pom.xml
+++ b/core/net/pom.xml
@@ -40,13 +40,14 @@
Currently required for DistributedDeviceManagerTest. -->
<dependency>
<groupId>org.onlab.onos</groupId>
- <artifactId>onos-core-store</artifactId>
+ <artifactId>onos-core-hz-net</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onlab.onos</groupId>
- <artifactId>onos-core-store</artifactId>
+ <!-- FIXME: should be somewhere else -->
+ <artifactId>onos-core-hz-common</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
diff --git a/core/net/src/main/java/org/onlab/onos/cluster/impl/package-info.java b/core/net/src/main/java/org/onlab/onos/cluster/impl/package-info.java
index d98f983..a31eb36 100644
--- a/core/net/src/main/java/org/onlab/onos/cluster/impl/package-info.java
+++ b/core/net/src/main/java/org/onlab/onos/cluster/impl/package-info.java
@@ -1,4 +1,4 @@
/**
* Subsystem for tracking controller cluster nodes.
*/
-package org.onlab.onos.cluster.impl;
\ No newline at end of file
+package org.onlab.onos.cluster.impl;
diff --git a/core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java b/core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
index 45b6c86..e7f2697 100644
--- a/core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
+++ b/core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
@@ -16,6 +16,7 @@
import org.onlab.onos.cluster.MastershipEvent;
import org.onlab.onos.cluster.MastershipListener;
import org.onlab.onos.cluster.MastershipService;
+import org.onlab.onos.cluster.MastershipTerm;
import org.onlab.onos.event.AbstractListenerRegistry;
import org.onlab.onos.event.EventDeliveryService;
import org.onlab.onos.net.Device;
@@ -36,6 +37,7 @@
import org.onlab.onos.net.device.PortDescription;
import org.onlab.onos.net.provider.AbstractProviderRegistry;
import org.onlab.onos.net.provider.AbstractProviderService;
+import org.onlab.onos.store.ClockService;
import org.slf4j.Logger;
/**
@@ -44,8 +46,8 @@
@Component(immediate = true)
@Service
public class DeviceManager
-extends AbstractProviderRegistry<DeviceProvider, DeviceProviderService>
-implements DeviceService, DeviceAdminService, DeviceProviderRegistry {
+ extends AbstractProviderRegistry<DeviceProvider, DeviceProviderService>
+ implements DeviceService, DeviceAdminService, DeviceProviderRegistry {
private static final String DEVICE_ID_NULL = "Device ID cannot be null";
private static final String PORT_NUMBER_NULL = "Port number cannot be null";
@@ -55,8 +57,8 @@
private final Logger log = getLogger(getClass());
- protected final AbstractListenerRegistry<DeviceEvent, DeviceListener>
- listenerRegistry = new AbstractListenerRegistry<>();
+ protected final AbstractListenerRegistry<DeviceEvent, DeviceListener> listenerRegistry =
+ new AbstractListenerRegistry<>();
private final DeviceStoreDelegate delegate = new InternalStoreDelegate();
@@ -74,6 +76,9 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected MastershipService mastershipService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ClockService clockService;
+
@Activate
public void activate() {
store.setDelegate(delegate);
@@ -164,7 +169,8 @@
}
@Override
- protected DeviceProviderService createProviderService(DeviceProvider provider) {
+ protected DeviceProviderService createProviderService(
+ DeviceProvider provider) {
return new InternalDeviceProviderService(provider);
}
@@ -178,14 +184,16 @@
}
@Override
- public void deviceConnected(DeviceId deviceId, DeviceDescription deviceDescription) {
+ public void deviceConnected(DeviceId deviceId,
+ DeviceDescription deviceDescription) {
checkNotNull(deviceId, DEVICE_ID_NULL);
checkNotNull(deviceDescription, DEVICE_DESCRIPTION_NULL);
checkValidity();
DeviceEvent event = store.createOrUpdateDevice(provider().id(),
deviceId, deviceDescription);
- // If there was a change of any kind, trigger role selection process.
+ // If there was a change of any kind, trigger role selection
+ // process.
if (event != null) {
log.info("Device {} connected", deviceId);
mastershipService.requestRoleFor(deviceId);
@@ -207,25 +215,30 @@
}
@Override
- public void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions) {
+ public void updatePorts(DeviceId deviceId,
+ List<PortDescription> portDescriptions) {
checkNotNull(deviceId, DEVICE_ID_NULL);
- checkNotNull(portDescriptions, "Port descriptions list cannot be null");
+ checkNotNull(portDescriptions,
+ "Port descriptions list cannot be null");
checkValidity();
- List<DeviceEvent> events = store.updatePorts(deviceId, portDescriptions);
+ List<DeviceEvent> events = store.updatePorts(deviceId,
+ portDescriptions);
for (DeviceEvent event : events) {
post(event);
}
}
@Override
- public void portStatusChanged(DeviceId deviceId, PortDescription portDescription) {
+ public void portStatusChanged(DeviceId deviceId,
+ PortDescription portDescription) {
checkNotNull(deviceId, DEVICE_ID_NULL);
checkNotNull(portDescription, PORT_DESCRIPTION_NULL);
checkValidity();
- DeviceEvent event = store.updatePortStatus(deviceId, portDescription);
+ DeviceEvent event = store.updatePortStatus(deviceId,
+ portDescription);
if (event != null) {
- log.info("Device {} port {} status changed", deviceId,
- event.port().number());
+ log.info("Device {} port {} status changed", deviceId, event
+ .port().number());
post(event);
}
}
@@ -233,8 +246,8 @@
@Override
public void unableToAssertRole(DeviceId deviceId, MastershipRole role) {
// FIXME: implement response to this notification
- log.warn("Failed to assert role [{}] onto Device {}",
- role, deviceId);
+ log.warn("Failed to assert role [{}] onto Device {}", role,
+ deviceId);
}
}
@@ -246,10 +259,14 @@
}
// Intercepts mastership events
- private class InternalMastershipListener implements MastershipListener {
+ private class InternalMastershipListener
+ implements MastershipListener {
@Override
public void event(MastershipEvent event) {
if (event.master().equals(clusterService.getLocalNode().id())) {
+ MastershipTerm term = mastershipService.requestTermService()
+ .getMastershipTerm(event.subject());
+ clockService.setMastershipTerm(event.subject(), term);
applyRole(event.subject(), MastershipRole.MASTER);
} else {
applyRole(event.subject(), MastershipRole.STANDBY);
@@ -258,7 +275,8 @@
}
// Store delegate to re-post events emitted from the store.
- private class InternalStoreDelegate implements DeviceStoreDelegate {
+ private class InternalStoreDelegate
+ implements DeviceStoreDelegate {
@Override
public void notify(DeviceEvent event) {
post(event);
diff --git a/core/net/src/main/java/org/onlab/onos/proxyarp/impl/ProxyArpManager.java b/core/net/src/main/java/org/onlab/onos/proxyarp/impl/ProxyArpManager.java
new file mode 100644
index 0000000..f267f68
--- /dev/null
+++ b/core/net/src/main/java/org/onlab/onos/proxyarp/impl/ProxyArpManager.java
@@ -0,0 +1,100 @@
+package org.onlab.onos.proxyarp.impl;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.nio.ByteBuffer;
+import java.util.Set;
+
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onlab.onos.net.Host;
+import org.onlab.onos.net.flow.DefaultTrafficTreatment;
+import org.onlab.onos.net.flow.TrafficTreatment;
+import org.onlab.onos.net.host.HostService;
+import org.onlab.onos.net.packet.DefaultOutboundPacket;
+import org.onlab.onos.net.packet.PacketService;
+import org.onlab.onos.net.proxyarp.ProxyArpService;
+import org.onlab.onos.net.topology.TopologyService;
+import org.onlab.packet.ARP;
+import org.onlab.packet.Ethernet;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.VlanId;
+
+public class ProxyArpManager implements ProxyArpService {
+
+ private static final String MAC_ADDR_NULL = "Mac address cannot be null.";
+ private static final String REQUEST_NULL = "Arp request cannot be null.";
+ private static final String REQUEST_NOT_ARP = "Ethernet frame does not contain ARP request.";
+ private static final String NOT_ARP_REQUEST = "ARP is not a request.";
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected HostService hostService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected PacketService packetService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected TopologyService topologyService;
+
+ @Override
+ public boolean known(IpPrefix addr) {
+ checkNotNull(MAC_ADDR_NULL, addr);
+ Set<Host> hosts = hostService.getHostsByIp(addr);
+ return !hosts.isEmpty();
+ }
+
+ @Override
+ public void reply(Ethernet request) {
+ checkNotNull(REQUEST_NULL, request);
+ checkArgument(request.getEtherType() == Ethernet.TYPE_ARP,
+ REQUEST_NOT_ARP);
+ ARP arp = (ARP) request.getPayload();
+ checkArgument(arp.getOpCode() == ARP.OP_REQUEST, NOT_ARP_REQUEST);
+
+ VlanId vlan = VlanId.vlanId(request.getVlanID());
+ Set<Host> hosts = hostService.getHostsByIp(IpPrefix.valueOf(arp
+ .getTargetProtocolAddress()));
+
+ Host h = null;
+ for (Host host : hosts) {
+ if (host.vlan().equals(vlan)) {
+ h = host;
+ break;
+ }
+ }
+
+ if (h == null) {
+ flood(request);
+ return;
+ }
+
+ Ethernet arpReply = buildArpReply(h, request);
+ // TODO: check send status with host service.
+ TrafficTreatment.Builder builder = new DefaultTrafficTreatment.Builder();
+ builder.setOutput(h.location().port());
+ packetService.emit(new DefaultOutboundPacket(h.location().deviceId(),
+ builder.build(), ByteBuffer.wrap(arpReply.serialize())));
+ }
+
+ private void flood(Ethernet request) {
+ // TODO: flood on all edge ports.
+ }
+
+ private Ethernet buildArpReply(Host h, Ethernet request) {
+ Ethernet eth = new Ethernet();
+ eth.setDestinationMACAddress(request.getSourceMACAddress());
+ eth.setSourceMACAddress(h.mac().getAddress());
+ eth.setEtherType(Ethernet.TYPE_ARP);
+ ARP arp = new ARP();
+ arp.setOpCode(ARP.OP_REPLY);
+ arp.setSenderHardwareAddress(h.mac().getAddress());
+ arp.setTargetHardwareAddress(request.getSourceMACAddress());
+
+ arp.setTargetProtocolAddress(((ARP) request.getPayload())
+ .getSenderProtocolAddress());
+ arp.setSenderProtocolAddress(h.ipAddresses().iterator().next().toInt());
+ eth.setPayload(arp);
+ return eth;
+ }
+}
diff --git a/core/net/src/main/java/org/onlab/onos/proxyarp/impl/package-info.java b/core/net/src/main/java/org/onlab/onos/proxyarp/impl/package-info.java
new file mode 100644
index 0000000..a9ad72a
--- /dev/null
+++ b/core/net/src/main/java/org/onlab/onos/proxyarp/impl/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Core subsystem for responding to arp requests.
+ */
+package org.onlab.onos.proxyarp.impl;
\ No newline at end of file
diff --git a/core/net/src/test/java/org/onlab/onos/net/device/impl/DistributedDeviceManagerTest.java b/core/net/src/test/java/org/onlab/onos/net/device/impl/DistributedDeviceManagerTest.java
index aeb0978..90cb49c 100644
--- a/core/net/src/test/java/org/onlab/onos/net/device/impl/DistributedDeviceManagerTest.java
+++ b/core/net/src/test/java/org/onlab/onos/net/device/impl/DistributedDeviceManagerTest.java
@@ -32,9 +32,9 @@
import org.onlab.onos.net.device.PortDescription;
import org.onlab.onos.net.provider.AbstractProvider;
import org.onlab.onos.net.provider.ProviderId;
+import org.onlab.onos.store.common.StoreManager;
+import org.onlab.onos.store.common.TestStoreManager;
import org.onlab.onos.store.device.impl.DistributedDeviceStore;
-import org.onlab.onos.store.impl.StoreManager;
-import org.onlab.onos.store.impl.TestStoreManager;
import org.onlab.packet.IpPrefix;
import java.util.ArrayList;
diff --git a/core/pom.xml b/core/pom.xml
index fc603df..afee0d0 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -20,7 +20,6 @@
<module>api</module>
<module>net</module>
<module>store</module>
- <module>trivial</module>
</modules>
<dependencies>
diff --git a/core/trivial/pom.xml b/core/store/dist/pom.xml
similarity index 67%
copy from core/trivial/pom.xml
copy to core/store/dist/pom.xml
index 1806ba4..900a2ff 100644
--- a/core/trivial/pom.xml
+++ b/core/store/dist/pom.xml
@@ -6,15 +6,15 @@
<parent>
<groupId>org.onlab.onos</groupId>
- <artifactId>onos-core</artifactId>
+ <artifactId>onos-core-store</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>onos-core-trivial</artifactId>
+ <artifactId>onos-core-dist</artifactId>
<packaging>bundle</packaging>
- <description>ONOS network control trivial implementations of core subsystems</description>
+ <description>ONOS Gossip based distributed store subsystems</description>
<dependencies>
<dependency>
@@ -22,9 +22,18 @@
<artifactId>onos-api</artifactId>
</dependency>
<dependency>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
</dependency>
+ <dependency>
+ <groupId>de.javakaffee</groupId>
+ <artifactId>kryo-serializers</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/OnosClockService.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/OnosClockService.java
new file mode 100644
index 0000000..a99482f
--- /dev/null
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/OnosClockService.java
@@ -0,0 +1,53 @@
+package org.onlab.onos.store.device.impl;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Service;
+import org.onlab.onos.cluster.MastershipTerm;
+import org.onlab.onos.net.DeviceId;
+import org.onlab.onos.store.ClockService;
+import org.onlab.onos.store.Timestamp;
+import org.onlab.onos.store.impl.OnosTimestamp;
+import org.slf4j.Logger;
+
+@Component(immediate = true)
+@Service
+public class OnosClockService implements ClockService {
+
+ private final Logger log = getLogger(getClass());
+
+ // TODO: Implement per device ticker that is reset to 0 at the beginning of a new term.
+ private final AtomicInteger ticker = new AtomicInteger(0);
+ private ConcurrentMap<DeviceId, MastershipTerm> deviceMastershipTerms = new ConcurrentHashMap<>();
+
+ @Activate
+ public void activate() {
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ log.info("Stopped");
+ }
+
+ @Override
+ public Timestamp getTimestamp(DeviceId deviceId) {
+ MastershipTerm term = deviceMastershipTerms.get(deviceId);
+ if (term == null) {
+ throw new IllegalStateException("Requesting timestamp for a deviceId without mastership");
+ }
+ return new OnosTimestamp(term.termNumber(), ticker.incrementAndGet());
+ }
+
+ @Override
+ public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) {
+ deviceMastershipTerms.put(deviceId, term);
+ }
+}
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/OnosDistributedDeviceStore.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/OnosDistributedDeviceStore.java
new file mode 100644
index 0000000..30374c3
--- /dev/null
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/OnosDistributedDeviceStore.java
@@ -0,0 +1,336 @@
+package org.onlab.onos.store.device.impl;
+
+import static com.google.common.base.Predicates.notNull;
+import static com.google.common.base.Preconditions.checkState;
+
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.Service;
+import org.onlab.onos.net.DefaultDevice;
+import org.onlab.onos.net.DefaultPort;
+import org.onlab.onos.net.Device;
+import org.onlab.onos.net.DeviceId;
+import org.onlab.onos.net.Port;
+import org.onlab.onos.net.PortNumber;
+import org.onlab.onos.net.device.DeviceDescription;
+import org.onlab.onos.net.device.DeviceEvent;
+import org.onlab.onos.net.device.DeviceStore;
+import org.onlab.onos.net.device.DeviceStoreDelegate;
+import org.onlab.onos.net.device.PortDescription;
+import org.onlab.onos.net.provider.ProviderId;
+import org.onlab.onos.store.AbstractStore;
+import org.onlab.onos.store.ClockService;
+import org.onlab.onos.store.Timestamp;
+import org.slf4j.Logger;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.onlab.onos.net.device.DeviceEvent.Type.*;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Manages inventory of infrastructure devices using a protocol that takes into consideration
+ * the order in which device events occur.
+ */
+@Component(immediate = true)
+@Service
+public class OnosDistributedDeviceStore
+ extends AbstractStore<DeviceEvent, DeviceStoreDelegate>
+ implements DeviceStore {
+
+ private final Logger log = getLogger(getClass());
+
+ public static final String DEVICE_NOT_FOUND = "Device with ID %s not found";
+
+ private ConcurrentHashMap<DeviceId, VersionedValue<Device>> devices;
+ private ConcurrentHashMap<DeviceId, Map<PortNumber, VersionedValue<Port>>> devicePorts;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ClockService clockService;
+
+ @Activate
+ public void activate() {
+
+ devices = new ConcurrentHashMap<>();
+ devicePorts = new ConcurrentHashMap<>();
+
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ log.info("Stopped");
+ }
+
+ @Override
+ public int getDeviceCount() {
+ return devices.size();
+ }
+
+ @Override
+ public Iterable<Device> getDevices() {
+ // TODO builder v.s. copyOf. Guava semms to be using copyOf?
+ // FIXME: synchronize.
+ Builder<Device> builder = ImmutableSet.builder();
+ for (VersionedValue<? extends Device> device : devices.values()) {
+ builder.add(device.entity());
+ }
+ return builder.build();
+ }
+
+ @Override
+ public Device getDevice(DeviceId deviceId) {
+ return devices.get(deviceId).entity();
+ }
+
+ @Override
+ public DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId,
+ DeviceDescription deviceDescription) {
+ Timestamp now = clockService.getTimestamp(deviceId);
+ VersionedValue<Device> device = devices.get(deviceId);
+
+ if (device == null) {
+ return createDevice(providerId, deviceId, deviceDescription, now);
+ }
+
+ checkState(now.compareTo(device.timestamp()) > 0,
+ "Existing device has a timestamp in the future!");
+
+ return updateDevice(providerId, device.entity(), deviceDescription, now);
+ }
+
+ // Creates the device and returns the appropriate event if necessary.
+ private DeviceEvent createDevice(ProviderId providerId, DeviceId deviceId,
+ DeviceDescription desc, Timestamp timestamp) {
+ DefaultDevice device = new DefaultDevice(providerId, deviceId, desc.type(),
+ desc.manufacturer(),
+ desc.hwVersion(), desc.swVersion(),
+ desc.serialNumber());
+
+ devices.put(deviceId, new VersionedValue<Device>(device, true, timestamp));
+ // FIXME: broadcast a message telling peers of a device event.
+ return new DeviceEvent(DEVICE_ADDED, device, null);
+ }
+
+ // Updates the device and returns the appropriate event if necessary.
+ private DeviceEvent updateDevice(ProviderId providerId, Device device,
+ DeviceDescription desc, Timestamp timestamp) {
+ // We allow only certain attributes to trigger update
+ if (!Objects.equals(device.hwVersion(), desc.hwVersion()) ||
+ !Objects.equals(device.swVersion(), desc.swVersion())) {
+
+ Device updated = new DefaultDevice(providerId, device.id(),
+ desc.type(),
+ desc.manufacturer(),
+ desc.hwVersion(),
+ desc.swVersion(),
+ desc.serialNumber());
+ devices.put(device.id(), new VersionedValue<Device>(updated, true, timestamp));
+ // FIXME: broadcast a message telling peers of a device event.
+ return new DeviceEvent(DeviceEvent.Type.DEVICE_UPDATED, updated, null);
+ }
+
+ // Otherwise merely attempt to change availability
+ DefaultDevice updated = new DefaultDevice(providerId, device.id(),
+ desc.type(),
+ desc.manufacturer(),
+ desc.hwVersion(),
+ desc.swVersion(),
+ desc.serialNumber());
+
+ VersionedValue<Device> oldDevice = devices.put(device.id(),
+ new VersionedValue<Device>(updated, true, timestamp));
+ if (!oldDevice.isUp()) {
+ return new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device, null);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public DeviceEvent markOffline(DeviceId deviceId) {
+ VersionedValue<Device> device = devices.get(deviceId);
+ boolean willRemove = device != null && device.isUp();
+ if (!willRemove) {
+ return null;
+ }
+ Timestamp timestamp = clockService.getTimestamp(deviceId);
+ if (replaceIfLatest(device.entity(), false, timestamp)) {
+ return new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device.entity(), null);
+ }
+ return null;
+ }
+
+ // Replace existing value if its timestamp is older.
+ private synchronized boolean replaceIfLatest(Device device, boolean isUp, Timestamp timestamp) {
+ VersionedValue<Device> existingValue = devices.get(device.id());
+ if (timestamp.compareTo(existingValue.timestamp()) > 0) {
+ devices.put(device.id(), new VersionedValue<Device>(device, isUp, timestamp));
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public List<DeviceEvent> updatePorts(DeviceId deviceId,
+ List<PortDescription> portDescriptions) {
+ List<DeviceEvent> events = new ArrayList<>();
+ synchronized (this) {
+ VersionedValue<Device> device = devices.get(deviceId);
+ checkArgument(device != null, DEVICE_NOT_FOUND, deviceId);
+ Map<PortNumber, VersionedValue<Port>> ports = getPortMap(deviceId);
+ Timestamp timestamp = clockService.getTimestamp(deviceId);
+
+ // Add new ports
+ Set<PortNumber> processed = new HashSet<>();
+ for (PortDescription portDescription : portDescriptions) {
+ VersionedValue<Port> port = ports.get(portDescription.portNumber());
+ if (port == null) {
+ events.add(createPort(device, portDescription, ports, timestamp));
+ }
+ checkState(timestamp.compareTo(port.timestamp()) > 0,
+ "Existing port state has a timestamp in the future!");
+ events.add(updatePort(device, port, portDescription, ports, timestamp));
+ processed.add(portDescription.portNumber());
+ }
+
+ updatePortMap(deviceId, ports);
+
+ events.addAll(pruneOldPorts(device.entity(), ports, processed));
+ }
+ return FluentIterable.from(events).filter(notNull()).toList();
+ }
+
+ // Creates a new port based on the port description adds it to the map and
+ // Returns corresponding event.
+ //@GuardedBy("this")
+ private DeviceEvent createPort(VersionedValue<Device> device, PortDescription portDescription,
+ Map<PortNumber, VersionedValue<Port>> ports, Timestamp timestamp) {
+ Port port = new DefaultPort(device.entity(), portDescription.portNumber(),
+ portDescription.isEnabled());
+ ports.put(port.number(), new VersionedValue<Port>(port, true, timestamp));
+ updatePortMap(device.entity().id(), ports);
+ return new DeviceEvent(PORT_ADDED, device.entity(), port);
+ }
+
+ // Checks if the specified port requires update and if so, it replaces the
+ // existing entry in the map and returns corresponding event.
+ //@GuardedBy("this")
+ private DeviceEvent updatePort(VersionedValue<Device> device, VersionedValue<Port> port,
+ PortDescription portDescription,
+ Map<PortNumber, VersionedValue<Port>> ports,
+ Timestamp timestamp) {
+ if (port.entity().isEnabled() != portDescription.isEnabled()) {
+ VersionedValue<Port> updatedPort = new VersionedValue<Port>(
+ new DefaultPort(device.entity(), portDescription.portNumber(),
+ portDescription.isEnabled()),
+ portDescription.isEnabled(),
+ timestamp);
+ ports.put(port.entity().number(), updatedPort);
+ updatePortMap(device.entity().id(), ports);
+ return new DeviceEvent(PORT_UPDATED, device.entity(), updatedPort.entity());
+ }
+ return null;
+ }
+
+ // Prunes the specified list of ports based on which ports are in the
+ // processed list and returns list of corresponding events.
+ //@GuardedBy("this")
+ private List<DeviceEvent> pruneOldPorts(Device device,
+ Map<PortNumber, VersionedValue<Port>> ports,
+ Set<PortNumber> processed) {
+ List<DeviceEvent> events = new ArrayList<>();
+ Iterator<PortNumber> iterator = ports.keySet().iterator();
+ while (iterator.hasNext()) {
+ PortNumber portNumber = iterator.next();
+ if (!processed.contains(portNumber)) {
+ events.add(new DeviceEvent(PORT_REMOVED, device,
+ ports.get(portNumber).entity()));
+ iterator.remove();
+ }
+ }
+ if (!events.isEmpty()) {
+ updatePortMap(device.id(), ports);
+ }
+ return events;
+ }
+
+ // Gets the map of ports for the specified device; if one does not already
+ // exist, it creates and registers a new one.
+ // WARN: returned value is a copy, changes made to the Map
+ // needs to be written back using updatePortMap
+ //@GuardedBy("this")
+ private Map<PortNumber, VersionedValue<Port>> getPortMap(DeviceId deviceId) {
+ Map<PortNumber, VersionedValue<Port>> ports = devicePorts.get(deviceId);
+ if (ports == null) {
+ ports = new HashMap<>();
+ // this probably is waste of time in most cases.
+ updatePortMap(deviceId, ports);
+ }
+ return ports;
+ }
+
+ //@GuardedBy("this")
+ private void updatePortMap(DeviceId deviceId, Map<PortNumber, VersionedValue<Port>> ports) {
+ devicePorts.put(deviceId, ports);
+ }
+
+ @Override
+ public DeviceEvent updatePortStatus(DeviceId deviceId,
+ PortDescription portDescription) {
+ VersionedValue<Device> device = devices.get(deviceId);
+ checkArgument(device != null, DEVICE_NOT_FOUND, deviceId);
+ Map<PortNumber, VersionedValue<Port>> ports = getPortMap(deviceId);
+ VersionedValue<Port> port = ports.get(portDescription.portNumber());
+ Timestamp timestamp = clockService.getTimestamp(deviceId);
+ return updatePort(device, port, portDescription, ports, timestamp);
+ }
+
+ @Override
+ public List<Port> getPorts(DeviceId deviceId) {
+ Map<PortNumber, VersionedValue<Port>> versionedPorts = devicePorts.get(deviceId);
+ if (versionedPorts == null) {
+ return Collections.emptyList();
+ }
+ List<Port> ports = new ArrayList<>();
+ for (VersionedValue<Port> port : versionedPorts.values()) {
+ ports.add(port.entity());
+ }
+ return ports;
+ }
+
+ @Override
+ public Port getPort(DeviceId deviceId, PortNumber portNumber) {
+ Map<PortNumber, VersionedValue<Port>> ports = devicePorts.get(deviceId);
+ return ports == null ? null : ports.get(portNumber).entity();
+ }
+
+ @Override
+ public boolean isAvailable(DeviceId deviceId) {
+ return devices.get(deviceId).isUp();
+ }
+
+ @Override
+ public DeviceEvent removeDevice(DeviceId deviceId) {
+ VersionedValue<Device> previousDevice = devices.remove(deviceId);
+ return previousDevice == null ? null :
+ new DeviceEvent(DEVICE_REMOVED, previousDevice.entity(), null);
+ }
+}
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/VersionedValue.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/VersionedValue.java
new file mode 100644
index 0000000..1a85c53
--- /dev/null
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/VersionedValue.java
@@ -0,0 +1,45 @@
+package org.onlab.onos.store.device.impl;
+
+import org.onlab.onos.store.Timestamp;
+
+/**
+ * Wrapper class for a entity that is versioned
+ * and can either be up or down.
+ *
+ * @param <T> type of the value.
+ */
+public class VersionedValue<T> {
+ private final T entity;
+ private final Timestamp timestamp;
+ private final boolean isUp;
+
+ public VersionedValue(T entity, boolean isUp, Timestamp timestamp) {
+ this.entity = entity;
+ this.isUp = isUp;
+ this.timestamp = timestamp;
+ }
+
+ /**
+ * Returns the value.
+ * @return value.
+ */
+ public T entity() {
+ return entity;
+ }
+
+ /**
+ * Tells whether the entity is up or down.
+ * @return true if up, false otherwise.
+ */
+ public boolean isUp() {
+ return isUp;
+ }
+
+ /**
+ * Returns the timestamp (version) associated with this entity.
+ * @return timestamp.
+ */
+ public Timestamp timestamp() {
+ return timestamp;
+ }
+}
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/package-info.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/package-info.java
new file mode 100644
index 0000000..b2fc91d
--- /dev/null
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Implementation of device store using distributed structures.
+ */
+package org.onlab.onos.store.device.impl;
diff --git a/core/store/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java b/core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
rename to core/store/dist/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/host/impl/DistributedHostStore.java b/core/store/dist/src/main/java/org/onlab/onos/store/host/impl/DistributedHostStore.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/host/impl/DistributedHostStore.java
rename to core/store/dist/src/main/java/org/onlab/onos/store/host/impl/DistributedHostStore.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/impl/OnosTimestamp.java b/core/store/dist/src/main/java/org/onlab/onos/store/impl/OnosTimestamp.java
similarity index 72%
rename from core/store/src/main/java/org/onlab/onos/store/impl/OnosTimestamp.java
rename to core/store/dist/src/main/java/org/onlab/onos/store/impl/OnosTimestamp.java
index f994e02..2005582 100644
--- a/core/store/src/main/java/org/onlab/onos/store/impl/OnosTimestamp.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/impl/OnosTimestamp.java
@@ -1,11 +1,9 @@
package org.onlab.onos.store.impl;
-import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkArgument;
import java.util.Objects;
-import org.onlab.onos.net.ElementId;
import org.onlab.onos.store.Timestamp;
import com.google.common.base.MoreObjects;
@@ -14,22 +12,20 @@
// If it is store specific, implement serializable interfaces?
/**
* Default implementation of Timestamp.
+ * TODO: Better documentation.
*/
public final class OnosTimestamp implements Timestamp {
- private final ElementId id;
private final int termNumber;
private final int sequenceNumber;
/**
* Default version tuple.
*
- * @param id identifier of the element
* @param termNumber the mastership termNumber
* @param sequenceNumber the sequenceNumber number within the termNumber
*/
- public OnosTimestamp(ElementId id, int termNumber, int sequenceNumber) {
- this.id = checkNotNull(id);
+ public OnosTimestamp(int termNumber, int sequenceNumber) {
this.termNumber = termNumber;
this.sequenceNumber = sequenceNumber;
}
@@ -38,9 +34,6 @@
public int compareTo(Timestamp o) {
checkArgument(o instanceof OnosTimestamp, "Must be OnosTimestamp", o);
OnosTimestamp that = (OnosTimestamp) o;
- checkArgument(this.id.equals(that.id),
- "Cannot compare version for different element this:%s, that:%s",
- this, that);
return ComparisonChain.start()
.compare(this.termNumber, that.termNumber)
@@ -50,7 +43,7 @@
@Override
public int hashCode() {
- return Objects.hash(id, termNumber, sequenceNumber);
+ return Objects.hash(termNumber, sequenceNumber);
}
@Override
@@ -62,30 +55,19 @@
return false;
}
OnosTimestamp that = (OnosTimestamp) obj;
- return Objects.equals(this.id, that.id) &&
- Objects.equals(this.termNumber, that.termNumber) &&
+ return Objects.equals(this.termNumber, that.termNumber) &&
Objects.equals(this.sequenceNumber, that.sequenceNumber);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
- .add("id", id)
.add("termNumber", termNumber)
.add("sequenceNumber", sequenceNumber)
.toString();
}
/**
- * Returns the element.
- *
- * @return element identifier
- */
- public ElementId id() {
- return id;
- }
-
- /**
* Returns the termNumber.
*
* @return termNumber
diff --git a/core/store/src/main/java/org/onlab/onos/store/serializers/OnosTimestampSerializer.java b/core/store/dist/src/main/java/org/onlab/onos/store/serializers/OnosTimestampSerializer.java
similarity index 81%
rename from core/store/src/main/java/org/onlab/onos/store/serializers/OnosTimestampSerializer.java
rename to core/store/dist/src/main/java/org/onlab/onos/store/serializers/OnosTimestampSerializer.java
index 812bc9d..192e035 100644
--- a/core/store/src/main/java/org/onlab/onos/store/serializers/OnosTimestampSerializer.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/serializers/OnosTimestampSerializer.java
@@ -1,6 +1,5 @@
package org.onlab.onos.store.serializers;
-import org.onlab.onos.net.ElementId;
import org.onlab.onos.store.impl.OnosTimestamp;
import com.esotericsoftware.kryo.Kryo;
@@ -20,18 +19,17 @@
// non-null, immutable
super(false, true);
}
+
@Override
public void write(Kryo kryo, Output output, OnosTimestamp object) {
- kryo.writeClassAndObject(output, object.id());
output.writeInt(object.termNumber());
output.writeInt(object.sequenceNumber());
}
@Override
public OnosTimestamp read(Kryo kryo, Input input, Class<OnosTimestamp> type) {
- ElementId id = (ElementId) kryo.readClassAndObject(input);
final int term = input.readInt();
final int sequence = input.readInt();
- return new OnosTimestamp(id, term, sequence);
+ return new OnosTimestamp(term, sequence);
}
}
diff --git a/core/store/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopology.java b/core/store/dist/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopology.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopology.java
rename to core/store/dist/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopology.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopologyGraph.java b/core/store/dist/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopologyGraph.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopologyGraph.java
rename to core/store/dist/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopologyGraph.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java b/core/store/dist/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java
rename to core/store/dist/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/topology/impl/PathKey.java b/core/store/dist/src/main/java/org/onlab/onos/store/topology/impl/PathKey.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/topology/impl/PathKey.java
rename to core/store/dist/src/main/java/org/onlab/onos/store/topology/impl/PathKey.java
diff --git a/core/store/hz/cluster/pom.xml b/core/store/hz/cluster/pom.xml
new file mode 100644
index 0000000..95307f1
--- /dev/null
+++ b/core/store/hz/cluster/pom.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onos-core-hz</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-core-hz-cluster</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>ONOS Hazelcast based distributed store subsystems</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onos-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onos-core-hz-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onos-core-hz-common</artifactId>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.hazelcast</groupId>
+ <artifactId>hazelcast</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>de.javakaffee</groupId>
+ <artifactId>kryo-serializers</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/core/store/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java b/core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java
similarity index 95%
rename from core/store/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java
rename to core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java
index 8983cf5..84009ac 100644
--- a/core/store/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java
+++ b/core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java
@@ -8,6 +8,7 @@
import com.hazelcast.core.MemberAttributeEvent;
import com.hazelcast.core.MembershipEvent;
import com.hazelcast.core.MembershipListener;
+
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -18,9 +19,9 @@
import org.onlab.onos.cluster.ControllerNode;
import org.onlab.onos.cluster.DefaultControllerNode;
import org.onlab.onos.cluster.NodeId;
-import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache;
-import org.onlab.onos.store.impl.AbstractDistributedStore;
-import org.onlab.onos.store.impl.OptionalCacheLoader;
+import org.onlab.onos.store.common.AbsentInvalidatingLoadingCache;
+import org.onlab.onos.store.common.AbstractHazelcastStore;
+import org.onlab.onos.store.common.OptionalCacheLoader;
import org.onlab.packet.IpPrefix;
import java.util.Map;
@@ -38,7 +39,7 @@
@Component(immediate = true)
@Service
public class DistributedClusterStore
- extends AbstractDistributedStore<ClusterEvent, ClusterStoreDelegate>
+ extends AbstractHazelcastStore<ClusterEvent, ClusterStoreDelegate>
implements ClusterStore {
private IMap<byte[], byte[]> rawNodes;
diff --git a/core/store/src/main/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStore.java b/core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStore.java
similarity index 94%
rename from core/store/src/main/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStore.java
rename to core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStore.java
index 989cc83..a2f2dd9 100644
--- a/core/store/src/main/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStore.java
+++ b/core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/DistributedMastershipStore.java
@@ -21,9 +21,9 @@
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.MastershipRole;
-import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache;
-import org.onlab.onos.store.impl.AbstractDistributedStore;
-import org.onlab.onos.store.impl.OptionalCacheLoader;
+import org.onlab.onos.store.common.AbsentInvalidatingLoadingCache;
+import org.onlab.onos.store.common.AbstractHazelcastStore;
+import org.onlab.onos.store.common.OptionalCacheLoader;
import com.google.common.base.Optional;
import com.google.common.cache.LoadingCache;
@@ -36,7 +36,7 @@
@Component(immediate = true)
@Service
public class DistributedMastershipStore
-extends AbstractDistributedStore<MastershipEvent, MastershipStoreDelegate>
+extends AbstractHazelcastStore<MastershipEvent, MastershipStoreDelegate>
implements MastershipStore {
private IMap<byte[], byte[]> rawMasters;
diff --git a/core/store/src/main/java/org/onlab/onos/store/cluster/impl/package-info.java b/core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/package-info.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/cluster/impl/package-info.java
rename to core/store/hz/cluster/src/main/java/org/onlab/onos/store/cluster/impl/package-info.java
diff --git a/core/trivial/pom.xml b/core/store/hz/common/pom.xml
similarity index 62%
copy from core/trivial/pom.xml
copy to core/store/hz/common/pom.xml
index 1806ba4..06aa0b7 100644
--- a/core/trivial/pom.xml
+++ b/core/store/hz/common/pom.xml
@@ -6,15 +6,15 @@
<parent>
<groupId>org.onlab.onos</groupId>
- <artifactId>onos-core</artifactId>
+ <artifactId>onos-core-hz</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>onos-core-trivial</artifactId>
+ <artifactId>onos-core-hz-common</artifactId>
<packaging>bundle</packaging>
- <description>ONOS network control trivial implementations of core subsystems</description>
+ <description>ONOS Hazelcast based distributed store subsystems</description>
<dependencies>
<dependency>
@@ -22,9 +22,22 @@
<artifactId>onos-api</artifactId>
</dependency>
<dependency>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.hazelcast</groupId>
+ <artifactId>hazelcast</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>de.javakaffee</groupId>
+ <artifactId>kryo-serializers</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/core/store/src/main/java/org/onlab/onos/store/impl/AbsentInvalidatingLoadingCache.java b/core/store/hz/common/src/main/java/org/onlab/onos/store/common/AbsentInvalidatingLoadingCache.java
similarity index 97%
rename from core/store/src/main/java/org/onlab/onos/store/impl/AbsentInvalidatingLoadingCache.java
rename to core/store/hz/common/src/main/java/org/onlab/onos/store/common/AbsentInvalidatingLoadingCache.java
index df4e70a..4dd8669 100644
--- a/core/store/src/main/java/org/onlab/onos/store/impl/AbsentInvalidatingLoadingCache.java
+++ b/core/store/hz/common/src/main/java/org/onlab/onos/store/common/AbsentInvalidatingLoadingCache.java
@@ -1,4 +1,4 @@
-package org.onlab.onos.store.impl;
+package org.onlab.onos.store.common;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
diff --git a/core/store/src/main/java/org/onlab/onos/store/impl/AbstractDistributedStore.java b/core/store/hz/common/src/main/java/org/onlab/onos/store/common/AbstractHazelcastStore.java
similarity index 95%
rename from core/store/src/main/java/org/onlab/onos/store/impl/AbstractDistributedStore.java
rename to core/store/hz/common/src/main/java/org/onlab/onos/store/common/AbstractHazelcastStore.java
index eb795a8..ab513af 100644
--- a/core/store/src/main/java/org/onlab/onos/store/impl/AbstractDistributedStore.java
+++ b/core/store/hz/common/src/main/java/org/onlab/onos/store/common/AbstractHazelcastStore.java
@@ -1,4 +1,4 @@
-package org.onlab.onos.store.impl;
+package org.onlab.onos.store.common;
import com.google.common.base.Optional;
import com.google.common.cache.LoadingCache;
@@ -6,6 +6,7 @@
import com.hazelcast.core.EntryEvent;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.MapEvent;
+
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
@@ -13,7 +14,6 @@
import org.onlab.onos.event.Event;
import org.onlab.onos.store.AbstractStore;
import org.onlab.onos.store.StoreDelegate;
-import org.onlab.onos.store.common.StoreService;
import org.slf4j.Logger;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -23,7 +23,7 @@
* Abstraction of a distributed store based on Hazelcast.
*/
@Component(componentAbstract = true)
-public abstract class AbstractDistributedStore<E extends Event, D extends StoreDelegate<E>>
+public abstract class AbstractHazelcastStore<E extends Event, D extends StoreDelegate<E>>
extends AbstractStore<E, D> {
protected final Logger log = getLogger(getClass());
diff --git a/core/store/src/main/java/org/onlab/onos/store/impl/OptionalCacheLoader.java b/core/store/hz/common/src/main/java/org/onlab/onos/store/common/OptionalCacheLoader.java
similarity index 93%
rename from core/store/src/main/java/org/onlab/onos/store/impl/OptionalCacheLoader.java
rename to core/store/hz/common/src/main/java/org/onlab/onos/store/common/OptionalCacheLoader.java
index dddd128..dd2b872 100644
--- a/core/store/src/main/java/org/onlab/onos/store/impl/OptionalCacheLoader.java
+++ b/core/store/hz/common/src/main/java/org/onlab/onos/store/common/OptionalCacheLoader.java
@@ -1,9 +1,7 @@
-package org.onlab.onos.store.impl;
+package org.onlab.onos.store.common;
import static com.google.common.base.Preconditions.checkNotNull;
-import org.onlab.onos.store.common.StoreService;
-
import com.google.common.base.Optional;
import com.google.common.cache.CacheLoader;
import com.hazelcast.core.IMap;
diff --git a/core/store/src/main/java/org/onlab/onos/store/impl/StoreManager.java b/core/store/hz/common/src/main/java/org/onlab/onos/store/common/StoreManager.java
similarity index 94%
rename from core/store/src/main/java/org/onlab/onos/store/impl/StoreManager.java
rename to core/store/hz/common/src/main/java/org/onlab/onos/store/common/StoreManager.java
index e2692d5..5685116 100644
--- a/core/store/src/main/java/org/onlab/onos/store/impl/StoreManager.java
+++ b/core/store/hz/common/src/main/java/org/onlab/onos/store/common/StoreManager.java
@@ -1,4 +1,4 @@
-package org.onlab.onos.store.impl;
+package org.onlab.onos.store.common;
import com.hazelcast.config.Config;
import com.hazelcast.config.FileSystemXmlConfig;
@@ -27,7 +27,6 @@
import org.onlab.onos.net.Port;
import org.onlab.onos.net.PortNumber;
import org.onlab.onos.net.provider.ProviderId;
-import org.onlab.onos.store.common.StoreService;
import org.onlab.onos.store.serializers.ConnectPointSerializer;
import org.onlab.onos.store.serializers.DefaultLinkSerializer;
import org.onlab.onos.store.serializers.DefaultPortSerializer;
@@ -35,7 +34,6 @@
import org.onlab.onos.store.serializers.IpPrefixSerializer;
import org.onlab.onos.store.serializers.LinkKeySerializer;
import org.onlab.onos.store.serializers.NodeIdSerializer;
-import org.onlab.onos.store.serializers.OnosTimestampSerializer;
import org.onlab.onos.store.serializers.PortNumberSerializer;
import org.onlab.onos.store.serializers.ProviderIdSerializer;
import org.onlab.packet.IpPrefix;
@@ -102,7 +100,6 @@
.register(DeviceId.class, new DeviceIdSerializer())
.register(PortNumber.class, new PortNumberSerializer())
.register(DefaultPort.class, new DefaultPortSerializer())
- .register(OnosTimestamp.class, new OnosTimestampSerializer())
.register(LinkKey.class, new LinkKeySerializer())
.register(ConnectPoint.class, new ConnectPointSerializer())
.register(DefaultLink.class, new DefaultLinkSerializer())
diff --git a/core/store/src/main/java/org/onlab/onos/store/common/StoreService.java b/core/store/hz/common/src/main/java/org/onlab/onos/store/common/StoreService.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/common/StoreService.java
rename to core/store/hz/common/src/main/java/org/onlab/onos/store/common/StoreService.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/common/package-info.java b/core/store/hz/common/src/main/java/org/onlab/onos/store/common/package-info.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/common/package-info.java
rename to core/store/hz/common/src/main/java/org/onlab/onos/store/common/package-info.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/impl/package-info.java b/core/store/hz/common/src/main/java/org/onlab/onos/store/impl/package-info.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/impl/package-info.java
rename to core/store/hz/common/src/main/java/org/onlab/onos/store/impl/package-info.java
diff --git a/core/store/src/test/java/org/onlab/onos/store/impl/TestStoreManager.java b/core/store/hz/common/src/test/java/org/onlab/onos/store/common/TestStoreManager.java
similarity index 97%
rename from core/store/src/test/java/org/onlab/onos/store/impl/TestStoreManager.java
rename to core/store/hz/common/src/test/java/org/onlab/onos/store/common/TestStoreManager.java
index c9d8821..1914fc3 100644
--- a/core/store/src/test/java/org/onlab/onos/store/impl/TestStoreManager.java
+++ b/core/store/hz/common/src/test/java/org/onlab/onos/store/common/TestStoreManager.java
@@ -1,4 +1,4 @@
-package org.onlab.onos.store.impl;
+package org.onlab.onos.store.common;
import java.io.FileNotFoundException;
import java.util.UUID;
diff --git a/core/store/hz/net/pom.xml b/core/store/hz/net/pom.xml
new file mode 100644
index 0000000..e3bc0e2
--- /dev/null
+++ b/core/store/hz/net/pom.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onos-core-hz</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-core-hz-net</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>ONOS Hazelcast based distributed store subsystems</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onos-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onos-core-hz-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onos-core-hz-common</artifactId>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.hazelcast</groupId>
+ <artifactId>hazelcast</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>de.javakaffee</groupId>
+ <artifactId>kryo-serializers</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/core/store/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java b/core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
similarity index 98%
rename from core/store/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
rename to core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
index 3186578..dcf2a3d 100644
--- a/core/store/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
+++ b/core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
@@ -1,6 +1,7 @@
package org.onlab.onos.store.device.impl;
import static com.google.common.base.Predicates.notNull;
+
import com.google.common.base.Optional;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.FluentIterable;
@@ -26,9 +27,9 @@
import org.onlab.onos.net.device.DeviceStoreDelegate;
import org.onlab.onos.net.device.PortDescription;
import org.onlab.onos.net.provider.ProviderId;
-import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache;
-import org.onlab.onos.store.impl.AbstractDistributedStore;
-import org.onlab.onos.store.impl.OptionalCacheLoader;
+import org.onlab.onos.store.common.AbsentInvalidatingLoadingCache;
+import org.onlab.onos.store.common.AbstractHazelcastStore;
+import org.onlab.onos.store.common.OptionalCacheLoader;
import org.slf4j.Logger;
import java.util.ArrayList;
@@ -52,7 +53,7 @@
@Component(immediate = true)
@Service
public class DistributedDeviceStore
- extends AbstractDistributedStore<DeviceEvent, DeviceStoreDelegate>
+ extends AbstractHazelcastStore<DeviceEvent, DeviceStoreDelegate>
implements DeviceStore {
private final Logger log = getLogger(getClass());
diff --git a/core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/NoOpClockService.java b/core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/NoOpClockService.java
new file mode 100644
index 0000000..2c443e9
--- /dev/null
+++ b/core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/NoOpClockService.java
@@ -0,0 +1,32 @@
+package org.onlab.onos.store.device.impl;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.onlab.onos.cluster.MastershipTerm;
+import org.onlab.onos.net.DeviceId;
+import org.onlab.onos.store.ClockService;
+import org.onlab.onos.store.Timestamp;
+
+// FIXME: Code clone in onos-core-trivial, onos-core-hz-net
+/**
+ * Dummy implementation of {@link ClockService}.
+ */
+@Component(immediate = true)
+@Service
+public class NoOpClockService implements ClockService {
+
+ @Override
+ public Timestamp getTimestamp(DeviceId deviceId) {
+ return new Timestamp() {
+
+ @Override
+ public int compareTo(Timestamp o) {
+ throw new IllegalStateException("Never expected to be used.");
+ }
+ };
+ }
+
+ @Override
+ public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) {
+ }
+}
diff --git a/core/store/src/main/java/org/onlab/onos/store/device/impl/package-info.java b/core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/package-info.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/device/impl/package-info.java
rename to core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/package-info.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java b/core/store/hz/net/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
similarity index 100%
copy from core/store/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
copy to core/store/hz/net/src/main/java/org/onlab/onos/store/flow/impl/DistributedFlowRuleStore.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/host/impl/DistributedHostStore.java b/core/store/hz/net/src/main/java/org/onlab/onos/store/host/impl/DistributedHostStore.java
similarity index 100%
copy from core/store/src/main/java/org/onlab/onos/store/host/impl/DistributedHostStore.java
copy to core/store/hz/net/src/main/java/org/onlab/onos/store/host/impl/DistributedHostStore.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/link/impl/DistributedLinkStore.java b/core/store/hz/net/src/main/java/org/onlab/onos/store/link/impl/DistributedLinkStore.java
similarity index 96%
rename from core/store/src/main/java/org/onlab/onos/store/link/impl/DistributedLinkStore.java
rename to core/store/hz/net/src/main/java/org/onlab/onos/store/link/impl/DistributedLinkStore.java
index 6db9695..d74ea49 100644
--- a/core/store/src/main/java/org/onlab/onos/store/link/impl/DistributedLinkStore.java
+++ b/core/store/hz/net/src/main/java/org/onlab/onos/store/link/impl/DistributedLinkStore.java
@@ -10,6 +10,7 @@
import java.util.HashSet;
import java.util.Set;
+
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -24,9 +25,9 @@
import org.onlab.onos.net.link.LinkStore;
import org.onlab.onos.net.link.LinkStoreDelegate;
import org.onlab.onos.net.provider.ProviderId;
-import org.onlab.onos.store.impl.AbsentInvalidatingLoadingCache;
-import org.onlab.onos.store.impl.AbstractDistributedStore;
-import org.onlab.onos.store.impl.OptionalCacheLoader;
+import org.onlab.onos.store.common.AbsentInvalidatingLoadingCache;
+import org.onlab.onos.store.common.AbstractHazelcastStore;
+import org.onlab.onos.store.common.OptionalCacheLoader;
import org.slf4j.Logger;
import com.google.common.base.Optional;
@@ -43,7 +44,7 @@
@Component(immediate = true)
@Service
public class DistributedLinkStore
- extends AbstractDistributedStore<LinkEvent, LinkStoreDelegate>
+ extends AbstractHazelcastStore<LinkEvent, LinkStoreDelegate>
implements LinkStore {
private final Logger log = getLogger(getClass());
diff --git a/core/store/src/main/java/org/onlab/onos/store/link/impl/package-info.java b/core/store/hz/net/src/main/java/org/onlab/onos/store/link/impl/package-info.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/link/impl/package-info.java
rename to core/store/hz/net/src/main/java/org/onlab/onos/store/link/impl/package-info.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopology.java b/core/store/hz/net/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopology.java
similarity index 100%
copy from core/store/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopology.java
copy to core/store/hz/net/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopology.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopologyGraph.java b/core/store/hz/net/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopologyGraph.java
similarity index 100%
copy from core/store/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopologyGraph.java
copy to core/store/hz/net/src/main/java/org/onlab/onos/store/topology/impl/DefaultTopologyGraph.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java b/core/store/hz/net/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java
similarity index 100%
copy from core/store/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java
copy to core/store/hz/net/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/topology/impl/PathKey.java b/core/store/hz/net/src/main/java/org/onlab/onos/store/topology/impl/PathKey.java
similarity index 100%
copy from core/store/src/main/java/org/onlab/onos/store/topology/impl/PathKey.java
copy to core/store/hz/net/src/main/java/org/onlab/onos/store/topology/impl/PathKey.java
diff --git a/core/store/src/test/java/org/onlab/onos/store/device/impl/DistributedDeviceStoreTest.java b/core/store/hz/net/src/test/java/org/onlab/onos/store/device/impl/DistributedDeviceStoreTest.java
similarity index 98%
rename from core/store/src/test/java/org/onlab/onos/store/device/impl/DistributedDeviceStoreTest.java
rename to core/store/hz/net/src/test/java/org/onlab/onos/store/device/impl/DistributedDeviceStoreTest.java
index d7494be..2fdad74 100644
--- a/core/store/src/test/java/org/onlab/onos/store/device/impl/DistributedDeviceStoreTest.java
+++ b/core/store/hz/net/src/test/java/org/onlab/onos/store/device/impl/DistributedDeviceStoreTest.java
@@ -32,9 +32,9 @@
import org.onlab.onos.net.device.DeviceStoreDelegate;
import org.onlab.onos.net.device.PortDescription;
import org.onlab.onos.net.provider.ProviderId;
+import org.onlab.onos.store.common.StoreManager;
import org.onlab.onos.store.common.StoreService;
-import org.onlab.onos.store.impl.StoreManager;
-import org.onlab.onos.store.impl.TestStoreManager;
+import org.onlab.onos.store.common.TestStoreManager;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
diff --git a/core/store/src/test/java/org/onlab/onos/store/link/impl/DistributedLinkStoreTest.java b/core/store/hz/net/src/test/java/org/onlab/onos/store/link/impl/DistributedLinkStoreTest.java
similarity index 98%
rename from core/store/src/test/java/org/onlab/onos/store/link/impl/DistributedLinkStoreTest.java
rename to core/store/hz/net/src/test/java/org/onlab/onos/store/link/impl/DistributedLinkStoreTest.java
index 41853f6..0f97358 100644
--- a/core/store/src/test/java/org/onlab/onos/store/link/impl/DistributedLinkStoreTest.java
+++ b/core/store/hz/net/src/test/java/org/onlab/onos/store/link/impl/DistributedLinkStoreTest.java
@@ -26,9 +26,9 @@
import org.onlab.onos.net.link.LinkEvent;
import org.onlab.onos.net.link.LinkStoreDelegate;
import org.onlab.onos.net.provider.ProviderId;
+import org.onlab.onos.store.common.StoreManager;
import org.onlab.onos.store.common.StoreService;
-import org.onlab.onos.store.impl.StoreManager;
-import org.onlab.onos.store.impl.TestStoreManager;
+import org.onlab.onos.store.common.TestStoreManager;
import com.google.common.collect.Iterables;
import com.hazelcast.config.Config;
diff --git a/core/store/hz/pom.xml b/core/store/hz/pom.xml
new file mode 100644
index 0000000..d6aa1fe
--- /dev/null
+++ b/core/store/hz/pom.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onos-core-store</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-core-hz</artifactId>
+ <packaging>pom</packaging>
+
+ <description>ONOS Core Hazelcast Store subsystem</description>
+
+ <modules>
+ <module>common</module>
+ <module>cluster</module>
+ <module>net</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onlab-misc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onlab-junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.hazelcast</groupId>
+ <artifactId>hazelcast</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/core/store/pom.xml b/core/store/pom.xml
index 246355c..b94b4fe 100644
--- a/core/store/pom.xml
+++ b/core/store/pom.xml
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -12,34 +10,41 @@
</parent>
<artifactId>onos-core-store</artifactId>
- <packaging>bundle</packaging>
+ <packaging>pom</packaging>
- <description>ONOS distributed store subsystems</description>
+ <description>ONOS Core Store subsystem</description>
+
+ <modules>
+ <module>trivial</module>
+ <module>dist</module>
+ <module>hz</module>
+ <module>serializers</module>
+ </modules>
<dependencies>
<dependency>
- <groupId>org.onlab.onos</groupId>
- <artifactId>onos-api</artifactId>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onlab-misc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onlab.onos</groupId>
+ <artifactId>onlab-junit</artifactId>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
</dependency>
- <dependency>
- <groupId>de.javakaffee</groupId>
- <artifactId>kryo-serializers</artifactId>
- </dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
- <artifactId>maven-scr-plugin</artifactId>
+ <artifactId>maven-bundle-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/core/trivial/pom.xml b/core/store/serializers/pom.xml
similarity index 77%
copy from core/trivial/pom.xml
copy to core/store/serializers/pom.xml
index 1806ba4..f222a23 100644
--- a/core/trivial/pom.xml
+++ b/core/store/serializers/pom.xml
@@ -6,15 +6,15 @@
<parent>
<groupId>org.onlab.onos</groupId>
- <artifactId>onos-core</artifactId>
+ <artifactId>onos-core-store</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>onos-core-trivial</artifactId>
+ <artifactId>onos-core-serializers</artifactId>
<packaging>bundle</packaging>
- <description>ONOS network control trivial implementations of core subsystems</description>
+ <description>Serializers for ONOS classes</description>
<dependencies>
<dependency>
@@ -25,6 +25,10 @@
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
</dependency>
+ <dependency>
+ <groupId>de.javakaffee</groupId>
+ <artifactId>kryo-serializers</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/core/store/src/main/java/org/onlab/onos/store/serializers/ConnectPointSerializer.java b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/ConnectPointSerializer.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/serializers/ConnectPointSerializer.java
rename to core/store/serializers/src/main/java/org/onlab/onos/store/serializers/ConnectPointSerializer.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/serializers/DefaultLinkSerializer.java b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/DefaultLinkSerializer.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/serializers/DefaultLinkSerializer.java
rename to core/store/serializers/src/main/java/org/onlab/onos/store/serializers/DefaultLinkSerializer.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/serializers/DefaultPortSerializer.java b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/DefaultPortSerializer.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/serializers/DefaultPortSerializer.java
rename to core/store/serializers/src/main/java/org/onlab/onos/store/serializers/DefaultPortSerializer.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/serializers/DeviceIdSerializer.java b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/DeviceIdSerializer.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/serializers/DeviceIdSerializer.java
rename to core/store/serializers/src/main/java/org/onlab/onos/store/serializers/DeviceIdSerializer.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/serializers/IpPrefixSerializer.java b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/IpPrefixSerializer.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/serializers/IpPrefixSerializer.java
rename to core/store/serializers/src/main/java/org/onlab/onos/store/serializers/IpPrefixSerializer.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/serializers/LinkKeySerializer.java b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/LinkKeySerializer.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/serializers/LinkKeySerializer.java
rename to core/store/serializers/src/main/java/org/onlab/onos/store/serializers/LinkKeySerializer.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/serializers/NodeIdSerializer.java b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/NodeIdSerializer.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/serializers/NodeIdSerializer.java
rename to core/store/serializers/src/main/java/org/onlab/onos/store/serializers/NodeIdSerializer.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/serializers/PortNumberSerializer.java b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/PortNumberSerializer.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/serializers/PortNumberSerializer.java
rename to core/store/serializers/src/main/java/org/onlab/onos/store/serializers/PortNumberSerializer.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/serializers/ProviderIdSerializer.java b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/ProviderIdSerializer.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/serializers/ProviderIdSerializer.java
rename to core/store/serializers/src/main/java/org/onlab/onos/store/serializers/ProviderIdSerializer.java
diff --git a/core/store/src/main/java/org/onlab/onos/store/serializers/package-info.java b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/package-info.java
similarity index 100%
rename from core/store/src/main/java/org/onlab/onos/store/serializers/package-info.java
rename to core/store/serializers/src/main/java/org/onlab/onos/store/serializers/package-info.java
diff --git a/core/trivial/pom.xml b/core/store/trivial/pom.xml
similarity index 95%
rename from core/trivial/pom.xml
rename to core/store/trivial/pom.xml
index 1806ba4..40016d4 100644
--- a/core/trivial/pom.xml
+++ b/core/store/trivial/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>org.onlab.onos</groupId>
- <artifactId>onos-core</artifactId>
+ <artifactId>onos-core-store</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/DefaultTopology.java b/core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/DefaultTopology.java
similarity index 100%
rename from core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/DefaultTopology.java
rename to core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/DefaultTopology.java
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/DefaultTopologyGraph.java b/core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/DefaultTopologyGraph.java
similarity index 100%
rename from core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/DefaultTopologyGraph.java
rename to core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/DefaultTopologyGraph.java
diff --git a/core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/NoOpClockService.java b/core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/NoOpClockService.java
new file mode 100644
index 0000000..88fcddf
--- /dev/null
+++ b/core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/NoOpClockService.java
@@ -0,0 +1,32 @@
+package org.onlab.onos.net.trivial.impl;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.onlab.onos.cluster.MastershipTerm;
+import org.onlab.onos.net.DeviceId;
+import org.onlab.onos.store.ClockService;
+import org.onlab.onos.store.Timestamp;
+
+//FIXME: Code clone in onos-core-trivial, onos-core-hz-net
+/**
+ * Dummy implementation of {@link ClockService}.
+ */
+@Component(immediate = true)
+@Service
+public class NoOpClockService implements ClockService {
+
+ @Override
+ public Timestamp getTimestamp(DeviceId deviceId) {
+ return new Timestamp() {
+
+ @Override
+ public int compareTo(Timestamp o) {
+ throw new IllegalStateException("Never expected to be used.");
+ }
+ };
+ }
+
+ @Override
+ public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) {
+ }
+}
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/PathKey.java b/core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/PathKey.java
similarity index 100%
rename from core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/PathKey.java
rename to core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/PathKey.java
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleClusterStore.java b/core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleClusterStore.java
similarity index 100%
rename from core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleClusterStore.java
rename to core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleClusterStore.java
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleDeviceStore.java b/core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleDeviceStore.java
similarity index 100%
rename from core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleDeviceStore.java
rename to core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleDeviceStore.java
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleFlowRuleStore.java b/core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleFlowRuleStore.java
similarity index 100%
rename from core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleFlowRuleStore.java
rename to core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleFlowRuleStore.java
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java b/core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java
similarity index 100%
rename from core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java
rename to core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleLinkStore.java b/core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleLinkStore.java
similarity index 100%
rename from core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleLinkStore.java
rename to core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleLinkStore.java
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleMastershipStore.java b/core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleMastershipStore.java
similarity index 100%
rename from core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleMastershipStore.java
rename to core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleMastershipStore.java
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleTopologyStore.java b/core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleTopologyStore.java
similarity index 100%
rename from core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleTopologyStore.java
rename to core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleTopologyStore.java
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/package-info.java b/core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/package-info.java
similarity index 100%
rename from core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/package-info.java
rename to core/store/trivial/src/main/java/org/onlab/onos/net/trivial/impl/package-info.java
diff --git a/core/trivial/src/test/java/org/onlab/onos/net/trivial/impl/DefaultTopologyTest.java b/core/store/trivial/src/test/java/org/onlab/onos/net/trivial/impl/DefaultTopologyTest.java
similarity index 100%
rename from core/trivial/src/test/java/org/onlab/onos/net/trivial/impl/DefaultTopologyTest.java
rename to core/store/trivial/src/test/java/org/onlab/onos/net/trivial/impl/DefaultTopologyTest.java
diff --git a/features/features.xml b/features/features.xml
index a27a781..739e6b6 100644
--- a/features/features.xml
+++ b/features/features.xml
@@ -49,7 +49,20 @@
description="ONOS core components">
<feature>onos-api</feature>
<bundle>mvn:org.onlab.onos/onos-core-net/1.0.0-SNAPSHOT</bundle>
- <bundle>mvn:org.onlab.onos/onos-core-store/1.0.0-SNAPSHOT</bundle>
+ <bundle>mvn:org.onlab.onos/onos-core-hz-common/1.0.0-SNAPSHOT</bundle>
+ <bundle>mvn:org.onlab.onos/onos-core-serializers/1.0.0-SNAPSHOT</bundle>
+ <bundle>mvn:org.onlab.onos/onos-core-hz-cluster/1.0.0-SNAPSHOT</bundle>
+ <bundle>mvn:org.onlab.onos/onos-core-hz-net/1.0.0-SNAPSHOT</bundle>
+ </feature>
+
+ <feature name="onos-core-dist" version="1.0.0"
+ description="ONOS core components">
+ <feature>onos-api</feature>
+ <bundle>mvn:org.onlab.onos/onos-core-net/1.0.0-SNAPSHOT</bundle>
+ <bundle>mvn:org.onlab.onos/onos-core-hz-common/1.0.0-SNAPSHOT</bundle>
+ <bundle>mvn:org.onlab.onos/onos-core-serializers/1.0.0-SNAPSHOT</bundle>
+ <bundle>mvn:org.onlab.onos/onos-core-hz-cluster/1.0.0-SNAPSHOT</bundle>
+ <bundle>mvn:org.onlab.onos/onos-core-dist/1.0.0-SNAPSHOT</bundle>
</feature>
<feature name="onos-core-trivial" version="1.0.0"
diff --git a/tools/build/conf/pom.xml b/tools/build/conf/pom.xml
index 8607de3..c2ad09c 100644
--- a/tools/build/conf/pom.xml
+++ b/tools/build/conf/pom.xml
@@ -1,4 +1,7 @@
-<project>
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.onlab.tools</groupId>
<artifactId>onos-build-conf</artifactId>
diff --git a/tools/test/bin/onos-start-network b/tools/test/bin/onos-start-network
new file mode 100755
index 0000000..c8245ab
--- /dev/null
+++ b/tools/test/bin/onos-start-network
@@ -0,0 +1,17 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+# Verifies connectivity to each node in ONOS cell.
+#-------------------------------------------------------------------------------
+
+[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
+. $ONOS_ROOT/tools/build/envDefaults
+
+SSHCMD="ssh -o PasswordAuthentication=no"
+SCPCMD="scp -q -o PasswordAuthentication=no"
+
+echo "Copying topology files to mininet vm."
+$SSHCMD -n $ONOS_USER@$OCN mkdir -p topos
+$SCPCMD $ONOS_ROOT/tools/test/topos/* $ONOS_USER@$OCN:topos/
+
+echo "Starting Network."
+$SSHCMD -t $ONOS_USER@$OCN sudo python topos/sol.py $(env | sort | egrep "OC[0-9]+" | cut -d= -f2)
diff --git a/utils/nio/src/main/java/org/onlab/nio/package-info.java b/utils/nio/src/main/java/org/onlab/nio/package-info.java
index d5ddd10..144236f 100644
--- a/utils/nio/src/main/java/org/onlab/nio/package-info.java
+++ b/utils/nio/src/main/java/org/onlab/nio/package-info.java
@@ -2,4 +2,4 @@
* Mechanism to transfer messages over network using IO loop and
* message stream, backed by NIO byte buffers.
*/
-package org.onlab.nio;
\ No newline at end of file
+package org.onlab.nio;