Class MulticastClient
- java.lang.Object
-
- com.kristensoft.kdc.Client
-
- com.kristensoft.kdc.MulticastClient
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Runnable
public class MulticastClient extends Client
Provides a KDC client for sending and receiving agents using multicast communication.The client may join one or more multicast groups and send asynchronous agents to those groups. Multicast communication is asynchronous and does not support synchronous agent requests.
- Author:
- Charles B. Kozoyed
- See Also:
Client,MulticastParameters,MulticastSocketOptions
-
-
Constructor Summary
Constructors Constructor Description MulticastClient(MulticastParameters parameters)Creates a multicast client using the specified configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the multicast socket associated with this client.voidflushMetrics()Flushes the accumulated latency metrics for this communication entity.AgentSerializergetAgentSerializer()Returns the agent serializer used by this communication entity.MulticastParametersgetMulticastParameters()Returns the configuration parameters for this multicast client.booleanisRunning()Determines whether this communication entity is currently running.voidjoinGroup(InetSocketAddress group)Joins the specified multicast group.voidleaveGroup(InetSocketAddress group)Leaves the specified multicast group.voidsendAsync(Agent agent, InetSocketAddress group)Sends an agent asynchronously to the specified multicast group.-
Methods inherited from class com.kristensoft.kdc.Client
getClientParameters, getServerHub, halt, nextReply, peekReply, pollReply, pollReply, replyAvailable, run, sendAsync, start, stop, takeReply
-
-
-
-
Constructor Detail
-
MulticastClient
public MulticastClient(MulticastParameters parameters) throws com.kristensoft.kdc.license.runtime.LicenseException, KristenCommsException
Creates a multicast client using the specified configuration.The client initializes its multicast agent queue and, if automatic startup is enabled, creates the multicast socket and starts the client. If latency metrics are enabled, the associated metric accumulators are also started.
- Parameters:
parameters- the parameters used to configure this multicast client- Throws:
IllegalArgumentException- ifparametersisnullcom.kristensoft.kdc.license.runtime.LicenseException- if the required KDC license cannot be validatedKristenCommsException- if automatic startup is enabled and the multicast socket cannot be created
-
-
Method Detail
-
getMulticastParameters
public MulticastParameters getMulticastParameters()
Returns the configuration parameters for this multicast client.- Returns:
- the multicast client parameters
-
joinGroup
public void joinGroup(InetSocketAddress group) throws IOException
Joins the specified multicast group.The group is joined using the network interface associated with the configured bind address when that interface can be resolved.
- Parameters:
group- the multicast group to join- Throws:
IllegalArgumentException- ifgroupisnullIllegalStateException- if the multicast socket has not been createdIOException- if an error occurs while joining the multicast group
-
leaveGroup
public void leaveGroup(InetSocketAddress group) throws KristenCommsException
Leaves the specified multicast group.- Parameters:
group- the multicast group to leave- Throws:
IllegalArgumentException- ifgroupisnullIllegalStateException- if the multicast socket has not been createdKristenCommsException- if an error occurs while leaving the multicast group
-
sendAsync
public void sendAsync(Agent agent, InetSocketAddress group) throws IOException, KristenCommsException
Sends an agent asynchronously to the specified multicast group.The agent is serialized and sent to the specified group without waiting for a reply.
- Parameters:
agent- the agent to sendgroup- the multicast group to which the agent is sent- Throws:
IllegalArgumentException- ifagentorgroupisnullIllegalStateException- if the multicast socket has not been createdIOException- if an error occurs while sending the agentKristenCommsException- if an error occurs while serializing the agent
-
close
public void close()
Closes the multicast socket associated with this client.If no socket is currently open, this method has no effect.
-
isRunning
public boolean isRunning()
Determines whether this communication entity is currently running.- Returns:
trueif this communication entity is running;falseotherwise
-
flushMetrics
public void flushMetrics()
Flushes the accumulated latency metrics for this communication entity.This method may be used to report any currently accumulated metrics without waiting for the configured latency reporting interval.
-
getAgentSerializer
public AgentSerializer getAgentSerializer()
Returns the agent serializer used by this communication entity.The serializer may be used to inspect or modify serialization settings at runtime, including compression and encryption settings.
- Returns:
- the agent serializer used by this communication entity
-
-