Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next
Showing
9 changed files
with
57 additions
and
51 deletions
... | @@ -63,7 +63,7 @@ public final class DefaultTrafficSelector implements TrafficSelector { | ... | @@ -63,7 +63,7 @@ public final class DefaultTrafficSelector implements TrafficSelector { |
63 | 63 | ||
64 | @Override | 64 | @Override |
65 | public int hashCode() { | 65 | public int hashCode() { |
66 | - return Objects.hash(criteria); | 66 | + return criteria.hashCode(); |
67 | } | 67 | } |
68 | 68 | ||
69 | @Override | 69 | @Override | ... | ... |
... | @@ -18,7 +18,7 @@ package org.onlab.onos.net.flow; | ... | @@ -18,7 +18,7 @@ package org.onlab.onos.net.flow; |
18 | import org.onlab.onos.core.ApplicationId; | 18 | import org.onlab.onos.core.ApplicationId; |
19 | import org.onlab.onos.net.provider.Provider; | 19 | import org.onlab.onos.net.provider.Provider; |
20 | 20 | ||
21 | -import com.google.common.util.concurrent.ListenableFuture; | 21 | +import java.util.concurrent.Future; |
22 | 22 | ||
23 | /** | 23 | /** |
24 | * Abstraction of a flow rule provider. | 24 | * Abstraction of a flow rule provider. |
... | @@ -58,6 +58,6 @@ public interface FlowRuleProvider extends Provider { | ... | @@ -58,6 +58,6 @@ public interface FlowRuleProvider extends Provider { |
58 | * @param batch a batch of flow rules | 58 | * @param batch a batch of flow rules |
59 | * @return a future indicating the status of this execution | 59 | * @return a future indicating the status of this execution |
60 | */ | 60 | */ |
61 | - ListenableFuture<CompletedBatchOperation> executeBatch(BatchOperation<FlowRuleBatchEntry> batch); | 61 | + Future<CompletedBatchOperation> executeBatch(BatchOperation<FlowRuleBatchEntry> batch); |
62 | 62 | ||
63 | } | 63 | } | ... | ... |
... | @@ -196,7 +196,7 @@ public final class Criteria { | ... | @@ -196,7 +196,7 @@ public final class Criteria { |
196 | 196 | ||
197 | @Override | 197 | @Override |
198 | public int hashCode() { | 198 | public int hashCode() { |
199 | - return Objects.hash(port, type()); | 199 | + return Objects.hash(type(), port); |
200 | } | 200 | } |
201 | 201 | ||
202 | @Override | 202 | @Override |
... | @@ -242,7 +242,7 @@ public final class Criteria { | ... | @@ -242,7 +242,7 @@ public final class Criteria { |
242 | 242 | ||
243 | @Override | 243 | @Override |
244 | public int hashCode() { | 244 | public int hashCode() { |
245 | - return Objects.hash(mac, type); | 245 | + return Objects.hash(type, mac); |
246 | } | 246 | } |
247 | 247 | ||
248 | @Override | 248 | @Override |
... | @@ -288,7 +288,7 @@ public final class Criteria { | ... | @@ -288,7 +288,7 @@ public final class Criteria { |
288 | 288 | ||
289 | @Override | 289 | @Override |
290 | public int hashCode() { | 290 | public int hashCode() { |
291 | - return Objects.hash(ethType, type()); | 291 | + return Objects.hash(type(), ethType); |
292 | } | 292 | } |
293 | 293 | ||
294 | @Override | 294 | @Override |
... | @@ -336,7 +336,7 @@ public final class Criteria { | ... | @@ -336,7 +336,7 @@ public final class Criteria { |
336 | 336 | ||
337 | @Override | 337 | @Override |
338 | public int hashCode() { | 338 | public int hashCode() { |
339 | - return Objects.hash(ip, type); | 339 | + return Objects.hash(type, ip); |
340 | } | 340 | } |
341 | 341 | ||
342 | @Override | 342 | @Override |
... | @@ -382,7 +382,7 @@ public final class Criteria { | ... | @@ -382,7 +382,7 @@ public final class Criteria { |
382 | 382 | ||
383 | @Override | 383 | @Override |
384 | public int hashCode() { | 384 | public int hashCode() { |
385 | - return Objects.hash(proto, type()); | 385 | + return Objects.hash(type(), proto); |
386 | } | 386 | } |
387 | 387 | ||
388 | @Override | 388 | @Override |
... | @@ -427,7 +427,7 @@ public final class Criteria { | ... | @@ -427,7 +427,7 @@ public final class Criteria { |
427 | 427 | ||
428 | @Override | 428 | @Override |
429 | public int hashCode() { | 429 | public int hashCode() { |
430 | - return Objects.hash(vlanPcp); | 430 | + return Objects.hash(type(), vlanPcp); |
431 | } | 431 | } |
432 | 432 | ||
433 | @Override | 433 | @Override |
... | @@ -474,7 +474,7 @@ public final class Criteria { | ... | @@ -474,7 +474,7 @@ public final class Criteria { |
474 | 474 | ||
475 | @Override | 475 | @Override |
476 | public int hashCode() { | 476 | public int hashCode() { |
477 | - return Objects.hash(vlanId, type()); | 477 | + return Objects.hash(type(), vlanId); |
478 | } | 478 | } |
479 | 479 | ||
480 | @Override | 480 | @Override |
... | @@ -522,7 +522,7 @@ public final class Criteria { | ... | @@ -522,7 +522,7 @@ public final class Criteria { |
522 | 522 | ||
523 | @Override | 523 | @Override |
524 | public int hashCode() { | 524 | public int hashCode() { |
525 | - return Objects.hash(tcpPort, type); | 525 | + return Objects.hash(type, tcpPort); |
526 | } | 526 | } |
527 | 527 | ||
528 | @Override | 528 | @Override |
... | @@ -568,7 +568,7 @@ public final class Criteria { | ... | @@ -568,7 +568,7 @@ public final class Criteria { |
568 | 568 | ||
569 | @Override | 569 | @Override |
570 | public int hashCode() { | 570 | public int hashCode() { |
571 | - return Objects.hash(lambda, type); | 571 | + return Objects.hash(type, lambda); |
572 | } | 572 | } |
573 | 573 | ||
574 | @Override | 574 | @Override |
... | @@ -612,7 +612,7 @@ public final class Criteria { | ... | @@ -612,7 +612,7 @@ public final class Criteria { |
612 | 612 | ||
613 | @Override | 613 | @Override |
614 | public int hashCode() { | 614 | public int hashCode() { |
615 | - return Objects.hash(signalType, type); | 615 | + return Objects.hash(type, signalType); |
616 | } | 616 | } |
617 | 617 | ||
618 | @Override | 618 | @Override | ... | ... |
... | @@ -190,7 +190,7 @@ public final class Instructions { | ... | @@ -190,7 +190,7 @@ public final class Instructions { |
190 | 190 | ||
191 | @Override | 191 | @Override |
192 | public int hashCode() { | 192 | public int hashCode() { |
193 | - return Objects.hash(port, type()); | 193 | + return Objects.hash(type(), port); |
194 | } | 194 | } |
195 | 195 | ||
196 | @Override | 196 | @Override | ... | ... |
... | @@ -70,7 +70,7 @@ public abstract class L0ModificationInstruction implements Instruction { | ... | @@ -70,7 +70,7 @@ public abstract class L0ModificationInstruction implements Instruction { |
70 | 70 | ||
71 | @Override | 71 | @Override |
72 | public int hashCode() { | 72 | public int hashCode() { |
73 | - return Objects.hash(lambda, type(), subtype); | 73 | + return Objects.hash(type(), subtype, lambda); |
74 | } | 74 | } |
75 | 75 | ||
76 | @Override | 76 | @Override | ... | ... |
... | @@ -93,7 +93,7 @@ public abstract class L2ModificationInstruction implements Instruction { | ... | @@ -93,7 +93,7 @@ public abstract class L2ModificationInstruction implements Instruction { |
93 | 93 | ||
94 | @Override | 94 | @Override |
95 | public int hashCode() { | 95 | public int hashCode() { |
96 | - return Objects.hash(mac, type(), subtype); | 96 | + return Objects.hash(type(), subtype, mac); |
97 | } | 97 | } |
98 | 98 | ||
99 | @Override | 99 | @Override |
... | @@ -142,7 +142,7 @@ public abstract class L2ModificationInstruction implements Instruction { | ... | @@ -142,7 +142,7 @@ public abstract class L2ModificationInstruction implements Instruction { |
142 | 142 | ||
143 | @Override | 143 | @Override |
144 | public int hashCode() { | 144 | public int hashCode() { |
145 | - return Objects.hash(vlanId, type(), subtype()); | 145 | + return Objects.hash(type(), subtype(), vlanId); |
146 | } | 146 | } |
147 | 147 | ||
148 | @Override | 148 | @Override |
... | @@ -191,7 +191,7 @@ public abstract class L2ModificationInstruction implements Instruction { | ... | @@ -191,7 +191,7 @@ public abstract class L2ModificationInstruction implements Instruction { |
191 | 191 | ||
192 | @Override | 192 | @Override |
193 | public int hashCode() { | 193 | public int hashCode() { |
194 | - return Objects.hash(vlanPcp, type(), subtype()); | 194 | + return Objects.hash(type(), subtype(), vlanPcp); |
195 | } | 195 | } |
196 | 196 | ||
197 | @Override | 197 | @Override | ... | ... |
... | @@ -85,7 +85,7 @@ public abstract class L3ModificationInstruction implements Instruction { | ... | @@ -85,7 +85,7 @@ public abstract class L3ModificationInstruction implements Instruction { |
85 | 85 | ||
86 | @Override | 86 | @Override |
87 | public int hashCode() { | 87 | public int hashCode() { |
88 | - return Objects.hash(ip, type(), subtype()); | 88 | + return Objects.hash(type(), subtype(), ip); |
89 | } | 89 | } |
90 | 90 | ||
91 | @Override | 91 | @Override | ... | ... |
... | @@ -15,22 +15,12 @@ | ... | @@ -15,22 +15,12 @@ |
15 | */ | 15 | */ |
16 | package org.onlab.onos.net.flow.impl; | 16 | package org.onlab.onos.net.flow.impl; |
17 | 17 | ||
18 | -import static com.google.common.base.Preconditions.checkNotNull; | 18 | +import com.google.common.collect.ArrayListMultimap; |
19 | -import static org.slf4j.LoggerFactory.getLogger; | 19 | +import com.google.common.collect.Iterables; |
20 | -import static org.onlab.util.Tools.namedThreads; | 20 | +import com.google.common.collect.Lists; |
21 | - | 21 | +import com.google.common.collect.Maps; |
22 | -import java.util.List; | 22 | +import com.google.common.collect.Multimap; |
23 | -import java.util.Map; | 23 | +import com.google.common.collect.Sets; |
24 | -import java.util.Set; | ||
25 | -import java.util.concurrent.CancellationException; | ||
26 | -import java.util.concurrent.ExecutionException; | ||
27 | -import java.util.concurrent.ExecutorService; | ||
28 | -import java.util.concurrent.Executors; | ||
29 | -import java.util.concurrent.Future; | ||
30 | -import java.util.concurrent.TimeUnit; | ||
31 | -import java.util.concurrent.TimeoutException; | ||
32 | -import java.util.concurrent.atomic.AtomicReference; | ||
33 | - | ||
34 | import org.apache.felix.scr.annotations.Activate; | 24 | import org.apache.felix.scr.annotations.Activate; |
35 | import org.apache.felix.scr.annotations.Component; | 25 | import org.apache.felix.scr.annotations.Component; |
36 | import org.apache.felix.scr.annotations.Deactivate; | 26 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -64,14 +54,21 @@ import org.onlab.onos.net.provider.AbstractProviderRegistry; | ... | @@ -64,14 +54,21 @@ import org.onlab.onos.net.provider.AbstractProviderRegistry; |
64 | import org.onlab.onos.net.provider.AbstractProviderService; | 54 | import org.onlab.onos.net.provider.AbstractProviderService; |
65 | import org.slf4j.Logger; | 55 | import org.slf4j.Logger; |
66 | 56 | ||
67 | -import com.google.common.collect.ArrayListMultimap; | 57 | +import java.util.List; |
68 | -import com.google.common.collect.Iterables; | 58 | +import java.util.Map; |
69 | -import com.google.common.collect.Lists; | 59 | +import java.util.Set; |
70 | -import com.google.common.collect.Maps; | 60 | +import java.util.concurrent.CancellationException; |
71 | -import com.google.common.collect.Multimap; | 61 | +import java.util.concurrent.ExecutionException; |
72 | -import com.google.common.collect.Sets; | 62 | +import java.util.concurrent.ExecutorService; |
73 | -import com.google.common.util.concurrent.Futures; | 63 | +import java.util.concurrent.Executors; |
74 | -import com.google.common.util.concurrent.ListenableFuture; | 64 | +import java.util.concurrent.Future; |
65 | +import java.util.concurrent.TimeUnit; | ||
66 | +import java.util.concurrent.TimeoutException; | ||
67 | +import java.util.concurrent.atomic.AtomicReference; | ||
68 | + | ||
69 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
70 | +import static org.onlab.util.Tools.namedThreads; | ||
71 | +import static org.slf4j.LoggerFactory.getLogger; | ||
75 | 72 | ||
76 | /** | 73 | /** |
77 | * Provides implementation of the flow NB & SB APIs. | 74 | * Provides implementation of the flow NB & SB APIs. |
... | @@ -92,8 +89,7 @@ public class FlowRuleManager | ... | @@ -92,8 +89,7 @@ public class FlowRuleManager |
92 | 89 | ||
93 | private final FlowRuleStoreDelegate delegate = new InternalStoreDelegate(); | 90 | private final FlowRuleStoreDelegate delegate = new InternalStoreDelegate(); |
94 | 91 | ||
95 | - private final ExecutorService futureListeners = | 92 | + private ExecutorService futureService; |
96 | - Executors.newCachedThreadPool(namedThreads("provider-future-listeners")); | ||
97 | 93 | ||
98 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 94 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
99 | protected FlowRuleStore store; | 95 | protected FlowRuleStore store; |
... | @@ -106,6 +102,7 @@ public class FlowRuleManager | ... | @@ -106,6 +102,7 @@ public class FlowRuleManager |
106 | 102 | ||
107 | @Activate | 103 | @Activate |
108 | public void activate() { | 104 | public void activate() { |
105 | + futureService = Executors.newCachedThreadPool(namedThreads("provider-future-listeners")); | ||
109 | store.setDelegate(delegate); | 106 | store.setDelegate(delegate); |
110 | eventDispatcher.addSink(FlowRuleEvent.class, listenerRegistry); | 107 | eventDispatcher.addSink(FlowRuleEvent.class, listenerRegistry); |
111 | log.info("Started"); | 108 | log.info("Started"); |
... | @@ -113,7 +110,7 @@ public class FlowRuleManager | ... | @@ -113,7 +110,7 @@ public class FlowRuleManager |
113 | 110 | ||
114 | @Deactivate | 111 | @Deactivate |
115 | public void deactivate() { | 112 | public void deactivate() { |
116 | - futureListeners.shutdownNow(); | 113 | + futureService.shutdownNow(); |
117 | 114 | ||
118 | store.unsetDelegate(delegate); | 115 | store.unsetDelegate(delegate); |
119 | eventDispatcher.removeSink(FlowRuleEvent.class); | 116 | eventDispatcher.removeSink(FlowRuleEvent.class); |
... | @@ -364,6 +361,9 @@ public class FlowRuleManager | ... | @@ -364,6 +361,9 @@ public class FlowRuleManager |
364 | 361 | ||
365 | // Store delegate to re-post events emitted from the store. | 362 | // Store delegate to re-post events emitted from the store. |
366 | private class InternalStoreDelegate implements FlowRuleStoreDelegate { | 363 | private class InternalStoreDelegate implements FlowRuleStoreDelegate { |
364 | + | ||
365 | + private static final int TIMEOUT = 5000; // ms | ||
366 | + | ||
367 | // TODO: Right now we only dispatch events at individual flowEntry level. | 367 | // TODO: Right now we only dispatch events at individual flowEntry level. |
368 | // It may be more efficient for also dispatch events as a batch. | 368 | // It may be more efficient for also dispatch events as a batch. |
369 | @Override | 369 | @Override |
... | @@ -384,15 +384,21 @@ public class FlowRuleManager | ... | @@ -384,15 +384,21 @@ public class FlowRuleManager |
384 | 384 | ||
385 | FlowRuleProvider flowRuleProvider = | 385 | FlowRuleProvider flowRuleProvider = |
386 | getProvider(batchOperation.getOperations().get(0).getTarget().deviceId()); | 386 | getProvider(batchOperation.getOperations().get(0).getTarget().deviceId()); |
387 | - final ListenableFuture<CompletedBatchOperation> result = | 387 | + final Future<CompletedBatchOperation> result = |
388 | flowRuleProvider.executeBatch(batchOperation); | 388 | flowRuleProvider.executeBatch(batchOperation); |
389 | - result.addListener(new Runnable() { | 389 | + futureService.submit(new Runnable() { |
390 | @Override | 390 | @Override |
391 | public void run() { | 391 | public void run() { |
392 | - store.batchOperationComplete(FlowRuleBatchEvent.completed(request, | 392 | + CompletedBatchOperation res = null; |
393 | - Futures.getUnchecked(result))); | 393 | + try { |
394 | + res = result.get(TIMEOUT, TimeUnit.MILLISECONDS); | ||
395 | + } catch (TimeoutException | InterruptedException | ExecutionException e) { | ||
396 | + log.warn("Something went wrong with the batch operation {}", | ||
397 | + request.batchId()); | ||
398 | + } | ||
399 | + store.batchOperationComplete(FlowRuleBatchEvent.completed(request, res)); | ||
394 | } | 400 | } |
395 | - }, futureListeners); | 401 | + }); |
396 | break; | 402 | break; |
397 | 403 | ||
398 | case BATCH_OPERATION_COMPLETED: | 404 | case BATCH_OPERATION_COMPLETED: | ... | ... |
providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/OpenFlowRuleProvider.java
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment