Class ConnectionRegistry
java.lang.Object
org.nustaq.kontraktor.remoting.base.ConnectionRegistry
Created by moelrue on 5/7/15.
Manages mapping of remote refs and callbacks of a single connection. E.g. if an actor ref or callback or spore is sent to
a remote actor, during serialization ConnectionRegistry generates and maps the callback id's required
to later on route incoming messages from remote to the appropriate local instances
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AtomicLongprotected org.nustaq.serialization.FSTConfigurationstatic Supplier<com.fasterxml.jackson.databind.ObjectMapper>protected booleanprotected longstatic intstatic final Objectprotected ConcurrentHashMap<Long,Object> protected ConcurrentHashMap<Object,Long> protected Map<String,RateLimitEntry> protected ConcurrentHashMap<Long,Actor> protected ConcurrentLinkedQueue<Actor>protected BiFunction<Actor,String, Boolean> static BiFunctionprotected RemoteSchedulerprotected boolean -
Constructor Summary
ConstructorsConstructorDescriptionConnectionRegistry(Coding code) ConnectionRegistry(org.nustaq.serialization.FSTConfiguration conf, Coding coding) -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanUp()cleanup after (virtual) connection closevoidprotected voidcloseRef(CallEntry ce, ObjectSocket chan) protected voidconfigureSerialization(Coding code) voidcalled from ObjectSocket in case of disconnect (decoding errors or network issues)voidorg.nustaq.serialization.FSTConfigurationgetConf()abstract ActorlongintgetPublishedActor(long id) long[]getPublishedCallback(long id) intlong[]longgetRemoteId(Actor act) abstract AtomicReference<ObjectSocket>voidinFacadeThread(Runnable toRun) static booleanIsJsonConfiguration(org.nustaq.serialization.FSTConfiguration conf) booleanbooleanbooleanvoidbooleanpollAndSend2Remote(AtomicReference<ObjectSocket> chanHolder) poll remote actor proxies and send. return true if there was at least one messageprotected booleanprocessRemoteCallEntry(ObjectSocket objSocket, RemoteCallEntry response, List<IPromise> createdFutures, Object authContext) longpublishActor(Actor act) voidreceiveCBResult(ObjectSocket chan, long id, Object result, Object error) booleanreceiveObject(ObjectSocket responseChannel, ObjectSink receiver, Object response, List<IPromise> createdFutures, Object authContext) process a remote call entry or an array of remote call entries.static voidregisterDefaultClassMappings(org.nustaq.serialization.FSTConfiguration conf) longregisterRemoteActorRef(Class actorClazz, long remoteId, Object client) voidprotected voidremoteRefStopped(Actor actor) warning: MThreadedvoidremovePublishedObject(long receiverKey) protected voidremoveRemoteActor(Actor act) voidvoidsetDisconnectHandler(Consumer<Actor> disconnectHandler) voidsetFacadeActor(Actor facadeActor) voidsetIsObsolete(boolean isObsolete) give the application a way to explecitely flag a connection as obsoletevoidsetServer(ActorServer server) voidsetTerminated(boolean terminated) voidvoidunpublishActor(Actor act) remove current <remoteId,actor> mappings if present.protected voidwriteObject(ObjectSocket chan, RemoteCallEntry rce)
-
Field Details
-
OUT_OF_ORDER_SEQ
-
MAX_BATCH_CALLS
public static int MAX_BATCH_CALLS -
remoteCallMapper
-
CreateDefaultObjectMapper
-
userData
-
lastRoutingClientPing
protected long lastRoutingClientPing -
conf
protected org.nustaq.serialization.FSTConfiguration conf -
scheduler
-
actorIdCount
-
publishedActorMap
-
publishedActorMappingReverse
-
remoteActors
-
remoteActorMap
-
terminated
protected volatile boolean terminated -
disconnectHandler
-
isObsolete
protected boolean isObsolete -
rateLimits
-
remoteCallInterceptor
-
-
Constructor Details
-
ConnectionRegistry
-
ConnectionRegistry
-
-
Method Details
-
registerDefaultClassMappings
public static void registerDefaultClassMappings(org.nustaq.serialization.FSTConfiguration conf) -
IsJsonConfiguration
public static boolean IsJsonConfiguration(org.nustaq.serialization.FSTConfiguration conf) -
getRemoteCallInterceptor
-
configureSerialization
-
getOpenRemoteMappingsCount
public int getOpenRemoteMappingsCount() -
getPublishedActor
-
getPublishedCallback
-
getScheduler
-
getRemoteActors
-
getRemoteActorMap
-
isTerminated
public boolean isTerminated() -
setTerminated
public void setTerminated(boolean terminated) -
publishActor
-
unpublishActor
remove current <remoteId,actor> mappings if present. return map containing removed mappings (for reconnection)- Parameters:
act-
-
registerPublishedCallback
-
removePublishedObject
public void removePublishedObject(long receiverKey) -
registerRemoteRefDirect
-
registerRemoteActorRef
-
remoteRefStopped
warning: MThreaded- Parameters:
actor-
-
stopRemoteRefs
public void stopRemoteRefs() -
removeRemoteActor
-
receiveObject
public boolean receiveObject(ObjectSocket responseChannel, ObjectSink receiver, Object response, List<IPromise> createdFutures, Object authContext) throws Exception process a remote call entry or an array of remote call entries.- Parameters:
responseChannel- - writer required to route callback messagesresponse-createdFutures- - can be null. Contains futures created by the submitted callsequenceauthContext-- Returns:
- Throws:
Exception
-
processRemoteCallEntry
protected boolean processRemoteCallEntry(ObjectSocket objSocket, RemoteCallEntry response, List<IPromise> createdFutures, Object authContext) throws Exception - Throws:
Exception
-
cleanUp
public void cleanUp()cleanup after (virtual) connection close -
disconnect
public void disconnect()called from ObjectSocket in case of disconnect (decoding errors or network issues) -
closeRef
- Throws:
IOException
-
writeObject
- Throws:
Exception
-
inFacadeThread
-
forwardRemoteMessage
-
receiveCBResult
-
close
-
getConf
public org.nustaq.serialization.FSTConfiguration getConf() -
getFacadeProxy
-
setDisconnectHandler
-
getDisconnectHandler
-
setClassLoader
-
getRemoteId
-
pollAndSend2Remote
poll remote actor proxies and send. return true if there was at least one message- Parameters:
chanHolder-- Throws:
Exception
-
getWriteObjectSocket
-
getSocketRef
-
isObsolete
public boolean isObsolete() -
setIsObsolete
public void setIsObsolete(boolean isObsolete) give the application a way to explecitely flag a connection as obsolete -
getRemoteActorSize
public int getRemoteActorSize() -
setFacadeActor
-
getFacadeActor
-
setServer
-
getServer
-
closeNetwork
-
pingFromRoutingClient
public void pingFromRoutingClient() -
getLastRoutingClientPing
public long getLastRoutingClientPing() -
getRemotedActorIds
public long[] getRemotedActorIds() -
getPublishedActorIds
public long[] getPublishedActorIds() -
getConnectionIdentifier
-
isJsonSerialized
public boolean isJsonSerialized()
-