Class 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 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 - if parameters is null
        com.kristensoft.kdc.license.runtime.LicenseException - if the required KDC license cannot be validated
        KristenCommsException - 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 - if group is null
        IllegalStateException - if the multicast socket has not been created
        IOException - if an error occurs while joining the multicast group
      • close

        public void close()
        Closes the multicast socket associated with this client.

        If no socket is currently open, this method has no effect.

        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in class Client
      • isRunning

        public boolean isRunning()
        Determines whether this communication entity is currently running.
        Returns:
        true if this communication entity is running; false otherwise
      • 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