Search in sources :

Example 6 with StoreTransaction

use of co.paralleluniverse.galaxy.StoreTransaction in project quasar by puniverse.

the class GlxGlobalRegistry method tryGetActor0.

private CacheEntry tryGetActor0(final String rootName) throws SuspendExecution, RuntimeException {
    final Store store = grid.store();
    final StoreTransaction txn = store.beginTransaction();
    try {
        try {
            final long root = store.getRoot(rootName, txn);
            final byte[] buf = store.gets(root, txn);
            if (buf == null) {
                LOG.debug("Store returned null for root {}", rootName);
                return null;
            }
            final long version = store.getVersion(root);
            store.commit(txn);
            LOG.debug("Store returned a buffer ({} bytes) for root {}", buf.length, rootName);
            if (buf.length == 0)
                // TODO: Galaxy should return null
                return null;
            ActorRef<?> actor = deserActor(rootName, buf);
            return new CacheEntry(actor, root, version);
        } catch (TimeoutException e) {
            LOG.error("Getting actor {} failed due to timeout", rootName);
            store.rollback(txn);
            store.abort(txn);
            throw new RuntimeException("Actor discovery failed");
        }
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
}
Also used : StoreTransaction(co.paralleluniverse.galaxy.StoreTransaction) Store(co.paralleluniverse.galaxy.quasar.Store) TimeoutException(co.paralleluniverse.galaxy.TimeoutException)

Aggregations

StoreTransaction (co.paralleluniverse.galaxy.StoreTransaction)6 TimeoutException (co.paralleluniverse.galaxy.TimeoutException)6 Store (co.paralleluniverse.galaxy.quasar.Store)5 Actor (co.paralleluniverse.actors.Actor)1 ActorRef (co.paralleluniverse.actors.ActorRef)1 BasicActor (co.paralleluniverse.actors.BasicActor)1 LocalActor (co.paralleluniverse.actors.LocalActor)1 MailboxConfig (co.paralleluniverse.actors.MailboxConfig)1 AbstractServerHandler (co.paralleluniverse.actors.behaviors.AbstractServerHandler)1 EventHandler (co.paralleluniverse.actors.behaviors.EventHandler)1 EventSource (co.paralleluniverse.actors.behaviors.EventSource)1 EventSourceActor (co.paralleluniverse.actors.behaviors.EventSourceActor)1 Initializer (co.paralleluniverse.actors.behaviors.Initializer)1 Server (co.paralleluniverse.actors.behaviors.Server)1 ServerActor (co.paralleluniverse.actors.behaviors.ServerActor)1 SuspendExecution (co.paralleluniverse.fibers.SuspendExecution)1 AbstractCacheListener (co.paralleluniverse.galaxy.AbstractCacheListener)1 Cache (co.paralleluniverse.galaxy.Cache)1 CacheListener (co.paralleluniverse.galaxy.CacheListener)1 Store (co.paralleluniverse.galaxy.Store)1