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 TypeMethodDescriptionvoid
close()
Close the host by closing the ActorGroups.protected void
forwardToHost
(int hostNumber, NormalMessage nm) Figure our where the host is and send this message theregetActorGroup
(HostEntry hostEntry) Get stats for all active actorGroupsint
getStatisticsFor
(ActorId actorId) boolean
protected void
replicate
(int host, NormalMessage nm) boolean
Send this message to live actor and also copy it to other specified host(s)protected boolean
void
setInitialized
(boolean initialized) void
update()
Get the updated configuration from coordinator and add/remove actor groups as needed.void
This 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:
getHostNumber
in interfaceHost
-
getActorGroupStatistics
Description copied from interface:Host
Get stats for all active actorGroups- Specified by:
getActorGroupStatistics
in interfaceHost
-
getStatisticsFor
- Specified by:
getStatisticsFor
in interfaceHost
-
isInitialized
public boolean isInitialized() -
getCoordinator
- Specified by:
getCoordinator
in 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:
getHostEntries
in interfaceHost
-
getActorGroup
- Specified by:
getActorGroup
in interfaceHost
-
getActorGroups
- Specified by:
getActorGroups
in interfaceHost
-
close
Close the host by closing the ActorGroups. ActorGroup < 0 precedes normal actor groups.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in 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:
waitForMessagesToFinish
in interfaceHost
-