當前位置: 首頁>>代碼示例>>Java>>正文


Java PersistentRepr類代碼示例

本文整理匯總了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());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:26,代碼來源:InMemoryJournal.java

示例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();
}
 
開發者ID:Romeh,項目名稱:akka-persistance-ignite,代碼行數:13,代碼來源:IgniteWriteJournal.java

示例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;
    });
}
 
開發者ID:Romeh,項目名稱:akka-persistance-ignite,代碼行數:41,代碼來源:IgniteWriteJournal.java

示例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());
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:32,代碼來源:InMemoryJournal.java

示例5: convert

import akka.persistence.PersistentRepr; //導入依賴的package包/類
private JournalItem convert(PersistentRepr p) {
    return new JournalItem(p.sequenceNr(), p.persistenceId(), serializer.toBinary(p));
}
 
開發者ID:Romeh,項目名稱:akka-persistance-ignite,代碼行數:4,代碼來源:IgniteWriteJournal.java


注:本文中的akka.persistence.PersistentRepr類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。