pankaj

Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next

Showing 56 changed files with 272 additions and 277 deletions
......@@ -170,7 +170,9 @@ public class ReactiveForwarding {
// We don't yet support bufferids in the flowservice so packet out first.
packetOut(context, portNumber);
if (true) {
return;
}
// Install the flow rule to handle this type of message from now on.
Ethernet inPkt = context.inPacket().parsed();
......
package org.onlab.onos.cli;
import com.google.common.collect.Lists;
import org.apache.karaf.shell.commands.Command;
import org.onlab.onos.cluster.ClusterService;
import org.onlab.onos.cluster.ControllerNode;
import org.onlab.onos.cluster.MastershipService;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.device.DeviceMastershipService;
import java.util.Collections;
import java.util.List;
......@@ -22,7 +23,7 @@ public class MastersListCommand extends AbstractShellCommand {
@Override
protected void execute() {
ClusterService service = get(ClusterService.class);
MastershipService mastershipService = get(MastershipService.class);
DeviceMastershipService mastershipService = get(DeviceMastershipService.class);
List<ControllerNode> nodes = newArrayList(service.getNodes());
Collections.sort(nodes, Comparators.NODE_COMPARATOR);
ControllerNode self = service.getLocalNode();
......
......@@ -3,9 +3,9 @@ package org.onlab.onos.cli.net;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onlab.onos.cli.AbstractShellCommand;
import org.onlab.onos.cluster.MastershipAdminService;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.net.MastershipRole;
import org.onlab.onos.net.device.DeviceMastershipAdminService;
import static org.onlab.onos.net.DeviceId.deviceId;
......@@ -30,7 +30,7 @@ public class DeviceRoleCommand extends AbstractShellCommand {
@Override
protected void execute() {
MastershipAdminService service = get(MastershipAdminService.class);
DeviceMastershipAdminService service = get(DeviceMastershipAdminService.class);
MastershipRole mastershipRole = MastershipRole.valueOf(role.toUpperCase());
service.setRole(new NodeId(node), deviceId(uri), mastershipRole);
}
......
......@@ -19,17 +19,16 @@ import org.onlab.onos.net.intent.IntentState;
description = "Wipes-out the entire network information base, i.e. devices, links, hosts")
public class WipeOutCommand extends ClustersListCommand {
private static final String DISCLAIMER = "Delete everything please.";
private static final String PLEASE = "please";
@Argument(index = 0, name = "disclaimer", description = "Device ID",
@Argument(index = 0, name = "please", description = "Confirmation phrase",
required = false, multiValued = false)
String disclaimer = null;
String please = null;
@Override
protected void execute() {
if (disclaimer == null || !disclaimer.equals(DISCLAIMER)) {
print("I'm afraid I can't do that!\nPlease acknowledge with phrase: '%s'",
DISCLAIMER);
if (please == null || !please.equals(PLEASE)) {
print("I'm afraid I can't do that!\nSay: %s", PLEASE);
return;
}
......
......@@ -9,10 +9,12 @@ import java.util.Objects;
public abstract class ElementId {
private final URI uri;
private final String str;
// Default constructor for serialization
protected ElementId() {
this.uri = null;
this.str = null;
}
/**
......@@ -22,6 +24,7 @@ public abstract class ElementId {
*/
protected ElementId(URI uri) {
this.uri = uri;
this.str = uri.toString();
}
/**
......@@ -35,7 +38,7 @@ public abstract class ElementId {
@Override
public int hashCode() {
return Objects.hash(uri);
return Objects.hash(str);
}
@Override
......@@ -46,14 +49,14 @@ public abstract class ElementId {
if (obj instanceof ElementId) {
final ElementId that = (ElementId) obj;
return this.getClass() == that.getClass() &&
Objects.equals(this.uri, that.uri);
Objects.equals(this.str, that.str);
}
return false;
}
@Override
public String toString() {
return uri.toString();
return str;
}
}
......
package org.onlab.onos.cluster;
package org.onlab.onos.net.device;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.MastershipRole;
/**
* Service for administering the inventory of device masterships.
*/
public interface MastershipAdminService {
public interface DeviceMastershipAdminService {
/**
* Applies the current mastership role for the specified device.
......
package org.onlab.onos.cluster;
package org.onlab.onos.net.device;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.event.AbstractEvent;
import org.onlab.onos.net.DeviceId;
/**
* Describes a device mastership event.
*/
public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceId> {
public class DeviceMastershipEvent extends AbstractEvent<DeviceMastershipEvent.Type, DeviceId> {
//do we worry about explicitly setting slaves/equals? probably not,
//to keep it simple
......@@ -30,7 +31,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI
* @param device event device subject
* @param master master ID subject
*/
public MastershipEvent(Type type, DeviceId device, NodeId master) {
public DeviceMastershipEvent(Type type, DeviceId device, NodeId master) {
super(type, device);
this.master = master;
}
......@@ -44,7 +45,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI
* @param master master ID subject
* @param time occurrence time
*/
public MastershipEvent(Type type, DeviceId device, NodeId master, long time) {
public DeviceMastershipEvent(Type type, DeviceId device, NodeId master, long time) {
super(type, device, time);
this.master = master;
}
......
package org.onlab.onos.cluster;
package org.onlab.onos.net.device;
import org.onlab.onos.event.EventListener;
/**
* Entity capable of receiving device mastership-related events.
*/
public interface MastershipListener extends EventListener<MastershipEvent> {
public interface DeviceMastershipListener extends EventListener<DeviceMastershipEvent> {
}
......
package org.onlab.onos.cluster;
package org.onlab.onos.net.device;
import java.util.Set;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.MastershipRole;
......@@ -11,7 +12,7 @@ import org.onlab.onos.net.MastershipRole;
* determining mastership, but is not responsible for actually applying it
* to the devices; this falls on the device service.
*/
public interface MastershipService {
public interface DeviceMastershipService {
/**
* Returns the role of the local node for the specified device, without
......@@ -62,20 +63,20 @@ public interface MastershipService {
*
* @return the MastershipTermService for this mastership manager
*/
MastershipTermService requestTermService();
DeviceMastershipTermService requestTermService();
/**
* Adds the specified mastership change listener.
*
* @param listener the mastership listener
*/
void addListener(MastershipListener listener);
void addListener(DeviceMastershipListener listener);
/**
* Removes the specified mastership change listener.
*
* @param listener the mastership listener
*/
void removeListener(MastershipListener listener);
void removeListener(DeviceMastershipListener listener);
}
......
package org.onlab.onos.cluster;
package org.onlab.onos.net.device;
import java.util.Set;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.MastershipRole;
import org.onlab.onos.store.Store;
......@@ -10,7 +11,7 @@ import org.onlab.onos.store.Store;
* Manages inventory of mastership roles for devices, across controller
* instances; not intended for direct use.
*/
public interface MastershipStore extends Store<MastershipEvent, MastershipStoreDelegate> {
public interface DeviceMastershipStore extends Store<DeviceMastershipEvent, DeviceMastershipStoreDelegate> {
// three things to map: NodeId, DeviceId, MastershipRole
......@@ -54,7 +55,7 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD
* @param deviceId device identifier
* @return a mastership event
*/
MastershipEvent setMaster(NodeId nodeId, DeviceId deviceId);
DeviceMastershipEvent setMaster(NodeId nodeId, DeviceId deviceId);
/**
* Returns the current master and number of past mastership hand-offs
......@@ -63,7 +64,7 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD
* @param deviceId the device identifier
* @return the current master's ID and the term value for device, or null
*/
MastershipTerm getTermFor(DeviceId deviceId);
DeviceMastershipTerm getTermFor(DeviceId deviceId);
/**
* Sets a controller instance's mastership role to STANDBY for a device.
......@@ -74,7 +75,7 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD
* @param deviceId device to revoke mastership role for
* @return a mastership event
*/
MastershipEvent setStandby(NodeId nodeId, DeviceId deviceId);
DeviceMastershipEvent setStandby(NodeId nodeId, DeviceId deviceId);
/**
* Allows a controller instance to give up its current role for a device.
......@@ -85,6 +86,6 @@ public interface MastershipStore extends Store<MastershipEvent, MastershipStoreD
* @param deviceId device to revoke mastership role for
* @return a mastership event
*/
MastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId);
DeviceMastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId);
}
......
package org.onlab.onos.cluster;
package org.onlab.onos.net.device;
import org.onlab.onos.store.StoreDelegate;
/**
* Mastership store delegate abstraction.
* DeviceMastership store delegate abstraction.
*/
public interface MastershipStoreDelegate extends StoreDelegate<MastershipEvent> {
public interface DeviceMastershipStoreDelegate extends StoreDelegate<DeviceMastershipEvent> {
}
......
package org.onlab.onos.cluster;
package org.onlab.onos.net.device;
import java.util.Objects;
public final class MastershipTerm {
import org.onlab.onos.cluster.NodeId;
public final class DeviceMastershipTerm {
private final NodeId master;
private final int termNumber;
private MastershipTerm(NodeId master, int term) {
private DeviceMastershipTerm(NodeId master, int term) {
this.master = master;
this.termNumber = term;
}
public static MastershipTerm of(NodeId master, int term) {
return new MastershipTerm(master, term);
public static DeviceMastershipTerm of(NodeId master, int term) {
return new DeviceMastershipTerm(master, term);
}
public NodeId master() {
......@@ -34,8 +36,8 @@ public final class MastershipTerm {
if (this == other) {
return true;
}
if (other instanceof MastershipTerm) {
MastershipTerm that = (MastershipTerm) other;
if (other instanceof DeviceMastershipTerm) {
DeviceMastershipTerm that = (DeviceMastershipTerm) other;
if (!this.master.equals(that.master)) {
return false;
}
......
package org.onlab.onos.cluster;
package org.onlab.onos.net.device;
import org.onlab.onos.net.DeviceId;
......@@ -6,7 +6,7 @@ import org.onlab.onos.net.DeviceId;
/**
* Service to obtain mastership term information.
*/
public interface MastershipTermService {
public interface DeviceMastershipTermService {
// TBD: manage/increment per device mastership change
// or increment on any change
......@@ -16,5 +16,5 @@ public interface MastershipTermService {
* @param deviceId the identifier of the device
* @return current master's term.
*/
MastershipTerm getMastershipTerm(DeviceId deviceId);
DeviceMastershipTerm getMastershipTerm(DeviceId deviceId);
}
......
package org.onlab.onos.net.flow;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import org.onlab.onos.net.PortNumber;
import org.onlab.onos.net.flow.instructions.Instruction;
import org.onlab.onos.net.flow.instructions.Instructions;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.slf4j.Logger;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
/**
* Default traffic treatment implementation.
......@@ -70,8 +67,6 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
*/
public static final class Builder implements TrafficTreatment.Builder {
private final Logger log = getLogger(getClass());
boolean drop = false;
List<Instruction> outputs = new LinkedList<>();
......@@ -107,7 +102,8 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
groups.add(instruction);
break;
default:
log.warn("Unknown instruction type {}", instruction.type());
throw new IllegalArgumentException("Unknown instruction type: " +
instruction.type());
}
return this;
}
......
package org.onlab.onos.store;
import org.onlab.onos.cluster.MastershipTerm;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.device.DeviceMastershipTerm;
//TODO: Consider renaming to DeviceClockProviderService?
/**
......@@ -16,5 +16,5 @@ public interface ClockProviderService {
* @param deviceId device identifier.
* @param term mastership term.
*/
public void setMastershipTerm(DeviceId deviceId, MastershipTerm term);
public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term);
}
......
package org.onlab.onos.store.common.impl;
package org.onlab.onos.store;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Objects;
import org.onlab.onos.store.Timestamp;
import com.google.common.base.MoreObjects;
/**
......
package org.onlab.onos.store.device.impl;
package org.onlab.onos.store;
import java.util.Objects;
import org.onlab.onos.store.Timestamp;
/**
* Wrapper class for a entity that is versioned
* and can either be up or down.
......
......@@ -2,13 +2,16 @@ package org.onlab.onos.cluster;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.MastershipRole;
import org.onlab.onos.net.device.DeviceMastershipListener;
import org.onlab.onos.net.device.DeviceMastershipService;
import org.onlab.onos.net.device.DeviceMastershipTermService;
import java.util.Set;
/**
* Test adapter for mastership service.
*/
public class MastershipServiceAdapter implements MastershipService {
public class MastershipServiceAdapter implements DeviceMastershipService {
@Override
public MastershipRole getLocalRole(DeviceId deviceId) {
return null;
......@@ -34,15 +37,15 @@ public class MastershipServiceAdapter implements MastershipService {
}
@Override
public void addListener(MastershipListener listener) {
public void addListener(DeviceMastershipListener listener) {
}
@Override
public void removeListener(MastershipListener listener) {
public void removeListener(DeviceMastershipListener listener) {
}
@Override
public MastershipTermService requestTermService() {
public DeviceMastershipTermService requestTermService() {
return null;
}
}
......
......@@ -3,6 +3,7 @@ package org.onlab.onos.cluster;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.onlab.onos.net.device.DeviceMastershipTerm;
import com.google.common.testing.EqualsTester;
......@@ -11,10 +12,10 @@ public class MastershipTermTest {
private static final NodeId N1 = new NodeId("foo");
private static final NodeId N2 = new NodeId("bar");
private static final MastershipTerm TERM1 = MastershipTerm.of(N1, 0);
private static final MastershipTerm TERM2 = MastershipTerm.of(N2, 1);
private static final MastershipTerm TERM3 = MastershipTerm.of(N2, 1);
private static final MastershipTerm TERM4 = MastershipTerm.of(N1, 1);
private static final DeviceMastershipTerm TERM1 = DeviceMastershipTerm.of(N1, 0);
private static final DeviceMastershipTerm TERM2 = DeviceMastershipTerm.of(N2, 1);
private static final DeviceMastershipTerm TERM3 = DeviceMastershipTerm.of(N2, 1);
private static final DeviceMastershipTerm TERM4 = DeviceMastershipTerm.of(N1, 1);
@Test
public void basics() {
......@@ -24,7 +25,7 @@ public class MastershipTermTest {
@Test
public void testEquality() {
new EqualsTester().addEqualityGroup(MastershipTerm.of(N1, 0), TERM1)
new EqualsTester().addEqualityGroup(DeviceMastershipTerm.of(N1, 0), TERM1)
.addEqualityGroup(TERM2, TERM3)
.addEqualityGroup(TERM4);
}
......
......@@ -14,25 +14,25 @@ import org.apache.felix.scr.annotations.Service;
import org.onlab.onos.cluster.ClusterEvent;
import org.onlab.onos.cluster.ClusterEventListener;
import org.onlab.onos.cluster.ClusterService;
import org.onlab.onos.cluster.MastershipAdminService;
import org.onlab.onos.cluster.MastershipEvent;
import org.onlab.onos.cluster.MastershipListener;
import org.onlab.onos.cluster.MastershipService;
import org.onlab.onos.cluster.MastershipStore;
import org.onlab.onos.cluster.MastershipStoreDelegate;
import org.onlab.onos.cluster.MastershipTerm;
import org.onlab.onos.cluster.MastershipTermService;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.event.AbstractListenerRegistry;
import org.onlab.onos.event.EventDeliveryService;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.MastershipRole;
import org.onlab.onos.net.device.DeviceMastershipAdminService;
import org.onlab.onos.net.device.DeviceMastershipEvent;
import org.onlab.onos.net.device.DeviceMastershipListener;
import org.onlab.onos.net.device.DeviceMastershipService;
import org.onlab.onos.net.device.DeviceMastershipStore;
import org.onlab.onos.net.device.DeviceMastershipStoreDelegate;
import org.onlab.onos.net.device.DeviceMastershipTerm;
import org.onlab.onos.net.device.DeviceMastershipTermService;
import org.slf4j.Logger;
@Component(immediate = true)
@Service
public class MastershipManager
implements MastershipService, MastershipAdminService {
implements DeviceMastershipService, DeviceMastershipAdminService {
private static final String NODE_ID_NULL = "Node ID cannot be null";
private static final String DEVICE_ID_NULL = "Device ID cannot be null";
......@@ -40,13 +40,13 @@ implements MastershipService, MastershipAdminService {
private final Logger log = getLogger(getClass());
protected final AbstractListenerRegistry<MastershipEvent, MastershipListener>
protected final AbstractListenerRegistry<DeviceMastershipEvent, DeviceMastershipListener>
listenerRegistry = new AbstractListenerRegistry<>();
private final MastershipStoreDelegate delegate = new InternalDelegate();
private final DeviceMastershipStoreDelegate delegate = new InternalDelegate();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected MastershipStore store;
protected DeviceMastershipStore store;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected EventDeliveryService eventDispatcher;
......@@ -58,7 +58,7 @@ implements MastershipService, MastershipAdminService {
@Activate
public void activate() {
eventDispatcher.addSink(MastershipEvent.class, listenerRegistry);
eventDispatcher.addSink(DeviceMastershipEvent.class, listenerRegistry);
clusterService.addListener(clusterListener);
store.setDelegate(delegate);
log.info("Started");
......@@ -66,7 +66,7 @@ implements MastershipService, MastershipAdminService {
@Deactivate
public void deactivate() {
eventDispatcher.removeSink(MastershipEvent.class);
eventDispatcher.removeSink(DeviceMastershipEvent.class);
clusterService.removeListener(clusterListener);
store.unsetDelegate(delegate);
log.info("Stopped");
......@@ -78,7 +78,7 @@ implements MastershipService, MastershipAdminService {
checkNotNull(deviceId, DEVICE_ID_NULL);
checkNotNull(role, ROLE_NULL);
MastershipEvent event = null;
DeviceMastershipEvent event = null;
if (role.equals(MastershipRole.MASTER)) {
event = store.setMaster(nodeId, deviceId);
} else {
......@@ -98,7 +98,7 @@ implements MastershipService, MastershipAdminService {
@Override
public void relinquishMastership(DeviceId deviceId) {
MastershipEvent event = null;
DeviceMastershipEvent event = null;
event = store.relinquishRole(
clusterService.getLocalNode().id(), deviceId);
......@@ -127,18 +127,18 @@ implements MastershipService, MastershipAdminService {
@Override
public MastershipTermService requestTermService() {
public DeviceMastershipTermService requestTermService() {
return new InternalMastershipTermService();
}
@Override
public void addListener(MastershipListener listener) {
public void addListener(DeviceMastershipListener listener) {
checkNotNull(listener);
listenerRegistry.addListener(listener);
}
@Override
public void removeListener(MastershipListener listener) {
public void removeListener(DeviceMastershipListener listener) {
checkNotNull(listener);
listenerRegistry.removeListener(listener);
}
......@@ -146,16 +146,16 @@ implements MastershipService, MastershipAdminService {
// FIXME: provide wiring to allow events to be triggered by changes within the store
// Posts the specified event to the local event dispatcher.
private void post(MastershipEvent event) {
private void post(DeviceMastershipEvent event) {
if (event != null && eventDispatcher != null) {
eventDispatcher.post(event);
}
}
private class InternalMastershipTermService implements MastershipTermService {
private class InternalMastershipTermService implements DeviceMastershipTermService {
@Override
public MastershipTerm getMastershipTerm(DeviceId deviceId) {
public DeviceMastershipTerm getMastershipTerm(DeviceId deviceId) {
return store.getTermFor(deviceId);
}
......@@ -181,10 +181,10 @@ implements MastershipService, MastershipAdminService {
}
public class InternalDelegate implements MastershipStoreDelegate {
public class InternalDelegate implements DeviceMastershipStoreDelegate {
@Override
public void notify(MastershipEvent event) {
public void notify(DeviceMastershipEvent event) {
log.info("dispatching mastership event {}", event);
eventDispatcher.post(event);
}
......
......@@ -13,11 +13,6 @@ 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.cluster.ClusterService;
import org.onlab.onos.cluster.MastershipEvent;
import org.onlab.onos.cluster.MastershipListener;
import org.onlab.onos.cluster.MastershipService;
import org.onlab.onos.cluster.MastershipTermService;
import org.onlab.onos.cluster.MastershipTerm;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.event.AbstractListenerRegistry;
import org.onlab.onos.event.EventDeliveryService;
......@@ -36,6 +31,11 @@ import org.onlab.onos.net.device.DeviceProviderService;
import org.onlab.onos.net.device.DeviceService;
import org.onlab.onos.net.device.DeviceStore;
import org.onlab.onos.net.device.DeviceStoreDelegate;
import org.onlab.onos.net.device.DeviceMastershipEvent;
import org.onlab.onos.net.device.DeviceMastershipListener;
import org.onlab.onos.net.device.DeviceMastershipService;
import org.onlab.onos.net.device.DeviceMastershipTerm;
import org.onlab.onos.net.device.DeviceMastershipTermService;
import org.onlab.onos.net.device.PortDescription;
import org.onlab.onos.net.provider.AbstractProviderRegistry;
import org.onlab.onos.net.provider.AbstractProviderService;
......@@ -64,7 +64,7 @@ public class DeviceManager
private final DeviceStoreDelegate delegate = new InternalStoreDelegate();
private final MastershipListener mastershipListener = new InternalMastershipListener();
private final DeviceMastershipListener mastershipListener = new InternalMastershipListener();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DeviceStore store;
......@@ -76,9 +76,9 @@ public class DeviceManager
protected ClusterService clusterService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected MastershipService mastershipService;
protected DeviceMastershipService mastershipService;
protected MastershipTermService termService;
protected DeviceMastershipTermService termService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ClockProviderService clockProviderService;
......@@ -209,7 +209,7 @@ public class DeviceManager
return;
}
MastershipTerm term = mastershipService.requestTermService()
DeviceMastershipTerm term = mastershipService.requestTermService()
.getMastershipTerm(deviceId);
if (!term.master().equals(clusterService.getLocalNode().id())) {
// lost mastership after requestRole told this instance was MASTER.
......@@ -320,16 +320,16 @@ public class DeviceManager
}
// Intercepts mastership events
private class InternalMastershipListener implements MastershipListener {
private class InternalMastershipListener implements DeviceMastershipListener {
@Override
public void event(MastershipEvent event) {
public void event(DeviceMastershipEvent event) {
final DeviceId did = event.subject();
if (isAvailable(did)) {
final NodeId myNodeId = clusterService.getLocalNode().id();
if (myNodeId.equals(event.master())) {
MastershipTerm term = termService.getMastershipTerm(did);
DeviceMastershipTerm term = termService.getMastershipTerm(did);
if (term.master().equals(myNodeId)) {
// only set the new term if I am the master
......
......@@ -10,11 +10,11 @@ import org.onlab.onos.cluster.ClusterService;
import org.onlab.onos.cluster.ControllerNode;
import org.onlab.onos.cluster.ControllerNode.State;
import org.onlab.onos.cluster.DefaultControllerNode;
import org.onlab.onos.cluster.MastershipService;
import org.onlab.onos.cluster.MastershipTermService;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.event.impl.TestEventDispatcher;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.device.DeviceMastershipService;
import org.onlab.onos.net.device.DeviceMastershipTermService;
import org.onlab.onos.store.trivial.impl.SimpleMastershipStore;
import org.onlab.packet.IpPrefix;
......@@ -34,7 +34,7 @@ public class MastershipManagerTest {
private static final DeviceId DEV_OTHER = DeviceId.deviceId("of:2");
private MastershipManager mgr;
protected MastershipService service;
protected DeviceMastershipService service;
@Before
public void setUp() {
......@@ -120,7 +120,7 @@ public class MastershipManagerTest {
@Test
public void termService() {
MastershipTermService ts = mgr.requestTermService();
DeviceMastershipTermService ts = mgr.requestTermService();
//term = 0 for both
mgr.setRole(NID_LOCAL, DEV_MASTER, MASTER);
......
......@@ -11,8 +11,6 @@ import org.onlab.onos.cluster.ClusterService;
import org.onlab.onos.cluster.ControllerNode;
import org.onlab.onos.cluster.DefaultControllerNode;
import org.onlab.onos.cluster.MastershipServiceAdapter;
import org.onlab.onos.cluster.MastershipTerm;
import org.onlab.onos.cluster.MastershipTermService;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.cluster.ControllerNode.State;
import org.onlab.onos.event.Event;
......@@ -32,6 +30,8 @@ import org.onlab.onos.net.device.DeviceProvider;
import org.onlab.onos.net.device.DeviceProviderRegistry;
import org.onlab.onos.net.device.DeviceProviderService;
import org.onlab.onos.net.device.DeviceService;
import org.onlab.onos.net.device.DeviceMastershipTerm;
import org.onlab.onos.net.device.DeviceMastershipTermService;
import org.onlab.onos.net.device.PortDescription;
import org.onlab.onos.net.provider.AbstractProvider;
import org.onlab.onos.net.provider.ProviderId;
......@@ -290,12 +290,12 @@ public class DeviceManagerTest {
}
@Override
public MastershipTermService requestTermService() {
return new MastershipTermService() {
public DeviceMastershipTermService requestTermService() {
return new DeviceMastershipTermService() {
@Override
public MastershipTerm getMastershipTerm(DeviceId deviceId) {
public DeviceMastershipTerm getMastershipTerm(DeviceId deviceId) {
// FIXME: just returning something not null
return MastershipTerm.of(NID_LOCAL, 1);
return DeviceMastershipTerm.of(NID_LOCAL, 1);
}
};
}
......@@ -339,7 +339,7 @@ public class DeviceManagerTest {
ClockProviderService {
@Override
public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) {
public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
// TODO Auto-generated method stub
}
}
......
......@@ -6,6 +6,7 @@ import java.io.IOException;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
......@@ -23,10 +24,8 @@ import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService;
import org.onlab.onos.store.cluster.messaging.ClusterMessage;
import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
import org.onlab.onos.store.cluster.messaging.MessageSubject;
import org.onlab.onos.store.serializers.ClusterMessageSerializer;
import org.onlab.onos.store.serializers.KryoPoolUtil;
import org.onlab.onos.store.serializers.KryoSerializer;
import org.onlab.onos.store.serializers.MessageSubjectSerializer;
import org.onlab.util.KryoPool;
import org.onlab.netty.Endpoint;
import org.onlab.netty.Message;
......
package org.onlab.onos.store.serializers;
package org.onlab.onos.store.cluster.messaging.impl;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.store.cluster.messaging.ClusterMessage;
......
package org.onlab.onos.store.serializers;
package org.onlab.onos.store.cluster.messaging.impl;
import org.onlab.onos.store.cluster.messaging.MessageSubject;
......
......@@ -4,7 +4,7 @@ import java.util.Map;
import java.util.Set;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.store.device.impl.VersionedValue;
import org.onlab.onos.store.VersionedValue;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
......
......@@ -13,7 +13,7 @@ import com.google.common.collect.ComparisonChain;
* Default implementation of Timestamp.
* TODO: Better documentation.
*/
public final class MastershipBasedTimestamp implements Timestamp {
public final class DeviceMastershipBasedTimestamp implements Timestamp {
private final int termNumber;
private final int sequenceNumber;
......@@ -24,16 +24,16 @@ public final class MastershipBasedTimestamp implements Timestamp {
* @param termNumber the mastership termNumber
* @param sequenceNumber the sequenceNumber number within the termNumber
*/
public MastershipBasedTimestamp(int termNumber, int sequenceNumber) {
public DeviceMastershipBasedTimestamp(int termNumber, int sequenceNumber) {
this.termNumber = termNumber;
this.sequenceNumber = sequenceNumber;
}
@Override
public int compareTo(Timestamp o) {
checkArgument(o instanceof MastershipBasedTimestamp,
checkArgument(o instanceof DeviceMastershipBasedTimestamp,
"Must be MastershipBasedTimestamp", o);
MastershipBasedTimestamp that = (MastershipBasedTimestamp) o;
DeviceMastershipBasedTimestamp that = (DeviceMastershipBasedTimestamp) o;
return ComparisonChain.start()
.compare(this.termNumber, that.termNumber)
......@@ -51,10 +51,10 @@ public final class MastershipBasedTimestamp implements Timestamp {
if (this == obj) {
return true;
}
if (!(obj instanceof MastershipBasedTimestamp)) {
if (!(obj instanceof DeviceMastershipBasedTimestamp)) {
return false;
}
MastershipBasedTimestamp that = (MastershipBasedTimestamp) obj;
DeviceMastershipBasedTimestamp that = (DeviceMastershipBasedTimestamp) obj;
return Objects.equals(this.termNumber, that.termNumber) &&
Objects.equals(this.sequenceNumber, that.sequenceNumber);
}
......@@ -87,7 +87,7 @@ public final class MastershipBasedTimestamp implements Timestamp {
// Default constructor for serialization
@Deprecated
protected MastershipBasedTimestamp() {
protected DeviceMastershipBasedTimestamp() {
this.termNumber = -1;
this.sequenceNumber = -1;
}
......
package org.onlab.onos.store.serializers;
import org.onlab.onos.store.common.impl.MastershipBasedTimestamp;
package org.onlab.onos.store.common.impl;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
......@@ -9,12 +7,12 @@ import com.esotericsoftware.kryo.io.Output;
// To be used if Timestamp ever needs to cross bundle boundary.
/**
* Kryo Serializer for {@link MastershipBasedTimestamp}.
* Kryo Serializer for {@link DeviceMastershipBasedTimestamp}.
*/
public class MastershipBasedTimestampSerializer extends Serializer<MastershipBasedTimestamp> {
public class MastershipBasedTimestampSerializer extends Serializer<DeviceMastershipBasedTimestamp> {
/**
* Creates a serializer for {@link MastershipBasedTimestamp}.
* Creates a serializer for {@link DeviceMastershipBasedTimestamp}.
*/
public MastershipBasedTimestampSerializer() {
// non-null, immutable
......@@ -22,15 +20,15 @@ public class MastershipBasedTimestampSerializer extends Serializer<MastershipBas
}
@Override
public void write(Kryo kryo, Output output, MastershipBasedTimestamp object) {
public void write(Kryo kryo, Output output, DeviceMastershipBasedTimestamp object) {
output.writeInt(object.termNumber());
output.writeInt(object.sequenceNumber());
}
@Override
public MastershipBasedTimestamp read(Kryo kryo, Input input, Class<MastershipBasedTimestamp> type) {
public DeviceMastershipBasedTimestamp read(Kryo kryo, Input input, Class<DeviceMastershipBasedTimestamp> type) {
final int term = input.readInt();
final int sequence = input.readInt();
return new MastershipBasedTimestamp(term, sequence);
return new DeviceMastershipBasedTimestamp(term, sequence);
}
}
......
......@@ -8,6 +8,7 @@ import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.net.Device;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.store.Timestamp;
import org.onlab.onos.store.VersionedValue;
import org.onlab.onos.store.common.impl.AntiEntropyAdvertisement;
// TODO DeviceID needs to be changed to something like (ProviderID, DeviceID)
......
......@@ -10,6 +10,7 @@ import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.net.Device;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.store.Timestamp;
import org.onlab.onos.store.VersionedValue;
import org.onlab.onos.store.common.impl.AntiEntropyReply;
import com.google.common.collect.ImmutableMap;
......
......@@ -10,12 +10,12 @@ 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.net.device.DeviceMastershipTerm;
import org.onlab.onos.store.ClockProviderService;
import org.onlab.onos.store.ClockService;
import org.onlab.onos.store.Timestamp;
import org.onlab.onos.store.common.impl.MastershipBasedTimestamp;
import org.onlab.onos.store.common.impl.DeviceMastershipBasedTimestamp;
import org.slf4j.Logger;
/**
......@@ -29,7 +29,7 @@ public class DeviceClockManager implements ClockService, ClockProviderService {
// 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<>();
private ConcurrentMap<DeviceId, DeviceMastershipTerm> deviceMastershipTerms = new ConcurrentHashMap<>();
@Activate
public void activate() {
......@@ -43,15 +43,15 @@ public class DeviceClockManager implements ClockService, ClockProviderService {
@Override
public Timestamp getTimestamp(DeviceId deviceId) {
MastershipTerm term = deviceMastershipTerms.get(deviceId);
DeviceMastershipTerm term = deviceMastershipTerms.get(deviceId);
if (term == null) {
throw new IllegalStateException("Requesting timestamp for a deviceId without mastership");
}
return new MastershipBasedTimestamp(term.termNumber(), ticker.incrementAndGet());
return new DeviceMastershipBasedTimestamp(term.termNumber(), ticker.incrementAndGet());
}
@Override
public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) {
public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
deviceMastershipTerms.put(deviceId, term);
}
}
......
......@@ -35,14 +35,14 @@ 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.onlab.onos.store.Timestamped;
import org.onlab.onos.store.cluster.messaging.ClusterCommunicationService;
import org.onlab.onos.store.cluster.messaging.ClusterMessage;
import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
import org.onlab.onos.store.common.impl.MastershipBasedTimestamp;
import org.onlab.onos.store.common.impl.Timestamped;
import org.onlab.onos.store.common.impl.DeviceMastershipBasedTimestamp;
import org.onlab.onos.store.common.impl.MastershipBasedTimestampSerializer;
import org.onlab.onos.store.serializers.KryoPoolUtil;
import org.onlab.onos.store.serializers.KryoSerializer;
import org.onlab.onos.store.serializers.MastershipBasedTimestampSerializer;
import org.onlab.util.KryoPool;
import org.onlab.util.NewConcurrentHashMap;
import org.slf4j.Logger;
......@@ -125,7 +125,7 @@ public class GossipDeviceStore
.register(InternalPortStatusEvent.class, new InternalPortStatusEventSerializer())
.register(Timestamp.class)
.register(Timestamped.class)
.register(MastershipBasedTimestamp.class, new MastershipBasedTimestampSerializer())
.register(DeviceMastershipBasedTimestamp.class, new MastershipBasedTimestampSerializer())
.build()
.populate(1);
}
......
......@@ -3,7 +3,7 @@ package org.onlab.onos.store.device.impl;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.device.DeviceDescription;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.onos.store.common.impl.Timestamped;
import org.onlab.onos.store.Timestamped;
/**
* Information published by GossipDeviceStore to notify peers of a device
......
......@@ -3,7 +3,7 @@ package org.onlab.onos.store.device.impl;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.device.DeviceDescription;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.onos.store.common.impl.Timestamped;
import org.onlab.onos.store.Timestamped;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
......
......@@ -5,7 +5,7 @@ import java.util.List;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.device.PortDescription;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.onos.store.common.impl.Timestamped;
import org.onlab.onos.store.Timestamped;
/**
* Information published by GossipDeviceStore to notify peers of a port
......
......@@ -5,7 +5,7 @@ import java.util.List;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.device.PortDescription;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.onos.store.common.impl.Timestamped;
import org.onlab.onos.store.Timestamped;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
......
......@@ -3,7 +3,7 @@ package org.onlab.onos.store.device.impl;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.device.PortDescription;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.onos.store.common.impl.Timestamped;
import org.onlab.onos.store.Timestamped;
/**
* Information published by GossipDeviceStore to notify peers of a port
......
......@@ -3,7 +3,7 @@ package org.onlab.onos.store.device.impl;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.device.PortDescription;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.onos.store.common.impl.Timestamped;
import org.onlab.onos.store.Timestamped;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
......
......@@ -31,7 +31,7 @@ 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.onlab.onos.store.device.impl.VersionedValue;
import org.onlab.onos.store.VersionedValue;
import org.slf4j.Logger;
import com.google.common.collect.HashMultimap;
......
......@@ -6,26 +6,25 @@ import java.nio.ByteBuffer;
import org.junit.Test;
import org.onlab.onos.store.Timestamp;
import org.onlab.onos.store.serializers.MastershipBasedTimestampSerializer;
import org.onlab.util.KryoPool;
import com.google.common.testing.EqualsTester;
/**
* Test of {@link MastershipBasedTimestamp}.
* Test of {@link DeviceMastershipBasedTimestamp}.
*/
public class MastershipBasedTimestampTest {
private static final Timestamp TS_1_1 = new MastershipBasedTimestamp(1, 1);
private static final Timestamp TS_1_2 = new MastershipBasedTimestamp(1, 2);
private static final Timestamp TS_2_1 = new MastershipBasedTimestamp(2, 1);
private static final Timestamp TS_2_2 = new MastershipBasedTimestamp(2, 2);
private static final Timestamp TS_1_1 = new DeviceMastershipBasedTimestamp(1, 1);
private static final Timestamp TS_1_2 = new DeviceMastershipBasedTimestamp(1, 2);
private static final Timestamp TS_2_1 = new DeviceMastershipBasedTimestamp(2, 1);
private static final Timestamp TS_2_2 = new DeviceMastershipBasedTimestamp(2, 2);
@Test
public final void testBasic() {
final int termNumber = 5;
final int sequenceNumber = 6;
MastershipBasedTimestamp ts = new MastershipBasedTimestamp(termNumber,
DeviceMastershipBasedTimestamp ts = new DeviceMastershipBasedTimestamp(termNumber,
sequenceNumber);
assertEquals(termNumber, ts.termNumber());
......@@ -35,7 +34,7 @@ public class MastershipBasedTimestampTest {
@Test
public final void testCompareTo() {
assertTrue(TS_1_1.compareTo(TS_1_1) == 0);
assertTrue(TS_1_1.compareTo(new MastershipBasedTimestamp(1, 1)) == 0);
assertTrue(TS_1_1.compareTo(new DeviceMastershipBasedTimestamp(1, 1)) == 0);
assertTrue(TS_1_1.compareTo(TS_1_2) < 0);
assertTrue(TS_1_2.compareTo(TS_1_1) > 0);
......@@ -49,14 +48,14 @@ public class MastershipBasedTimestampTest {
@Test
public final void testEqualsObject() {
new EqualsTester()
.addEqualityGroup(new MastershipBasedTimestamp(1, 1),
new MastershipBasedTimestamp(1, 1), TS_1_1)
.addEqualityGroup(new MastershipBasedTimestamp(1, 2),
new MastershipBasedTimestamp(1, 2), TS_1_2)
.addEqualityGroup(new MastershipBasedTimestamp(2, 1),
new MastershipBasedTimestamp(2, 1), TS_2_1)
.addEqualityGroup(new MastershipBasedTimestamp(2, 2),
new MastershipBasedTimestamp(2, 2), TS_2_2)
.addEqualityGroup(new DeviceMastershipBasedTimestamp(1, 1),
new DeviceMastershipBasedTimestamp(1, 1), TS_1_1)
.addEqualityGroup(new DeviceMastershipBasedTimestamp(1, 2),
new DeviceMastershipBasedTimestamp(1, 2), TS_1_2)
.addEqualityGroup(new DeviceMastershipBasedTimestamp(2, 1),
new DeviceMastershipBasedTimestamp(2, 1), TS_2_1)
.addEqualityGroup(new DeviceMastershipBasedTimestamp(2, 2),
new DeviceMastershipBasedTimestamp(2, 2), TS_2_2)
.testEquals();
}
......@@ -64,7 +63,7 @@ public class MastershipBasedTimestampTest {
public final void testKryoSerializable() {
final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
final KryoPool kryos = KryoPool.newBuilder()
.register(MastershipBasedTimestamp.class)
.register(DeviceMastershipBasedTimestamp.class)
.build();
kryos.serialize(TS_2_1, buffer);
......@@ -80,7 +79,7 @@ public class MastershipBasedTimestampTest {
public final void testKryoSerializableWithHandcraftedSerializer() {
final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
final KryoPool kryos = KryoPool.newBuilder()
.register(MastershipBasedTimestamp.class, new MastershipBasedTimestampSerializer())
.register(DeviceMastershipBasedTimestamp.class, new MastershipBasedTimestampSerializer())
.build();
kryos.serialize(TS_1_2, buffer);
......
......@@ -6,6 +6,7 @@ import java.nio.ByteBuffer;
import org.junit.Test;
import org.onlab.onos.store.Timestamp;
import org.onlab.onos.store.Timestamped;
import org.onlab.util.KryoPool;
import com.google.common.testing.EqualsTester;
......@@ -15,9 +16,9 @@ import com.google.common.testing.EqualsTester;
*/
public class TimestampedTest {
private static final Timestamp TS_1_1 = new MastershipBasedTimestamp(1, 1);
private static final Timestamp TS_1_2 = new MastershipBasedTimestamp(1, 2);
private static final Timestamp TS_2_1 = new MastershipBasedTimestamp(2, 1);
private static final Timestamp TS_1_1 = new DeviceMastershipBasedTimestamp(1, 1);
private static final Timestamp TS_1_2 = new DeviceMastershipBasedTimestamp(1, 2);
private static final Timestamp TS_2_1 = new DeviceMastershipBasedTimestamp(2, 1);
@Test
public final void testHashCode() {
......@@ -79,7 +80,7 @@ public class TimestampedTest {
final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
final KryoPool kryos = KryoPool.newBuilder()
.register(Timestamped.class,
MastershipBasedTimestamp.class)
DeviceMastershipBasedTimestamp.class)
.build();
Timestamped<String> original = new Timestamped<>("foobar", TS_1_1);
......
......@@ -25,7 +25,6 @@ import org.onlab.onos.cluster.ClusterService;
import org.onlab.onos.cluster.ControllerNode;
import org.onlab.onos.cluster.ControllerNode.State;
import org.onlab.onos.cluster.DefaultControllerNode;
import org.onlab.onos.cluster.MastershipTerm;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.net.Annotations;
import org.onlab.onos.net.DefaultAnnotations;
......@@ -40,6 +39,7 @@ 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.DeviceMastershipTerm;
import org.onlab.onos.net.device.PortDescription;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.onos.store.ClockService;
......@@ -113,8 +113,8 @@ public class GossipDeviceStoreTest {
deviceClockManager.activate();
clockService = deviceClockManager;
deviceClockManager.setMastershipTerm(DID1, MastershipTerm.of(MYSELF, 1));
deviceClockManager.setMastershipTerm(DID2, MastershipTerm.of(MYSELF, 2));
deviceClockManager.setMastershipTerm(DID1, DeviceMastershipTerm.of(MYSELF, 1));
deviceClockManager.setMastershipTerm(DID2, DeviceMastershipTerm.of(MYSELF, 2));
ClusterCommunicationService clusterCommunicator = new TestClusterCommunicationService();
ClusterService clusterService = new TestClusterService();
......
package org.onlab.onos.store.cluster.impl;
import static org.onlab.onos.cluster.MastershipEvent.Type.MASTER_CHANGED;
import static org.onlab.onos.net.device.DeviceMastershipEvent.Type.MASTER_CHANGED;
import java.util.Map;
import java.util.Set;
......@@ -12,13 +12,13 @@ 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.cluster.ClusterService;
import org.onlab.onos.cluster.MastershipEvent;
import org.onlab.onos.cluster.MastershipStore;
import org.onlab.onos.cluster.MastershipStoreDelegate;
import org.onlab.onos.cluster.MastershipTerm;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.MastershipRole;
import org.onlab.onos.net.device.DeviceMastershipEvent;
import org.onlab.onos.net.device.DeviceMastershipStore;
import org.onlab.onos.net.device.DeviceMastershipStoreDelegate;
import org.onlab.onos.net.device.DeviceMastershipTerm;
import org.onlab.onos.store.common.AbstractHazelcastStore;
import com.google.common.collect.ImmutableSet;
......@@ -32,9 +32,9 @@ import com.hazelcast.core.MultiMap;
*/
@Component(immediate = true)
@Service
public class DistributedMastershipStore
extends AbstractHazelcastStore<MastershipEvent, MastershipStoreDelegate>
implements MastershipStore {
public class DistributedDeviceMastershipStore
extends AbstractHazelcastStore<DeviceMastershipEvent, DeviceMastershipStoreDelegate>
implements DeviceMastershipStore {
//arbitrary lock name
private static final String LOCK = "lock";
......@@ -100,7 +100,7 @@ implements MastershipStore {
}
@Override
public MastershipEvent setMaster(NodeId nodeId, DeviceId deviceId) {
public DeviceMastershipEvent setMaster(NodeId nodeId, DeviceId deviceId) {
byte [] did = serialize(deviceId);
byte [] nid = serialize(nodeId);
......@@ -123,12 +123,12 @@ implements MastershipStore {
masters.put(did, nid);
evict(nid, did);
updateTerm(did);
return new MastershipEvent(MASTER_CHANGED, deviceId, nodeId);
return new DeviceMastershipEvent(MASTER_CHANGED, deviceId, nodeId);
case NONE:
masters.put(did, nid);
evict(nid, did);
updateTerm(did);
return new MastershipEvent(MASTER_CHANGED, deviceId, nodeId);
return new DeviceMastershipEvent(MASTER_CHANGED, deviceId, nodeId);
default:
log.warn("unknown Mastership Role {}", role);
return null;
......@@ -191,21 +191,21 @@ implements MastershipStore {
}
@Override
public MastershipTerm getTermFor(DeviceId deviceId) {
public DeviceMastershipTerm getTermFor(DeviceId deviceId) {
byte[] did = serialize(deviceId);
if ((masters.get(did) == null) ||
(terms.get(did) == null)) {
return null;
}
return MastershipTerm.of(
return DeviceMastershipTerm.of(
(NodeId) deserialize(masters.get(did)), terms.get(did));
}
@Override
public MastershipEvent setStandby(NodeId nodeId, DeviceId deviceId) {
public DeviceMastershipEvent setStandby(NodeId nodeId, DeviceId deviceId) {
byte [] did = serialize(deviceId);
byte [] nid = serialize(nodeId);
MastershipEvent event = null;
DeviceMastershipEvent event = null;
ILock lock = theInstance.getLock(LOCK);
lock.lock();
......@@ -231,10 +231,10 @@ implements MastershipStore {
}
@Override
public MastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId) {
public DeviceMastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId) {
byte [] did = serialize(deviceId);
byte [] nid = serialize(nodeId);
MastershipEvent event = null;
DeviceMastershipEvent event = null;
ILock lock = theInstance.getLock(LOCK);
lock.lock();
......@@ -260,7 +260,7 @@ implements MastershipStore {
}
//helper to fetch a new master candidate for a given device.
private MastershipEvent reelect(NodeId current, DeviceId deviceId) {
private DeviceMastershipEvent reelect(NodeId current, DeviceId deviceId) {
byte [] did = serialize(deviceId);
byte [] nid = serialize(current);
......@@ -281,7 +281,7 @@ implements MastershipStore {
evict(backup, did);
Integer term = terms.get(did);
terms.put(did, ++term);
return new MastershipEvent(
return new DeviceMastershipEvent(
MASTER_CHANGED, deviceId, (NodeId) deserialize(backup));
}
}
......@@ -320,7 +320,7 @@ implements MastershipStore {
@Override
protected void onAdd(DeviceId deviceId, NodeId nodeId) {
notifyDelegate(new MastershipEvent(MASTER_CHANGED, deviceId, nodeId));
notifyDelegate(new DeviceMastershipEvent(MASTER_CHANGED, deviceId, nodeId));
}
@Override
......
......@@ -21,12 +21,12 @@ import org.onlab.onos.cluster.ClusterService;
import org.onlab.onos.cluster.ControllerNode;
import org.onlab.onos.cluster.ControllerNode.State;
import org.onlab.onos.cluster.DefaultControllerNode;
import org.onlab.onos.cluster.MastershipEvent;
import org.onlab.onos.cluster.MastershipEvent.Type;
import org.onlab.onos.cluster.MastershipStoreDelegate;
import org.onlab.onos.cluster.MastershipTerm;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.device.DeviceMastershipEvent;
import org.onlab.onos.net.device.DeviceMastershipStoreDelegate;
import org.onlab.onos.net.device.DeviceMastershipTerm;
import org.onlab.onos.net.device.DeviceMastershipEvent.Type;
import org.onlab.onos.store.common.StoreManager;
import org.onlab.onos.store.common.StoreService;
import org.onlab.onos.store.common.TestStoreManager;
......@@ -40,7 +40,7 @@ import com.hazelcast.core.Hazelcast;
/**
* Test of the Hazelcast-based distributed MastershipStore implementation.
*/
public class DistributedMastershipStoreTest {
public class DistributedDeviceMastershipStoreTest {
private static final DeviceId DID1 = DeviceId.deviceId("of:01");
private static final DeviceId DID2 = DeviceId.deviceId("of:02");
......@@ -54,8 +54,8 @@ public class DistributedMastershipStoreTest {
private static final ControllerNode CN1 = new DefaultControllerNode(N1, IP);
private static final ControllerNode CN2 = new DefaultControllerNode(N2, IP);
private DistributedMastershipStore dms;
private TestDistributedMastershipStore testStore;
private DistributedDeviceMastershipStore dms;
private TestDistributedDeviceMastershipStore testStore;
private KryoSerializer serializationMgr;
private StoreManager storeMgr;
......@@ -77,11 +77,11 @@ public class DistributedMastershipStoreTest {
serializationMgr = new KryoSerializer();
dms = new TestDistributedMastershipStore(storeMgr, serializationMgr);
dms = new TestDistributedDeviceMastershipStore(storeMgr, serializationMgr);
dms.clusterService = new TestClusterService();
dms.activate();
testStore = (TestDistributedMastershipStore) dms;
testStore = (TestDistributedDeviceMastershipStore) dms;
}
@After
......@@ -133,7 +133,7 @@ public class DistributedMastershipStoreTest {
assertEquals("wrong role for NONE:", MASTER, dms.requestRole(DID1));
assertTrue("wrong state for store:", !dms.terms.isEmpty());
assertEquals("wrong term",
MastershipTerm.of(N1, 0), dms.getTermFor(DID1));
DeviceMastershipTerm.of(N1, 0), dms.getTermFor(DID1));
//CN2 now local. DID2 has N1 as MASTER so N2 is STANDBY
testStore.setCurrent(CN2);
......@@ -143,7 +143,7 @@ public class DistributedMastershipStoreTest {
//change term and requestRole() again; should persist
testStore.increment(DID2);
assertEquals("wrong role for STANDBY:", STANDBY, dms.requestRole(DID2));
assertEquals("wrong term", MastershipTerm.of(N1, 1), dms.getTermFor(DID2));
assertEquals("wrong term", DeviceMastershipTerm.of(N1, 1), dms.getTermFor(DID2));
}
@Test
......@@ -155,15 +155,15 @@ public class DistributedMastershipStoreTest {
//switch over to N2
assertEquals("wrong event:", Type.MASTER_CHANGED, dms.setMaster(N2, DID1).type());
assertEquals("wrong term", MastershipTerm.of(N2, 1), dms.getTermFor(DID1));
assertEquals("wrong term", DeviceMastershipTerm.of(N2, 1), dms.getTermFor(DID1));
//orphan switch - should be rare case
assertEquals("wrong event:", Type.MASTER_CHANGED, dms.setMaster(N2, DID2).type());
assertEquals("wrong term", MastershipTerm.of(N2, 0), dms.getTermFor(DID2));
assertEquals("wrong term", DeviceMastershipTerm.of(N2, 0), dms.getTermFor(DID2));
//disconnect and reconnect - sign of failing re-election or single-instance channel
testStore.reset(true, false, false);
dms.setMaster(N2, DID2);
assertEquals("wrong term", MastershipTerm.of(N2, 1), dms.getTermFor(DID2));
assertEquals("wrong term", DeviceMastershipTerm.of(N2, 1), dms.getTermFor(DID2));
}
@Test
......@@ -211,9 +211,9 @@ public class DistributedMastershipStoreTest {
//shamelessly copy other distributed store tests
final CountDownLatch addLatch = new CountDownLatch(1);
MastershipStoreDelegate checkAdd = new MastershipStoreDelegate() {
DeviceMastershipStoreDelegate checkAdd = new DeviceMastershipStoreDelegate() {
@Override
public void notify(MastershipEvent event) {
public void notify(DeviceMastershipEvent event) {
assertEquals("wrong event:", Type.MASTER_CHANGED, event.type());
assertEquals("wrong subject", DID1, event.subject());
assertEquals("wrong subject", N1, event.master());
......@@ -227,9 +227,9 @@ public class DistributedMastershipStoreTest {
assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS));
}
private class TestDistributedMastershipStore extends
DistributedMastershipStore {
public TestDistributedMastershipStore(StoreService storeService,
private class TestDistributedDeviceMastershipStore extends
DistributedDeviceMastershipStore {
public TestDistributedDeviceMastershipStore(StoreService storeService,
KryoSerializer kryoSerialization) {
this.storeService = storeService;
this.serializer = kryoSerialization;
......
......@@ -2,8 +2,8 @@ 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.net.device.DeviceMastershipTerm;
import org.onlab.onos.store.ClockProviderService;
// FIXME: Code clone in onos-core-trivial, onos-core-hz-net
......@@ -15,6 +15,6 @@ import org.onlab.onos.store.ClockProviderService;
public class NoOpClockProviderService implements ClockProviderService {
@Override
public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) {
public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
}
}
......
......@@ -7,7 +7,6 @@ import java.util.HashMap;
import org.onlab.onos.cluster.ControllerNode;
import org.onlab.onos.cluster.DefaultControllerNode;
import org.onlab.onos.cluster.MastershipTerm;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.DefaultAnnotations;
......@@ -24,6 +23,7 @@ import org.onlab.onos.net.Port;
import org.onlab.onos.net.PortNumber;
import org.onlab.onos.net.device.DefaultDeviceDescription;
import org.onlab.onos.net.device.DefaultPortDescription;
import org.onlab.onos.net.device.DeviceMastershipTerm;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
......@@ -74,7 +74,7 @@ public final class KryoPoolUtil {
.register(LinkKey.class, new LinkKeySerializer())
.register(ConnectPoint.class, new ConnectPointSerializer())
.register(DefaultLink.class, new DefaultLinkSerializer())
.register(MastershipTerm.class, new MastershipTermSerializer())
.register(DeviceMastershipTerm.class, new MastershipTermSerializer())
.register(MastershipRole.class, new MastershipRoleSerializer())
.build();
......
package org.onlab.onos.store.serializers;
import org.onlab.onos.cluster.MastershipTerm;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.net.device.DeviceMastershipTerm;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
/**
* Kryo Serializer for {@link org.onlab.onos.cluster.MastershipTerm}.
* Kryo Serializer for {@link org.onlab.onos.net.device.DeviceMastershipTerm}.
*/
public class MastershipTermSerializer extends Serializer<MastershipTerm> {
public class MastershipTermSerializer extends Serializer<DeviceMastershipTerm> {
/**
* Creates {@link MastershipTerm} serializer instance.
* Creates {@link DeviceMastershipTerm} serializer instance.
*/
public MastershipTermSerializer() {
// non-null, immutable
......@@ -21,14 +22,14 @@ public class MastershipTermSerializer extends Serializer<MastershipTerm> {
}
@Override
public MastershipTerm read(Kryo kryo, Input input, Class<MastershipTerm> type) {
public DeviceMastershipTerm read(Kryo kryo, Input input, Class<DeviceMastershipTerm> type) {
final NodeId node = new NodeId(input.readString());
final int term = input.readInt();
return MastershipTerm.of(node, term);
return DeviceMastershipTerm.of(node, term);
}
@Override
public void write(Kryo kryo, Output output, MastershipTerm object) {
public void write(Kryo kryo, Output output, DeviceMastershipTerm object) {
output.writeString(object.master().toString());
output.writeInt(object.termNumber());
}
......
......@@ -10,7 +10,6 @@ import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onlab.onos.cluster.MastershipTerm;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.net.Annotations;
import org.onlab.onos.net.ConnectPoint;
......@@ -25,6 +24,7 @@ import org.onlab.onos.net.LinkKey;
import org.onlab.onos.net.MastershipRole;
import org.onlab.onos.net.PortNumber;
import org.onlab.onos.net.SparseAnnotations;
import org.onlab.onos.net.device.DeviceMastershipTerm;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
......@@ -114,7 +114,7 @@ public class KryoSerializerTest {
testSerialized(PID);
testSerialized(PIDA);
testSerialized(new NodeId("bar"));
testSerialized(MastershipTerm.of(new NodeId("foo"), 2));
testSerialized(DeviceMastershipTerm.of(new NodeId("foo"), 2));
for (MastershipRole role : MastershipRole.values()) {
testSerialized(role);
}
......
......@@ -2,8 +2,8 @@ package org.onlab.onos.store.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.net.device.DeviceMastershipTerm;
import org.onlab.onos.store.ClockProviderService;
//FIXME: Code clone in onos-core-trivial, onos-core-hz-net
......@@ -15,6 +15,6 @@ import org.onlab.onos.store.ClockProviderService;
public class NoOpClockProviderService implements ClockProviderService {
@Override
public void setMastershipTerm(DeviceId deviceId, MastershipTerm term) {
public void setMastershipTerm(DeviceId deviceId, DeviceMastershipTerm term) {
}
}
......
......@@ -15,18 +15,18 @@ import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.onlab.onos.cluster.ControllerNode;
import org.onlab.onos.cluster.DefaultControllerNode;
import org.onlab.onos.cluster.MastershipEvent;
import org.onlab.onos.cluster.MastershipStore;
import org.onlab.onos.cluster.MastershipStoreDelegate;
import org.onlab.onos.cluster.MastershipTerm;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.MastershipRole;
import org.onlab.onos.net.device.DeviceMastershipEvent;
import org.onlab.onos.net.device.DeviceMastershipStore;
import org.onlab.onos.net.device.DeviceMastershipStoreDelegate;
import org.onlab.onos.net.device.DeviceMastershipTerm;
import org.onlab.onos.store.AbstractStore;
import org.onlab.packet.IpPrefix;
import org.slf4j.Logger;
import static org.onlab.onos.cluster.MastershipEvent.Type.*;
import static org.onlab.onos.net.device.DeviceMastershipEvent.Type.*;
/**
* Manages inventory of controller mastership over devices using
......@@ -35,8 +35,8 @@ import static org.onlab.onos.cluster.MastershipEvent.Type.*;
@Component(immediate = true)
@Service
public class SimpleMastershipStore
extends AbstractStore<MastershipEvent, MastershipStoreDelegate>
implements MastershipStore {
extends AbstractStore<DeviceMastershipEvent, DeviceMastershipStoreDelegate>
implements DeviceMastershipStore {
private final Logger log = getLogger(getClass());
......@@ -63,7 +63,7 @@ public class SimpleMastershipStore
}
@Override
public MastershipEvent setMaster(NodeId nodeId, DeviceId deviceId) {
public DeviceMastershipEvent setMaster(NodeId nodeId, DeviceId deviceId) {
MastershipRole role = getRole(nodeId, deviceId);
synchronized (this) {
......@@ -86,7 +86,7 @@ public class SimpleMastershipStore
}
}
return new MastershipEvent(MASTER_CHANGED, deviceId, nodeId);
return new DeviceMastershipEvent(MASTER_CHANGED, deviceId, nodeId);
}
@Override
......@@ -164,17 +164,17 @@ public class SimpleMastershipStore
}
@Override
public MastershipTerm getTermFor(DeviceId deviceId) {
public DeviceMastershipTerm getTermFor(DeviceId deviceId) {
if ((masterMap.get(deviceId) == null) ||
(termMap.get(deviceId) == null)) {
return null;
}
return MastershipTerm.of(
return DeviceMastershipTerm.of(
masterMap.get(deviceId), termMap.get(deviceId).get());
}
@Override
public MastershipEvent setStandby(NodeId nodeId, DeviceId deviceId) {
public DeviceMastershipEvent setStandby(NodeId nodeId, DeviceId deviceId) {
MastershipRole role = getRole(nodeId, deviceId);
synchronized (this) {
switch (role) {
......@@ -185,7 +185,7 @@ public class SimpleMastershipStore
} else {
masterMap.put(deviceId, backup);
termMap.get(deviceId).incrementAndGet();
return new MastershipEvent(MASTER_CHANGED, deviceId, backup);
return new DeviceMastershipEvent(MASTER_CHANGED, deviceId, backup);
}
case STANDBY:
case NONE:
......@@ -215,7 +215,7 @@ public class SimpleMastershipStore
}
@Override
public MastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId) {
public DeviceMastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId) {
return setStandby(nodeId, deviceId);
}
......
......@@ -6,9 +6,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.onos.cluster.MastershipTerm;
import org.onlab.onos.cluster.NodeId;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.device.DeviceMastershipTerm;
import com.google.common.collect.Sets;
......@@ -16,7 +16,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.onlab.onos.net.MastershipRole.*;
import static org.onlab.onos.cluster.MastershipEvent.Type.*;
import static org.onlab.onos.net.device.DeviceMastershipEvent.Type.*;
/**
* Test for the simple MastershipStore implementation.
......@@ -98,12 +98,12 @@ public class SimpleMastershipStoreTest {
@Test
public void getTermFor() {
put(DID1, N1, true, true);
assertEquals("wrong term", MastershipTerm.of(N1, 0), sms.getTermFor(DID1));
assertEquals("wrong term", DeviceMastershipTerm.of(N1, 0), sms.getTermFor(DID1));
//switch to N2 and back - 2 term switches
sms.setMaster(N2, DID1);
sms.setMaster(N1, DID1);
assertEquals("wrong term", MastershipTerm.of(N1, 2), sms.getTermFor(DID1));
assertEquals("wrong term", DeviceMastershipTerm.of(N1, 2), sms.getTermFor(DID1));
}
@Test
......
package org.onlab.onos.openflow.controller;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicBoolean;
import org.onlab.packet.Ethernet;
import org.projectfloodlight.openflow.protocol.OFPacketIn;
import org.projectfloodlight.openflow.protocol.OFPacketOut;
......@@ -13,11 +8,11 @@ import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
import org.projectfloodlight.openflow.protocol.match.MatchField;
import org.projectfloodlight.openflow.types.OFBufferId;
import org.projectfloodlight.openflow.types.OFPort;
import org.slf4j.Logger;
public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext {
import java.util.Collections;
import java.util.concurrent.atomic.AtomicBoolean;
private final Logger log = getLogger(getClass());
public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext {
private final AtomicBoolean free = new AtomicBoolean(true);
private final AtomicBoolean isBuilt = new AtomicBoolean(false);
......
......@@ -157,9 +157,7 @@ public class Controller {
}
log.debug("OpenFlow port set to {}", this.openFlowPort);
String threads = configParams.get("workerthreads");
if (threads != null) {
this.workerThreads = Integer.parseInt(threads);
}
this.workerThreads = threads != null ? Integer.parseInt(threads) : 16;
log.debug("Number of worker threads set to {}", this.workerThreads);
}
......
......@@ -44,7 +44,6 @@ public class OpenFlowControllerImpl implements OpenFlowController {
private final ExecutorService executor = Executors.newFixedThreadPool(16,
namedThreads("of-event-%d"));
protected ConcurrentHashMap<Dpid, OpenFlowSwitch> connectedSwitches =
new ConcurrentHashMap<Dpid, OpenFlowSwitch>();
protected ConcurrentHashMap<Dpid, OpenFlowSwitch> activeMasterSwitches =
......
package org.onlab.onos.provider.of.packet.impl;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.List;
import org.onlab.onos.net.PortNumber;
import org.onlab.onos.net.flow.instructions.Instruction;
import org.onlab.onos.net.flow.instructions.Instruction.Type;
......@@ -14,16 +10,16 @@ import org.onlab.onos.net.packet.OutboundPacket;
import org.onlab.onos.openflow.controller.OpenFlowPacketContext;
import org.onlab.packet.Ethernet;
import org.projectfloodlight.openflow.types.OFPort;
import org.slf4j.Logger;
public class OpenFlowCorePacketContext extends DefaultPacketContext {
import java.util.List;
private final Logger log = getLogger(getClass());
public class OpenFlowCorePacketContext extends DefaultPacketContext {
private final OpenFlowPacketContext ofPktCtx;
protected OpenFlowCorePacketContext(long time, InboundPacket inPkt,
OutboundPacket outPkt, boolean block, OpenFlowPacketContext ofPktCtx) {
OutboundPacket outPkt, boolean block,
OpenFlowPacketContext ofPktCtx) {
super(time, inPkt, outPkt, block);
this.ofPktCtx = ofPktCtx;
}
......@@ -38,7 +34,6 @@ public class OpenFlowCorePacketContext extends DefaultPacketContext {
eth.deserialize(outPacket().data().array(), 0,
outPacket().data().array().length);
sendPacket(eth);
}
}
......@@ -61,6 +56,7 @@ public class OpenFlowCorePacketContext extends DefaultPacketContext {
}
ofPktCtx.send();
}
private OFPort buildPort(PortNumber port) {
return OFPort.of((int) port.toLong());
}
......