Class AbstractHost
- All Implemented Interfaces:
Closeable,AutoCloseable,Host
- Direct Known Subclasses:
DefaultHost
A host starts out by hosting no actorGroups. The coordinator will tell the host when it should:
- Add a numbered actorGroup (the host will actually construct the actorGroup).
- Tell a actorGroup to stop processing messages. This process can take time.
- Tell a actorGroup to start processing messages. At this point, the actorGroup will create a scheduler and be open to accepting new messages.
The coordinator is not involved in message delivery, only to specify what each host should do actorGroup-wise.
All in-flight messages pass through the host where the actorGroup id of the target is determined and if the actorGroup is active on this host, it will e forwarded, without intermediate queuing, to the actorGroup which will then add it to the message queue of the target actor. If on the other hand, the host is not hosting the target actorGroup, the message will be queued to a special static actorGroup and then to a special actor that will deal with communication to the host where that target actor is "running".
The only thing special about a special actorGroup is that it is locked to the host that created it. In other words, a special actorGroup is only special to the host. The special actorGroup is always active. The special actors are only special in that their purpose is to relay a message to another remote host. The special actorGroup will have one actor for each host in the network. These actors are also used for sending actor replicas.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the host by closing the ActorGroups.protected voidforwardToHost(int hostNumber, NormalMessage nm) Figure our where the host is and send this message theregetActorGroup(HostEntry hostEntry) Get stats for all active actorGroupsintgetStatisticsFor(ActorId actorId) booleanprotected voidreplicate(int host, NormalMessage nm) booleanSend this message to live actor and also copy it to other specified host(s)protected booleanvoidsetInitialized(boolean initialized) voidupdate()Get the updated configuration from coordinator and add/remove actor groups as needed.voidThis method is only useful for testing when it is expected that the message load will drop to zero.
-
Field Details
-
activeActorGroups
-
-
Constructor Details
-
AbstractHost
-
-
Method Details
-
getConfig
-
getHostNumber
public int getHostNumber()- Specified by:
getHostNumberin interfaceHost
-
getActorGroupStatistics
Description copied from interface:HostGet stats for all active actorGroups- Specified by:
getActorGroupStatisticsin interfaceHost
-
getStatisticsFor
- Specified by:
getStatisticsForin interfaceHost
-
isInitialized
public boolean isInitialized() -
getCoordinator
- Specified by:
getCoordinatorin interfaceHost
-
setInitialized
public void setInitialized(boolean initialized) -
update
public void update()Get the updated configuration from coordinator and add/remove actor groups as needed. -
getHostEntries
- Specified by:
getHostEntriesin interfaceHost
-
getActorGroup
- Specified by:
getActorGroupin interfaceHost
-
getActorGroups
- Specified by:
getActorGroupsin interfaceHost
-
close
Close the host by closing the ActorGroups. ActorGroup < 0 precedes normal actor groups.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceHost- Throws:
IOException
-
replicate
-
forwardToHost
Figure our where the host is and send this message there- Parameters:
hostNumber-nm- A normal message
-
send
Send this message to live actor and also copy it to other specified host(s) -
sendNormalMessage
-
waitForMessagesToFinish
public void waitForMessagesToFinish()This method is only useful for testing when it is expected that the message load will drop to zero.- Specified by:
waitForMessagesToFinishin interfaceHost
-