Committed by
Gerrit Code Review
[GoldenEye] [ONOS-4163] Add provider service update API with status change
Change-Id: Id8774f5577f735566b1826ab4adfe5969c3aa168
Showing
6 changed files
with
56 additions
and
4 deletions
... | @@ -60,6 +60,14 @@ public interface TunnelProviderService extends ProviderService<TunnelProvider> { | ... | @@ -60,6 +60,14 @@ public interface TunnelProviderService extends ProviderService<TunnelProvider> { |
60 | void tunnelUpdated(TunnelDescription tunnel); | 60 | void tunnelUpdated(TunnelDescription tunnel); |
61 | 61 | ||
62 | /** | 62 | /** |
63 | + * Signals that the tunnel was changed with tunnel status change. | ||
64 | + * | ||
65 | + * @param tunnel tunnel information | ||
66 | + * @param state tunnel working status | ||
67 | + */ | ||
68 | + void tunnelUpdated(TunnelDescription tunnel, State state); | ||
69 | + | ||
70 | + /** | ||
63 | * Signals that the a tunnel was queried. | 71 | * Signals that the a tunnel was queried. |
64 | * | 72 | * |
65 | * @param tunnelId tunnel identity | 73 | * @param tunnelId tunnel identity | ... | ... |
... | @@ -19,6 +19,7 @@ import java.util.Collection; | ... | @@ -19,6 +19,7 @@ import java.util.Collection; |
19 | 19 | ||
20 | import com.google.common.annotations.Beta; | 20 | import com.google.common.annotations.Beta; |
21 | import org.onosproject.core.ApplicationId; | 21 | import org.onosproject.core.ApplicationId; |
22 | +import org.onosproject.incubator.net.tunnel.Tunnel.State; | ||
22 | import org.onosproject.incubator.net.tunnel.Tunnel.Type; | 23 | import org.onosproject.incubator.net.tunnel.Tunnel.Type; |
23 | import org.onosproject.net.Annotations; | 24 | import org.onosproject.net.Annotations; |
24 | import org.onosproject.net.provider.ProviderId; | 25 | import org.onosproject.net.provider.ProviderId; |
... | @@ -38,6 +39,15 @@ public interface TunnelStore extends Store<TunnelEvent, TunnelStoreDelegate> { | ... | @@ -38,6 +39,15 @@ public interface TunnelStore extends Store<TunnelEvent, TunnelStoreDelegate> { |
38 | TunnelId createOrUpdateTunnel(Tunnel tunnel); | 39 | TunnelId createOrUpdateTunnel(Tunnel tunnel); |
39 | 40 | ||
40 | /** | 41 | /** |
42 | + * Creates a tunnel or updates a tunnel with the new state given in input. | ||
43 | + * | ||
44 | + * @param tunnel tunnel | ||
45 | + * @param state tunnel state | ||
46 | + * @return tunnel identity | ||
47 | + */ | ||
48 | + TunnelId createOrUpdateTunnel(Tunnel tunnel, State state); | ||
49 | + | ||
50 | + /** | ||
41 | * Deletes a tunnel by a specific tunnel identifier. | 51 | * Deletes a tunnel by a specific tunnel identifier. |
42 | * | 52 | * |
43 | * @param tunnelId tunnel unique identifier generated by ONOS | 53 | * @param tunnelId tunnel unique identifier generated by ONOS | ... | ... |
... | @@ -337,6 +337,20 @@ public class TunnelManager | ... | @@ -337,6 +337,20 @@ public class TunnelManager |
337 | } | 337 | } |
338 | 338 | ||
339 | @Override | 339 | @Override |
340 | + public void tunnelUpdated(TunnelDescription tunnel, State state) { | ||
341 | + Tunnel storedTunnel = new DefaultTunnel(provider().id(), | ||
342 | + tunnel.src(), tunnel.dst(), | ||
343 | + tunnel.type(), | ||
344 | + state, | ||
345 | + tunnel.groupId(), | ||
346 | + tunnel.id(), | ||
347 | + tunnel.tunnelName(), | ||
348 | + tunnel.path(), | ||
349 | + tunnel.annotations()); | ||
350 | + store.createOrUpdateTunnel(storedTunnel, state); | ||
351 | + } | ||
352 | + | ||
353 | + @Override | ||
340 | public void tunnelRemoved(TunnelDescription tunnel) { | 354 | public void tunnelRemoved(TunnelDescription tunnel) { |
341 | if (tunnel.id() != null) { | 355 | if (tunnel.id() != null) { |
342 | store.deleteTunnel(tunnel.id()); | 356 | store.deleteTunnel(tunnel.id()); | ... | ... |
... | @@ -38,6 +38,7 @@ import org.onosproject.core.CoreService; | ... | @@ -38,6 +38,7 @@ import org.onosproject.core.CoreService; |
38 | import org.onosproject.core.IdGenerator; | 38 | import org.onosproject.core.IdGenerator; |
39 | import org.onosproject.incubator.net.tunnel.DefaultTunnel; | 39 | import org.onosproject.incubator.net.tunnel.DefaultTunnel; |
40 | import org.onosproject.incubator.net.tunnel.Tunnel; | 40 | import org.onosproject.incubator.net.tunnel.Tunnel; |
41 | +import org.onosproject.incubator.net.tunnel.Tunnel.State; | ||
41 | import org.onosproject.incubator.net.tunnel.Tunnel.Type; | 42 | import org.onosproject.incubator.net.tunnel.Tunnel.Type; |
42 | import org.onosproject.incubator.net.tunnel.TunnelEndPoint; | 43 | import org.onosproject.incubator.net.tunnel.TunnelEndPoint; |
43 | import org.onosproject.incubator.net.tunnel.TunnelEvent; | 44 | import org.onosproject.incubator.net.tunnel.TunnelEvent; |
... | @@ -147,6 +148,15 @@ public class DistributedTunnelStore | ... | @@ -147,6 +148,15 @@ public class DistributedTunnelStore |
147 | 148 | ||
148 | @Override | 149 | @Override |
149 | public TunnelId createOrUpdateTunnel(Tunnel tunnel) { | 150 | public TunnelId createOrUpdateTunnel(Tunnel tunnel) { |
151 | + return handleCreateOrUpdateTunnel(tunnel, null); | ||
152 | + } | ||
153 | + | ||
154 | + @Override | ||
155 | + public TunnelId createOrUpdateTunnel(Tunnel tunnel, State state) { | ||
156 | + return handleCreateOrUpdateTunnel(tunnel, state); | ||
157 | + } | ||
158 | + | ||
159 | + private TunnelId handleCreateOrUpdateTunnel(Tunnel tunnel, State state) { | ||
150 | // tunnelIdAsKeyStore. | 160 | // tunnelIdAsKeyStore. |
151 | if (tunnel.tunnelId() != null && !"".equals(tunnel.tunnelId().toString())) { | 161 | if (tunnel.tunnelId() != null && !"".equals(tunnel.tunnelId().toString())) { |
152 | Tunnel old = tunnelIdAsKeyStore.get(tunnel.tunnelId()); | 162 | Tunnel old = tunnelIdAsKeyStore.get(tunnel.tunnelId()); |
... | @@ -156,24 +166,25 @@ public class DistributedTunnelStore | ... | @@ -156,24 +166,25 @@ public class DistributedTunnelStore |
156 | } | 166 | } |
157 | DefaultAnnotations oldAnno = (DefaultAnnotations) old.annotations(); | 167 | DefaultAnnotations oldAnno = (DefaultAnnotations) old.annotations(); |
158 | SparseAnnotations newAnno = (SparseAnnotations) tunnel.annotations(); | 168 | SparseAnnotations newAnno = (SparseAnnotations) tunnel.annotations(); |
169 | + State newTunnelState = (state != null) ? state : old.state(); | ||
159 | Tunnel newT = new DefaultTunnel(old.providerId(), old.src(), | 170 | Tunnel newT = new DefaultTunnel(old.providerId(), old.src(), |
160 | old.dst(), old.type(), | 171 | old.dst(), old.type(), |
161 | - old.state(), old.groupId(), | 172 | + newTunnelState, old.groupId(), |
162 | old.tunnelId(), | 173 | old.tunnelId(), |
163 | old.tunnelName(), | 174 | old.tunnelName(), |
164 | old.path(), | 175 | old.path(), |
165 | DefaultAnnotations.merge(oldAnno, newAnno)); | 176 | DefaultAnnotations.merge(oldAnno, newAnno)); |
166 | tunnelIdAsKeyStore.put(tunnel.tunnelId(), newT); | 177 | tunnelIdAsKeyStore.put(tunnel.tunnelId(), newT); |
167 | - TunnelEvent event = new TunnelEvent( | 178 | + TunnelEvent event = new TunnelEvent(TunnelEvent.Type.TUNNEL_UPDATED, |
168 | - TunnelEvent.Type.TUNNEL_UPDATED, | ||
169 | tunnel); | 179 | tunnel); |
170 | notifyDelegate(event); | 180 | notifyDelegate(event); |
171 | return tunnel.tunnelId(); | 181 | return tunnel.tunnelId(); |
172 | } else { | 182 | } else { |
173 | TunnelId tunnelId = TunnelId.valueOf(idGenerator.getNewId()); | 183 | TunnelId tunnelId = TunnelId.valueOf(idGenerator.getNewId()); |
184 | + State tunnelState = (state != null) ? state : tunnel.state(); | ||
174 | Tunnel newT = new DefaultTunnel(tunnel.providerId(), tunnel.src(), | 185 | Tunnel newT = new DefaultTunnel(tunnel.providerId(), tunnel.src(), |
175 | tunnel.dst(), tunnel.type(), | 186 | tunnel.dst(), tunnel.type(), |
176 | - tunnel.state(), tunnel.groupId(), | 187 | + tunnelState, tunnel.groupId(), |
177 | tunnelId, | 188 | tunnelId, |
178 | tunnel.tunnelName(), | 189 | tunnel.tunnelName(), |
179 | tunnel.path(), | 190 | tunnel.path(), | ... | ... |
... | @@ -182,6 +182,11 @@ public class OvsdbTunnelProviderTest { | ... | @@ -182,6 +182,11 @@ public class OvsdbTunnelProviderTest { |
182 | } | 182 | } |
183 | 183 | ||
184 | @Override | 184 | @Override |
185 | + public void tunnelUpdated(TunnelDescription tunnel, State state) { | ||
186 | + | ||
187 | + } | ||
188 | + | ||
189 | + @Override | ||
185 | public Tunnel tunnelQueryById(TunnelId tunnelId) { | 190 | public Tunnel tunnelQueryById(TunnelId tunnelId) { |
186 | return null; | 191 | return null; |
187 | } | 192 | } | ... | ... |
... | @@ -70,6 +70,10 @@ public class TunnelProviderRegistryAdapter implements TunnelProviderRegistry { | ... | @@ -70,6 +70,10 @@ public class TunnelProviderRegistryAdapter implements TunnelProviderRegistry { |
70 | } | 70 | } |
71 | 71 | ||
72 | @Override | 72 | @Override |
73 | + public void tunnelUpdated(TunnelDescription tunnel, State state) { | ||
74 | + } | ||
75 | + | ||
76 | + @Override | ||
73 | public Tunnel tunnelQueryById(TunnelId tunnelId) { | 77 | public Tunnel tunnelQueryById(TunnelId tunnelId) { |
74 | return null; | 78 | return null; |
75 | } | 79 | } | ... | ... |
-
Please register or login to post a comment