Enable Raft version of IntentStore
- Turning off state transition verification for now Change-Id: I59d9796995d7349cd19e741c6f00e7dd2d2c3d73
Showing
2 changed files
with
28 additions
and
4 deletions
| ... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onlab.onos.store.intent.impl; | 16 | package org.onlab.onos.store.intent.impl; |
| 17 | 17 | ||
| 18 | +import com.google.common.base.Verify; | ||
| 18 | import com.google.common.collect.ImmutableSet; | 19 | import com.google.common.collect.ImmutableSet; |
| 19 | 20 | ||
| 20 | import org.apache.felix.scr.annotations.Activate; | 21 | import org.apache.felix.scr.annotations.Activate; |
| ... | @@ -45,11 +46,10 @@ import java.util.Map; | ... | @@ -45,11 +46,10 @@ import java.util.Map; |
| 45 | import java.util.Set; | 46 | import java.util.Set; |
| 46 | import java.util.concurrent.ConcurrentHashMap; | 47 | import java.util.concurrent.ConcurrentHashMap; |
| 47 | 48 | ||
| 48 | -import static com.google.common.base.Verify.verify; | ||
| 49 | import static org.onlab.onos.net.intent.IntentState.*; | 49 | import static org.onlab.onos.net.intent.IntentState.*; |
| 50 | import static org.slf4j.LoggerFactory.getLogger; | 50 | import static org.slf4j.LoggerFactory.getLogger; |
| 51 | 51 | ||
| 52 | -@Component(immediate = false, enabled = false) | 52 | +@Component(immediate = true, enabled = true) |
| 53 | @Service | 53 | @Service |
| 54 | public class DistributedIntentStore | 54 | public class DistributedIntentStore |
| 55 | extends AbstractStore<IntentEvent, IntentStoreDelegate> | 55 | extends AbstractStore<IntentEvent, IntentStoreDelegate> |
| ... | @@ -81,6 +81,9 @@ public class DistributedIntentStore | ... | @@ -81,6 +81,9 @@ public class DistributedIntentStore |
| 81 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 81 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 82 | protected DatabaseService dbService; | 82 | protected DatabaseService dbService; |
| 83 | 83 | ||
| 84 | + // TODO make this configurable | ||
| 85 | + private boolean onlyLogTransitionError = true; | ||
| 86 | + | ||
| 84 | @Activate | 87 | @Activate |
| 85 | public void activate() { | 88 | public void activate() { |
| 86 | // FIXME: We need a way to add serializer for intents which has been plugged-in. | 89 | // FIXME: We need a way to add serializer for intents which has been plugged-in. |
| ... | @@ -164,6 +167,15 @@ public class DistributedIntentStore | ... | @@ -164,6 +167,15 @@ public class DistributedIntentStore |
| 164 | return states.get(id); | 167 | return states.get(id); |
| 165 | } | 168 | } |
| 166 | 169 | ||
| 170 | + private void verify(boolean expression, String errorMessageTemplate, Object... errorMessageArgs) { | ||
| 171 | + if (onlyLogTransitionError) { | ||
| 172 | + if (!expression) { | ||
| 173 | + log.error(errorMessageTemplate.replace("%s", "{}"), errorMessageArgs); | ||
| 174 | + } | ||
| 175 | + } else { | ||
| 176 | + Verify.verify(expression, errorMessageTemplate, errorMessageArgs); | ||
| 177 | + } | ||
| 178 | + } | ||
| 167 | 179 | ||
| 168 | @Override | 180 | @Override |
| 169 | public IntentEvent setState(Intent intent, IntentState state) { | 181 | public IntentEvent setState(Intent intent, IntentState state) { | ... | ... |
| ... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onlab.onos.store.intent.impl; | 16 | package org.onlab.onos.store.intent.impl; |
| 17 | 17 | ||
| 18 | +import com.google.common.base.Verify; | ||
| 18 | import com.google.common.collect.ImmutableSet; | 19 | import com.google.common.collect.ImmutableSet; |
| 19 | import com.hazelcast.core.EntryAdapter; | 20 | import com.hazelcast.core.EntryAdapter; |
| 20 | import com.hazelcast.core.EntryEvent; | 21 | import com.hazelcast.core.EntryEvent; |
| ... | @@ -45,11 +46,10 @@ import java.util.Map; | ... | @@ -45,11 +46,10 @@ import java.util.Map; |
| 45 | import java.util.Set; | 46 | import java.util.Set; |
| 46 | import java.util.concurrent.ConcurrentHashMap; | 47 | import java.util.concurrent.ConcurrentHashMap; |
| 47 | 48 | ||
| 48 | -import static com.google.common.base.Verify.verify; | ||
| 49 | import static org.onlab.onos.net.intent.IntentState.*; | 49 | import static org.onlab.onos.net.intent.IntentState.*; |
| 50 | import static org.slf4j.LoggerFactory.getLogger; | 50 | import static org.slf4j.LoggerFactory.getLogger; |
| 51 | 51 | ||
| 52 | -@Component(immediate = true, enabled = true) | 52 | +@Component(immediate = true, enabled = false) |
| 53 | @Service | 53 | @Service |
| 54 | public class HazelcastIntentStore | 54 | public class HazelcastIntentStore |
| 55 | extends AbstractHazelcastStore<IntentEvent, IntentStoreDelegate> | 55 | extends AbstractHazelcastStore<IntentEvent, IntentStoreDelegate> |
| ... | @@ -72,6 +72,9 @@ public class HazelcastIntentStore | ... | @@ -72,6 +72,9 @@ public class HazelcastIntentStore |
| 72 | 72 | ||
| 73 | private SMap<IntentId, List<Intent>> installable; | 73 | private SMap<IntentId, List<Intent>> installable; |
| 74 | 74 | ||
| 75 | + // TODO make this configurable | ||
| 76 | + private boolean onlyLogTransitionError = true; | ||
| 77 | + | ||
| 75 | @Override | 78 | @Override |
| 76 | @Activate | 79 | @Activate |
| 77 | public void activate() { | 80 | public void activate() { |
| ... | @@ -166,6 +169,15 @@ public class HazelcastIntentStore | ... | @@ -166,6 +169,15 @@ public class HazelcastIntentStore |
| 166 | return states.get(id); | 169 | return states.get(id); |
| 167 | } | 170 | } |
| 168 | 171 | ||
| 172 | + private void verify(boolean expression, String errorMessageTemplate, Object... errorMessageArgs) { | ||
| 173 | + if (onlyLogTransitionError) { | ||
| 174 | + if (!expression) { | ||
| 175 | + log.error(errorMessageTemplate.replace("%s", "{}"), errorMessageArgs); | ||
| 176 | + } | ||
| 177 | + } else { | ||
| 178 | + Verify.verify(expression, errorMessageTemplate, errorMessageArgs); | ||
| 179 | + } | ||
| 180 | + } | ||
| 169 | 181 | ||
| 170 | @Override | 182 | @Override |
| 171 | public IntentEvent setState(Intent intent, IntentState state) { | 183 | public IntentEvent setState(Intent intent, IntentState state) { | ... | ... |
-
Please register or login to post a comment