Package co.paralleluniverse.actors

Examples of co.paralleluniverse.actors.ActorRef


    @Override
    public void onOpen(Session session, EndpointConfig config) {
        if (this.config == null)
            this.config = config;
        ActorRef webActor = getHttpSessionActor(config).getWebActor();
        if (webActor != null) {
            WebSocketActor wsa = attachWebActor(session, config, webActor);
            wsa.onOpen();
        } else {
            try {
View Full Code Here


        }
    }

    private ChildEntry addChild1(ChildSpec spec) {
        log().debug("Adding child {}", spec);
        ActorRef actor = null;
        if (spec.builder instanceof ActorRef) {
            actor = (ActorRef) spec.builder;
            if (findEntry(actor) != null)
                throw new SupervisorException("Supervisor " + this + " already supervises actor " + actor);
        }

        Object id = spec.getId();
        if (id == null && actor != null)
            id = actor.getName();
        if (id != null && findEntryById(id) != null)
            throw new SupervisorException("Supervisor " + this + " already supervises an actor by the name " + id);
        final ChildEntry child = new ChildEntry(spec, actor);
        children.add(child);
        if (id != null)
View Full Code Here

        boolean handled = false;
        try {
            if (m instanceof ExitMessage) {
                final ExitMessage death = (ExitMessage) m;
                if (death.getWatch() != null) {
                    final ActorRef actor = death.actor;
                    final ChildEntry child = findEntry(actor);

                    if (child != null) {
                        log().info("Detected child death: " + child + ". cause: ", death.cause);
                        if (!restartStrategy.onChildDeath(this, child, death.cause)) {
View Full Code Here

                    return true;
                }
            // fall through
            case PERMANENT:
                log().info("Supervisor trying to restart child {}. (cause: {})", child, cause);
                final ActorRef actor = child.actor;
                shutdownChild(child, true);
                child.restartHistory.addRestart(now);
                final int numRestarts = child.restartHistory.numRestarts(now - child.spec.unit.toMillis(child.spec.duration));
                if (log().isDebugEnabled())
                    log().debug("Child {} has been restarted {} times in the last {} {}s", child, numRestarts, child.spec.duration, child.spec.unit);
View Full Code Here

                throw new AssertionError();
        }
    }

    private ActorRef<?> start(ChildEntry child) {
        final ActorRef old = child.actor;
        if (old != null && !LocalActor.isDone(old))
            throw new IllegalStateException("Actor " + child.actor + " cannot be restarted because it is not dead");

        final Actor actor = child.spec.builder.build();
        if (actor.getName() == null && child.spec.id != null)
View Full Code Here

            child.actor = null;
        }
    }

    private boolean joinChild(ChildEntry child) throws InterruptedException {
        final ActorRef actor = child.actor;

        log().debug("Joining child {}", child);
        if (child.actor != null) {
            try {
                LocalActor.join(actor, child.spec.shutdownDeadline, TimeUnit.MILLISECONDS);
View Full Code Here

    public static void replyError(RequestMessage<?> req, Throwable e) throws SuspendExecution {
        req.getFrom().send(new ErrorResponseMessage(req.getId(), e));
    }

    private static ActorRef getCurrentActor() {
        ActorRef actorRef = LocalActor.self();
        if (actorRef == null) {
            // create a "dummy actor" on the current strand
            Actor actor = new Actor(Strand.currentStrand(), null, new MailboxConfig(5, OverflowPolicy.THROW)) {
                @Override
                protected Object doRun() throws InterruptedException, SuspendExecution {
View Full Code Here

            this.actor = null;
            this.done = true;
        }

        private ActorRef getActor() {
            ActorRef a = null;
            if (actor != null)
                a = actor.get().ref();
            return a;
        }
View Full Code Here

                a = actor.get().ref();
            return a;
        }

        private ActorRef actor() {
            final ActorRef a = getActor();
            if (a == null)
                throw new RuntimeException("Temporary actor is out of scope");
            return a;
        }
View Full Code Here

            return actor().getName();
        }

        @Override
        public void interrupt() {
            final ActorRef a = getActor();
            if (a != null)
                a.interrupt();
        }
View Full Code Here

TOP

Related Classes of co.paralleluniverse.actors.ActorRef

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.