Search in sources :

Example 6 with TimeoutException

use of co.paralleluniverse.galaxy.TimeoutException 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)

Example 7 with TimeoutException

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

the class GlxRemoteChannel method send.

private static void send(Object message, GlxGlobalChannelId id) throws SuspendExecution {
    LOG.debug("sent {}", message);
    try {
        if (id.isGlobal()) {
            final long ref = id.getAddress();
            if (message instanceof Streamable) {
                getStore().send(ref, (Streamable) message);
            } else {
                final byte[] buf = Serialization.getInstance().write(message);
                getStore().send(ref, buf);
            }
        } else {
            final short node = (short) id.getAddress();
            if (message instanceof Streamable) {
                getMessenger().send(node, (Long) id.getTopic(), (Streamable) message);
            } else {
                final byte[] buf = Serialization.getInstance().write(message);
                getMessenger().send(node, (Long) id.getTopic(), buf);
            }
        }
    } catch (TimeoutException e) {
        throw new RemoteException(e);
    }
}
Also used : Streamable(co.paralleluniverse.common.io.Streamable) RemoteException(co.paralleluniverse.remote.RemoteException) TimeoutException(co.paralleluniverse.galaxy.TimeoutException)

Aggregations

TimeoutException (co.paralleluniverse.galaxy.TimeoutException)7 StoreTransaction (co.paralleluniverse.galaxy.StoreTransaction)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 Streamable (co.paralleluniverse.common.io.Streamable)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