Jonathan Hart
Committed by Brian O'Connor

Removed deprecated IntentStore#batchWrite() API.

Also javadoc fixes.

Change-Id: I4ccd109a22189f4762afec15a719e42a3b9e4f7b
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
15 */ 15 */
16 package org.onosproject.net.intent; 16 package org.onosproject.net.intent;
17 17
18 -import org.onosproject.net.intent.BatchWrite.Operation;
19 import org.onosproject.store.Store; 18 import org.onosproject.store.Store;
20 19
21 import java.util.List; 20 import java.util.List;
...@@ -61,16 +60,18 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> { ...@@ -61,16 +60,18 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> {
61 } 60 }
62 61
63 /** 62 /**
64 - * Execute writes in a batch. 63 + * Writes an IntentData object to the store.
65 - * If the specified BatchWrite is empty, write will not be executed.
66 * 64 *
67 - * @param batch BatchWrite to execute 65 + * @param newData new intent data to write
68 - * @return failed operations
69 */ 66 */
70 - @Deprecated
71 - List<Operation> batchWrite(BatchWrite batch);
72 -
73 default void write(IntentData newData) {} 67 default void write(IntentData newData) {}
68 +
69 + /**
70 + * Writes a batch of IntentData objects to the store. A batch has no
71 + * semantics, this is simply a convenience API.
72 + *
73 + * @param updates collection of intent data objects to write
74 + */
74 default void batchWrite(Iterable<IntentData> updates) {} 75 default void batchWrite(Iterable<IntentData> updates) {}
75 76
76 /** 77 /**
......
...@@ -22,7 +22,6 @@ import com.google.common.cache.CacheBuilder; ...@@ -22,7 +22,6 @@ import com.google.common.cache.CacheBuilder;
22 import com.google.common.cache.CacheLoader; 22 import com.google.common.cache.CacheLoader;
23 import com.google.common.cache.LoadingCache; 23 import com.google.common.cache.LoadingCache;
24 import com.google.common.collect.ImmutableSet; 24 import com.google.common.collect.ImmutableSet;
25 -import com.google.common.collect.Lists;
26 import org.apache.felix.scr.annotations.Activate; 25 import org.apache.felix.scr.annotations.Activate;
27 import org.apache.felix.scr.annotations.Component; 26 import org.apache.felix.scr.annotations.Component;
28 import org.apache.felix.scr.annotations.Deactivate; 27 import org.apache.felix.scr.annotations.Deactivate;
...@@ -32,8 +31,6 @@ import org.apache.felix.scr.annotations.Service; ...@@ -32,8 +31,6 @@ import org.apache.felix.scr.annotations.Service;
32 import org.onlab.metrics.MetricsService; 31 import org.onlab.metrics.MetricsService;
33 import org.onlab.util.KryoNamespace; 32 import org.onlab.util.KryoNamespace;
34 import org.onosproject.core.MetricsHelper; 33 import org.onosproject.core.MetricsHelper;
35 -import org.onosproject.net.intent.BatchWrite;
36 -import org.onosproject.net.intent.BatchWrite.Operation;
37 import org.onosproject.net.intent.Intent; 34 import org.onosproject.net.intent.Intent;
38 import org.onosproject.net.intent.IntentEvent; 35 import org.onosproject.net.intent.IntentEvent;
39 import org.onosproject.net.intent.IntentId; 36 import org.onosproject.net.intent.IntentId;
...@@ -45,24 +42,17 @@ import org.onosproject.store.AbstractStore; ...@@ -45,24 +42,17 @@ import org.onosproject.store.AbstractStore;
45 import org.onosproject.store.serializers.KryoNamespaces; 42 import org.onosproject.store.serializers.KryoNamespaces;
46 import org.onosproject.store.serializers.KryoSerializer; 43 import org.onosproject.store.serializers.KryoSerializer;
47 import org.onosproject.store.serializers.StoreSerializer; 44 import org.onosproject.store.serializers.StoreSerializer;
48 -import org.onosproject.store.service.BatchWriteRequest;
49 -import org.onosproject.store.service.BatchWriteRequest.Builder;
50 -import org.onosproject.store.service.BatchWriteResult;
51 import org.onosproject.store.service.DatabaseAdminService; 45 import org.onosproject.store.service.DatabaseAdminService;
52 import org.onosproject.store.service.DatabaseService; 46 import org.onosproject.store.service.DatabaseService;
53 import org.onosproject.store.service.impl.CMap; 47 import org.onosproject.store.service.impl.CMap;
54 import org.slf4j.Logger; 48 import org.slf4j.Logger;
55 49
56 -import java.util.ArrayList;
57 -import java.util.Collections;
58 import java.util.EnumSet; 50 import java.util.EnumSet;
59 -import java.util.HashSet;
60 import java.util.List; 51 import java.util.List;
61 import java.util.Map; 52 import java.util.Map;
62 import java.util.Set; 53 import java.util.Set;
63 import java.util.concurrent.ConcurrentHashMap; 54 import java.util.concurrent.ConcurrentHashMap;
64 55
65 -import static com.google.common.base.Preconditions.checkArgument;
66 import static org.onlab.metrics.MetricsUtil.startTimer; 56 import static org.onlab.metrics.MetricsUtil.startTimer;
67 import static org.onlab.metrics.MetricsUtil.stopTimer; 57 import static org.onlab.metrics.MetricsUtil.stopTimer;
68 import static org.onosproject.net.intent.IntentState.FAILED; 58 import static org.onosproject.net.intent.IntentState.FAILED;
...@@ -292,7 +282,7 @@ public class DistributedIntentStore ...@@ -292,7 +282,7 @@ public class DistributedIntentStore
292 } 282 }
293 } 283 }
294 284
295 - @Override 285 + /*@Override
296 public List<Operation> batchWrite(BatchWrite batch) { 286 public List<Operation> batchWrite(BatchWrite batch) {
297 if (batch.isEmpty()) { 287 if (batch.isEmpty()) {
298 return Collections.emptyList(); 288 return Collections.emptyList();
...@@ -370,5 +360,5 @@ public class DistributedIntentStore ...@@ -370,5 +360,5 @@ public class DistributedIntentStore
370 // everything failed 360 // everything failed
371 return batch.operations(); 361 return batch.operations();
372 } 362 }
373 - } 363 + }*/
374 } 364 }
......
...@@ -23,7 +23,6 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; ...@@ -23,7 +23,6 @@ import org.apache.felix.scr.annotations.ReferenceCardinality;
23 import org.apache.felix.scr.annotations.Service; 23 import org.apache.felix.scr.annotations.Service;
24 import org.onlab.util.KryoNamespace; 24 import org.onlab.util.KryoNamespace;
25 import org.onosproject.cluster.ClusterService; 25 import org.onosproject.cluster.ClusterService;
26 -import org.onosproject.net.intent.BatchWrite;
27 import org.onosproject.net.intent.Intent; 26 import org.onosproject.net.intent.Intent;
28 import org.onosproject.net.intent.IntentData; 27 import org.onosproject.net.intent.IntentData;
29 import org.onosproject.net.intent.IntentEvent; 28 import org.onosproject.net.intent.IntentEvent;
...@@ -45,11 +44,7 @@ import org.slf4j.Logger; ...@@ -45,11 +44,7 @@ import org.slf4j.Logger;
45 import java.util.List; 44 import java.util.List;
46 import java.util.stream.Collectors; 45 import java.util.stream.Collectors;
47 46
48 -import static org.onosproject.net.intent.IntentState.FAILED; 47 +import static org.onosproject.net.intent.IntentState.*;
49 -import static org.onosproject.net.intent.IntentState.INSTALLED;
50 -import static org.onosproject.net.intent.IntentState.INSTALLING;
51 -import static org.onosproject.net.intent.IntentState.WITHDRAWING;
52 -import static org.onosproject.net.intent.IntentState.WITHDRAWN;
53 import static org.slf4j.LoggerFactory.getLogger; 48 import static org.slf4j.LoggerFactory.getLogger;
54 49
55 /** 50 /**
...@@ -143,12 +138,6 @@ public class GossipIntentStore ...@@ -143,12 +138,6 @@ public class GossipIntentStore
143 return null; 138 return null;
144 } 139 }
145 140
146 - @Override
147 - public List<BatchWrite.Operation> batchWrite(BatchWrite batch) {
148 - // Deprecated
149 - return null;
150 - }
151 -
152 private IntentData copyData(IntentData original) { 141 private IntentData copyData(IntentData original) {
153 if (original == null) { 142 if (original == null) {
154 return null; 143 return null;
...@@ -163,10 +152,13 @@ public class GossipIntentStore ...@@ -163,10 +152,13 @@ public class GossipIntentStore
163 } 152 }
164 153
165 /** 154 /**
166 - * TODO. 155 + * Determines whether an intent data update is allowed. The update must
167 - * @param currentData 156 + * either have a higher version than the current data, or the state
168 - * @param newData 157 + * transition between two updates of the same version must be sane.
169 - * @return 158 + *
159 + * @param currentData existing intent data in the store
160 + * @param newData new intent data update proposal
161 + * @return true if we can apply the update, otherwise false
170 */ 162 */
171 private boolean isUpdateAcceptable(IntentData currentData, IntentData newData) { 163 private boolean isUpdateAcceptable(IntentData currentData, IntentData newData) {
172 164
......
...@@ -20,7 +20,6 @@ import com.codahale.metrics.Timer.Context; ...@@ -20,7 +20,6 @@ import com.codahale.metrics.Timer.Context;
20 import com.google.common.base.Verify; 20 import com.google.common.base.Verify;
21 import com.google.common.collect.ImmutableList; 21 import com.google.common.collect.ImmutableList;
22 import com.google.common.collect.ImmutableSet; 22 import com.google.common.collect.ImmutableSet;
23 -import com.google.common.collect.Lists;
24 import com.hazelcast.config.Config; 23 import com.hazelcast.config.Config;
25 import com.hazelcast.config.MapConfig; 24 import com.hazelcast.config.MapConfig;
26 import com.hazelcast.core.EntryAdapter; 25 import com.hazelcast.core.EntryAdapter;
...@@ -53,8 +52,6 @@ import org.onosproject.store.serializers.KryoNamespaces; ...@@ -53,8 +52,6 @@ import org.onosproject.store.serializers.KryoNamespaces;
53 import org.onosproject.store.serializers.KryoSerializer; 52 import org.onosproject.store.serializers.KryoSerializer;
54 import org.slf4j.Logger; 53 import org.slf4j.Logger;
55 54
56 -import java.util.ArrayList;
57 -import java.util.Collections;
58 import java.util.EnumSet; 55 import java.util.EnumSet;
59 import java.util.List; 56 import java.util.List;
60 import java.util.Map; 57 import java.util.Map;
...@@ -66,7 +63,10 @@ import java.util.concurrent.Future; ...@@ -66,7 +63,10 @@ import java.util.concurrent.Future;
66 import static com.google.common.base.Preconditions.checkArgument; 63 import static com.google.common.base.Preconditions.checkArgument;
67 import static org.onlab.metrics.MetricsUtil.startTimer; 64 import static org.onlab.metrics.MetricsUtil.startTimer;
68 import static org.onlab.metrics.MetricsUtil.stopTimer; 65 import static org.onlab.metrics.MetricsUtil.stopTimer;
69 -import static org.onosproject.net.intent.IntentState.*; 66 +import static org.onosproject.net.intent.IntentState.FAILED;
67 +import static org.onosproject.net.intent.IntentState.INSTALLED;
68 +import static org.onosproject.net.intent.IntentState.INSTALL_REQ;
69 +import static org.onosproject.net.intent.IntentState.WITHDRAWN;
70 import static org.slf4j.LoggerFactory.getLogger; 70 import static org.slf4j.LoggerFactory.getLogger;
71 71
72 //TODO Note: this store will be removed 72 //TODO Note: this store will be removed
...@@ -277,7 +277,7 @@ public class HazelcastIntentStore ...@@ -277,7 +277,7 @@ public class HazelcastIntentStore
277 */ 277 */
278 } 278 }
279 279
280 - @Override 280 + /*@Override
281 public List<Operation> batchWrite(BatchWrite batch) { 281 public List<Operation> batchWrite(BatchWrite batch) {
282 if (batch.isEmpty()) { 282 if (batch.isEmpty()) {
283 return Collections.emptyList(); 283 return Collections.emptyList();
...@@ -297,7 +297,7 @@ public class HazelcastIntentStore ...@@ -297,7 +297,7 @@ public class HazelcastIntentStore
297 notifyDelegate(events); 297 notifyDelegate(events);
298 298
299 return failed; 299 return failed;
300 - } 300 + }*/
301 301
302 private void batchWriteAsync(BatchWrite batch, List<Operation> failed, 302 private void batchWriteAsync(BatchWrite batch, List<Operation> failed,
303 List<Pair<Operation, List<Future<?>>>> futures) { 303 List<Pair<Operation, List<Future<?>>>> futures) {
......
...@@ -20,8 +20,6 @@ import org.apache.felix.scr.annotations.Activate; ...@@ -20,8 +20,6 @@ import org.apache.felix.scr.annotations.Activate;
20 import org.apache.felix.scr.annotations.Component; 20 import org.apache.felix.scr.annotations.Component;
21 import org.apache.felix.scr.annotations.Deactivate; 21 import org.apache.felix.scr.annotations.Deactivate;
22 import org.apache.felix.scr.annotations.Service; 22 import org.apache.felix.scr.annotations.Service;
23 -import org.onosproject.net.intent.BatchWrite;
24 -import org.onosproject.net.intent.BatchWrite.Operation;
25 import org.onosproject.net.intent.Intent; 23 import org.onosproject.net.intent.Intent;
26 import org.onosproject.net.intent.IntentData; 24 import org.onosproject.net.intent.IntentData;
27 import org.onosproject.net.intent.IntentEvent; 25 import org.onosproject.net.intent.IntentEvent;
...@@ -110,76 +108,15 @@ public class SimpleIntentStore ...@@ -110,76 +108,15 @@ public class SimpleIntentStore
110 */ 108 */
111 } 109 }
112 110
113 - /*
114 - * Execute writes in a batch.
115 - *
116 - * @param batch BatchWrite to execute
117 - * @return failed operations
118 - */
119 - @Override
120 - public List<Operation> batchWrite(BatchWrite batch) {
121 - throw new UnsupportedOperationException("deprecated");
122 - /*
123 - if (batch.isEmpty()) {
124 - return Collections.emptyList();
125 - }
126 -
127 - List<Operation> failed = Lists.newArrayList();
128 - for (Operation op : batch.operations()) {
129 - switch (op.type()) {
130 - case CREATE_INTENT:
131 - checkArgument(op.args().size() == 1,
132 - "CREATE_INTENT takes 1 argument. %s", op);
133 - Intent intent = (Intent) op.args().get(0);
134 - // TODO: what if it failed?
135 -// createIntent(intent); FIXME
136 - break;
137 -
138 - case REMOVE_INTENT:
139 - checkArgument(op.args().size() == 1,
140 - "REMOVE_INTENT takes 1 argument. %s", op);
141 - IntentId intentId = (IntentId) op.args().get(0);
142 -// removeIntent(intentId); FIXME
143 - break;
144 -
145 - case REMOVE_INSTALLED:
146 - checkArgument(op.args().size() == 1,
147 - "REMOVE_INSTALLED takes 1 argument. %s", op);
148 - intentId = (IntentId) op.args().get(0);
149 - removeInstalledIntents(intentId);
150 - break;
151 -
152 - case SET_INSTALLABLE:
153 - checkArgument(op.args().size() == 2,
154 - "SET_INSTALLABLE takes 2 arguments. %s", op);
155 - intentId = (IntentId) op.args().get(0);
156 - @SuppressWarnings("unchecked")
157 - List<Intent> installableIntents = (List<Intent>) op.args().get(1);
158 - setInstallableIntents(intentId, installableIntents);
159 - break;
160 -
161 - case SET_STATE:
162 - checkArgument(op.args().size() == 2,
163 - "SET_STATE takes 2 arguments. %s", op);
164 - intent = (Intent) op.args().get(0);
165 - IntentState newState = (IntentState) op.args().get(1);
166 - setState(intent, newState);
167 - break;
168 -
169 - default:
170 - break;
171 - }
172 - }
173 - return failed;
174 - */
175 - }
176 -
177 111
178 /** 112 /**
179 - * TODO. 113 + * Determines whether an intent data update is allowed. The update must
180 - * @param currentData 114 + * either have a higher version than the current data, or the state
181 - * @param newData 115 + * transition between two updates of the same version must be sane.
182 - * @return 116 + *
117 + * @param currentData existing intent data in the store
118 + * @param newData new intent data update proposal
119 + * @return true if we can apply the update, otherwise false
183 */ 120 */
184 private boolean isUpdateAcceptable(IntentData currentData, IntentData newData) { 121 private boolean isUpdateAcceptable(IntentData currentData, IntentData newData) {
185 122
......
...@@ -20,8 +20,6 @@ import org.apache.felix.scr.annotations.Activate; ...@@ -20,8 +20,6 @@ import org.apache.felix.scr.annotations.Activate;
20 import org.apache.felix.scr.annotations.Component; 20 import org.apache.felix.scr.annotations.Component;
21 import org.apache.felix.scr.annotations.Deactivate; 21 import org.apache.felix.scr.annotations.Deactivate;
22 import org.apache.felix.scr.annotations.Service; 22 import org.apache.felix.scr.annotations.Service;
23 -import org.onosproject.net.intent.BatchWrite;
24 -import org.onosproject.net.intent.BatchWrite.Operation;
25 import org.onosproject.net.intent.Intent; 23 import org.onosproject.net.intent.Intent;
26 import org.onosproject.net.intent.IntentData; 24 import org.onosproject.net.intent.IntentData;
27 import org.onosproject.net.intent.IntentEvent; 25 import org.onosproject.net.intent.IntentEvent;
...@@ -87,70 +85,6 @@ public class SimpleIntentStore ...@@ -87,70 +85,6 @@ public class SimpleIntentStore
87 return (data != null) ? data.installables() : null; 85 return (data != null) ? data.installables() : null;
88 } 86 }
89 87
90 - /*
91 - * Execute writes in a batch.
92 - *
93 - * @param batch BatchWrite to execute
94 - * @return failed operations
95 - */
96 - @Override
97 - public List<Operation> batchWrite(BatchWrite batch) {
98 - throw new UnsupportedOperationException("deprecated");
99 - /*
100 - if (batch.isEmpty()) {
101 - return Collections.emptyList();
102 - }
103 -
104 - List<Operation> failed = Lists.newArrayList();
105 - for (Operation op : batch.operations()) {
106 - switch (op.type()) {
107 - case CREATE_INTENT:
108 - checkArgument(op.args().size() == 1,
109 - "CREATE_INTENT takes 1 argument. %s", op);
110 - Intent intent = (Intent) op.args().get(0);
111 - // TODO: what if it failed?
112 -// createIntent(intent); FIXME
113 - break;
114 -
115 - case REMOVE_INTENT:
116 - checkArgument(op.args().size() == 1,
117 - "REMOVE_INTENT takes 1 argument. %s", op);
118 - IntentId intentId = (IntentId) op.args().get(0);
119 -// removeIntent(intentId); FIXME
120 - break;
121 -
122 - case REMOVE_INSTALLED:
123 - checkArgument(op.args().size() == 1,
124 - "REMOVE_INSTALLED takes 1 argument. %s", op);
125 - intentId = (IntentId) op.args().get(0);
126 - removeInstalledIntents(intentId);
127 - break;
128 -
129 - case SET_INSTALLABLE:
130 - checkArgument(op.args().size() == 2,
131 - "SET_INSTALLABLE takes 2 arguments. %s", op);
132 - intentId = (IntentId) op.args().get(0);
133 - @SuppressWarnings("unchecked")
134 - List<Intent> installableIntents = (List<Intent>) op.args().get(1);
135 - setInstallableIntents(intentId, installableIntents);
136 - break;
137 -
138 - case SET_STATE:
139 - checkArgument(op.args().size() == 2,
140 - "SET_STATE takes 2 arguments. %s", op);
141 - intent = (Intent) op.args().get(0);
142 - IntentState newState = (IntentState) op.args().get(1);
143 - setState(intent, newState);
144 - break;
145 -
146 - default:
147 - break;
148 - }
149 - }
150 - return failed;
151 - */
152 - }
153 -
154 @Override 88 @Override
155 public void write(IntentData newData) { 89 public void write(IntentData newData) {
156 //FIXME need to compare the versions 90 //FIXME need to compare the versions
......