mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-20 11:52:12 +02:00
Remove unused IntentStore write APIs.
All write operations now come through the batchWrite API. Change-Id: I982c5f785bf108dc2c9716db5ed744882d88aa55
This commit is contained in:
parent
acf410ba9d
commit
dac3008f5f
@ -55,23 +55,6 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> {
|
|||||||
*/
|
*/
|
||||||
IntentState getIntentState(IntentId intentId);
|
IntentState getIntentState(IntentId intentId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the state of the specified intent to the new state.
|
|
||||||
*
|
|
||||||
* @param intent intent whose state is to be changed
|
|
||||||
* @param newState new state
|
|
||||||
*/
|
|
||||||
void setState(Intent intent, IntentState newState);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the installable intents which resulted from compilation of the
|
|
||||||
* specified original intent.
|
|
||||||
*
|
|
||||||
* @param intentId original intent identifier
|
|
||||||
* @param installableIntents compiled installable intents
|
|
||||||
*/
|
|
||||||
void setInstallableIntents(IntentId intentId, List<Intent> installableIntents);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of the installable events associated with the specified
|
* Returns the list of the installable events associated with the specified
|
||||||
* original intent.
|
* original intent.
|
||||||
@ -81,14 +64,6 @@ public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> {
|
|||||||
*/
|
*/
|
||||||
List<Intent> getInstallableIntents(IntentId intentId);
|
List<Intent> getInstallableIntents(IntentId intentId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes any installable intents which resulted from compilation of the
|
|
||||||
* specified original intent.
|
|
||||||
*
|
|
||||||
* @param intentId original intent identifier
|
|
||||||
*/
|
|
||||||
void removeInstalledIntents(IntentId intentId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute writes in a batch.
|
* Execute writes in a batch.
|
||||||
* If the specified BatchWrite is empty, write will not be executed.
|
* If the specified BatchWrite is empty, write will not be executed.
|
||||||
|
@ -116,10 +116,7 @@ public class DistributedIntentStore
|
|||||||
// TODO make this configurable
|
// TODO make this configurable
|
||||||
private boolean onlyLogTransitionError = true;
|
private boolean onlyLogTransitionError = true;
|
||||||
|
|
||||||
private Timer setInstallableIntentsTimer;
|
|
||||||
private Timer getInstallableIntentsTimer;
|
private Timer getInstallableIntentsTimer;
|
||||||
private Timer removeInstalledIntentsTimer;
|
|
||||||
private Timer setStateTimer;
|
|
||||||
private Timer getIntentCountTimer;
|
private Timer getIntentCountTimer;
|
||||||
private Timer getIntentsTimer;
|
private Timer getIntentsTimer;
|
||||||
private Timer getIntentTimer;
|
private Timer getIntentTimer;
|
||||||
@ -132,10 +129,7 @@ public class DistributedIntentStore
|
|||||||
|
|
||||||
@Activate
|
@Activate
|
||||||
public void activate() {
|
public void activate() {
|
||||||
setInstallableIntentsTimer = createResponseTimer("setInstallableIntents");
|
|
||||||
getInstallableIntentsTimer = createResponseTimer("getInstallableIntents");
|
getInstallableIntentsTimer = createResponseTimer("getInstallableIntents");
|
||||||
removeInstalledIntentsTimer = createResponseTimer("removeInstalledIntents");
|
|
||||||
setStateTimer = createResponseTimer("setState");
|
|
||||||
getIntentCountTimer = createResponseTimer("getIntentCount");
|
getIntentCountTimer = createResponseTimer("getIntentCount");
|
||||||
getIntentsTimer = createResponseTimer("getIntents");
|
getIntentsTimer = createResponseTimer("getIntents");
|
||||||
getIntentTimer = createResponseTimer("getIntent");
|
getIntentTimer = createResponseTimer("getIntent");
|
||||||
@ -241,94 +235,6 @@ public class DistributedIntentStore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setState(Intent intent, IntentState state) {
|
|
||||||
Context timer = startTimer(setStateTimer);
|
|
||||||
try {
|
|
||||||
final IntentId id = intent.id();
|
|
||||||
IntentEvent.Type evtType = null;
|
|
||||||
final IntentState prevParking;
|
|
||||||
boolean transitionedToParking = true;
|
|
||||||
boolean updated;
|
|
||||||
|
|
||||||
// parking state transition
|
|
||||||
switch (state) {
|
|
||||||
case INSTALL_REQ:
|
|
||||||
prevParking = states.get(id);
|
|
||||||
if (prevParking == null) {
|
|
||||||
updated = states.putIfAbsent(id, INSTALL_REQ);
|
|
||||||
verify(updated, "Conditional replace %s => %s failed", prevParking, INSTALL_REQ);
|
|
||||||
} else {
|
|
||||||
verify(prevParking == WITHDRAWN,
|
|
||||||
"Illegal state transition attempted from %s to INSTALL_REQ",
|
|
||||||
prevParking);
|
|
||||||
updated = states.replace(id, prevParking, INSTALL_REQ);
|
|
||||||
verify(updated, "Conditional replace %s => %s failed", prevParking, INSTALL_REQ);
|
|
||||||
}
|
|
||||||
evtType = IntentEvent.Type.INSTALL_REQ;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INSTALLED:
|
|
||||||
prevParking = states.get(id);
|
|
||||||
verify(PRE_INSTALLED.contains(prevParking),
|
|
||||||
"Illegal state transition attempted from %s to INSTALLED",
|
|
||||||
prevParking);
|
|
||||||
updated = states.replace(id, prevParking, INSTALLED);
|
|
||||||
verify(updated, "Conditional replace %s => %s failed", prevParking, INSTALLED);
|
|
||||||
evtType = IntentEvent.Type.INSTALLED;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FAILED:
|
|
||||||
prevParking = states.get(id);
|
|
||||||
updated = states.replace(id, prevParking, FAILED);
|
|
||||||
verify(updated, "Conditional replace %s => %s failed", prevParking, FAILED);
|
|
||||||
evtType = IntentEvent.Type.FAILED;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WITHDRAWN:
|
|
||||||
prevParking = states.get(id);
|
|
||||||
verify(PRE_WITHDRAWN.contains(prevParking),
|
|
||||||
"Illegal state transition attempted from %s to WITHDRAWN",
|
|
||||||
prevParking);
|
|
||||||
updated = states.replace(id, prevParking, WITHDRAWN);
|
|
||||||
verify(updated, "Conditional replace %s => %s failed", prevParking, WITHDRAWN);
|
|
||||||
evtType = IntentEvent.Type.WITHDRAWN;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
transitionedToParking = false;
|
|
||||||
prevParking = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (transitionedToParking) {
|
|
||||||
log.debug("Parking State change: {} {}=>{}", id, prevParking, state);
|
|
||||||
// remove instance local state
|
|
||||||
transientStates.remove(id);
|
|
||||||
} else {
|
|
||||||
// Update instance local state, which includes non-parking state transition
|
|
||||||
final IntentState prevTransient = transientStates.put(id, state);
|
|
||||||
log.debug("Transient State change: {} {}=>{}", id, prevTransient, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (evtType != null) {
|
|
||||||
notifyDelegate(new IntentEvent(evtType, intent));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} finally {
|
|
||||||
stopTimer(timer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInstallableIntents(IntentId intentId, List<Intent> result) {
|
|
||||||
Context timer = startTimer(setInstallableIntentsTimer);
|
|
||||||
try {
|
|
||||||
installable.put(intentId, result);
|
|
||||||
} finally {
|
|
||||||
stopTimer(timer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Intent> getInstallableIntents(IntentId intentId) {
|
public List<Intent> getInstallableIntents(IntentId intentId) {
|
||||||
Context timer = startTimer(getInstallableIntentsTimer);
|
Context timer = startTimer(getInstallableIntentsTimer);
|
||||||
@ -339,16 +245,6 @@ public class DistributedIntentStore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeInstalledIntents(IntentId intentId) {
|
|
||||||
Context timer = startTimer(removeInstalledIntentsTimer);
|
|
||||||
try {
|
|
||||||
installable.remove(intentId);
|
|
||||||
} finally {
|
|
||||||
stopTimer(timer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String strIntentId(IntentId key) {
|
protected String strIntentId(IntentId key) {
|
||||||
return keyCache.getUnchecked(key);
|
return keyCache.getUnchecked(key);
|
||||||
}
|
}
|
||||||
|
@ -186,11 +186,6 @@ public class GossipIntentStore
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setState(Intent intent, IntentState newState) {
|
|
||||||
// TODO implement
|
|
||||||
}
|
|
||||||
|
|
||||||
private IntentEvent setStateInternal(IntentId intentId, IntentState newState, Timestamp timestamp) {
|
private IntentEvent setStateInternal(IntentId intentId, IntentState newState, Timestamp timestamp) {
|
||||||
switch (newState) {
|
switch (newState) {
|
||||||
case WITHDRAW_REQ:
|
case WITHDRAW_REQ:
|
||||||
@ -225,12 +220,6 @@ public class GossipIntentStore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInstallableIntents(IntentId intentId,
|
|
||||||
List<Intent> installableIntents) {
|
|
||||||
// TODO implement
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setInstallableIntentsInternal(IntentId intentId,
|
private void setInstallableIntentsInternal(IntentId intentId,
|
||||||
List<Intent> installableIntents,
|
List<Intent> installableIntents,
|
||||||
Timestamp timestamp) {
|
Timestamp timestamp) {
|
||||||
@ -252,11 +241,6 @@ public class GossipIntentStore
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeInstalledIntents(IntentId intentId) {
|
|
||||||
// TODO implement
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BatchWrite.Operation> batchWrite(BatchWrite batch) {
|
public List<BatchWrite.Operation> batchWrite(BatchWrite batch) {
|
||||||
|
|
||||||
|
@ -101,10 +101,7 @@ public class HazelcastIntentStore
|
|||||||
|
|
||||||
private boolean onlyLogTransitionError = true;
|
private boolean onlyLogTransitionError = true;
|
||||||
|
|
||||||
private Timer setInstallableIntentsTimer;
|
|
||||||
private Timer getInstallableIntentsTimer;
|
private Timer getInstallableIntentsTimer;
|
||||||
private Timer removeInstalledIntentsTimer;
|
|
||||||
private Timer setStateTimer;
|
|
||||||
private Timer getIntentCountTimer;
|
private Timer getIntentCountTimer;
|
||||||
private Timer getIntentsTimer;
|
private Timer getIntentsTimer;
|
||||||
private Timer getIntentTimer;
|
private Timer getIntentTimer;
|
||||||
@ -128,10 +125,7 @@ public class HazelcastIntentStore
|
|||||||
public void activate() {
|
public void activate() {
|
||||||
localIntents = new ConcurrentHashMap<>();
|
localIntents = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
setInstallableIntentsTimer = createResponseTimer("setInstallableIntents");
|
|
||||||
getInstallableIntentsTimer = createResponseTimer("getInstallableIntents");
|
getInstallableIntentsTimer = createResponseTimer("getInstallableIntents");
|
||||||
removeInstalledIntentsTimer = createResponseTimer("removeInstalledIntents");
|
|
||||||
setStateTimer = createResponseTimer("setState");
|
|
||||||
getIntentCountTimer = createResponseTimer("getIntentCount");
|
getIntentCountTimer = createResponseTimer("getIntentCount");
|
||||||
getIntentsTimer = createResponseTimer("getIntents");
|
getIntentsTimer = createResponseTimer("getIntents");
|
||||||
getIntentTimer = createResponseTimer("getIntent");
|
getIntentTimer = createResponseTimer("getIntent");
|
||||||
@ -256,86 +250,6 @@ public class HazelcastIntentStore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setState(Intent intent, IntentState state) {
|
|
||||||
Context timer = startTimer(setStateTimer);
|
|
||||||
try {
|
|
||||||
final IntentId id = intent.id();
|
|
||||||
IntentEvent.Type type = null;
|
|
||||||
final IntentState prevParking;
|
|
||||||
boolean transientStateChangeOnly = false;
|
|
||||||
|
|
||||||
// parking state transition
|
|
||||||
switch (state) {
|
|
||||||
case INSTALL_REQ:
|
|
||||||
prevParking = states.get(id);
|
|
||||||
if (prevParking == null) {
|
|
||||||
IntentState existing = states.putIfAbsent(id, INSTALL_REQ);
|
|
||||||
verify(existing == null, "Conditional replace %s => %s failed", prevParking, INSTALL_REQ);
|
|
||||||
} else {
|
|
||||||
verify(PRE_INSTALLED.contains(prevParking),
|
|
||||||
"Illegal state transition attempted from %s to INSTALL_REQ",
|
|
||||||
prevParking);
|
|
||||||
boolean updated = states.replace(id, prevParking, INSTALL_REQ);
|
|
||||||
verify(updated, "Conditional replace %s => %s failed", prevParking, INSTALL_REQ);
|
|
||||||
}
|
|
||||||
type = IntentEvent.Type.INSTALL_REQ;
|
|
||||||
break;
|
|
||||||
case INSTALLED:
|
|
||||||
prevParking = states.replace(id, INSTALLED);
|
|
||||||
verify(prevParking == INSTALL_REQ,
|
|
||||||
"Illegal state transition attempted from %s to INSTALLED",
|
|
||||||
prevParking);
|
|
||||||
type = IntentEvent.Type.INSTALLED;
|
|
||||||
break;
|
|
||||||
case FAILED:
|
|
||||||
prevParking = states.replace(id, FAILED);
|
|
||||||
type = IntentEvent.Type.FAILED;
|
|
||||||
break;
|
|
||||||
case WITHDRAW_REQ:
|
|
||||||
prevParking = states.replace(id, WITHDRAW_REQ);
|
|
||||||
verify(PRE_WITHDRAWN.contains(prevParking),
|
|
||||||
"Illegal state transition attempted from %s to WITHDRAW_REQ",
|
|
||||||
prevParking);
|
|
||||||
type = IntentEvent.Type.WITHDRAW_REQ;
|
|
||||||
break;
|
|
||||||
case WITHDRAWN:
|
|
||||||
prevParking = states.replace(id, WITHDRAWN);
|
|
||||||
verify(prevParking == WITHDRAW_REQ,
|
|
||||||
"Illegal state transition attempted from %s to WITHDRAWN",
|
|
||||||
prevParking);
|
|
||||||
type = IntentEvent.Type.WITHDRAWN;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
transientStateChangeOnly = true;
|
|
||||||
prevParking = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!transientStateChangeOnly) {
|
|
||||||
log.debug("Parking State change: {} {}=>{}", id, prevParking, state);
|
|
||||||
}
|
|
||||||
// Update instance local state, which includes non-parking state transition
|
|
||||||
final IntentState prevTransient = transientStates.put(id, state);
|
|
||||||
log.debug("Transient State change: {} {}=>{}", id, prevTransient, state);
|
|
||||||
|
|
||||||
if (type != null) {
|
|
||||||
notifyDelegate(new IntentEvent(type, intent));
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
stopTimer(timer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInstallableIntents(IntentId intentId, List<Intent> result) {
|
|
||||||
Context timer = startTimer(setInstallableIntentsTimer);
|
|
||||||
try {
|
|
||||||
installable.put(intentId, result);
|
|
||||||
} finally {
|
|
||||||
stopTimer(timer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Intent> getInstallableIntents(IntentId intentId) {
|
public List<Intent> getInstallableIntents(IntentId intentId) {
|
||||||
Context timer = startTimer(getInstallableIntentsTimer);
|
Context timer = startTimer(getInstallableIntentsTimer);
|
||||||
@ -346,16 +260,6 @@ public class HazelcastIntentStore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeInstalledIntents(IntentId intentId) {
|
|
||||||
Context timer = startTimer(removeInstalledIntentsTimer);
|
|
||||||
try {
|
|
||||||
installable.remove(intentId);
|
|
||||||
} finally {
|
|
||||||
stopTimer(timer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Operation> batchWrite(BatchWrite batch) {
|
public List<Operation> batchWrite(BatchWrite batch) {
|
||||||
if (batch.isEmpty()) {
|
if (batch.isEmpty()) {
|
||||||
|
@ -101,8 +101,7 @@ public class SimpleIntentStore
|
|||||||
return states.get(id);
|
return states.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void setState(Intent intent, IntentState state) {
|
||||||
public void setState(Intent intent, IntentState state) {
|
|
||||||
IntentId id = intent.id();
|
IntentId id = intent.id();
|
||||||
states.put(id, state);
|
states.put(id, state);
|
||||||
IntentEvent.Type type = null;
|
IntentEvent.Type type = null;
|
||||||
@ -131,8 +130,7 @@ public class SimpleIntentStore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void setInstallableIntents(IntentId intentId, List<Intent> result) {
|
||||||
public void setInstallableIntents(IntentId intentId, List<Intent> result) {
|
|
||||||
installable.put(intentId, result);
|
installable.put(intentId, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,10 +139,10 @@ public class SimpleIntentStore
|
|||||||
return installable.get(intentId);
|
return installable.get(intentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void removeInstalledIntents(IntentId intentId) {
|
||||||
public void removeInstalledIntents(IntentId intentId) {
|
|
||||||
installable.remove(intentId);
|
installable.remove(intentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute writes in a batch.
|
* Execute writes in a batch.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user