本文整理匯總了Java中akka.persistence.PersistentRepr類的典型用法代碼示例。如果您正苦於以下問題:Java PersistentRepr類的具體用法?Java PersistentRepr怎麽用?Java PersistentRepr使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PersistentRepr類屬於akka.persistence包,在下文中一共展示了PersistentRepr類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doAsyncWriteMessages
import akka.persistence.PersistentRepr; //導入依賴的package包/類
@Override
public Future<Iterable<Optional<Exception>>> doAsyncWriteMessages(final Iterable<AtomicWrite> messages) {
return Futures.future(() -> {
for (AtomicWrite write : messages) {
// Copy to array - workaround for eclipse "ambiguous method" errors for toIterator, toIterable etc
PersistentRepr[] array = new PersistentRepr[write.payload().size()];
write.payload().copyToArray(array);
for (PersistentRepr repr: array) {
LOG.trace("doAsyncWriteMessages: id: {}: seqNr: {}, payload: {}", repr.persistenceId(),
repr.sequenceNr(), repr.payload());
addEntry(repr.persistenceId(), repr.sequenceNr(), repr.payload());
WriteMessagesComplete complete = WRITE_MESSAGES_COMPLETE.get(repr.persistenceId());
if (complete != null) {
if (complete.ofType == null || complete.ofType.equals(repr.payload().getClass())) {
complete.latch.countDown();
}
}
}
}
return Collections.emptyList();
}, context().dispatcher());
}
示例2: IgniteWriteJournal
import akka.persistence.PersistentRepr; //導入依賴的package包/類
/**
* @param config akka configuration
* @throws NotSerializableException
*/
public IgniteWriteJournal(Config config) throws NotSerializableException {
ActorSystem actorSystem = context().system();
serializer = SerializationExtension.get(actorSystem).serializerFor(PersistentRepr.class);
storage = new Store<>(actorSystem);
JournalCaches journalCaches = journalCacheProvider.apply(config, actorSystem);
sequenceNumberTrack = journalCaches.getSequenceCache();
cache = journalCaches.getJournalCache();
}
示例3: doAsyncReplayMessages
import akka.persistence.PersistentRepr; //導入依賴的package包/類
@Override
public Future<Void> doAsyncReplayMessages(String persistenceId, long fromSequenceNr, long toSequenceNr, long max, Consumer<PersistentRepr> replayCallback) {
return storage.execute(persistenceId, cache, (entityIdParam, cacheParam) -> {
if (log.isDebugEnabled()) {
log.debug("doAsyncReplayMessages with params persistenceId: '{}' :fromSequenceNr {} :toSequenceNr {} :max {}"
, persistenceId, fromSequenceNr, toSequenceNr, max);
}
try (QueryCursor<Cache.Entry<Long, JournalItem>> query = cache
.query(new SqlQuery<Long, JournalItem>(JournalItem.class, "sequenceNr >= ? AND sequenceNr <= ? AND persistenceId=?")
.setArgs(fromSequenceNr, toSequenceNr, persistenceId))) {
final List<Cache.Entry<Long, JournalItem>> all = query.getAll();
if (log.isDebugEnabled()) {
log.debug("replyMessage results {} {} {}", query.toString(), all.toString(), all.size());
}
if (null != all && !all.isEmpty()) {
if (all.size() < max) {
for (Cache.Entry<Long, JournalItem> entry : all) {
if (log.isDebugEnabled()) {
log.debug("replay message persistenceId '{}' getKey {}", persistenceId, entry.getKey());
}
replayCallback.accept(convert(entry.getValue()));
}
} else {
all.subList(0, (int) max).forEach(longJournalItemEntry -> {
if (log.isDebugEnabled()) {
log.debug("replay message persistenceId'{}' getKey {}", persistenceId, longJournalItemEntry.getKey());
}
replayCallback.accept(convert(longJournalItemEntry.getValue()));
});
}
}
}
return null;
});
}
示例4: doAsyncReplayMessages
import akka.persistence.PersistentRepr; //導入依賴的package包/類
@Override
public Future<Void> doAsyncReplayMessages(final String persistenceId, final long fromSequenceNr,
final long toSequenceNr, final long max, final Consumer<PersistentRepr> replayCallback) {
LOG.trace("doAsyncReplayMessages for {}: fromSequenceNr: {}, toSequenceNr: {}", persistenceId,
fromSequenceNr,toSequenceNr);
return Futures.future(() -> {
CountDownLatch blockLatch = BLOCK_READ_MESSAGES_LATCHES.remove(persistenceId);
if (blockLatch != null) {
Uninterruptibles.awaitUninterruptibly(blockLatch);
}
Map<Long, Object> journal = JOURNALS.get(persistenceId);
if (journal == null) {
return null;
}
synchronized (journal) {
int count = 0;
for (Map.Entry<Long,Object> entry : journal.entrySet()) {
if (++count <= max && entry.getKey() >= fromSequenceNr && entry.getKey() <= toSequenceNr) {
PersistentRepr persistentMessage =
new PersistentImpl(deserialize(entry.getValue()), entry.getKey(), persistenceId,
null, false, null, null);
replayCallback.accept(persistentMessage);
}
}
}
return null;
}, context().dispatcher());
}
示例5: convert
import akka.persistence.PersistentRepr; //導入依賴的package包/類
private JournalItem convert(PersistentRepr p) {
return new JournalItem(p.sequenceNr(), p.persistenceId(), serializer.toBinary(p));
}