Yuta HIGUCHI

Enable Raft version of IntentStore

- Turning off state transition verification for now

Change-Id: I59d9796995d7349cd19e741c6f00e7dd2d2c3d73
......@@ -15,6 +15,7 @@
*/
package org.onlab.onos.store.intent.impl;
import com.google.common.base.Verify;
import com.google.common.collect.ImmutableSet;
import org.apache.felix.scr.annotations.Activate;
......@@ -45,11 +46,10 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import static com.google.common.base.Verify.verify;
import static org.onlab.onos.net.intent.IntentState.*;
import static org.slf4j.LoggerFactory.getLogger;
@Component(immediate = false, enabled = false)
@Component(immediate = true, enabled = true)
@Service
public class DistributedIntentStore
extends AbstractStore<IntentEvent, IntentStoreDelegate>
......@@ -81,6 +81,9 @@ public class DistributedIntentStore
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DatabaseService dbService;
// TODO make this configurable
private boolean onlyLogTransitionError = true;
@Activate
public void activate() {
// FIXME: We need a way to add serializer for intents which has been plugged-in.
......@@ -164,6 +167,15 @@ public class DistributedIntentStore
return states.get(id);
}
private void verify(boolean expression, String errorMessageTemplate, Object... errorMessageArgs) {
if (onlyLogTransitionError) {
if (!expression) {
log.error(errorMessageTemplate.replace("%s", "{}"), errorMessageArgs);
}
} else {
Verify.verify(expression, errorMessageTemplate, errorMessageArgs);
}
}
@Override
public IntentEvent setState(Intent intent, IntentState state) {
......
......@@ -15,6 +15,7 @@
*/
package org.onlab.onos.store.intent.impl;
import com.google.common.base.Verify;
import com.google.common.collect.ImmutableSet;
import com.hazelcast.core.EntryAdapter;
import com.hazelcast.core.EntryEvent;
......@@ -45,11 +46,10 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import static com.google.common.base.Verify.verify;
import static org.onlab.onos.net.intent.IntentState.*;
import static org.slf4j.LoggerFactory.getLogger;
@Component(immediate = true, enabled = true)
@Component(immediate = true, enabled = false)
@Service
public class HazelcastIntentStore
extends AbstractHazelcastStore<IntentEvent, IntentStoreDelegate>
......@@ -72,6 +72,9 @@ public class HazelcastIntentStore
private SMap<IntentId, List<Intent>> installable;
// TODO make this configurable
private boolean onlyLogTransitionError = true;
@Override
@Activate
public void activate() {
......@@ -166,6 +169,15 @@ public class HazelcastIntentStore
return states.get(id);
}
private void verify(boolean expression, String errorMessageTemplate, Object... errorMessageArgs) {
if (onlyLogTransitionError) {
if (!expression) {
log.error(errorMessageTemplate.replace("%s", "{}"), errorMessageArgs);
}
} else {
Verify.verify(expression, errorMessageTemplate, errorMessageArgs);
}
}
@Override
public IntentEvent setState(Intent intent, IntentState state) {
......