Committed by
Gerrit Code Review
Replaced GossipHostStore with a implementation built on top of EventuallyConsistentMap
Change-Id: I6b580727e5f4bb03e606c87a6748e6fbb90223e7
Showing
15 changed files
with
265 additions
and
586 deletions
| 1 | -/* | ||
| 2 | - * Copyright 2014 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.net.host; | ||
| 17 | - | ||
| 18 | -import org.onosproject.net.HostId; | ||
| 19 | -import org.onosproject.store.Timestamp; | ||
| 20 | - | ||
| 21 | -/** | ||
| 22 | - * Interface for a logical clock service that issues per host timestamps. | ||
| 23 | - */ | ||
| 24 | -public interface HostClockService { | ||
| 25 | - | ||
| 26 | - /** | ||
| 27 | - * Returns a new timestamp for the specified host. | ||
| 28 | - * @param hostId identifier for the host. | ||
| 29 | - * @return timestamp. | ||
| 30 | - */ | ||
| 31 | - Timestamp getTimestamp(HostId hostId); | ||
| 32 | -} |
| ... | @@ -27,7 +27,6 @@ import org.onosproject.net.flowobjective.FlowObjectiveService; | ... | @@ -27,7 +27,6 @@ import org.onosproject.net.flowobjective.FlowObjectiveService; |
| 27 | import org.onosproject.net.group.GroupService; | 27 | import org.onosproject.net.group.GroupService; |
| 28 | import org.onosproject.net.host.HostAdminService; | 28 | import org.onosproject.net.host.HostAdminService; |
| 29 | import org.onosproject.net.host.HostService; | 29 | import org.onosproject.net.host.HostService; |
| 30 | -import org.onosproject.net.host.HostClockService; | ||
| 31 | import org.onosproject.net.intent.IntentService; | 30 | import org.onosproject.net.intent.IntentService; |
| 32 | import org.onosproject.net.intent.IntentExtensionService; | 31 | import org.onosproject.net.intent.IntentExtensionService; |
| 33 | import org.onosproject.net.intent.IntentClockService; | 32 | import org.onosproject.net.intent.IntentClockService; |
| ... | @@ -136,8 +135,6 @@ public final class PolicyBuilder { | ... | @@ -136,8 +135,6 @@ public final class PolicyBuilder { |
| 136 | new PermissionInfo(ServicePermission.class.getName(), | 135 | new PermissionInfo(ServicePermission.class.getName(), |
| 137 | HostService.class.getName(), ServicePermission.GET), | 136 | HostService.class.getName(), ServicePermission.GET), |
| 138 | new PermissionInfo(ServicePermission.class.getName(), | 137 | new PermissionInfo(ServicePermission.class.getName(), |
| 139 | - HostClockService.class.getName(), ServicePermission.GET), | ||
| 140 | - new PermissionInfo(ServicePermission.class.getName(), | ||
| 141 | IntentService.class.getName(), ServicePermission.GET), | 138 | IntentService.class.getName(), ServicePermission.GET), |
| 142 | new PermissionInfo(ServicePermission.class.getName(), | 139 | new PermissionInfo(ServicePermission.class.getName(), |
| 143 | IntentClockService.class.getName(), ServicePermission.GET), | 140 | IntentClockService.class.getName(), ServicePermission.GET), |
| ... | @@ -209,8 +206,6 @@ public final class PolicyBuilder { | ... | @@ -209,8 +206,6 @@ public final class PolicyBuilder { |
| 209 | GroupService.class.getName())); | 206 | GroupService.class.getName())); |
| 210 | serviceDirectory.put(Permission.GROUP_EVENT, ImmutableSet.of( | 207 | serviceDirectory.put(Permission.GROUP_EVENT, ImmutableSet.of( |
| 211 | GroupService.class.getName())); | 208 | GroupService.class.getName())); |
| 212 | - serviceDirectory.put(Permission.HOST_READ, ImmutableSet.of( | ||
| 213 | - HostService.class.getName(), HostClockService.class.getName())); | ||
| 214 | serviceDirectory.put(Permission.HOST_WRITE, ImmutableSet.of( | 209 | serviceDirectory.put(Permission.HOST_WRITE, ImmutableSet.of( |
| 215 | HostService.class.getName())); | 210 | HostService.class.getName())); |
| 216 | serviceDirectory.put(Permission.HOST_EVENT, ImmutableSet.of( | 211 | serviceDirectory.put(Permission.HOST_EVENT, ImmutableSet.of( | ... | ... |
| 1 | +package org.onosproject.store.host.impl; | ||
| 2 | + | ||
| 3 | +import static org.onosproject.net.DefaultAnnotations.merge; | ||
| 4 | +import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED; | ||
| 5 | +import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED; | ||
| 6 | +import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.PUT; | ||
| 7 | +import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.REMOVE; | ||
| 8 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 9 | + | ||
| 10 | +import java.util.Collection; | ||
| 11 | +import java.util.Collections; | ||
| 12 | +import java.util.Objects; | ||
| 13 | +import java.util.Set; | ||
| 14 | +import java.util.concurrent.ConcurrentHashMap; | ||
| 15 | +import java.util.function.Predicate; | ||
| 16 | +import java.util.stream.Collectors; | ||
| 17 | + | ||
| 18 | +import org.apache.felix.scr.annotations.Activate; | ||
| 19 | +import org.apache.felix.scr.annotations.Component; | ||
| 20 | +import org.apache.felix.scr.annotations.Deactivate; | ||
| 21 | +import org.apache.felix.scr.annotations.Reference; | ||
| 22 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
| 23 | +import org.apache.felix.scr.annotations.Service; | ||
| 24 | +import org.onlab.packet.IpAddress; | ||
| 25 | +import org.onlab.packet.MacAddress; | ||
| 26 | +import org.onlab.packet.VlanId; | ||
| 27 | +import org.onlab.util.KryoNamespace; | ||
| 28 | +import org.onosproject.net.Annotations; | ||
| 29 | +import org.onosproject.net.ConnectPoint; | ||
| 30 | +import org.onosproject.net.DefaultAnnotations; | ||
| 31 | +import org.onosproject.net.DefaultHost; | ||
| 32 | +import org.onosproject.net.DeviceId; | ||
| 33 | +import org.onosproject.net.Host; | ||
| 34 | +import org.onosproject.net.HostId; | ||
| 35 | +import org.onosproject.net.host.HostDescription; | ||
| 36 | +import org.onosproject.net.host.HostEvent; | ||
| 37 | +import org.onosproject.net.host.HostStore; | ||
| 38 | +import org.onosproject.net.host.HostStoreDelegate; | ||
| 39 | +import org.onosproject.net.host.PortAddresses; | ||
| 40 | +import org.onosproject.net.host.HostEvent.Type; | ||
| 41 | +import org.onosproject.net.provider.ProviderId; | ||
| 42 | +import org.onosproject.store.AbstractStore; | ||
| 43 | +import org.onosproject.store.serializers.KryoNamespaces; | ||
| 44 | +import org.onosproject.store.service.EventuallyConsistentMap; | ||
| 45 | +import org.onosproject.store.service.EventuallyConsistentMapEvent; | ||
| 46 | +import org.onosproject.store.service.EventuallyConsistentMapListener; | ||
| 47 | +import org.onosproject.store.service.LogicalClockService; | ||
| 48 | +import org.onosproject.store.service.StorageService; | ||
| 49 | +import org.slf4j.Logger; | ||
| 50 | + | ||
| 51 | +import com.google.common.collect.HashMultimap; | ||
| 52 | +import com.google.common.collect.ImmutableSet; | ||
| 53 | +import com.google.common.collect.Multimap; | ||
| 54 | +import com.google.common.collect.Multimaps; | ||
| 55 | +import com.google.common.collect.SetMultimap; | ||
| 56 | +import com.google.common.collect.Sets; | ||
| 57 | +import static com.google.common.collect.Multimaps.newSetMultimap; | ||
| 58 | +import static com.google.common.collect.Multimaps.synchronizedSetMultimap; | ||
| 59 | +import static com.google.common.collect.Sets.newConcurrentHashSet; | ||
| 60 | + | ||
| 61 | +/** | ||
| 62 | + * Manages the inventory of hosts using a {@code EventuallyConsistentMap}. | ||
| 63 | + */ | ||
| 64 | +@Component(immediate = true) | ||
| 65 | +@Service | ||
| 66 | +public class ECHostStore | ||
| 67 | + extends AbstractStore<HostEvent, HostStoreDelegate> | ||
| 68 | + implements HostStore { | ||
| 69 | + | ||
| 70 | + private final Logger log = getLogger(getClass()); | ||
| 71 | + | ||
| 72 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 73 | + protected StorageService storageService; | ||
| 74 | + | ||
| 75 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 76 | + protected LogicalClockService clockService; | ||
| 77 | + | ||
| 78 | + // Hosts tracked by their location | ||
| 79 | + private final Multimap<ConnectPoint, Host> locations | ||
| 80 | + = synchronizedSetMultimap(newSetMultimap(new ConcurrentHashMap<>(), | ||
| 81 | + () -> newConcurrentHashSet())); | ||
| 82 | + private final SetMultimap<ConnectPoint, PortAddresses> portAddresses = | ||
| 83 | + Multimaps.synchronizedSetMultimap( | ||
| 84 | + HashMultimap.<ConnectPoint, PortAddresses>create()); | ||
| 85 | + | ||
| 86 | + private EventuallyConsistentMap<HostId, DefaultHost> hosts; | ||
| 87 | + | ||
| 88 | + private EventuallyConsistentMapListener<HostId, DefaultHost> hostLocationTracker = | ||
| 89 | + new HostLocationTracker(); | ||
| 90 | + | ||
| 91 | + @Activate | ||
| 92 | + public void activate() { | ||
| 93 | + KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder() | ||
| 94 | + .register(KryoNamespaces.API); | ||
| 95 | + | ||
| 96 | + hosts = storageService.<HostId, DefaultHost>eventuallyConsistentMapBuilder() | ||
| 97 | + .withName("onos-hosts") | ||
| 98 | + .withSerializer(hostSerializer) | ||
| 99 | + .withTimestampProvider((k, v) -> clockService.getTimestamp()) | ||
| 100 | + .build(); | ||
| 101 | + | ||
| 102 | + hosts.addListener(hostLocationTracker); | ||
| 103 | + | ||
| 104 | + log.info("Started"); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + @Deactivate | ||
| 108 | + public void deactivate() { | ||
| 109 | + hosts.removeListener(hostLocationTracker); | ||
| 110 | + hosts.destroy(); | ||
| 111 | + locations.clear(); | ||
| 112 | + portAddresses.clear(); | ||
| 113 | + | ||
| 114 | + log.info("Stopped"); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + @Override | ||
| 118 | + public HostEvent createOrUpdateHost(ProviderId providerId, | ||
| 119 | + HostId hostId, | ||
| 120 | + HostDescription hostDescription) { | ||
| 121 | + DefaultHost currentHost = hosts.get(hostId); | ||
| 122 | + if (currentHost == null) { | ||
| 123 | + DefaultHost newhost = new DefaultHost( | ||
| 124 | + providerId, | ||
| 125 | + hostId, | ||
| 126 | + hostDescription.hwAddress(), | ||
| 127 | + hostDescription.vlan(), | ||
| 128 | + hostDescription.location(), | ||
| 129 | + ImmutableSet.copyOf(hostDescription.ipAddress())); | ||
| 130 | + hosts.put(hostId, newhost); | ||
| 131 | + return new HostEvent(HOST_ADDED, newhost); | ||
| 132 | + } | ||
| 133 | + return updateHost(providerId, hostId, hostDescription, currentHost); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + @Override | ||
| 137 | + public HostEvent removeHost(HostId hostId) { | ||
| 138 | + Host host = hosts.remove(hostId); | ||
| 139 | + return host != null ? new HostEvent(HOST_REMOVED, host) : null; | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + @Override | ||
| 143 | + public int getHostCount() { | ||
| 144 | + return hosts.size(); | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + @Override | ||
| 148 | + public Iterable<Host> getHosts() { | ||
| 149 | + return ImmutableSet.copyOf(hosts.values()); | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + @Override | ||
| 153 | + public Host getHost(HostId hostId) { | ||
| 154 | + return hosts.get(hostId); | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + @Override | ||
| 158 | + public Set<Host> getHosts(VlanId vlanId) { | ||
| 159 | + return filter(hosts.values(), host -> Objects.equals(host.vlan(), vlanId)); | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + @Override | ||
| 163 | + public Set<Host> getHosts(MacAddress mac) { | ||
| 164 | + return filter(hosts.values(), host -> Objects.equals(host.mac(), mac)); | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + @Override | ||
| 168 | + public Set<Host> getHosts(IpAddress ip) { | ||
| 169 | + return filter(hosts.values(), host -> host.ipAddresses().contains(ip)); | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + @Override | ||
| 173 | + public Set<Host> getConnectedHosts(ConnectPoint connectPoint) { | ||
| 174 | + return ImmutableSet.copyOf(locations.get(connectPoint)); | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + @Override | ||
| 178 | + public Set<Host> getConnectedHosts(DeviceId deviceId) { | ||
| 179 | + return locations.entries() | ||
| 180 | + .stream() | ||
| 181 | + .filter(entry -> entry.getKey().deviceId().equals(deviceId)) | ||
| 182 | + .map(entry -> entry.getValue()) | ||
| 183 | + .collect(Collectors.toSet()); | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + @Override | ||
| 187 | + public void updateAddressBindings(PortAddresses addresses) { | ||
| 188 | + portAddresses.put(addresses.connectPoint(), addresses); | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + @Override | ||
| 192 | + public void removeAddressBindings(PortAddresses addresses) { | ||
| 193 | + portAddresses.remove(addresses.connectPoint(), addresses); | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + @Override | ||
| 197 | + public void clearAddressBindings(ConnectPoint connectPoint) { | ||
| 198 | + portAddresses.removeAll(connectPoint); | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + @Override | ||
| 202 | + public Set<PortAddresses> getAddressBindings() { | ||
| 203 | + return ImmutableSet.copyOf(portAddresses.values()); | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + @Override | ||
| 207 | + public Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint) { | ||
| 208 | + synchronized (portAddresses) { | ||
| 209 | + Set<PortAddresses> addresses = portAddresses.get(connectPoint); | ||
| 210 | + return addresses == null ? Collections.emptySet() : ImmutableSet.copyOf(addresses); | ||
| 211 | + } | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + private Set<Host> filter(Collection<DefaultHost> collection, Predicate<DefaultHost> predicate) { | ||
| 215 | + return collection.stream().filter(predicate).collect(Collectors.toSet()); | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + // checks for type of update to host, sends appropriate event | ||
| 219 | + private HostEvent updateHost(ProviderId providerId, | ||
| 220 | + HostId hostId, | ||
| 221 | + HostDescription descr, | ||
| 222 | + DefaultHost currentHost) { | ||
| 223 | + | ||
| 224 | + final boolean hostMoved = !currentHost.location().equals(descr.location()); | ||
| 225 | + if (hostMoved || | ||
| 226 | + !currentHost.ipAddresses().containsAll(descr.ipAddress()) || | ||
| 227 | + !descr.annotations().keys().isEmpty()) { | ||
| 228 | + | ||
| 229 | + Set<IpAddress> addresses = Sets.newHashSet(currentHost.ipAddresses()); | ||
| 230 | + addresses.addAll(descr.ipAddress()); | ||
| 231 | + Annotations annotations = merge((DefaultAnnotations) currentHost.annotations(), | ||
| 232 | + descr.annotations()); | ||
| 233 | + | ||
| 234 | + DefaultHost updatedHost = new DefaultHost(providerId, currentHost.id(), | ||
| 235 | + currentHost.mac(), currentHost.vlan(), | ||
| 236 | + descr.location(), | ||
| 237 | + addresses, | ||
| 238 | + annotations); | ||
| 239 | + | ||
| 240 | + // TODO: We need a way to detect conflicting changes and abort update. | ||
| 241 | + hosts.put(hostId, updatedHost); | ||
| 242 | + locations.remove(currentHost.location(), currentHost); | ||
| 243 | + locations.put(updatedHost.location(), updatedHost); | ||
| 244 | + | ||
| 245 | + HostEvent.Type eventType = hostMoved ? Type.HOST_MOVED : Type.HOST_UPDATED; | ||
| 246 | + return new HostEvent(eventType, updatedHost); | ||
| 247 | + } | ||
| 248 | + return null; | ||
| 249 | + } | ||
| 250 | + | ||
| 251 | + private class HostLocationTracker implements EventuallyConsistentMapListener<HostId, DefaultHost> { | ||
| 252 | + | ||
| 253 | + @Override | ||
| 254 | + public void event(EventuallyConsistentMapEvent<HostId, DefaultHost> event) { | ||
| 255 | + DefaultHost host = event.value(); | ||
| 256 | + if (event.type() == PUT) { | ||
| 257 | + locations.put(host.location(), host); | ||
| 258 | + } else if (event.type() == REMOVE) { | ||
| 259 | + locations.remove(host.location(), host); | ||
| 260 | + } | ||
| 261 | + } | ||
| 262 | + } | ||
| 263 | +} |
core/store/dist/src/main/java/org/onosproject/store/host/impl/GossipHostStore.java
deleted
100644 → 0
This diff is collapsed. Click to expand it.
| 1 | -/* | ||
| 2 | - * Copyright 2014-2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.store.host.impl; | ||
| 17 | - | ||
| 18 | -import org.onosproject.store.cluster.messaging.MessageSubject; | ||
| 19 | - | ||
| 20 | -public final class GossipHostStoreMessageSubjects { | ||
| 21 | - private GossipHostStoreMessageSubjects() {} | ||
| 22 | - | ||
| 23 | - public static final MessageSubject HOST_UPDATED_MSG | ||
| 24 | - = new MessageSubject("peer-host-updated"); | ||
| 25 | - public static final MessageSubject HOST_REMOVED_MSG | ||
| 26 | - = new MessageSubject("peer-host-removed"); | ||
| 27 | - public static final MessageSubject HOST_ANTI_ENTROPY_ADVERTISEMENT | ||
| 28 | - = new MessageSubject("host-enti-entropy-advertisement");; | ||
| 29 | -} |
| 1 | -/* | ||
| 2 | - * Copyright 2014 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.store.host.impl; | ||
| 17 | - | ||
| 18 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
| 19 | - | ||
| 20 | -import java.util.Map; | ||
| 21 | - | ||
| 22 | -import org.onosproject.cluster.NodeId; | ||
| 23 | -import org.onosproject.net.HostId; | ||
| 24 | -import org.onosproject.store.Timestamp; | ||
| 25 | - | ||
| 26 | -/** | ||
| 27 | - * Host AE Advertisement message. | ||
| 28 | - */ | ||
| 29 | -public final class HostAntiEntropyAdvertisement { | ||
| 30 | - | ||
| 31 | - private final NodeId sender; | ||
| 32 | - private final Map<HostFragmentId, Timestamp> timestamps; | ||
| 33 | - private final Map<HostId, Timestamp> tombstones; | ||
| 34 | - | ||
| 35 | - | ||
| 36 | - public HostAntiEntropyAdvertisement(NodeId sender, | ||
| 37 | - Map<HostFragmentId, Timestamp> timestamps, | ||
| 38 | - Map<HostId, Timestamp> tombstones) { | ||
| 39 | - this.sender = checkNotNull(sender); | ||
| 40 | - this.timestamps = checkNotNull(timestamps); | ||
| 41 | - this.tombstones = checkNotNull(tombstones); | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - public NodeId sender() { | ||
| 45 | - return sender; | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - public Map<HostFragmentId, Timestamp> timestamps() { | ||
| 49 | - return timestamps; | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - public Map<HostId, Timestamp> tombstones() { | ||
| 53 | - return tombstones; | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - // For serializer | ||
| 57 | - @SuppressWarnings("unused") | ||
| 58 | - private HostAntiEntropyAdvertisement() { | ||
| 59 | - this.sender = null; | ||
| 60 | - this.timestamps = null; | ||
| 61 | - this.tombstones = null; | ||
| 62 | - } | ||
| 63 | -} |
core/store/dist/src/main/java/org/onosproject/store/host/impl/HostClockManager.java
deleted
100644 → 0
| 1 | -/* | ||
| 2 | - * Copyright 2014 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.store.host.impl; | ||
| 17 | - | ||
| 18 | -import static org.slf4j.LoggerFactory.getLogger; | ||
| 19 | - | ||
| 20 | -import org.apache.felix.scr.annotations.Activate; | ||
| 21 | -import org.apache.felix.scr.annotations.Component; | ||
| 22 | -import org.apache.felix.scr.annotations.Deactivate; | ||
| 23 | -import org.apache.felix.scr.annotations.Service; | ||
| 24 | -import org.onosproject.net.HostId; | ||
| 25 | -import org.onosproject.net.host.HostClockService; | ||
| 26 | -import org.onosproject.store.Timestamp; | ||
| 27 | -import org.onosproject.store.service.WallClockTimestamp; | ||
| 28 | -import org.slf4j.Logger; | ||
| 29 | - | ||
| 30 | -/** | ||
| 31 | - * HostClockService to issue Timestamps based on local wallclock time. | ||
| 32 | - */ | ||
| 33 | -@Component(immediate = true) | ||
| 34 | -@Service | ||
| 35 | -public class HostClockManager implements HostClockService { | ||
| 36 | - | ||
| 37 | - private final Logger log = getLogger(getClass()); | ||
| 38 | - | ||
| 39 | - @Activate | ||
| 40 | - public void activate() { | ||
| 41 | - log.info("Started"); | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - @Deactivate | ||
| 45 | - public void deactivate() { | ||
| 46 | - log.info("Stopped"); | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - @Override | ||
| 50 | - public Timestamp getTimestamp(HostId hostId) { | ||
| 51 | - return new WallClockTimestamp(); | ||
| 52 | - } | ||
| 53 | -} |
core/store/dist/src/main/java/org/onosproject/store/host/impl/HostFragmentId.java
deleted
100644 → 0
| 1 | -/* | ||
| 2 | - * Copyright 2014 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.store.host.impl; | ||
| 17 | - | ||
| 18 | -import java.util.Objects; | ||
| 19 | - | ||
| 20 | -import org.onosproject.net.HostId; | ||
| 21 | -import org.onosproject.net.provider.ProviderId; | ||
| 22 | - | ||
| 23 | -import com.google.common.base.MoreObjects; | ||
| 24 | - | ||
| 25 | -/** | ||
| 26 | - * Identifier for HostDescription from a Provider. | ||
| 27 | - */ | ||
| 28 | -public final class HostFragmentId { | ||
| 29 | - public final ProviderId providerId; | ||
| 30 | - public final HostId hostId; | ||
| 31 | - | ||
| 32 | - public HostFragmentId(HostId hostId, ProviderId providerId) { | ||
| 33 | - this.providerId = providerId; | ||
| 34 | - this.hostId = hostId; | ||
| 35 | - } | ||
| 36 | - | ||
| 37 | - public HostId hostId() { | ||
| 38 | - return hostId; | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - public ProviderId providerId() { | ||
| 42 | - return providerId; | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | - @Override | ||
| 46 | - public int hashCode() { | ||
| 47 | - return Objects.hash(providerId, hostId); | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - @Override | ||
| 51 | - public boolean equals(Object obj) { | ||
| 52 | - if (this == obj) { | ||
| 53 | - return true; | ||
| 54 | - } | ||
| 55 | - if (!(obj instanceof HostFragmentId)) { | ||
| 56 | - return false; | ||
| 57 | - } | ||
| 58 | - HostFragmentId that = (HostFragmentId) obj; | ||
| 59 | - return Objects.equals(this.hostId, that.hostId) && | ||
| 60 | - Objects.equals(this.providerId, that.providerId); | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - @Override | ||
| 64 | - public String toString() { | ||
| 65 | - return MoreObjects.toStringHelper(getClass()) | ||
| 66 | - .add("providerId", providerId) | ||
| 67 | - .add("hostId", hostId) | ||
| 68 | - .toString(); | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - // for serializer | ||
| 72 | - @SuppressWarnings("unused") | ||
| 73 | - private HostFragmentId() { | ||
| 74 | - this.providerId = null; | ||
| 75 | - this.hostId = null; | ||
| 76 | - } | ||
| 77 | -} |
core/store/dist/src/main/java/org/onosproject/store/host/impl/InternalHostEvent.java
deleted
100644 → 0
| 1 | -/* | ||
| 2 | - * Copyright 2014 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.store.host.impl; | ||
| 17 | - | ||
| 18 | -import org.onosproject.net.HostId; | ||
| 19 | -import org.onosproject.net.host.HostDescription; | ||
| 20 | -import org.onosproject.net.provider.ProviderId; | ||
| 21 | -import org.onosproject.store.Timestamp; | ||
| 22 | - | ||
| 23 | -/** | ||
| 24 | - * Information published by GossipHostStore to notify peers of a host | ||
| 25 | - * change (create/update) event. | ||
| 26 | - */ | ||
| 27 | -public class InternalHostEvent { | ||
| 28 | - | ||
| 29 | - private final ProviderId providerId; | ||
| 30 | - private final HostId hostId; | ||
| 31 | - private final HostDescription hostDescription; | ||
| 32 | - private final Timestamp timestamp; | ||
| 33 | - | ||
| 34 | - public InternalHostEvent(ProviderId providerId, HostId hostId, | ||
| 35 | - HostDescription hostDescription, Timestamp timestamp) { | ||
| 36 | - this.providerId = providerId; | ||
| 37 | - this.hostId = hostId; | ||
| 38 | - this.hostDescription = hostDescription; | ||
| 39 | - this.timestamp = timestamp; | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - public ProviderId providerId() { | ||
| 43 | - return providerId; | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - public HostId hostId() { | ||
| 47 | - return hostId; | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - public HostDescription hostDescription() { | ||
| 51 | - return hostDescription; | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - public Timestamp timestamp() { | ||
| 55 | - return timestamp; | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | - // Needed for serialization. | ||
| 59 | - @SuppressWarnings("unused") | ||
| 60 | - private InternalHostEvent() { | ||
| 61 | - providerId = null; | ||
| 62 | - hostId = null; | ||
| 63 | - hostDescription = null; | ||
| 64 | - timestamp = null; | ||
| 65 | - } | ||
| 66 | -} |
core/store/dist/src/main/java/org/onosproject/store/host/impl/InternalHostRemovedEvent.java
deleted
100644 → 0
| 1 | -/* | ||
| 2 | - * Copyright 2014 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.store.host.impl; | ||
| 17 | - | ||
| 18 | -import org.onosproject.net.HostId; | ||
| 19 | -import org.onosproject.store.Timestamp; | ||
| 20 | - | ||
| 21 | -/** | ||
| 22 | - * Information published by GossipHostStore to notify peers of a host | ||
| 23 | - * removed event. | ||
| 24 | - */ | ||
| 25 | -public class InternalHostRemovedEvent { | ||
| 26 | - | ||
| 27 | - private final HostId hostId; | ||
| 28 | - private final Timestamp timestamp; | ||
| 29 | - | ||
| 30 | - public InternalHostRemovedEvent(HostId hostId, Timestamp timestamp) { | ||
| 31 | - this.hostId = hostId; | ||
| 32 | - this.timestamp = timestamp; | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - public HostId hostId() { | ||
| 36 | - return hostId; | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | - public Timestamp timestamp() { | ||
| 40 | - return timestamp; | ||
| 41 | - } | ||
| 42 | - | ||
| 43 | - // for serialization. | ||
| 44 | - @SuppressWarnings("unused") | ||
| 45 | - private InternalHostRemovedEvent() { | ||
| 46 | - hostId = null; | ||
| 47 | - timestamp = null; | ||
| 48 | - } | ||
| 49 | -} |
| 1 | -/* | ||
| 2 | - * Copyright 2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.store.intent.impl; | ||
| 17 | - | ||
| 18 | -import org.onosproject.store.cluster.messaging.MessageSubject; | ||
| 19 | - | ||
| 20 | -/** | ||
| 21 | - * Message subjects for internal gossip intent store node-to-node messages. | ||
| 22 | - */ | ||
| 23 | -public final class GossipIntentStoreMessageSubjects { | ||
| 24 | - private GossipIntentStoreMessageSubjects() {} | ||
| 25 | - | ||
| 26 | - public static final MessageSubject INTENT_UPDATED_MSG | ||
| 27 | - = new MessageSubject("peer-intent-updated"); | ||
| 28 | - public static final MessageSubject INTENT_SET_INSTALLABLES_MSG | ||
| 29 | - = new MessageSubject("peer-intent-set-installables"); | ||
| 30 | - public static final MessageSubject INTENT_ANTI_ENTROPY_ADVERTISEMENT | ||
| 31 | - = new MessageSubject("intent-anti-entropy-advertisement"); | ||
| 32 | -} |
core/store/dist/src/main/java/org/onosproject/store/intent/impl/IntentClockManager.java
deleted
100644 → 0
| 1 | -/* | ||
| 2 | - * Copyright 2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.store.intent.impl; | ||
| 17 | - | ||
| 18 | -import org.apache.felix.scr.annotations.Activate; | ||
| 19 | -import org.apache.felix.scr.annotations.Component; | ||
| 20 | -import org.apache.felix.scr.annotations.Deactivate; | ||
| 21 | -import org.apache.felix.scr.annotations.Service; | ||
| 22 | -import org.onosproject.net.intent.IntentClockService; | ||
| 23 | -import org.onosproject.net.intent.IntentId; | ||
| 24 | -import org.onosproject.store.Timestamp; | ||
| 25 | -import org.onosproject.store.service.WallClockTimestamp; | ||
| 26 | -import org.slf4j.Logger; | ||
| 27 | - | ||
| 28 | -import static org.slf4j.LoggerFactory.getLogger; | ||
| 29 | - | ||
| 30 | -/** | ||
| 31 | - * IntentClockService that issues timestamps based on local wallclock time. | ||
| 32 | - */ | ||
| 33 | -@Component(immediate = true) | ||
| 34 | -@Service | ||
| 35 | -public class IntentClockManager implements IntentClockService { | ||
| 36 | - | ||
| 37 | - private final Logger log = getLogger(getClass()); | ||
| 38 | - | ||
| 39 | - @Activate | ||
| 40 | - public void activate() { | ||
| 41 | - log.info("Started"); | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - @Deactivate | ||
| 45 | - public void deactivate() { | ||
| 46 | - log.info("Stopped"); | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - @Override | ||
| 50 | - public Timestamp getTimestamp(IntentId intentId) { | ||
| 51 | - return new WallClockTimestamp(); | ||
| 52 | - } | ||
| 53 | -} |
core/store/dist/src/main/java/org/onosproject/store/intent/impl/InternalIntentEvent.java
deleted
100644 → 0
| 1 | -/* | ||
| 2 | - * Copyright 2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.store.intent.impl; | ||
| 17 | - | ||
| 18 | -import org.onosproject.net.intent.Intent; | ||
| 19 | -import org.onosproject.net.intent.IntentId; | ||
| 20 | -import org.onosproject.net.intent.IntentState; | ||
| 21 | -import org.onosproject.store.Timestamp; | ||
| 22 | - | ||
| 23 | -/** | ||
| 24 | - * Information published by GossipIntentStore to notify peers of an intent | ||
| 25 | - * creation or state update event. | ||
| 26 | - */ | ||
| 27 | -public class InternalIntentEvent { | ||
| 28 | - | ||
| 29 | - private final IntentId intentId; | ||
| 30 | - private final Intent intent; | ||
| 31 | - private final IntentState state; | ||
| 32 | - private final Timestamp timestamp; | ||
| 33 | - | ||
| 34 | - public InternalIntentEvent(IntentId intentId, Intent intent, IntentState state, | ||
| 35 | - Timestamp timestamp) { | ||
| 36 | - this.intentId = intentId; | ||
| 37 | - this.intent = intent; | ||
| 38 | - this.state = state; | ||
| 39 | - this.timestamp = timestamp; | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - public IntentId intentId() { | ||
| 43 | - return intentId; | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - public Intent intent() { | ||
| 47 | - return intent; | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - public IntentState state() { | ||
| 51 | - return state; | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - public Timestamp timestamp() { | ||
| 55 | - return timestamp; | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | - // Needed for serialization. | ||
| 59 | - @SuppressWarnings("unused") | ||
| 60 | - private InternalIntentEvent() { | ||
| 61 | - intentId = null; | ||
| 62 | - intent = null; | ||
| 63 | - state = null; | ||
| 64 | - timestamp = null; | ||
| 65 | - } | ||
| 66 | -} |
| 1 | -/* | ||
| 2 | - * Copyright 2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.store.intent.impl; | ||
| 17 | - | ||
| 18 | -import org.onosproject.net.intent.Intent; | ||
| 19 | -import org.onosproject.net.intent.IntentId; | ||
| 20 | -import org.onosproject.store.Timestamp; | ||
| 21 | - | ||
| 22 | -import java.util.List; | ||
| 23 | - | ||
| 24 | -/** | ||
| 25 | - * Information published by GossipIntentStore to notify peers of an intent | ||
| 26 | - * set installables event. | ||
| 27 | - */ | ||
| 28 | -public class InternalSetInstallablesEvent { | ||
| 29 | - | ||
| 30 | - private final IntentId intentId; | ||
| 31 | - private final List<Intent> installables; | ||
| 32 | - private final Timestamp timestamp; | ||
| 33 | - | ||
| 34 | - public InternalSetInstallablesEvent(IntentId intentId, | ||
| 35 | - List<Intent> installables, | ||
| 36 | - Timestamp timestamp) { | ||
| 37 | - this.intentId = intentId; | ||
| 38 | - this.installables = installables; | ||
| 39 | - this.timestamp = timestamp; | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - public IntentId intentId() { | ||
| 43 | - return intentId; | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - public List<Intent> installables() { | ||
| 47 | - return installables; | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - public Timestamp timestamp() { | ||
| 51 | - return timestamp; | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - // Needed for serialization. | ||
| 55 | - @SuppressWarnings("unused") | ||
| 56 | - private InternalSetInstallablesEvent() { | ||
| 57 | - intentId = null; | ||
| 58 | - installables = null; | ||
| 59 | - timestamp = null; | ||
| 60 | - } | ||
| 61 | -} |
| ... | @@ -51,6 +51,7 @@ import org.onosproject.net.ConnectPoint; | ... | @@ -51,6 +51,7 @@ import org.onosproject.net.ConnectPoint; |
| 51 | import org.onosproject.net.DefaultAnnotations; | 51 | import org.onosproject.net.DefaultAnnotations; |
| 52 | import org.onosproject.net.DefaultDevice; | 52 | import org.onosproject.net.DefaultDevice; |
| 53 | import org.onosproject.net.DefaultEdgeLink; | 53 | import org.onosproject.net.DefaultEdgeLink; |
| 54 | +import org.onosproject.net.DefaultHost; | ||
| 54 | import org.onosproject.net.DefaultLink; | 55 | import org.onosproject.net.DefaultLink; |
| 55 | import org.onosproject.net.DefaultPath; | 56 | import org.onosproject.net.DefaultPath; |
| 56 | import org.onosproject.net.DefaultPort; | 57 | import org.onosproject.net.DefaultPort; |
| ... | @@ -267,6 +268,7 @@ public final class KryoNamespaces { | ... | @@ -267,6 +268,7 @@ public final class KryoNamespaces { |
| 267 | DefaultControllerNode.class, | 268 | DefaultControllerNode.class, |
| 268 | DefaultDevice.class, | 269 | DefaultDevice.class, |
| 269 | DefaultDeviceDescription.class, | 270 | DefaultDeviceDescription.class, |
| 271 | + DefaultHost.class, | ||
| 270 | DefaultLinkDescription.class, | 272 | DefaultLinkDescription.class, |
| 271 | Port.class, | 273 | Port.class, |
| 272 | DefaultPortDescription.class, | 274 | DefaultPortDescription.class, | ... | ... |
-
Please register or login to post a comment