finished STM and persistence test for Ref, Vector, Map + implemented STM for Ref
This commit is contained in:
parent
f3ac665274
commit
795c7b3da0
8 changed files with 503 additions and 180 deletions
|
|
@ -5,46 +5,54 @@ import se.scalablesolutions.akka.annotation.transactional;
|
|||
import se.scalablesolutions.akka.annotation.state;
|
||||
|
||||
public class PersistentStateful {
|
||||
private TransactionalMap mapState = new CassandraPersistentTransactionalMap(this);
|
||||
private TransactionalVector vectorState = new CassandraPersistentTransactionalVector(this);
|
||||
//private TransactionalRef refState = new CassandraPersistentTransactionalRef(this);
|
||||
private TransactionalMap mapState = new CassandraPersistentTransactionalMap();
|
||||
private TransactionalVector vectorState = new CassandraPersistentTransactionalVector();
|
||||
private TransactionalRef refState = new CassandraPersistentTransactionalRef();
|
||||
|
||||
@transactional
|
||||
public String getMapState(String key) {
|
||||
return (String) mapState.get(key).get();
|
||||
}
|
||||
|
||||
public String getVectorState() {
|
||||
return (String) vectorState.first();
|
||||
@transactional
|
||||
public String getVectorState(int index) {
|
||||
return (String) vectorState.get(index);
|
||||
}
|
||||
|
||||
// public String getRefState() {
|
||||
// return (String) refState.get().get();
|
||||
// }
|
||||
@transactional
|
||||
public String getRefState() {
|
||||
if (refState.isDefined()) {
|
||||
return (String) refState.get().get();
|
||||
} else throw new IllegalStateException("No such element");
|
||||
}
|
||||
|
||||
@transactional
|
||||
public void setMapState(String key, String msg) {
|
||||
mapState.put(key, msg);
|
||||
}
|
||||
|
||||
@transactional
|
||||
public void setVectorState(String msg) {
|
||||
vectorState.add(msg);
|
||||
}
|
||||
|
||||
// public void setRefState(String msg) {
|
||||
// refState.swap(msg);
|
||||
// }
|
||||
@transactional
|
||||
public void setRefState(String msg) {
|
||||
refState.swap(msg);
|
||||
}
|
||||
|
||||
@transactional
|
||||
public void success(String key, String msg) {
|
||||
mapState.put(key, msg);
|
||||
vectorState.add(msg);
|
||||
// refState.swap(msg);
|
||||
refState.swap(msg);
|
||||
}
|
||||
|
||||
@transactional
|
||||
public void failure(String key, String msg, PersistentFailer failer) {
|
||||
mapState.put(key, msg);
|
||||
vectorState.add(msg);
|
||||
// refState.swap(msg);
|
||||
refState.swap(msg);
|
||||
failer.fail();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue