Merge remote-tracking branch 'origin/master'
Conflicts: apps/ifwd/src/main/java/org/onlab/onos/ifwd/IntentReactiveForwarding.java
Showing
20 changed files
with
295 additions
and
43 deletions
| 1 | package org.onlab.onos.ifwd; | 1 | package org.onlab.onos.ifwd; |
| 2 | 2 | ||
| 3 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 4 | + | ||
| 3 | import org.apache.felix.scr.annotations.Activate; | 5 | import org.apache.felix.scr.annotations.Activate; |
| 4 | import org.apache.felix.scr.annotations.Component; | 6 | import org.apache.felix.scr.annotations.Component; |
| 5 | import org.apache.felix.scr.annotations.Deactivate; | 7 | import org.apache.felix.scr.annotations.Deactivate; |
| ... | @@ -14,7 +16,6 @@ import org.onlab.onos.net.flow.TrafficSelector; | ... | @@ -14,7 +16,6 @@ import org.onlab.onos.net.flow.TrafficSelector; |
| 14 | import org.onlab.onos.net.flow.TrafficTreatment; | 16 | import org.onlab.onos.net.flow.TrafficTreatment; |
| 15 | import org.onlab.onos.net.host.HostService; | 17 | import org.onlab.onos.net.host.HostService; |
| 16 | import org.onlab.onos.net.intent.HostToHostIntent; | 18 | import org.onlab.onos.net.intent.HostToHostIntent; |
| 17 | -import org.onlab.onos.net.intent.Intent; | ||
| 18 | import org.onlab.onos.net.intent.IntentId; | 19 | import org.onlab.onos.net.intent.IntentId; |
| 19 | import org.onlab.onos.net.intent.IntentService; | 20 | import org.onlab.onos.net.intent.IntentService; |
| 20 | import org.onlab.onos.net.packet.DefaultOutboundPacket; | 21 | import org.onlab.onos.net.packet.DefaultOutboundPacket; |
| ... | @@ -27,11 +28,6 @@ import org.onlab.onos.net.topology.TopologyService; | ... | @@ -27,11 +28,6 @@ import org.onlab.onos.net.topology.TopologyService; |
| 27 | import org.onlab.packet.Ethernet; | 28 | import org.onlab.packet.Ethernet; |
| 28 | import org.slf4j.Logger; | 29 | import org.slf4j.Logger; |
| 29 | 30 | ||
| 30 | -import java.util.Map; | ||
| 31 | -import java.util.concurrent.ConcurrentHashMap; | ||
| 32 | - | ||
| 33 | -import static org.slf4j.LoggerFactory.getLogger; | ||
| 34 | - | ||
| 35 | /** | 31 | /** |
| 36 | * WORK-IN-PROGRESS: Sample reactive forwarding application using intent framework. | 32 | * WORK-IN-PROGRESS: Sample reactive forwarding application using intent framework. |
| 37 | */ | 33 | */ |
| ... | @@ -54,9 +50,7 @@ public class IntentReactiveForwarding { | ... | @@ -54,9 +50,7 @@ public class IntentReactiveForwarding { |
| 54 | 50 | ||
| 55 | private ReactivePacketProcessor processor = new ReactivePacketProcessor(); | 51 | private ReactivePacketProcessor processor = new ReactivePacketProcessor(); |
| 56 | 52 | ||
| 57 | - private static long intentId = 1; | 53 | + private static long intentId = 0x123000; |
| 58 | - | ||
| 59 | - private Map<HostIdPair, IntentId> intents = new ConcurrentHashMap<>(); | ||
| 60 | 54 | ||
| 61 | @Activate | 55 | @Activate |
| 62 | public void activate() { | 56 | public void activate() { |
| ... | @@ -97,12 +91,8 @@ public class IntentReactiveForwarding { | ... | @@ -97,12 +91,8 @@ public class IntentReactiveForwarding { |
| 97 | return; | 91 | return; |
| 98 | } | 92 | } |
| 99 | 93 | ||
| 100 | - // Install a new intent only if we have not installed one already | 94 | + // Otherwise forward and be done with it. |
| 101 | - HostIdPair key = new HostIdPair(srcId, dstId); | 95 | + setUpConnectivity(context, srcId, dstId); |
| 102 | - if (!intents.containsKey(key)) { | ||
| 103 | - // Otherwise forward and be done with it. | ||
| 104 | - intents.put(key, setUpConnectivity(context, srcId, dstId).getId()); | ||
| 105 | - } | ||
| 106 | forwardPacketToDst(context, dst); | 96 | forwardPacketToDst(context, dst); |
| 107 | } | 97 | } |
| 108 | } | 98 | } |
| ... | @@ -132,26 +122,15 @@ public class IntentReactiveForwarding { | ... | @@ -132,26 +122,15 @@ public class IntentReactiveForwarding { |
| 132 | } | 122 | } |
| 133 | 123 | ||
| 134 | // Install a rule forwarding the packet to the specified port. | 124 | // Install a rule forwarding the packet to the specified port. |
| 135 | - private Intent setUpConnectivity(PacketContext context, HostId srcId, HostId dstId) { | 125 | + private void setUpConnectivity(PacketContext context, HostId srcId, HostId dstId) { |
| 136 | TrafficSelector selector = DefaultTrafficSelector.builder().build(); | 126 | TrafficSelector selector = DefaultTrafficSelector.builder().build(); |
| 137 | TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); | 127 | TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); |
| 138 | 128 | ||
| 139 | HostToHostIntent intent = | 129 | HostToHostIntent intent = |
| 140 | new HostToHostIntent(new IntentId(intentId++), srcId, dstId, | 130 | new HostToHostIntent(new IntentId(intentId++), srcId, dstId, |
| 141 | selector, treatment); | 131 | selector, treatment); |
| 132 | + | ||
| 142 | intentService.submit(intent); | 133 | intentService.submit(intent); |
| 143 | - return intent; | ||
| 144 | } | 134 | } |
| 145 | 135 | ||
| 146 | - | ||
| 147 | - private class HostIdPair { | ||
| 148 | - HostId one; | ||
| 149 | - HostId two; | ||
| 150 | - | ||
| 151 | - HostIdPair(HostId one, HostId two) { | ||
| 152 | - boolean oneFirst = one.hashCode() < two.hashCode(); | ||
| 153 | - this.one = oneFirst ? one : two; | ||
| 154 | - this.two = oneFirst ? two : one; | ||
| 155 | - } | ||
| 156 | - } | ||
| 157 | } | 136 | } | ... | ... |
| ... | @@ -2,4 +2,4 @@ | ... | @@ -2,4 +2,4 @@ |
| 2 | * Trivial application that provides simple form of reactive forwarding | 2 | * Trivial application that provides simple form of reactive forwarding |
| 3 | * using the intent service. | 3 | * using the intent service. |
| 4 | */ | 4 | */ |
| 5 | -package org.onlab.onos.fwd; | 5 | +package org.onlab.onos.ifwd; | ... | ... |
| ... | @@ -36,6 +36,12 @@ | ... | @@ -36,6 +36,12 @@ |
| 36 | <scope>test</scope> | 36 | <scope>test</scope> |
| 37 | </dependency> | 37 | </dependency> |
| 38 | 38 | ||
| 39 | + <dependency> | ||
| 40 | + <groupId>org.easymock</groupId> | ||
| 41 | + <artifactId>easymock</artifactId> | ||
| 42 | + <scope>test</scope> | ||
| 43 | + </dependency> | ||
| 44 | + | ||
| 39 | <!-- TODO Consider removing store dependency. | 45 | <!-- TODO Consider removing store dependency. |
| 40 | Currently required for DistributedDeviceManagerTest. --> | 46 | Currently required for DistributedDeviceManagerTest. --> |
| 41 | <dependency> | 47 | <dependency> | ... | ... |
| ... | @@ -60,14 +60,15 @@ public class HostMonitor implements TimerTask { | ... | @@ -60,14 +60,15 @@ public class HostMonitor implements TimerTask { |
| 60 | * | 60 | * |
| 61 | * @param deviceService device service used to find edge ports | 61 | * @param deviceService device service used to find edge ports |
| 62 | * @param packetService packet service used to send packets on the data plane | 62 | * @param packetService packet service used to send packets on the data plane |
| 63 | - * @param hostService host service used to look up host information | 63 | + * @param hostManager host manager used to look up host information and |
| 64 | + * probe existing hosts | ||
| 64 | */ | 65 | */ |
| 65 | public HostMonitor(DeviceService deviceService, PacketService packetService, | 66 | public HostMonitor(DeviceService deviceService, PacketService packetService, |
| 66 | - HostManager hostService) { | 67 | + HostManager hostManager) { |
| 67 | 68 | ||
| 68 | this.deviceService = deviceService; | 69 | this.deviceService = deviceService; |
| 69 | this.packetService = packetService; | 70 | this.packetService = packetService; |
| 70 | - this.hostManager = hostService; | 71 | + this.hostManager = hostManager; |
| 71 | 72 | ||
| 72 | monitoredAddresses = Collections.newSetFromMap( | 73 | monitoredAddresses = Collections.newSetFromMap( |
| 73 | new ConcurrentHashMap<IpAddress, Boolean>()); | 74 | new ConcurrentHashMap<IpAddress, Boolean>()); | ... | ... |
| 1 | +package org.onlab.onos.net.host.impl; | ||
| 2 | + | ||
| 3 | +import static org.easymock.EasyMock.createMock; | ||
| 4 | +import static org.easymock.EasyMock.expect; | ||
| 5 | +import static org.easymock.EasyMock.expectLastCall; | ||
| 6 | +import static org.easymock.EasyMock.replay; | ||
| 7 | +import static org.easymock.EasyMock.verify; | ||
| 8 | +import static org.junit.Assert.assertTrue; | ||
| 9 | + | ||
| 10 | +import java.util.ArrayList; | ||
| 11 | +import java.util.Arrays; | ||
| 12 | +import java.util.Collections; | ||
| 13 | +import java.util.List; | ||
| 14 | +import java.util.Set; | ||
| 15 | + | ||
| 16 | +import org.junit.Test; | ||
| 17 | +import org.onlab.onos.net.ConnectPoint; | ||
| 18 | +import org.onlab.onos.net.Device; | ||
| 19 | +import org.onlab.onos.net.DeviceId; | ||
| 20 | +import org.onlab.onos.net.Host; | ||
| 21 | +import org.onlab.onos.net.MastershipRole; | ||
| 22 | +import org.onlab.onos.net.Port; | ||
| 23 | +import org.onlab.onos.net.PortNumber; | ||
| 24 | +import org.onlab.onos.net.device.DeviceListener; | ||
| 25 | +import org.onlab.onos.net.device.DeviceService; | ||
| 26 | +import org.onlab.onos.net.flow.instructions.Instruction; | ||
| 27 | +import org.onlab.onos.net.flow.instructions.Instructions.OutputInstruction; | ||
| 28 | +import org.onlab.onos.net.host.HostProvider; | ||
| 29 | +import org.onlab.onos.net.host.PortAddresses; | ||
| 30 | +import org.onlab.onos.net.packet.OutboundPacket; | ||
| 31 | +import org.onlab.onos.net.packet.PacketProcessor; | ||
| 32 | +import org.onlab.onos.net.packet.PacketService; | ||
| 33 | +import org.onlab.onos.net.provider.ProviderId; | ||
| 34 | +import org.onlab.packet.ARP; | ||
| 35 | +import org.onlab.packet.Ethernet; | ||
| 36 | +import org.onlab.packet.IpAddress; | ||
| 37 | +import org.onlab.packet.IpPrefix; | ||
| 38 | +import org.onlab.packet.MacAddress; | ||
| 39 | + | ||
| 40 | +import com.google.common.collect.HashMultimap; | ||
| 41 | +import com.google.common.collect.Lists; | ||
| 42 | +import com.google.common.collect.Multimap; | ||
| 43 | + | ||
| 44 | +public class HostMonitorTest { | ||
| 45 | + | ||
| 46 | + private IpAddress targetIpAddress = IpAddress.valueOf("10.0.0.1"); | ||
| 47 | + private IpPrefix targetIpPrefix = IpPrefix.valueOf(targetIpAddress.toOctets()); | ||
| 48 | + | ||
| 49 | + private IpPrefix sourcePrefix = IpPrefix.valueOf("10.0.0.99/24"); | ||
| 50 | + private MacAddress sourceMac = MacAddress.valueOf(1L); | ||
| 51 | + | ||
| 52 | + private HostMonitor hostMonitor; | ||
| 53 | + | ||
| 54 | + @Test | ||
| 55 | + public void testMonitorHostExists() throws Exception { | ||
| 56 | + ProviderId id = new ProviderId("fake://", "id"); | ||
| 57 | + | ||
| 58 | + Host host = createMock(Host.class); | ||
| 59 | + expect(host.providerId()).andReturn(id); | ||
| 60 | + replay(host); | ||
| 61 | + | ||
| 62 | + HostManager hostManager = createMock(HostManager.class); | ||
| 63 | + expect(hostManager.getHostsByIp(targetIpPrefix)) | ||
| 64 | + .andReturn(Collections.singleton(host)); | ||
| 65 | + replay(hostManager); | ||
| 66 | + | ||
| 67 | + HostProvider hostProvider = createMock(HostProvider.class); | ||
| 68 | + expect(hostProvider.id()).andReturn(id).anyTimes(); | ||
| 69 | + hostProvider.triggerProbe(host); | ||
| 70 | + expectLastCall().once(); | ||
| 71 | + replay(hostProvider); | ||
| 72 | + | ||
| 73 | + hostMonitor = new HostMonitor(null, null, hostManager); | ||
| 74 | + | ||
| 75 | + hostMonitor.registerHostProvider(hostProvider); | ||
| 76 | + hostMonitor.addMonitoringFor(targetIpAddress); | ||
| 77 | + | ||
| 78 | + hostMonitor.run(null); | ||
| 79 | + | ||
| 80 | + verify(hostProvider); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @Test | ||
| 84 | + public void testMonitorHostDoesNotExist() throws Exception { | ||
| 85 | + HostManager hostManager = createMock(HostManager.class); | ||
| 86 | + | ||
| 87 | + DeviceId devId = DeviceId.deviceId("fake"); | ||
| 88 | + | ||
| 89 | + Device device = createMock(Device.class); | ||
| 90 | + expect(device.id()).andReturn(devId).anyTimes(); | ||
| 91 | + replay(device); | ||
| 92 | + | ||
| 93 | + PortNumber portNum = PortNumber.portNumber(1L); | ||
| 94 | + | ||
| 95 | + Port port = createMock(Port.class); | ||
| 96 | + expect(port.number()).andReturn(portNum).anyTimes(); | ||
| 97 | + replay(port); | ||
| 98 | + | ||
| 99 | + TestDeviceService deviceService = new TestDeviceService(); | ||
| 100 | + deviceService.addDevice(device, Collections.singleton(port)); | ||
| 101 | + | ||
| 102 | + ConnectPoint cp = new ConnectPoint(devId, portNum); | ||
| 103 | + PortAddresses pa = new PortAddresses(cp, Collections.singleton(sourcePrefix), | ||
| 104 | + sourceMac); | ||
| 105 | + | ||
| 106 | + expect(hostManager.getHostsByIp(targetIpPrefix)) | ||
| 107 | + .andReturn(Collections.<Host>emptySet()).anyTimes(); | ||
| 108 | + expect(hostManager.getAddressBindingsForPort(cp)) | ||
| 109 | + .andReturn(pa).anyTimes(); | ||
| 110 | + replay(hostManager); | ||
| 111 | + | ||
| 112 | + TestPacketService packetService = new TestPacketService(); | ||
| 113 | + | ||
| 114 | + | ||
| 115 | + // Run the test | ||
| 116 | + hostMonitor = new HostMonitor(deviceService, packetService, hostManager); | ||
| 117 | + | ||
| 118 | + hostMonitor.addMonitoringFor(targetIpAddress); | ||
| 119 | + hostMonitor.run(null); | ||
| 120 | + | ||
| 121 | + | ||
| 122 | + // Check that a packet was sent to our PacketService and that it has | ||
| 123 | + // the properties we expect | ||
| 124 | + assertTrue(packetService.packets.size() == 1); | ||
| 125 | + OutboundPacket packet = packetService.packets.get(0); | ||
| 126 | + | ||
| 127 | + // Check the output port is correct | ||
| 128 | + assertTrue(packet.treatment().instructions().size() == 1); | ||
| 129 | + Instruction instruction = packet.treatment().instructions().get(0); | ||
| 130 | + assertTrue(instruction instanceof OutputInstruction); | ||
| 131 | + OutputInstruction oi = (OutputInstruction) instruction; | ||
| 132 | + assertTrue(oi.port().equals(portNum)); | ||
| 133 | + | ||
| 134 | + // Check the output packet is correct (well the important bits anyway) | ||
| 135 | + Ethernet eth = new Ethernet(); | ||
| 136 | + eth.deserialize(packet.data().array(), 0, packet.data().array().length); | ||
| 137 | + ARP arp = (ARP) eth.getPayload(); | ||
| 138 | + assertTrue(Arrays.equals(arp.getSenderProtocolAddress(), sourcePrefix.toOctets())); | ||
| 139 | + assertTrue(Arrays.equals(arp.getSenderHardwareAddress(), sourceMac.toBytes())); | ||
| 140 | + assertTrue(Arrays.equals(arp.getTargetProtocolAddress(), targetIpPrefix.toOctets())); | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + class TestPacketService implements PacketService { | ||
| 144 | + | ||
| 145 | + List<OutboundPacket> packets = new ArrayList<>(); | ||
| 146 | + | ||
| 147 | + @Override | ||
| 148 | + public void addProcessor(PacketProcessor processor, int priority) { | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + @Override | ||
| 152 | + public void removeProcessor(PacketProcessor processor) { | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + @Override | ||
| 156 | + public void emit(OutboundPacket packet) { | ||
| 157 | + packets.add(packet); | ||
| 158 | + } | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + class TestDeviceService implements DeviceService { | ||
| 162 | + | ||
| 163 | + List<Device> devices = Lists.newArrayList(); | ||
| 164 | + Multimap<DeviceId, Port> devicePorts = HashMultimap.create(); | ||
| 165 | + | ||
| 166 | + void addDevice(Device device, Set<Port> ports) { | ||
| 167 | + devices.add(device); | ||
| 168 | + for (Port p : ports) { | ||
| 169 | + devicePorts.put(device.id(), p); | ||
| 170 | + } | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + @Override | ||
| 174 | + public int getDeviceCount() { | ||
| 175 | + return 0; | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + @Override | ||
| 179 | + public Iterable<Device> getDevices() { | ||
| 180 | + return devices; | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + @Override | ||
| 184 | + public Device getDevice(DeviceId deviceId) { | ||
| 185 | + return null; | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + @Override | ||
| 189 | + public MastershipRole getRole(DeviceId deviceId) { | ||
| 190 | + return null; | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + @Override | ||
| 194 | + public List<Port> getPorts(DeviceId deviceId) { | ||
| 195 | + List<Port> ports = Lists.newArrayList(); | ||
| 196 | + for (Port p : devicePorts.get(deviceId)) { | ||
| 197 | + ports.add(p); | ||
| 198 | + } | ||
| 199 | + return ports; | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + @Override | ||
| 203 | + public Port getPort(DeviceId deviceId, PortNumber portNumber) { | ||
| 204 | + return null; | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + @Override | ||
| 208 | + public boolean isAvailable(DeviceId deviceId) { | ||
| 209 | + return false; | ||
| 210 | + } | ||
| 211 | + | ||
| 212 | + @Override | ||
| 213 | + public void addListener(DeviceListener listener) { | ||
| 214 | + } | ||
| 215 | + | ||
| 216 | + @Override | ||
| 217 | + public void removeListener(DeviceListener listener) { | ||
| 218 | + } | ||
| 219 | + } | ||
| 220 | +} |
| ... | @@ -3,6 +3,8 @@ package org.onlab.onos.store.cluster.messaging; | ... | @@ -3,6 +3,8 @@ package org.onlab.onos.store.cluster.messaging; |
| 3 | import org.onlab.onos.cluster.ControllerNode; | 3 | import org.onlab.onos.cluster.ControllerNode; |
| 4 | import org.onlab.onos.store.cluster.impl.ClusterNodesDelegate; | 4 | import org.onlab.onos.store.cluster.impl.ClusterNodesDelegate; |
| 5 | 5 | ||
| 6 | +// TODO: This service interface can be removed, once we properly start | ||
| 7 | +// using ClusterService | ||
| 6 | /** | 8 | /** |
| 7 | * Service for administering communications manager. | 9 | * Service for administering communications manager. |
| 8 | */ | 10 | */ | ... | ... |
| ... | @@ -2,6 +2,8 @@ package org.onlab.onos.store.cluster.messaging; | ... | @@ -2,6 +2,8 @@ package org.onlab.onos.store.cluster.messaging; |
| 2 | 2 | ||
| 3 | import org.onlab.onos.cluster.NodeId; | 3 | import org.onlab.onos.cluster.NodeId; |
| 4 | 4 | ||
| 5 | +// TODO: ClusterMessage should be aware about how to serialize the payload | ||
| 6 | +// TODO: Should payload type be made generic? | ||
| 5 | /** | 7 | /** |
| 6 | * Base message for cluster-wide communications. | 8 | * Base message for cluster-wide communications. |
| 7 | */ | 9 | */ | ... | ... |
| ... | @@ -10,4 +10,4 @@ public interface ClusterMessageHandler { | ... | @@ -10,4 +10,4 @@ public interface ClusterMessageHandler { |
| 10 | * @param message cluster message. | 10 | * @param message cluster message. |
| 11 | */ | 11 | */ |
| 12 | public void handle(ClusterMessage message); | 12 | public void handle(ClusterMessage message); |
| 13 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 13 | +} | ... | ... |
| 1 | package org.onlab.onos.store.cluster.messaging; | 1 | package org.onlab.onos.store.cluster.messaging; |
| 2 | 2 | ||
| 3 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 4 | + | ||
| 5 | +import java.util.Objects; | ||
| 6 | + | ||
| 3 | /** | 7 | /** |
| 4 | * Representation of a message subject. | 8 | * Representation of a message subject. |
| 5 | * Cluster messages have associated subjects that dictate how they get handled | 9 | * Cluster messages have associated subjects that dictate how they get handled |
| ... | @@ -10,7 +14,7 @@ public class MessageSubject { | ... | @@ -10,7 +14,7 @@ public class MessageSubject { |
| 10 | private final String value; | 14 | private final String value; |
| 11 | 15 | ||
| 12 | public MessageSubject(String value) { | 16 | public MessageSubject(String value) { |
| 13 | - this.value = value; | 17 | + this.value = checkNotNull(value); |
| 14 | } | 18 | } |
| 15 | 19 | ||
| 16 | public String value() { | 20 | public String value() { |
| ... | @@ -21,4 +25,24 @@ public class MessageSubject { | ... | @@ -21,4 +25,24 @@ public class MessageSubject { |
| 21 | public String toString() { | 25 | public String toString() { |
| 22 | return value; | 26 | return value; |
| 23 | } | 27 | } |
| 28 | + | ||
| 29 | + @Override | ||
| 30 | + public int hashCode() { | ||
| 31 | + return value.hashCode(); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + public boolean equals(Object obj) { | ||
| 36 | + if (this == obj) { | ||
| 37 | + return true; | ||
| 38 | + } | ||
| 39 | + if (obj == null) { | ||
| 40 | + return false; | ||
| 41 | + } | ||
| 42 | + if (getClass() != obj.getClass()) { | ||
| 43 | + return false; | ||
| 44 | + } | ||
| 45 | + MessageSubject that = (MessageSubject) obj; | ||
| 46 | + return Objects.equals(this.value, that.value); | ||
| 47 | + } | ||
| 24 | } | 48 | } | ... | ... |
| ... | @@ -39,6 +39,7 @@ public class ClusterCommunicationManager | ... | @@ -39,6 +39,7 @@ public class ClusterCommunicationManager |
| 39 | 39 | ||
| 40 | private ControllerNode localNode; | 40 | private ControllerNode localNode; |
| 41 | private ClusterNodesDelegate nodesDelegate; | 41 | private ClusterNodesDelegate nodesDelegate; |
| 42 | + // FIXME: `members` should go away and should be using ClusterService | ||
| 42 | private Map<NodeId, ControllerNode> members = new HashMap<>(); | 43 | private Map<NodeId, ControllerNode> members = new HashMap<>(); |
| 43 | private final Timer timer = new Timer("onos-controller-heatbeats"); | 44 | private final Timer timer = new Timer("onos-controller-heatbeats"); |
| 44 | public static final long HEART_BEAT_INTERVAL_MILLIS = 1000L; | 45 | public static final long HEART_BEAT_INTERVAL_MILLIS = 1000L; | ... | ... |
| ... | @@ -3,6 +3,8 @@ package org.onlab.onos.store.cluster.messaging.impl; | ... | @@ -3,6 +3,8 @@ package org.onlab.onos.store.cluster.messaging.impl; |
| 3 | import org.onlab.onos.store.cluster.messaging.MessageSubject; | 3 | import org.onlab.onos.store.cluster.messaging.MessageSubject; |
| 4 | 4 | ||
| 5 | public final class ClusterMessageSubjects { | 5 | public final class ClusterMessageSubjects { |
| 6 | + // avoid instantiation | ||
| 6 | private ClusterMessageSubjects() {} | 7 | private ClusterMessageSubjects() {} |
| 8 | + | ||
| 7 | public static final MessageSubject CLUSTER_MEMBERSHIP_EVENT = new MessageSubject("CLUSTER_MEMBERSHIP_EVENT"); | 9 | public static final MessageSubject CLUSTER_MEMBERSHIP_EVENT = new MessageSubject("CLUSTER_MEMBERSHIP_EVENT"); |
| 8 | } | 10 | } | ... | ... |
| ... | @@ -6,6 +6,8 @@ import java.util.Objects; | ... | @@ -6,6 +6,8 @@ import java.util.Objects; |
| 6 | 6 | ||
| 7 | import org.onlab.onos.store.Timestamp; | 7 | import org.onlab.onos.store.Timestamp; |
| 8 | 8 | ||
| 9 | +import com.google.common.base.MoreObjects; | ||
| 10 | + | ||
| 9 | /** | 11 | /** |
| 10 | * Wrapper class to store Timestamped value. | 12 | * Wrapper class to store Timestamped value. |
| 11 | * @param <T> | 13 | * @param <T> |
| ... | @@ -70,6 +72,14 @@ public final class Timestamped<T> { | ... | @@ -70,6 +72,14 @@ public final class Timestamped<T> { |
| 70 | return Objects.equals(this.timestamp, that.timestamp); | 72 | return Objects.equals(this.timestamp, that.timestamp); |
| 71 | } | 73 | } |
| 72 | 74 | ||
| 75 | + @Override | ||
| 76 | + public String toString() { | ||
| 77 | + return MoreObjects.toStringHelper(getClass()) | ||
| 78 | + .add("timestamp", timestamp) | ||
| 79 | + .add("value", value) | ||
| 80 | + .toString(); | ||
| 81 | + } | ||
| 82 | + | ||
| 73 | // Default constructor for serialization | 83 | // Default constructor for serialization |
| 74 | @Deprecated | 84 | @Deprecated |
| 75 | protected Timestamped() { | 85 | protected Timestamped() { | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
| ... | @@ -122,6 +122,12 @@ | ... | @@ -122,6 +122,12 @@ |
| 122 | <version>1.9.13</version> | 122 | <version>1.9.13</version> |
| 123 | </dependency> | 123 | </dependency> |
| 124 | 124 | ||
| 125 | + <dependency> | ||
| 126 | + <groupId>org.easymock</groupId> | ||
| 127 | + <artifactId>easymock</artifactId> | ||
| 128 | + <version>3.2</version> | ||
| 129 | + <scope>test</scope> | ||
| 130 | + </dependency> | ||
| 125 | 131 | ||
| 126 | <!-- Web related --> | 132 | <!-- Web related --> |
| 127 | <dependency> | 133 | <dependency> | ... | ... |
| ... | @@ -72,24 +72,23 @@ public final class MetricsManager implements MetricsService { | ... | @@ -72,24 +72,23 @@ public final class MetricsManager implements MetricsService { |
| 72 | private final CsvReporter reporter; | 72 | private final CsvReporter reporter; |
| 73 | 73 | ||
| 74 | public MetricsManager() { | 74 | public MetricsManager() { |
| 75 | - this.componentsRegistry = new ConcurrentHashMap<>(); | ||
| 76 | this.metricsRegistry = new MetricRegistry(); | 75 | this.metricsRegistry = new MetricRegistry(); |
| 77 | - | ||
| 78 | this.reporter = CsvReporter.forRegistry(metricsRegistry) | 76 | this.reporter = CsvReporter.forRegistry(metricsRegistry) |
| 79 | .formatFor(Locale.US) | 77 | .formatFor(Locale.US) |
| 80 | .convertRatesTo(TimeUnit.SECONDS) | 78 | .convertRatesTo(TimeUnit.SECONDS) |
| 81 | .convertDurationsTo(TimeUnit.MICROSECONDS) | 79 | .convertDurationsTo(TimeUnit.MICROSECONDS) |
| 82 | - .build(new File("/tmp/")); | 80 | + .build(new File("/var/onos/log/metrics/")); |
| 83 | - | ||
| 84 | - reporter.start(10, TimeUnit.SECONDS); | ||
| 85 | } | 81 | } |
| 86 | 82 | ||
| 87 | @Activate | 83 | @Activate |
| 88 | public void activate() { | 84 | public void activate() { |
| 85 | + this.componentsRegistry = new ConcurrentHashMap<>(); | ||
| 86 | + reporter.start(10, TimeUnit.SECONDS); | ||
| 89 | } | 87 | } |
| 90 | 88 | ||
| 91 | @Deactivate | 89 | @Deactivate |
| 92 | public void deactivate() { | 90 | public void deactivate() { |
| 91 | + reporter.stop(); | ||
| 93 | } | 92 | } |
| 94 | 93 | ||
| 95 | /** | 94 | /** | ... | ... |
| ... | @@ -53,4 +53,4 @@ public class KryoSerializer implements Serializer { | ... | @@ -53,4 +53,4 @@ public class KryoSerializer implements Serializer { |
| 53 | public void serialize(Object obj, ByteBuffer buffer) { | 53 | public void serialize(Object obj, ByteBuffer buffer) { |
| 54 | serializerPool.serialize(obj, buffer); | 54 | serializerPool.serialize(obj, buffer); |
| 55 | } | 55 | } |
| 56 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 56 | +} | ... | ... |
-
Please register or login to post a comment