Package org.nustaq.kontraktor.impl
Class SimpleScheduler
java.lang.Object
org.nustaq.kontraktor.impl.SimpleScheduler
- All Implemented Interfaces:
Monitorable,Scheduler
- Direct Known Subclasses:
RemoteScheduler
Created by ruedi on 02/04/15.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BackOffStrategystatic longtime ms until a warning is printed once a sender is blocked by a full actor queuestatic final booleanstatic intprotected com.fasterxml.jackson.databind.ObjectMapperprotected DispatcherThread -
Constructor Summary
ConstructorsModifierConstructorDescriptionSimpleScheduler(boolean keepAlive) SimpleScheduler(int qsize) SimpleScheduler(int qsize, boolean keepAlive) SimpleScheduler(int qsize, boolean keepAlive, String name) protectedSimpleScheduler(String dummy) -
Method Summary
Modifier and TypeMethodDescriptionassignDispatcher(int minLoadPerc) protected CallEntrycreateCallentry(ConnectionRegistry reg, Object[] args, boolean isCB, Actor actor, Method method) voiddelayedCall(long millis, Runnable toRun) static voidDelayedCall(long millis, Runnable toRun) enqueueCall(Actor sendingActor, Actor receiver, String methodName, Object[] args, boolean isCB) enqueueCall(ConnectionRegistry reg, Actor sendingActor, Actor receiver, String methodName, Object[] args, boolean isCB) enqueueCallFromRemote(ConnectionRegistry reg, Actor sendingActor, Actor receiver, String methodName, Object[] args, boolean isCB, Object securityContext, BiFunction<Actor, String, Boolean> callInterceptor, RemoteCallEntry remoteCallEntry) Warning: side effects on RCE transient to pass Method object from lookup up the calling hierarchystatic Class[]getAllInterfaces(Class<?> clazz) getAllInterfacesForClassAsSet(Class<?> clazz, ClassLoader classLoader) intgetInvoker(Actor dispatcher, Object toWrap) int<T> TCreates a wrapper on the given object enqueuing all calls to INTERFACE methods of the given object to the given actors's queue.mapResult(Object result, RemoteCallEntry rce) maps a JsonMapped result of a promisevoidpollDelay(int count) voidput2QueuePolling(Queue q, boolean isCBQ, Object o, Object receiver) voidrebalance(DispatcherThread dispatcherThread) called from inside overloaded thread with load all actors assigned to the calling thread therefore can be safely moved<T> voidrunBlockingCall(Actor emitter, Callable<T> toCall, Callback<T> resultHandler) voidsetKeepAlive(boolean b) voidvoidvoidtryIsolate(DispatcherThread dp, Actor actorRef) voidtryStopThread(DispatcherThread dispatcherThread)
-
Field Details
-
DEBUG_SCHEDULING
public static final boolean DEBUG_SCHEDULING- See Also:
-
BLOCKED_MS_TIL_WARN
public static long BLOCKED_MS_TIL_WARNtime ms until a warning is printed once a sender is blocked by a full actor queue -
DEFQSIZE
public static int DEFQSIZE -
mapper
protected com.fasterxml.jackson.databind.ObjectMapper mapper -
backOffStrategy
-
myThread
-
-
Constructor Details
-
SimpleScheduler
-
SimpleScheduler
public SimpleScheduler() -
SimpleScheduler
public SimpleScheduler(boolean keepAlive) -
SimpleScheduler
public SimpleScheduler(int qsize) -
SimpleScheduler
public SimpleScheduler(int qsize, boolean keepAlive) - Parameters:
qsize-keepAlive- - keep thread idle even if no actor is scheduled. Required for assisted scheduling e.g. in servers
-
SimpleScheduler
-
-
Method Details
-
mapResult
maps a JsonMapped result of a promise -
getDefaultQSize
public int getDefaultQSize()- Specified by:
getDefaultQSizein interfaceScheduler
-
pollDelay
public void pollDelay(int count) -
put2QueuePolling
- Specified by:
put2QueuePollingin interfaceScheduler
-
put2QueuePolling
-
enqueueCall
public Object enqueueCall(Actor sendingActor, Actor receiver, String methodName, Object[] args, boolean isCB) - Specified by:
enqueueCallin interfaceScheduler
-
enqueueCall
public Object enqueueCall(ConnectionRegistry reg, Actor sendingActor, Actor receiver, String methodName, Object[] args, boolean isCB) - Specified by:
enqueueCallin interfaceScheduler
-
enqueueCallFromRemote
public Object enqueueCallFromRemote(ConnectionRegistry reg, Actor sendingActor, Actor receiver, String methodName, Object[] args, boolean isCB, Object securityContext, BiFunction<Actor, String, Boolean> callInterceptor, RemoteCallEntry remoteCallEntry) Description copied from interface:SchedulerWarning: side effects on RCE transient to pass Method object from lookup up the calling hierarchy- Specified by:
enqueueCallFromRemotein interfaceScheduler- Returns:
-
createCallentry
protected CallEntry createCallentry(ConnectionRegistry reg, Object[] args, boolean isCB, Actor actor, Method method) -
terminateIfIdle
public void terminateIfIdle()- Specified by:
terminateIfIdlein interfaceScheduler
-
threadStopped
- Specified by:
threadStoppedin interfaceScheduler
-
setKeepAlive
public void setKeepAlive(boolean b) -
getInvoker
- Specified by:
getInvokerin interfaceScheduler
-
getAllInterfaces
-
getAllInterfacesForClassAsSet
-
inThread
Description copied from interface:SchedulerCreates a wrapper on the given object enqueuing all calls to INTERFACE methods of the given object to the given actors's queue. This is used to enable processing of resulting callback's in the callers thread. see also @InThread annotation. -
delayedCall
- Specified by:
delayedCallin interfaceScheduler
-
DelayedCall
-
runBlockingCall
- Specified by:
runBlockingCallin interfaceScheduler
-
assignDispatcher
- Specified by:
assignDispatcherin interfaceScheduler
-
rebalance
Description copied from interface:Schedulercalled from inside overloaded thread with load all actors assigned to the calling thread therefore can be safely moved -
getBackoffStrategy
- Specified by:
getBackoffStrategyin interfaceScheduler
-
tryStopThread
- Specified by:
tryStopThreadin interfaceScheduler
-
tryIsolate
- Specified by:
tryIsolatein interfaceScheduler
-
getNumActors
public int getNumActors()- Specified by:
getNumActorsin interfaceScheduler- Returns:
- number of actors scheduled by this scheduler. Note this is not precise as not thread safe'd.
-
getReport
- Specified by:
getReportin interfaceMonitorable
-
getSubMonitorables
- Specified by:
getSubMonitorablesin interfaceMonitorable
-