forked from akka/akka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+per #3746 Remote sharing of LevelDB for testing purposes
Further changes - remove obsolete identity checks in Eventsourced - fix wrong serialize-messages config in tests
- Loading branch information
Showing
20 changed files
with
648 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,15 +5,52 @@ | |
package docs.persistence; | ||
|
||
//#plugin-imports | ||
import akka.actor.UntypedActor; | ||
import scala.concurrent.Future; | ||
import akka.japi.Option; | ||
import akka.japi.Procedure; | ||
import akka.persistence.*; | ||
import akka.persistence.journal.japi.*; | ||
import akka.persistence.snapshot.japi.*; | ||
//#plugin-imports | ||
import akka.actor.*; | ||
import akka.persistence.journal.leveldb.SharedLeveldbJournal; | ||
import akka.persistence.journal.leveldb.SharedLeveldbStore; | ||
|
||
public class PersistencePluginDocTest { | ||
|
||
|
||
static Object o1 = new Object() { | ||
final ActorSystem system = null; | ||
//#shared-store-creation | ||
final ActorRef store = system.actorOf(Props.create(SharedLeveldbStore.class), "store"); | ||
//#shared-store-creation | ||
|
||
//#shared-store-usage | ||
class SharedStorageUsage extends UntypedActor { | ||
@Override | ||
public void preStart() throws Exception { | ||
String path = "akka.tcp://[email protected]:2552/user/store"; | ||
ActorSelection selection = getContext().actorSelection(path); | ||
selection.tell(new Identify(1), getSelf()); | ||
} | ||
|
||
@Override | ||
public void onReceive(Object message) throws Exception { | ||
if (message instanceof ActorIdentity) { | ||
ActorIdentity identity = (ActorIdentity) message; | ||
if (identity.correlationId().equals(1)) { | ||
ActorRef store = identity.getRef(); | ||
if (store != null) { | ||
SharedLeveldbJournal.setStore(store, getContext().system()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
//#shared-store-usage | ||
}; | ||
|
||
class MySnapshotStore extends SnapshotStore { | ||
@Override | ||
public Future<Option<SelectedSnapshot>> doLoadAsync(String processorId, SnapshotSelectionCriteria criteria) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,47 @@ class PersistencePluginDocSpec extends WordSpec { | |
} | ||
} | ||
|
||
object SharedLeveldbPluginDocSpec { | ||
import akka.actor._ | ||
import akka.persistence.journal.leveldb.SharedLeveldbJournal | ||
|
||
val config = | ||
""" | ||
//#shared-journal-config | ||
akka.persistence.journal.plugin = "akka.persistence.journal.leveldb-shared" | ||
//#shared-journal-config | ||
//#shared-store-config | ||
akka.persistence.journal.leveldb-shared.store.dir = "target/shared" | ||
//#shared-store-config | ||
""" | ||
|
||
//#shared-store-usage | ||
trait SharedStoreUsage extends Actor { | ||
override def preStart(): Unit = { | ||
context.actorSelection("akka.tcp://[email protected]:2552/user/store") ! Identify(1) | ||
} | ||
|
||
def receive = { | ||
case ActorIdentity(1, Some(store)) ⇒ | ||
SharedLeveldbJournal.setStore(store, context.system) | ||
} | ||
} | ||
//#shared-store-usage | ||
} | ||
|
||
trait SharedLeveldbPluginDocSpec { | ||
val system: ActorSystem | ||
|
||
new AnyRef { | ||
import akka.actor._ | ||
//#shared-store-creation | ||
import akka.persistence.journal.leveldb.SharedLeveldbStore | ||
|
||
val store = system.actorOf(Props[SharedLeveldbStore], "store") | ||
//#shared-store-creation | ||
} | ||
} | ||
|
||
class MyJournal extends AsyncWriteJournal { | ||
def writeAsync(persistentBatch: Seq[PersistentRepr]): Future[Unit] = ??? | ||
def deleteAsync(processorId: String, fromSequenceNr: Long, toSequenceNr: Long, permanent: Boolean): Future[Unit] = ??? | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.