diff --git a/akka.iml b/akka.iml index d26ed1fee1..5695410d8b 100755 --- a/akka.iml +++ b/akka.iml @@ -8,12 +8,12 @@ - + diff --git a/akka.ipr b/akka.ipr index 36e92c08a2..5a6b3cb3fe 100755 --- a/akka.ipr +++ b/akka.ipr @@ -2,6 +2,14 @@ + + + + + + + + - + + + + + + + + @@ -242,6 +257,7 @@ + diff --git a/akka.iws b/akka.iws index 0a35525542..7a296d33b2 100755 --- a/akka.iws +++ b/akka.iws @@ -2,38 +2,27 @@ - - - - - - - - - - - - - - - - + - - + + + + + + + - - - - - - - - + + + + + + + @@ -53,34 +42,6 @@ - - - - - - @@ -138,19 +99,73 @@ - - + + - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -159,54 +174,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -223,6 +191,9 @@ + + + @@ -234,78 +205,215 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - - - - + + + + - + + + + - - + + + + + + - + + - + + + + + + + + + - - - - - - - - - + + + + + + + + + + - + + + + + - - + + + + + localhost @@ -431,12 +558,12 @@ - + - + @@ -444,16 +571,16 @@ - + - - + + - + - + - + @@ -490,119 +617,113 @@ - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + - + + + + + + + + + + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - - - - + + diff --git a/api-java/api-java.iml b/api-java/api-java.iml index d6de3dcf6c..49b8e78ddc 100755 --- a/api-java/api-java.iml +++ b/api-java/api-java.iml @@ -8,9 +8,18 @@ - - - + + + + + + + + + + + + @@ -19,7 +28,7 @@ - + @@ -31,7 +40,7 @@ - + diff --git a/api-java/src/main/java/se/scalablesolutions/akka/api/ActiveObjectGuiceConfigurator.java b/api-java/src/main/java/se/scalablesolutions/akka/api/ActiveObjectGuiceConfigurator.java index fb4136da3b..88200cb51f 100755 --- a/api-java/src/main/java/se/scalablesolutions/akka/api/ActiveObjectGuiceConfigurator.java +++ b/api-java/src/main/java/se/scalablesolutions/akka/api/ActiveObjectGuiceConfigurator.java @@ -12,7 +12,6 @@ import se.scalablesolutions.akka.kernel.ActiveObjectFactory; import se.scalablesolutions.akka.kernel.ActiveObjectProxy; import se.scalablesolutions.akka.kernel.Supervisor; import se.scalablesolutions.akka.kernel.Worker; -import se.scalablesolutions.akka.kernel.TransientStringState; import java.util.List; import java.util.ArrayList; @@ -56,7 +55,6 @@ public class ActiveObjectGuiceConfigurator { this.components = components; modules.add(new AbstractModule() { protected void configure() { - bind(TransientStringState.class); bind(ResourceProviderFactory.class); for (int i = 0; i < components.length; i++) { Component c = components[i]; diff --git a/api-java/src/test/java/se/scalablesolutions/akka/api/ActiveObjectGuiceConfiguratorTest.java b/api-java/src/test/java/se/scalablesolutions/akka/api/ActiveObjectGuiceConfiguratorTest.java index de6327a3c9..89e2bab034 100755 --- a/api-java/src/test/java/se/scalablesolutions/akka/api/ActiveObjectGuiceConfiguratorTest.java +++ b/api-java/src/test/java/se/scalablesolutions/akka/api/ActiveObjectGuiceConfiguratorTest.java @@ -6,7 +6,6 @@ package se.scalablesolutions.akka.api; import se.scalablesolutions.akka.annotation.*; import se.scalablesolutions.akka.kernel.configuration.*; -import se.scalablesolutions.akka.kernel.TransientObjectState; import com.google.inject.Inject; import com.google.inject.AbstractModule; @@ -35,22 +34,7 @@ public class ActiveObjectGuiceConfiguratorTest extends TestCase { Bar.class, BarImpl.class, new LifeCycle(new Permanent(), 1000), - 1000), - new Component( - Stateful.class, - StatefulImpl.class, - new LifeCycle(new Permanent(), 1000), - 10000000), - new Component( - Failer.class, - FailerImpl.class, - new LifeCycle(new Permanent(), 1000), - 1000), - new Component( - Clasher.class, - ClasherImpl.class, - new LifeCycle(new Permanent(), 1000), - 100000) + 1000) }).inject().supervise(); } @@ -119,180 +103,58 @@ public class ActiveObjectGuiceConfiguratorTest extends TestCase { } catch (RuntimeException e) { } } -// -// public void testShouldNotRollbackStateForStatefulServerInCaseOfSuccess() { -// Stateful stateful = conf.getActiveObject(Stateful.class); -// stateful.setState("stateful", "init"); // set init state -// stateful.success("stateful", "new state"); // transactional -// assertEquals("new state", stateful.getState("stateful")); -// } -// -// public void testShouldRollbackStateForStatefulServerInCaseOfFailure() { -// Stateful stateful = conf.getActiveObject(Stateful.class); -// stateful.setState("stateful", "init"); // set init state -// -// Failer failer = conf.getActiveObject(Failer.class); -// try { -// stateful.failure("stateful", "new state", failer); // call failing transactional method -// fail("should have thrown an exception"); -// } catch (RuntimeException e) { } // expected -// assertEquals("init", stateful.getState("stateful")); // check that state is == init state -// } - public void testShouldRollbackStateForStatefulServerInCaseOfMessageClash() { - Stateful stateful = conf.getActiveObject(Stateful.class); - stateful.setState("stateful", "init"); // set init state - - Clasher clasher = conf.getActiveObject(Clasher.class); - clasher.setState("clasher", "init"); // set init state - -// try { -// stateful.clashOk("stateful", "new state", clasher); -// } catch (RuntimeException e) { } // expected -// assertEquals("new state", stateful.getState("stateful")); // check that state is == init state -// assertEquals("was here", clasher.getState("clasher")); // check that state is == init state - - try { - stateful.clashNotOk("stateful", "new state", clasher); - fail("should have thrown an exception"); - } catch (RuntimeException e) { System.out.println(e); } // expected - assertEquals("init", stateful.getState("stateful")); // check that state is == init state - //assertEquals("init", clasher.getState("clasher")); // check that state is == init state + interface Foo { + public String foo(String msg); + @oneway public void bar(String msg); + public void longRunning(); + public void throwsException(); + public Bar getBar(); } -} -// ============== TEST SERVICES =============== - -interface Foo { - public String foo(String msg); - @oneway public void bar(String msg); - public void longRunning(); - public void throwsException(); - public Bar getBar(); -} - -class FooImpl implements Foo { - @Inject private Bar bar; - public Bar getBar() { - return bar; - } - public String foo(String msg) { - return msg + "return_foo "; - } - public void bar(String msg) { - bar.bar(msg); - } - public void longRunning() { - try { - Thread.sleep(10000); - } catch (InterruptedException e) { + class FooImpl implements Foo { + @Inject private Bar bar; + public Bar getBar() { + return bar; } - } - public void throwsException() { - throw new RuntimeException("expected"); - } -} - -interface Bar { - @oneway void bar(String msg); - Ext getExt(); -} - -class BarImpl implements Bar { - @Inject private Ext ext; - public Ext getExt() { - return ext; - } - public void bar(String msg) { - } -} - -interface Ext { - void ext(); -} - -class ExtImpl implements Ext { - public void ext() { - } -} - -interface Stateful { - // transactional - @transactional public void success(String key, String msg); - @transactional public void failure(String key, String msg, Failer failer); - @transactional public void clashOk(String key, String msg, Clasher clasher); - @transactional public void clashNotOk(String key, String msg, Clasher clasher); - - // non-transactional - public String getState(String key); - public void setState(String key, String value); -} - -class StatefulImpl implements Stateful { - @state private TransientObjectState state = new TransientObjectState(); - public String getState(String key) { - return (String)state.get(key); - } - public void setState(String key, String msg) { - state.put(key, msg); - } - public void success(String key, String msg) { - state.put(key, msg); - } - public void failure(String key, String msg, Failer failer) { - state.put(key, msg); - failer.fail(); - } - public void clashOk(String key, String msg, Clasher clasher) { - state.put(key, msg); - clasher.clash(); - } - public void clashNotOk(String key, String msg, Clasher clasher) { - state.put(key, msg); - clasher.clash(); - clasher.clash(); - } -} - -interface Failer { - public void fail(); -} - -class FailerImpl implements Failer { - public void fail() { - throw new RuntimeException("expected"); - } -} - -interface Clasher { - public void clash(); - public String getState(String key); - public void setState(String key, String value); -} - -class ClasherImpl implements Clasher { - @state private TransientObjectState state = new TransientObjectState(); - public String getState(String key) { - return (String)state.get(key); - } - public void setState(String key, String msg) { - state.put(key, msg); - } - public void clash() { - state.put("clasher", "was here"); - // spend some time here - for (long i = 0; i < 1000000000; i++) { - for (long j = 0; j < 10000000; j++) { - j += i; + public String foo(String msg) { + return msg + "return_foo "; + } + public void bar(String msg) { + bar.bar(msg); + } + public void longRunning() { + try { + Thread.sleep(10000); + } catch (InterruptedException e) { } } + public void throwsException() { + throw new RuntimeException("expected"); + } + } - // FIXME: this statement gives me this error: - // se.scalablesolutions.akka.kernel.ActiveObjectException: - // Unexpected message [!(scala.actors.Channel@c2b2f6,ErrRef[Right(null)])] to - // [GenericServer[se.scalablesolutions.akka.api.StatefulImpl]] from - // [GenericServer[se.scalablesolutions.akka.api.ClasherImpl]]] - //try { Thread.sleep(1000); } catch (InterruptedException e) {} + interface Bar { + @oneway void bar(String msg); + Ext getExt(); + } + + class BarImpl implements Bar { + @Inject private Ext ext; + public Ext getExt() { + return ext; + } + public void bar(String msg) { + } + } + + interface Ext { + void ext(); + } + + class ExtImpl implements Ext { + public void ext() { + } } } diff --git a/api-java/src/test/java/se/scalablesolutions/akka/api/InMemoryStateTest.java b/api-java/src/test/java/se/scalablesolutions/akka/api/InMemoryStateTest.java new file mode 100755 index 0000000000..39e5c21333 --- /dev/null +++ b/api-java/src/test/java/se/scalablesolutions/akka/api/InMemoryStateTest.java @@ -0,0 +1,192 @@ +/** + * Copyright (C) 2009 Scalable Solutions. + */ + +package se.scalablesolutions.akka.api; + +import se.scalablesolutions.akka.annotation.*; +import se.scalablesolutions.akka.kernel.configuration.*; +import se.scalablesolutions.akka.kernel.InMemoryState; + +import com.google.inject.Inject; +import com.google.inject.AbstractModule; +import com.google.inject.Scopes; + +import junit.framework.TestCase; + + +public class InMemoryStateTest extends TestCase { + static String messageLog = ""; + + final private ActiveObjectGuiceConfigurator conf = new ActiveObjectGuiceConfigurator(); + + protected void setUp() { + conf.configureActiveObjects( + new RestartStrategy(new AllForOne(), 3, 5000), new Component[]{ + new Component( + Stateful.class, + StatefulImpl.class, + new LifeCycle(new Permanent(), 1000), + 10000000), + new Component( + Failer.class, + FailerImpl.class, + new LifeCycle(new Permanent(), 1000), + 1000), + new Component( + Clasher.class, + ClasherImpl.class, + new LifeCycle(new Permanent(), 1000), + 100000) + }).inject().supervise(); + + } + +// public void testShouldNotRollbackStateForStatefulServerInCaseOfSuccess() { +// Stateful stateful = conf.getActiveObject(Stateful.class); +// stateful.setState("stateful", "init"); // set init state +// stateful.success("stateful", "new state"); // transactional +// assertEquals("new state", stateful.getState("stateful")); +// } +// +// public void testShouldRollbackStateForStatefulServerInCaseOfFailure() { +// Stateful stateful = conf.getActiveObject(Stateful.class); +// stateful.setState("stateful", "init"); // set init state +// +// Failer failer = conf.getActiveObject(Failer.class); +// try { +// stateful.failure("stateful", "new state", failer); // call failing transactional method +// fail("should have thrown an exception"); +// } catch (RuntimeException e) { } // expected +// assertEquals("init", stateful.getState("stateful")); // check that state is == init state +// } + + public void testShouldRollbackStateForStatefulServerInCaseOfMessageClash() { + Stateful stateful = conf.getActiveObject(Stateful.class); + stateful.setState("stateful", "init"); // set init state + + Clasher clasher = conf.getActiveObject(Clasher.class); + clasher.setState("clasher", "init"); // set init state + +// try { +// stateful.clashOk("stateful", "new state", clasher); +// } catch (RuntimeException e) { } // expected +// assertEquals("new state", stateful.getState("stateful")); // check that state is == init state +// assertEquals("was here", clasher.getState("clasher")); // check that state is == init state + + try { + stateful.clashNotOk("stateful", "new state", clasher); + fail("should have thrown an exception"); + } catch (RuntimeException e) { + System.out.println(e); + } // expected + assertEquals("init", stateful.getState("stateful")); // check that state is == init state + //assertEquals("init", clasher.getState("clasher")); // check that state is == init state + } + + + interface Stateful { + // transactional + @transactional + public void success(String key, String msg); + + @transactional + public void failure(String key, String msg, Failer failer); + + @transactional + public void clashOk(String key, String msg, Clasher clasher); + + @transactional + public void clashNotOk(String key, String msg, Clasher clasher); + + // non-transactional + public String getState(String key); + + public void setState(String key, String value); + } + + class StatefulImpl implements Stateful { + @state + private + InMemoryState state = new InMemoryState(); + + public String getState(String key) { + return (String) state.get(key); + } + + public void setState(String key, String msg) { + state.put(key, msg); + } + + public void success(String key, String msg) { + state.put(key, msg); + } + + public void failure(String key, String msg, Failer failer) { + state.put(key, msg); + failer.fail(); + } + + public void clashOk(String key, String msg, Clasher clasher) { + state.put(key, msg); + clasher.clash(); + } + + public void clashNotOk(String key, String msg, Clasher clasher) { + state.put(key, msg); + clasher.clash(); + clasher.clash(); + } + } + + interface Failer { + public void fail(); + } + + class FailerImpl implements Failer { + public void fail() { + throw new RuntimeException("expected"); + } + } + + interface Clasher { + public void clash(); + + public String getState(String key); + + public void setState(String key, String value); + } + + class ClasherImpl implements Clasher { + @state + private InMemoryState state = new InMemoryState(); + + public String getState(String key) { + return (String) state.get(key); + } + + public void setState(String key, String msg) { + state.put(key, msg); + } + + public void clash() { + state.put("clasher", "was here"); + // spend some time here + for (long i = 0; i < 1000000000; i++) { + for (long j = 0; j < 10000000; j++) { + j += i; + } + } + + // FIXME: this statement gives me this error: + // se.scalablesolutions.akka.kernel.ActiveObjectException: + // Unexpected message [!(scala.actors.Channel@c2b2f6,ErrRef[Right(null)])] to + // [GenericServer[se.scalablesolutions.akka.api.StatefulImpl]] from + // [GenericServer[se.scalablesolutions.akka.api.ClasherImpl]]] + //try { Thread.sleep(1000); } catch (InterruptedException e) {} + } + } +} + + + diff --git a/api-java/src/test/java/se/scalablesolutions/akka/api/PersistentStateTest.java b/api-java/src/test/java/se/scalablesolutions/akka/api/PersistentStateTest.java new file mode 100755 index 0000000000..d70ee70049 --- /dev/null +++ b/api-java/src/test/java/se/scalablesolutions/akka/api/PersistentStateTest.java @@ -0,0 +1,152 @@ +/** + * Copyright (C) 2009 Scalable Solutions. + */ + +package se.scalablesolutions.akka.api; + +import se.scalablesolutions.akka.annotation.*; +import se.scalablesolutions.akka.kernel.configuration.*; +import se.scalablesolutions.akka.kernel.InMemoryState; + +import com.google.inject.Inject; +import com.google.inject.AbstractModule; +import com.google.inject.Scopes; + +import junit.framework.TestCase; + + +public class PersistentStateTest extends TestCase { + static String messageLog = ""; + + final private ActiveObjectGuiceConfigurator conf = new ActiveObjectGuiceConfigurator(); + + protected void setUp() { + conf.configureActiveObjects( + new RestartStrategy(new AllForOne(), 3, 5000), new Component[]{ + new Component( + Stateful.class, + StatefulImpl.class, + new LifeCycle(new Permanent(), 1000), + 10000000), + new Component( + Failer.class, + FailerImpl.class, + new LifeCycle(new Permanent(), 1000), + 1000), + new Component( + Clasher.class, + ClasherImpl.class, + new LifeCycle(new Permanent(), 1000), + 100000) + }).inject().supervise(); + + } + + public void testShouldNotRollbackStateForStatefulServerInCaseOfSuccess() { + Stateful stateful = conf.getActiveObject(Stateful.class); + stateful.setState("stateful", "init"); // set init state + stateful.success("stateful", "new state"); // transactional + assertEquals("new state", stateful.getState("stateful")); + } + + interface Stateful { + // transactional + @transactional + public void success(String key, String msg); + + @transactional + public void failure(String key, String msg, Failer failer); + + @transactional + public void clashOk(String key, String msg, Clasher clasher); + + @transactional + public void clashNotOk(String key, String msg, Clasher clasher); + + // non-transactional + public String getState(String key); + + public void setState(String key, String value); + } + + class StatefulImpl implements Stateful { + @state + private InMemoryState state = new InMemoryState(); + + public String getState(String key) { + return (String) state.get(key); + } + + public void setState(String key, String msg) { + state.put(key, msg); + } + + public void success(String key, String msg) { + state.put(key, msg); + } + + public void failure(String key, String msg, Failer failer) { + state.put(key, msg); + failer.fail(); + } + + public void clashOk(String key, String msg, Clasher clasher) { + state.put(key, msg); + clasher.clash(); + } + + public void clashNotOk(String key, String msg, Clasher clasher) { + state.put(key, msg); + clasher.clash(); + clasher.clash(); + } + } + + interface Failer { + public void fail(); + } + + class FailerImpl implements Failer { + public void fail() { + throw new RuntimeException("expected"); + } + } + + interface Clasher { + public void clash(); + + public String getState(String key); + + public void setState(String key, String value); + } + + class ClasherImpl implements Clasher { + @state + private InMemoryState state = new InMemoryState(); + + public String getState(String key) { + return (String) state.get(key); + } + + public void setState(String key, String msg) { + state.put(key, msg); + } + + public void clash() { + state.put("clasher", "was here"); + // spend some time here + for (long i = 0; i < 1000000000; i++) { + for (long j = 0; j < 10000000; j++) { + j += i; + } + } + + // FIXME: this statement gives me this error: + // se.scalablesolutions.akka.kernel.ActiveObjectException: + // Unexpected message [!(scala.actors.Channel@c2b2f6,ErrRef[Right(null)])] to + // [GenericServer[se.scalablesolutions.akka.api.StatefulImpl]] from + // [GenericServer[se.scalablesolutions.akka.api.ClasherImpl]]] + //try { Thread.sleep(1000); } catch (InterruptedException e) {} + } + } +} \ No newline at end of file diff --git a/bin/start-akka-server.sh b/bin/start-akka-server.sh old mode 100644 new mode 100755 index d16f9a1bdb..cb079b69fd --- a/bin/start-akka-server.sh +++ b/bin/start-akka-server.sh @@ -6,11 +6,37 @@ then exit 1 fi -base_dir=$(dirname $0)/.. +BASE_DIR=$(dirname $0)/.. -for file in $base_dir/lib/*.jar; +echo 'Starting Akka Kernel from directory' $BASE_DIR + +for FILE in $BASE_DIR/lib/*.jar; do - CLASSPATH=$CLASSPATH:$file + CLASSPATH=$CLASSPATH:$FILE done +CLASSPATH=$CLASSPATH:$BASE_DIR/config +CLASSPATH=$CLASSPATH:$BASE_DIR/kernel/build/classes -java -Xmx1G -server -cp $CLASSPATH -Dcom.sun.management.jmxremote com.scalablesolutions.akka.Boot com.scalablesolutions.akka.kernel.Kernel ${1} +STORAGE_OPTS=" \ + -Dcassandra \ + -Dstorage-config=$BASE_DIR/config/storage-conf.xml" + +JVM_OPTS=" \ + -server \ + -Xdebug \ + -Xrunjdwp:transport=dt_socket,server=y,address=8888,suspend=n \ + -Xms128M \ + -Xmx1G \ + -XX:SurvivorRatio=8 \ + -XX:TargetSurvivorRatio=90 \ + -XX:+AggressiveOpts \ + -XX:+UseParNewGC \ + -XX:+UseConcMarkSweepGC \ + -XX:CMSInitiatingOccupancyFraction=1 \ + -XX:+CMSParallelRemarkEnabled \ + -XX:+HeapDumpOnOutOfMemoryError \ + -Dcom.sun.management.jmxremote.port=8080 \ + -Dcom.sun.management.jmxremote.ssl=false \ + -Dcom.sun.management.jmxremote.authenticate=false" + +java $JVM_OPTS $STORAGE_OPTS -cp $CLASSPATH se.scalablesolutions.akka.Boot se.scalablesolutions.akka.kernel.Kernel ${1} diff --git a/config/cluster.xml b/config/cluster.xml deleted file mode 100644 index 611d46a681..0000000000 --- a/config/cluster.xml +++ /dev/null @@ -1,10 +0,0 @@ - - akka - - 0 - localhost - 8081 - 6666 - 0, 1 - - diff --git a/config/log4j.properties b/config/log4j.properties new file mode 100755 index 0000000000..c03de259b2 --- /dev/null +++ b/config/log4j.properties @@ -0,0 +1,22 @@ +# for production, you should probably set the root to INFO +# and the pattern to %c instead of %l. (%l is slower.) + +# output messages into a rolling log file as well as stdout +log4j.rootLogger=DEBUG,stdout,R + +# stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout + +# rolling log file ("system.log +log4j.appender.R=org.apache.log4j.DailyRollingFileAppender +log4j.appender.R.DatePattern='.'yyyy-MM-dd-HH +log4j.appender.R.layout=org.apache.log4j.PatternLayout +log4j.appender.R.layout.ConversionPattern=%5p [%t] %d{ISO8601} %F (line %L) %m%n +# Edit the next line to point to your logs directory +log4j.appender.R.File=/var/cassandra/logs/system.log + +# Application logging options +#log4j.logger.com.facebook=DEBUG +#log4j.logger.com.facebook.infrastructure.gms=DEBUG +#log4j.logger.com.facebook.infrastructure.db=DEBUG diff --git a/config/server.properties b/config/server.properties deleted file mode 100644 index 52111f7888..0000000000 --- a/config/server.properties +++ /dev/null @@ -1,24 +0,0 @@ -# The ID of *this* particular cluster node -node.id=0 - -max.threads=100 - -############### DB options ###################### - -http.enable=true -socket.enable=true - -# BDB -bdb.sync.transactions=false -bdb.cache.size=100MB - -# Mysql -mysql.host=localhost -mysql.port=1521 -mysql.user=root -mysql.password=3306 -mysql.database=test - -#ReadOnly -enable.readonly.engine=true - diff --git a/config/storage-conf.xml b/config/storage-conf.xml new file mode 100755 index 0000000000..88bfa99c16 --- /dev/null +++ b/config/storage-conf.xml @@ -0,0 +1,45 @@ + + akka + + org.apache.cassandra.dht.RandomPartitioner + false + 230.0.0.1 + 1 + 127.0.0.1 + 5000 + + 7000 + 7001 + 9160 + 256 + 7002 + ./storage/system + ./storage/commitlog + 128 + + 127.0.0.1:12000 + + + ./storage/data + + ./storage/callouts + ./storage/bootstrap + ./storage/staging + false + + + + +
+
+ + + 127.0.0.1 + +
diff --git a/config/stores.xml b/config/stores.xml deleted file mode 100644 index 393e6b69d2..0000000000 --- a/config/stores.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - actors - bdb - client - 1 - 1 - 1 - - json - "string" - - - json - "string" - - - diff --git a/kernel/kernel.iml b/kernel/kernel.iml index 3468b93952..5e8568e938 100755 --- a/kernel/kernel.iml +++ b/kernel/kernel.iml @@ -14,10 +14,56 @@ + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -35,7 +81,16 @@ - + + + + + + + + + + @@ -50,6 +105,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -62,7 +207,115 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -80,7 +333,106 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -107,70 +459,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -188,7 +477,7 @@ - + @@ -197,295 +486,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -503,7 +504,7 @@ - + @@ -512,7 +513,7 @@ - + @@ -521,7 +522,7 @@ - + @@ -530,7 +531,52 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -548,13 +594,84 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -
diff --git a/kernel/nbproject/project.properties b/kernel/nbproject/project.properties index 3eb244b3ed..2ab8028fef 100644 --- a/kernel/nbproject/project.properties +++ b/kernel/nbproject/project.properties @@ -20,18 +20,24 @@ dist.javadoc.dir=${dist.dir}/javadoc excludes= file.reference.activation-1.1.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\activation-1.1.jar file.reference.akka-util-java.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\akka-util-java.jar +file.reference.antlr-3.1.3.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\antlr-3.1.3.jar file.reference.aopalliance-1.0.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\aopalliance-1.0.jar file.reference.asm-3.1.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\asm-3.1.jar +file.reference.asm-all-2.2.1.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\asm-all-2.2.1.jar +file.reference.cassandra.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\cassandra.jar file.reference.catalina-ant.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\catalina-ant.jar file.reference.cglib-2.2.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\cglib-2.2.jar file.reference.colt-1.2.0.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\colt-1.2.0.jar +file.reference.commons-cli-1.1.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\commons-cli-1.1.jar file.reference.commons-codec-1.3.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\commons-codec-1.3.jar -file.reference.commons-collections-3.1.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\commons-collections-3.1.jar +file.reference.commons-collections-3.2.1.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\commons-collections-3.2.1.jar file.reference.commons-dbcp-1.2.2.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\commons-dbcp-1.2.2.jar file.reference.commons-httpclient-3.1.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\commons-httpclient-3.1.jar file.reference.commons-io-1.3.2.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\commons-io-1.3.2.jar -file.reference.commons-lang-2.1.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\commons-lang-2.1.jar -file.reference.commons-logging.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\commons-logging.jar +file.reference.commons-javaflow-1.0-SNAPSHOT.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\commons-javaflow-1.0-SNAPSHOT.jar +file.reference.commons-lang-2.4.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\commons-lang-2.4.jar +file.reference.commons-logging-1.0.4.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\commons-logging-1.0.4.jar +file.reference.commons-math-1.1.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\commons-math-1.1.jar file.reference.commons-pool-1.4.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\commons-pool-1.4.jar file.reference.configgy-1.2.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\configgy-1.2.jar file.reference.google-collect-snapshot-20090211.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\google-collect-snapshot-20090211.jar @@ -44,6 +50,7 @@ file.reference.grizzly-rcm-1.8.6.3.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\ file.reference.grizzly-servlet-webserver-1.8.6.3.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\grizzly-servlet-webserver-1.8.6.3.jar file.reference.guice-core-2.0-SNAPSHOT.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\guice-core-2.0-SNAPSHOT.jar file.reference.guice-jsr250-2.0-SNAPSHOT.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\guice-jsr250-2.0-SNAPSHOT.jar +file.reference.high-scale-lib.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\high-scale-lib.jar file.reference.jaxb-api-2.1.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\jaxb-api-2.1.jar file.reference.jaxb-impl-2.1.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\jaxb-impl-2.1.jar file.reference.jdom-1.0.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\jdom-1.0.jar @@ -55,24 +62,32 @@ file.reference.jersey-server-1.0.1.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\ file.reference.jettison-1.0.1.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\jettison-1.0.1.jar file.reference.jetty-6.1.6rc0.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\jetty-6.1.6rc0.jar file.reference.jetty-util-6.1.6rc0.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\jetty-util-6.1.6rc0.jar +file.reference.JSAP-2.1.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\JSAP-2.1.jar file.reference.jsr250-api-1.0.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\jsr250-api-1.0.jar file.reference.jsr311-api-1.0.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\jsr311-api-1.0.jar file.reference.junit-3.8.2.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\junit-3.8.2.jar file.reference.junit-4.5.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\junit-4.5.jar file.reference.junit4runner-1.0-SNAPSHOT.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\junit4runner-1.0-SNAPSHOT.jar +file.reference.libfb303.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\libfb303.jar file.reference.libthrift-20080411p1.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\libthrift-20080411p1.jar -file.reference.log4j-1.2.13.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\log4j-1.2.13.jar +file.reference.libthrift.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\libthrift.jar +file.reference.log4j-1.2.15.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\log4j-1.2.15.jar +file.reference.lucene-core-2.2.0.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\lucene-core-2.2.0.jar file.reference.main-scala=src/main/scala file.reference.mina-core-2.0.0-M2-SNAPSHOT.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\mina-core-2.0.0-M2-SNAPSHOT.jar file.reference.mina-integration-scala-2.0.0-M2-SNAPSHOT.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\mina-integration-scala-2.0.0-M2-SNAPSHOT.jar +file.reference.pcj.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\pcj.jar file.reference.protobuf-java-2.0.3.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\protobuf-java-2.0.3.jar file.reference.rome-0.9.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\rome-0.9.jar file.reference.scala-library-2.7.3.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\scala-library-2.7.3.jar +file.reference.scala-library-2.7.3.zip=C:\\home\\jboner\\src\\scala\\akka\\lib\\scala-library-2.7.3.zip file.reference.scalatest-0.9.5.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\scalatest-0.9.5.jar +file.reference.scalatest-0.9.5.zip=C:\\home\\jboner\\src\\scala\\akka\\lib\\scalatest-0.9.5.zip file.reference.servlet-api-2.5.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\servlet-api-2.5.jar file.reference.slf4j-api-1.4.3.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\slf4j-api-1.4.3.jar file.reference.slf4j-log4j12-1.4.3.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\slf4j-log4j12-1.4.3.jar file.reference.stax-api-1.0-2.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\stax-api-1.0-2.jar +file.reference.stringtemplate-3.0.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\stringtemplate-3.0.jar file.reference.test-scala=src/test/scala file.reference.velocity-1.5.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\velocity-1.5.jar file.reference.voldemort-0.4a.jar=C:\\home\\jboner\\src\\scala\\akka\\lib\\voldemort-0.4a.jar @@ -84,19 +99,25 @@ jar.compress=false java.platform.active=java_default_platform javac.classpath=\ ${file.reference.activation-1.1.jar}:\ - ${file.reference.aopalliance-1.0.jar}:\ ${file.reference.akka-util-java.jar}:\ + ${file.reference.antlr-3.1.3.jar}:\ + ${file.reference.aopalliance-1.0.jar}:\ ${file.reference.asm-3.1.jar}:\ + ${file.reference.asm-all-2.2.1.jar}:\ + ${file.reference.cassandra.jar}:\ ${file.reference.catalina-ant.jar}:\ ${file.reference.cglib-2.2.jar}:\ ${file.reference.colt-1.2.0.jar}:\ + ${file.reference.commons-cli-1.1.jar}:\ ${file.reference.commons-codec-1.3.jar}:\ - ${file.reference.commons-collections-3.1.jar}:\ + ${file.reference.commons-collections-3.2.1.jar}:\ ${file.reference.commons-dbcp-1.2.2.jar}:\ ${file.reference.commons-httpclient-3.1.jar}:\ ${file.reference.commons-io-1.3.2.jar}:\ - ${file.reference.commons-lang-2.1.jar}:\ - ${file.reference.commons-logging.jar}:\ + ${file.reference.commons-javaflow-1.0-SNAPSHOT.jar}:\ + ${file.reference.commons-lang-2.4.jar}:\ + ${file.reference.commons-logging-1.0.4.jar}:\ + ${file.reference.commons-math-1.1.jar}:\ ${file.reference.commons-pool-1.4.jar}:\ ${file.reference.configgy-1.2.jar}:\ ${file.reference.google-collect-snapshot-20090211.jar}:\ @@ -109,6 +130,7 @@ javac.classpath=\ ${file.reference.grizzly-servlet-webserver-1.8.6.3.jar}:\ ${file.reference.guice-core-2.0-SNAPSHOT.jar}:\ ${file.reference.guice-jsr250-2.0-SNAPSHOT.jar}:\ + ${file.reference.high-scale-lib.jar}:\ ${file.reference.jaxb-api-2.1.jar}:\ ${file.reference.jaxb-impl-2.1.jar}:\ ${file.reference.jdom-1.0.jar}:\ @@ -120,28 +142,36 @@ javac.classpath=\ ${file.reference.jettison-1.0.1.jar}:\ ${file.reference.jetty-6.1.6rc0.jar}:\ ${file.reference.jetty-util-6.1.6rc0.jar}:\ + ${file.reference.JSAP-2.1.jar}:\ ${file.reference.jsr250-api-1.0.jar}:\ ${file.reference.jsr311-api-1.0.jar}:\ ${file.reference.junit-3.8.2.jar}:\ + ${file.reference.junit-4.5.jar}:\ + ${file.reference.junit4runner-1.0-SNAPSHOT.jar}:\ + ${file.reference.libfb303.jar}:\ ${file.reference.libthrift-20080411p1.jar}:\ - ${file.reference.log4j-1.2.13.jar}:\ + ${file.reference.libthrift.jar}:\ + ${file.reference.log4j-1.2.15.jar}:\ + ${file.reference.lucene-core-2.2.0.jar}:\ ${file.reference.mina-core-2.0.0-M2-SNAPSHOT.jar}:\ ${file.reference.mina-integration-scala-2.0.0-M2-SNAPSHOT.jar}:\ + ${file.reference.pcj.jar}:\ ${file.reference.protobuf-java-2.0.3.jar}:\ ${file.reference.rome-0.9.jar}:\ ${file.reference.scala-library-2.7.3.jar}:\ + ${file.reference.scala-library-2.7.3.zip}:\ ${file.reference.scalatest-0.9.5.jar}:\ + ${file.reference.scalatest-0.9.5.zip}:\ ${file.reference.servlet-api-2.5.jar}:\ ${file.reference.slf4j-api-1.4.3.jar}:\ ${file.reference.slf4j-log4j12-1.4.3.jar}:\ ${file.reference.stax-api-1.0-2.jar}:\ + ${file.reference.stringtemplate-3.0.jar}:\ ${file.reference.velocity-1.5.jar}:\ ${file.reference.voldemort-0.4a.jar}:\ ${file.reference.voldemort-contrib-0.4a.jar}:\ ${file.reference.xerces.jar}:\ - ${file.reference.zookeeper-3.1.0.jar}:\ - ${file.reference.junit4runner-1.0-SNAPSHOT.jar}:\ - ${file.reference.junit-4.5.jar} + ${file.reference.zookeeper-3.1.0.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false diff --git a/kernel/src/main/scala/CassandraNode.scala b/kernel/src/main/scala/CassandraNode.scala new file mode 100755 index 0000000000..95151d2947 --- /dev/null +++ b/kernel/src/main/scala/CassandraNode.scala @@ -0,0 +1,73 @@ +/** + * Copyright (C) 2009 Scalable Solutions. + */ + +package se.scalablesolutions.akka.kernel + +import java.io.File + +import com.facebook.thrift.protocol.TBinaryProtocol +import com.facebook.thrift.protocol.TProtocolFactory +import com.facebook.thrift.server.TThreadPoolServer +import com.facebook.thrift.transport.TServerSocket +import com.facebook.thrift.transport.TTransportException +import com.facebook.thrift.transport.TTransportFactory +import com.facebook.thrift.TProcessorFactory + +import org.apache.cassandra.config.DatabaseDescriptor +import org.apache.cassandra.service._ + +/** + * @author Jonas Bonér + */ +final class CassandraNode extends Logging { + val server = try { + val cassandra = new CassandraServer + cassandra.start + cassandra + } catch { + case e => + log.error("Could not start up persistent storage node") + throw e + } + + private val serverEngine: TThreadPoolServer = try { + val pidFile = System.getProperty("pidfile") + if (pidFile != null) new File(pidFile).deleteOnExit(); + val listenPort = DatabaseDescriptor.getThriftPort + + val processor = new Cassandra.Processor(server) + val tServerSocket = new TServerSocket(listenPort) + val tProtocolFactory = new TBinaryProtocol.Factory + + val options = new TThreadPoolServer.Options + options.minWorkerThreads = 64 + new TThreadPoolServer(new TProcessorFactory(processor), + tServerSocket, + new TTransportFactory, + new TTransportFactory, + tProtocolFactory, + tProtocolFactory, + options) + } catch { + case e => + log.error("Could not start up persistent storage node.") + throw e + } + + def start = { + scala.actors.Actor.actor { + log.info("Persistent storage node starting up..."); + serverEngine.serve + } + log.info("Persistent storage node starting up 2222..."); + server.insert("akka", "TestActor", "hash:data", "some data", System.currentTimeMillis) + val column = server.get_column("akka", "TestActor", "hash:data") + log.info("column: " + column) + + } + def stop = { + log.info("Persistent storage node shutting down...") + serverEngine.stop + } +} diff --git a/kernel/src/main/scala/Kernel.scala b/kernel/src/main/scala/Kernel.scala index cf3aca4cd9..0596dcf2f1 100755 --- a/kernel/src/main/scala/Kernel.scala +++ b/kernel/src/main/scala/Kernel.scala @@ -30,7 +30,7 @@ import javax.management.JMException object Kernel extends Logging { val SERVER_URL = "localhost" - + val JERSEY_SERVER_URL = "http://" + SERVER_URL + "/" val JERSEY_SERVER_PORT = 9998 val JERSEY_REST_CLASSES_ROOT_PACKAGE = "se.scalablesolutions.akka.kernel" @@ -43,12 +43,16 @@ object Kernel extends Logging { val ZOO_KEEPER_SERVER_URL = SERVER_URL val ZOO_KEEPER_SERVER_PORT = 9898 - private[this] var storageFactory: StoreClientFactory = _ - private[this] var storageServer: VoldemortServer = _ - + private[this] var cassandraNode: CassandraNode = _ + + //private[this] var storageFactory: StoreClientFactory = _ + //private[this] var storageServer: VoldemortServer = _ + def main(args: Array[String]): Unit = { + log.info("Starting Akka kernel...") //startZooKeeper - startVoldemort + //startVoldemort + startCassandra //val threadSelector = startJersey // TODO: handle shutdown of Jersey in separate thread @@ -65,51 +69,56 @@ object Kernel extends Logging { GrizzlyWebContainerFactory.create(JERSEY_BASE_URI, initParams) } - private[akka] def startVoldemort = { - // Start Voldemort server - val config = VoldemortConfig.loadFromVoldemortHome(Boot.HOME) - storageServer = new VoldemortServer(config) - storageServer.start - log.info("Replicated persistent storage server started at %s", VOLDEMORT_BOOTSTRAP_URL) - - // Create Voldemort client factory - val numThreads = 10 - val maxQueuedRequests = 10 - val maxConnectionsPerNode = 10 - val maxTotalConnections = 100 - storageFactory = new SocketStoreClientFactory( - numThreads, - numThreads, - maxQueuedRequests, - maxConnectionsPerNode, - maxTotalConnections, - VOLDEMORT_BOOTSTRAP_URL) - - val name = this.getClass.getName - val storage = getStorageFor("actors") -// val value = storage.get(name) - val value = new Versioned("state") - //value.setObject("state") - storage.put(name, value) + private[akka] def startCassandra = { + cassandraNode = new CassandraNode + cassandraNode.start } - - private[akka] def getStorageFor(storageName: String): StoreClient[String, String] = - storageFactory.getStoreClient(storageName) + +// private[akka] def startVoldemort = { +// // Start Voldemort server +// val config = VoldemortConfig.loadFromVoldemortHome(Boot.HOME) +// storageServer = new VoldemortServer(config) +// storageServer.start +// log.info("Replicated persistent storage server started at %s", VOLDEMORT_BOOTSTRAP_URL) +// +// // Create Voldemort client factory +// val numThreads = 10 +// val maxQueuedRequests = 10 +// val maxConnectionsPerNode = 10 +// val maxTotalConnections = 100 +// storageFactory = new SocketStoreClientFactory( +// numThreads, +// numThreads, +// maxQueuedRequests, +// maxConnectionsPerNode, +// maxTotalConnections, +// VOLDEMORT_BOOTSTRAP_URL) +// +// val name = this.getClass.getName +// val storage = getStorageFor("actors") +//// val value = storage.get(name) +// val value = new Versioned("state") +// //value.setObject("state") +// storage.put(name, value) +// } +// +// private[akka] def getStorageFor(storageName: String): StoreClient[String, String] = +// storageFactory.getStoreClient(storageName) // private[akka] def startZooKeeper = { // try { // ManagedUtil.registerLog4jMBeans // ServerConfig.parse(args) - // } catch { + // } catch { // case e: JMException => log.warning("Unable to register log4j JMX control: s%", e) - // case e => log.fatal("Error in ZooKeeper config: s%", e) + // case e => log.fatal("Error in ZooKeeper config: s%", e) // } // val factory = new ZooKeeperServer.Factory() { // override def createConnectionFactory = new NIOServerCnxn.Factory(ServerConfig.getClientPort) // override def createServer = { // val server = new ZooKeeperServer // val txLog = new FileTxnSnapLog( - // new File(ServerConfig.getDataLogDir), + // new File(ServerConfig.getDataLogDir), // new File(ServerConfig.getDataDir)) // server.setTxnLogFactory(txLog) // server @@ -124,7 +133,7 @@ object Kernel extends Logging { // // cnxnFactory.setZooKeeperServer(zooKeeper) // // cnxnFactory.join // // if (zooKeeper.isRunning) zooKeeper.shutdown - // } catch { case e => log.fatal("Unexpected exception: s%",e) } + // } catch { case e => log.fatal("Unexpected exception: s%",e) } // } private def getPort(defaultPort: Int) = { diff --git a/kernel/src/main/scala/State.scala b/kernel/src/main/scala/State.scala index 5aacd98bec..0f7d94b462 100755 --- a/kernel/src/main/scala/State.scala +++ b/kernel/src/main/scala/State.scala @@ -1,110 +1,110 @@ -/** - * Copyright (C) 2009 Scalable Solutions. - */ - -package se.scalablesolutions.akka.kernel - -import se.scalablesolutions.akka.collection._ -import scala.collection.mutable.{HashMap} - -trait Transactional { - private[kernel] def begin - private[kernel] def commit - private[kernel] def rollback -} - -sealed trait State[K, V] extends Transactional { - def put(key: K, value: V) - def remove(key: K) - def get(key: K): V - def contains(key: K): Boolean - def elements: Iterator[(K, V)] - def size: Int - def clear -} - -/** - * Not thread-safe, but should only be using from within an Actor, e.g. one single thread at a time. - */ -sealed class TransientState[K, V] extends State[K, V] { - private[kernel] var state = new HashTrie[K, V] - private[kernel] var snapshot = state - - private[kernel] override def begin = { - snapshot = state - } - - private[kernel] override def commit = { - snapshot = state - } - - private[kernel] override def rollback = { - state = snapshot - } - - override def put(key: K, value: V) = { - state = state.update(key, value) - } - - override def remove(key: K) = { - state = state - key - } - - def get(key: K): V = state.get(key).getOrElse { throw new NoSuchElementException("No value for key [" + key + "]") } - - def contains(key: K): Boolean = state.contains(key) - - def elements: Iterator[(K, V)] = state.elements - - def size: Int = state.size - - def clear = state = new HashTrie[K, V] -} - -final class TransientStringState extends TransientState[String, String] -final class TransientObjectState extends TransientState[String, AnyRef] - -/** - * Not thread-safe, but should only be using from within an Actor, e.g. one single thread at a time. - */ -trait UnitOfWork[K, V] extends State[K, V] with Transactional { - this: TransientState[K, V] => - private[kernel] val changeSet = new HashMap[K, V] - - abstract override def begin = { - super.begin - changeSet.clear - } - - abstract override def put(key: K, value: V) = { - super.put(key, value) - changeSet += key -> value - } - - abstract override def remove(key: K) = { - super.remove(key) - changeSet -= key - } -} - -//class VectorState[T] { -// private[kernel] var state: Vector[T] = EmptyVector -// private[kernel] var snapshot = state -// private[kernel] var unitOfWork: List[T] = Nil -// -// private[kernel] def record = { -// snapshot = state -// unitOfWork = Nil -// } -// -// def add(elem: T): VectorState[T] = { -// state = state + elem -// unitOfWork ::= elem -// } -// -// def get(index: Int): T = state(index) -// -// def size: Int = state.size -//} -// -// +/** + * Copyright (C) 2009 Scalable Solutions. + */ + +package se.scalablesolutions.akka.kernel + +import se.scalablesolutions.akka.collection._ +import scala.collection.mutable.HashMap + +trait Transactional { + private[kernel] def begin + private[kernel] def commit + private[kernel] def rollback +} + +sealed trait State[K, V] extends Transactional { + def put(key: K, value: V) + def remove(key: K) + def get(key: K): V + def contains(key: K): Boolean + def elements: Iterator[(K, V)] + def size: Int + def clear +} + +/** + * Not thread-safe, but should only be using from within an Actor, e.g. one single thread at a time. + */ +sealed class InMemoryState[K, V] extends State[K, V] { + private[kernel] var state = new HashTrie[K, V] + private[kernel] var snapshot = state + + private[kernel] override def begin = { + snapshot = state + } + + private[kernel] override def commit = { + snapshot = state + } + + private[kernel] override def rollback = { + state = snapshot + } + + override def put(key: K, value: V) = { + state = state.update(key, value) + } + + override def remove(key: K) = { + state = state - key + } + + def get(key: K): V = state.get(key).getOrElse { throw new NoSuchElementException("No value for key [" + key + "]") } + + def contains(key: K): Boolean = state.contains(key) + + def elements: Iterator[(K, V)] = state.elements + + def size: Int = state.size + + def clear = state = new HashTrie[K, V] +} + +//final class InMemoryStringState extends InMemoryState[String, String] +//final class InMemoryObjectState extends InMemoryState[String, AnyRef] +// +/** + * Not thread-safe, but should only be using from within an Actor, e.g. one single thread at a time. + */ +trait UnitOfWork[K, V] extends State[K, V] with Transactional { + this: InMemoryState[K, V] => + private[kernel] val changeSet = new HashMap[K, V] + + abstract override def begin = { + super.begin + changeSet.clear + } + + abstract override def put(key: K, value: V) = { + super.put(key, value) + changeSet += key -> value + } + + abstract override def remove(key: K) = { + super.remove(key) + changeSet -= key + } +} + +//class VectorState[T] { +// private[kernel] var state: Vector[T] = EmptyVector +// private[kernel] var snapshot = state +// private[kernel] var unitOfWork: List[T] = Nil +// +// private[kernel] def record = { +// snapshot = state +// unitOfWork = Nil +// } +// +// def add(elem: T): VectorState[T] = { +// state = state + elem +// unitOfWork ::= elem +// } +// +// def get(index: Int): T = state(index) +// +// def size: Int = state.size +//} +// +// diff --git a/kernel/src/main/scala/Transaction.scala b/kernel/src/main/scala/Transaction.scala index 7a3fab8d80..5fb614a74b 100644 --- a/kernel/src/main/scala/Transaction.scala +++ b/kernel/src/main/scala/Transaction.scala @@ -7,7 +7,7 @@ package se.scalablesolutions.akka.kernel import java.util.concurrent.atomic.AtomicLong import scala.collection.mutable.HashMap -sealed abstract case class TransactionStatus +sealed abstract class TransactionStatus object TransactionStatus { case object New extends TransactionStatus case object Active extends TransactionStatus diff --git a/lib/JSAP-2.1.jar b/lib/JSAP-2.1.jar new file mode 100755 index 0000000000..15d1f37a78 Binary files /dev/null and b/lib/JSAP-2.1.jar differ diff --git a/lib/akka-util-java.jar b/lib/akka-util-java.jar new file mode 100755 index 0000000000..8543e8a9f0 Binary files /dev/null and b/lib/akka-util-java.jar differ diff --git a/lib/antlr-3.1.3.jar b/lib/antlr-3.1.3.jar new file mode 100755 index 0000000000..d3bd9cf942 Binary files /dev/null and b/lib/antlr-3.1.3.jar differ diff --git a/lib/asm-all-2.2.1.jar b/lib/asm-all-2.2.1.jar new file mode 100755 index 0000000000..8e7ee3186d Binary files /dev/null and b/lib/asm-all-2.2.1.jar differ diff --git a/lib/cassandra.jar b/lib/cassandra.jar new file mode 100755 index 0000000000..5f93a9b3fb Binary files /dev/null and b/lib/cassandra.jar differ diff --git a/lib/commons-cli-1.1.jar b/lib/commons-cli-1.1.jar new file mode 100755 index 0000000000..e633afbe68 Binary files /dev/null and b/lib/commons-cli-1.1.jar differ diff --git a/lib/commons-collections-3.1.jar b/lib/commons-collections-3.1.jar deleted file mode 100644 index 41e230feea..0000000000 Binary files a/lib/commons-collections-3.1.jar and /dev/null differ diff --git a/lib/commons-collections-3.2.1.jar b/lib/commons-collections-3.2.1.jar new file mode 100755 index 0000000000..c35fa1fee1 Binary files /dev/null and b/lib/commons-collections-3.2.1.jar differ diff --git a/lib/commons-javaflow-1.0-SNAPSHOT.jar b/lib/commons-javaflow-1.0-SNAPSHOT.jar new file mode 100755 index 0000000000..199b853307 Binary files /dev/null and b/lib/commons-javaflow-1.0-SNAPSHOT.jar differ diff --git a/lib/commons-lang-2.1.jar b/lib/commons-lang-2.1.jar deleted file mode 100644 index 87b80ab5db..0000000000 Binary files a/lib/commons-lang-2.1.jar and /dev/null differ diff --git a/lib/commons-lang-2.4.jar b/lib/commons-lang-2.4.jar new file mode 100755 index 0000000000..532939ecab Binary files /dev/null and b/lib/commons-lang-2.4.jar differ diff --git a/lib/commons-logging.jar b/lib/commons-logging-1.0.4.jar similarity index 100% rename from lib/commons-logging.jar rename to lib/commons-logging-1.0.4.jar diff --git a/lib/commons-math-1.1.jar b/lib/commons-math-1.1.jar new file mode 100755 index 0000000000..6888813fc1 Binary files /dev/null and b/lib/commons-math-1.1.jar differ diff --git a/lib/high-scale-lib.jar b/lib/high-scale-lib.jar new file mode 100755 index 0000000000..421a436eed Binary files /dev/null and b/lib/high-scale-lib.jar differ diff --git a/lib/junit-4.5.jar b/lib/junit-4.5.jar new file mode 100755 index 0000000000..733921623d Binary files /dev/null and b/lib/junit-4.5.jar differ diff --git a/lib/junit4runner-1.0-SNAPSHOT.jar b/lib/junit4runner-1.0-SNAPSHOT.jar new file mode 100755 index 0000000000..6f91bd8044 Binary files /dev/null and b/lib/junit4runner-1.0-SNAPSHOT.jar differ diff --git a/lib/libfb303.jar b/lib/libfb303.jar new file mode 100755 index 0000000000..129328deff Binary files /dev/null and b/lib/libfb303.jar differ diff --git a/lib/libthrift.jar b/lib/libthrift.jar new file mode 100755 index 0000000000..e34bf79a85 Binary files /dev/null and b/lib/libthrift.jar differ diff --git a/lib/log4j-1.2.13.jar b/lib/log4j-1.2.13.jar deleted file mode 100755 index dde9972109..0000000000 Binary files a/lib/log4j-1.2.13.jar and /dev/null differ diff --git a/lib/log4j-1.2.15.jar b/lib/log4j-1.2.15.jar new file mode 100755 index 0000000000..c930a6ab4d Binary files /dev/null and b/lib/log4j-1.2.15.jar differ diff --git a/lib/lucene-core-2.2.0.jar b/lib/lucene-core-2.2.0.jar new file mode 100755 index 0000000000..2469481c38 Binary files /dev/null and b/lib/lucene-core-2.2.0.jar differ diff --git a/lib/pcj.jar b/lib/pcj.jar new file mode 100755 index 0000000000..0b6a0e879e Binary files /dev/null and b/lib/pcj.jar differ diff --git a/lib/scala-library-2.7.3.zip b/lib/scala-library-2.7.3.zip new file mode 100644 index 0000000000..734d361f12 Binary files /dev/null and b/lib/scala-library-2.7.3.zip differ diff --git a/lib/stringtemplate-3.0.jar b/lib/stringtemplate-3.0.jar new file mode 100755 index 0000000000..df5e6e517f Binary files /dev/null and b/lib/stringtemplate-3.0.jar differ diff --git a/storage/bootstrap/.nil b/storage/bootstrap/.nil new file mode 100644 index 0000000000..e69de29bb2 diff --git a/storage/callouts/.nil b/storage/callouts/.nil new file mode 100644 index 0000000000..e69de29bb2 diff --git a/storage/commitlog/.nil b/storage/commitlog/.nil new file mode 100644 index 0000000000..e69de29bb2 diff --git a/storage/staging/.nil b/storage/staging/.nil new file mode 100644 index 0000000000..e69de29bb2 diff --git a/storage/system/.nil b/storage/system/.nil new file mode 100644 index 0000000000..e69de29bb2