tom

Merge remote-tracking branch 'origin/master'

......@@ -8,7 +8,7 @@ import java.util.concurrent.atomic.AtomicInteger;
*/
public final class ApplicationId {
private static AtomicInteger idDispenser;
private static final AtomicInteger ID_DISPENCER = new AtomicInteger(1);
private final Integer id;
// Ban public construction
......@@ -50,10 +50,7 @@ public final class ApplicationId {
* @return app id
*/
public static ApplicationId getAppId() {
if (ApplicationId.idDispenser == null) {
ApplicationId.idDispenser = new AtomicInteger(1);
}
return new ApplicationId(ApplicationId.idDispenser.getAndIncrement());
return new ApplicationId(ApplicationId.ID_DISPENCER.getAndIncrement());
}
}
......
......@@ -26,6 +26,9 @@ public final class FlowId {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (obj.getClass() == this.getClass()) {
FlowId that = (FlowId) obj;
return Objects.equal(this.flowid, that.flowid);
......
......@@ -39,7 +39,7 @@ public class DeviceEventTest extends AbstractEventTest {
Device device = createDevice();
Port port = new DefaultPort(device, PortNumber.portNumber(123), true);
long before = System.currentTimeMillis();
DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device);
DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device, port);
long after = System.currentTimeMillis();
validateEvent(event, DeviceEvent.Type.DEVICE_ADDED, device, before, after);
}
......
......@@ -94,14 +94,14 @@ public class ProxyArpManager implements ProxyArpService {
@Override
public boolean known(IpPrefix addr) {
checkNotNull(MAC_ADDR_NULL, addr);
checkNotNull(addr, MAC_ADDR_NULL);
Set<Host> hosts = hostService.getHostsByIp(addr);
return !hosts.isEmpty();
}
@Override
public void reply(Ethernet eth) {
checkNotNull(REQUEST_NULL, eth);
checkNotNull(eth, REQUEST_NULL);
checkArgument(eth.getEtherType() == Ethernet.TYPE_ARP,
REQUEST_NOT_ARP);
ARP arp = (ARP) eth.getPayload();
......@@ -137,7 +137,7 @@ public class ProxyArpManager implements ProxyArpService {
@Override
public void forward(Ethernet eth) {
checkNotNull(REQUEST_NULL, eth);
checkNotNull(eth, REQUEST_NULL);
checkArgument(eth.getEtherType() == Ethernet.TYPE_ARP,
REQUEST_NOT_ARP);
ARP arp = (ARP) eth.getPayload();
......@@ -206,12 +206,12 @@ public class ProxyArpManager implements ProxyArpService {
for (Link l : links) {
// for each link, mark the concerned ports as internal
// and the remaining ports are therefore external.
if (l.src().deviceId().equals(d)
if (l.src().deviceId().equals(d.id())
&& ports.contains(l.src().port())) {
ports.remove(l.src().port());
internalPorts.put(d, l.src().port());
}
if (l.dst().deviceId().equals(d)
if (l.dst().deviceId().equals(d.id())
&& ports.contains(l.dst().port())) {
ports.remove(l.dst().port());
internalPorts.put(d, l.dst().port());
......
......@@ -34,7 +34,8 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.testing.EqualsTester;
public class KryoSerializerTests {
public class KryoSerializerTest {
private static final ProviderId PID = new ProviderId("of", "foo");
private static final ProviderId PIDA = new ProviderId("of", "foo", true);
private static final DeviceId DID1 = deviceId("of:foo");
......@@ -92,7 +93,7 @@ public class KryoSerializerTests {
@Test
public final void test() {
public final void testSerialization() {
testSerialized(new ConnectPoint(DID1, P1));
testSerialized(new DefaultLink(PID, CP1, CP2, Link.Type.DIRECT));
testSerialized(new DefaultPort(DEV1, P1, true));
......@@ -119,6 +120,7 @@ public class KryoSerializerTests {
}
}
@Test
public final void testAnnotations() {
// Annotations does not have equals defined, manually test equality
final byte[] a1Bytes = kryos.serialize(A1);
......@@ -132,9 +134,9 @@ public class KryoSerializerTests {
// code clone
public static void assertAnnotationsEquals(Annotations actual, SparseAnnotations... annotations) {
DefaultAnnotations expected = DefaultAnnotations.builder().build();
SparseAnnotations expected = DefaultAnnotations.builder().build();
for (SparseAnnotations a : annotations) {
expected = DefaultAnnotations.merge(expected, a);
expected = DefaultAnnotations.union(expected, a);
}
assertEquals(expected.keys(), actual.keys());
for (String key : expected.keys()) {
......
......@@ -8,7 +8,7 @@ import org.jboss.netty.util.HashedWheelTimer;
*/
public final class Timer {
private static HashedWheelTimer timer;
private static volatile HashedWheelTimer timer;
// Ban public construction
private Timer() {
......@@ -21,10 +21,16 @@ public final class Timer {
*/
public static HashedWheelTimer getTimer() {
if (Timer.timer == null) {
initTimer();
}
return Timer.timer;
}
private static synchronized void initTimer() {
if (Timer.timer == null) {
Timer.timer = new HashedWheelTimer();
Timer.timer.start();
}
return Timer.timer;
}
}
......