public void addActor(Actor act) { Actor ref = act.getActorRef(); Actor thisActor = act.getActor(); ref.__currentDispatcher = this; if ( thisActor != null ) // pseudo interface thisActor.__currentDispatcher = this; toAdd.offer(ref); }
public void open(Path file, OpenOption... options) throws IOException { if ( fileChannel != null ) throw new RuntimeException("can only open once"); Actor sender = Actor.current(); Set<OpenOption> set = new HashSet<OpenOption>(options.length); Collections.addAll(set, options); fileChannel = AsynchronousFileChannel.open(file, set, new ActorExecutorService(sender), NO_ATTRIBUTES); }
public void inFacadeThread(Runnable toRun) { if (facadeActor!=null) { if ( Thread.currentThread() != facadeActor.getCurrentDispatcher() ) { facadeActor.execute( toRun ); return; } } else { int debug = 1; } toRun.run(); }
service.getActor().zzRoutingGCEnabled = true; service.getActorRef().zzRoutingGCEnabled = true; if (connectable.getActorClass() == null ) { connectable.actorClass(Krouter.class); service.execute( () -> { connectable .connect(null, (Consumer<Actor>) disconnectCallback) if ( r != null ) { try { ((AbstractKrouter) r).router$RegisterService(service.getUntypedRef(), stateful).await(); } catch (Exception ex) { p.complete(null,ex);
/** * return a future which is completed upon connection close * * @param reg * * @return future completed upon termination of scheduling (disconnect) * */ public IPromise scheduleSendLoop(ConnectionRegistry reg) { Promise promise = new Promise(); sendJobs.add(new ScheduleEntry(reg, promise)); synchronized (this) { if ( ! loopStarted ) { loopStarted = true; Actor.current().execute(this); } } return promise; }
public long getRemoteId(Actor act) { Long integer = publishedActorMappingReverse.get(act.getActorRef()); return integer == null ? -1 : integer; }
@Override public void execute(Runnable command) { actor.execute(command); } }
@Override public Object enqueueCallFromRemote(ConnectionRegistry reg, Actor sendingActor, Actor receiver, String methodName, Object[] args, boolean isCB, Object securityContext, BiFunction<Actor, String, Boolean> callInterceptor) { // System.out.println("dispatch "+methodName+" "+Thread.currentThread()); // here sender + receiver are known in a ST context Actor actor = receiver.getActor(); Method method = actor.__getCachedMethod(methodName, actor, callInterceptor); if ( method == null ) throw new RuntimeException("unknown method "+methodName+" on "+actor); // scan for callbacks in arguments .. for (int i = 0; i < args.length; i++) { Object arg = args[i]; if ( arg instanceof Callback) { args[i] = new CallbackWrapper<>(sendingActor,(Callback<Object>) arg); } } CallEntry e = createCallentry(reg, args, isCB, actor, method); return put2QueuePolling(e); }
/** * closes the connection to the remote client which has sent currently executing message. * If current message was not sent by a client, NOP. */ protected void closeCurrentClient() { ConnectionRegistry remoteConnection = connection.get(); if ( remoteConnection != null ) { delayed(1000, () -> remoteConnection.close(this)); } }
public void registerRemoteRefDirect(Actor act) { act = act.getActorRef(); remoteActorMap.put(act.__remoteId,act); remoteActors.add(act); act.__clientConnection = this; act.__addStopHandler((actor, err) -> { remoteRefStopped((Actor) actor); }); }
private void publishActorDirect(Long id, Actor act) { Object o = publishedActorMap.get(id); if ( o != null && o != act.getActorRef() ) { Log.Error(this,"id already present old:"+o+" new:"+act); } publishedActorMap.put(id, act.getActorRef()); publishedActorMappingReverse.put(act.getActorRef(), id); act.__addRemoteConnection(this); }
@Override @Local public IPromise getReport() { return new Promise( new ActorReport(getActor().getClass().getSimpleName(), getMailboxSize(), getCallbackSize() ) ); }
public void run() { pollThread = Thread.currentThread(); if ( underway ) return; underway = true; try { int count = 1; while( count > 0 ) { // as long there are messages, keep sending them count = onePoll(); if ( sendJobs.size() > 0 ) { if ( count > 0 ) { int debug =1; } else { if ( remoteRefCounter == 0 ) // no remote actors registered { Actor.current().delayed(100, this); // backoff massively } else { Actor.current().delayed(1, this); // backoff a bit (remoteactors present, no messages) } } } else { // no schedule entries (== no clients) Actor.current().delayed(100, this ); } } } finally { underway = false; } }
if ( publishedActor != null && ! publishedActor.isStopped() && publishedActor.isPublished() ) { System.out.println("unpublishing " + zzLastLiveActorId + " " + publishedActor); connectionRegistry.unpublishActor(publishedActor); publishedActor.stop();
rce.unpackArgs(registry.getConf()); try { Object future = getScheduler().enqueueCallFromRemote(registry, null, self(), rce.getMethod(), rce.getArgs(), false, null, callInterceptor); if ( future instanceof IPromise) { Promise p = null; self().execute(runnable); else runnable.run(); Log.Warn(this,th); if ( rce.getFutureKey() != 0 ) { self().execute(() -> { try { registry.receiveCBResult(objSocket, rce.getFutureKey(), null, FSTUtil.toString(th));
public void setFacadeActor(Actor facadeActor) { this.facadeActor = facadeActor; if ( facadeActor.getActor().getClass().getAnnotation(Secured.class) != null) { secured = true; } }
@Override public <T extends Actor> IPromise<T> connect(Callback<ActorClientConnector> disconnectCallback, Consumer<Actor> actorDisconnecCB) { if ( actorClz == null ) throw new RuntimeException("actor class cannot be null on TCPConnectable"); if ( host == null ) throw new RuntimeException("host cannot be null on TCPConnectable"); Promise result = new Promise(); Runnable connect = () -> { TCPClientConnector client = new TCPClientConnector(port,host,disconnectCallback); ActorClient connector = new ActorClient(client,actorClz,coding); connector.connect(inboundQueueSize, actorDisconnecCB).then(result); }; if ( ! Actor.inside() ) { TCPClientConnector.get().execute(() -> Thread.currentThread().setName("tcp singleton remote client actor polling")); TCPClientConnector.get().execute(connect); } else connect.run(); return result; }