Top Description Inners Fields Constructors Methods
net.sf.ehcache.distribution

public final Class MulticastKeepaliveHeartbeatReceiver

extends Object
Class Inheritance
Imports
java.io.IOException, java.net.DatagramPacket, .InetAddress, .MulticastSocket, java.rmi.RemoteException, java.util.Collections, .HashSet, .List, .Set, .StringTokenizer, java.util.concurrent.ExecutorService, .Executors, net.sf.ehcache.CacheManager, net.sf.ehcache.util.NamedThreadFactory, org.slf4j.Logger, .LoggerFactory

Receives heartbeats from any MulticastKeepaliveHeartbeatSenders out there.

Our own multicast heartbeats are ignored.

Author
Greg Luck
Version
$Id: MulticastKeepaliveHeartbeatReceiver.java 10789 2018-04-26 02:08:13Z adahanne $

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
MulticastKeepaliveHeartbeatReceiver.MulticastReceiverThread

A multicast receiver which continously receives heartbeats.

Field Summary

Modifier and TypeField and Description
private final InetAddress
private final Integer
private InetAddress
private static final Logger
private final MulticastRMICacheManagerPeerProvider
private ExecutorService
private MulticastKeepaliveHeartbeatReceiver.MulticastReceiverThread
private Set<E>
private MulticastSocket
private volatile boolean

Constructor Summary

AccessConstructor and Description
public
MulticastKeepaliveHeartbeatReceiver(MulticastRMICacheManagerPeerProvider peerProvider, InetAddress multicastAddress, Integer multicastPort, InetAddress hostAddress)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public final void
dispose()

Shutdown the heartbeat.

pack-priv final void
init()

Start.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

groupMulticastAddressback to summary
private final InetAddress groupMulticastAddress
groupMulticastPortback to summary
private final Integer groupMulticastPort
hostAddressback to summary
private InetAddress hostAddress
LOGback to summary
private static final Logger LOG
peerProviderback to summary
private final MulticastRMICacheManagerPeerProvider peerProvider
processingThreadPoolback to summary
private ExecutorService processingThreadPool
receiverThreadback to summary
private MulticastKeepaliveHeartbeatReceiver.MulticastReceiverThread receiverThread
rmiUrlsProcessingQueueback to summary
private Set<E> rmiUrlsProcessingQueue
socketback to summary
private MulticastSocket socket
stoppedback to summary
private volatile boolean stopped

Constructor Detail

MulticastKeepaliveHeartbeatReceiverback to summary
public MulticastKeepaliveHeartbeatReceiver(MulticastRMICacheManagerPeerProvider peerProvider, InetAddress multicastAddress, Integer multicastPort, InetAddress hostAddress)

Constructor.

Method Detail

disposeback to summary
public final void dispose()

Shutdown the heartbeat.

initback to summary
pack-priv final void init() throws IOException

Start.

net.sf.ehcache.distribution back to summary

private final Class MulticastKeepaliveHeartbeatReceiver.MulticastReceiverThread

extends Thread
Class Inheritance

A multicast receiver which continously receives heartbeats.

Field Summary

Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final void
interrupt()

Overrides java.lang.Thread.interrupt.

Interrupts this thread.
private void
processPayload(byte[] compressedPayload)

private void
processRmiUrls(final String rmiUrls)

This method forks a new executor to process the received heartbeat in a thread pool.

private void
public final void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.
private boolean

Returns:

true if our own hostname and listener port are found in the list. This then means we have caught our onw multicast, and should be ignored.
self
(String rmiUrls)

Inherited from java.lang.Thread:
activeCountcheckAccessclonecountStackFramescurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitresumesetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopsuspendthreadIdtoStringyield

Constructor Detail

MulticastReceiverThreadback to summary
public MulticastReceiverThread()

Constructor

Method Detail

interruptback to summary
public final void interrupt()

Overrides java.lang.Thread.interrupt.

Doc from java.lang.Thread.interrupt.

Interrupts this thread.

Unless the current thread is interrupting itself, which is always permitted, the checkAccess method of this thread is invoked, which may cause a SecurityException to be thrown.

If this thread is blocked in an invocation of the wait(), wait(long), or wait(long, int) methods of the Object class, or of the join(), join(long), join(long, int), sleep(long), or sleep(long, int) methods of this class, then its interrupt status will be cleared and it will receive an InterruptedException.

If this thread is blocked in an I/O operation upon an InterruptibleChannel then the channel will be closed, the thread's interrupt status will be set, and the thread will receive a java.nio.channels.ClosedByInterruptException.

If this thread is blocked in a java.nio.channels.Selector then the thread's interrupt status will be set and it will return immediately from the selection operation, possibly with a non-zero value, just as if the selector's wakeup method were invoked.

If none of the previous conditions hold then this thread's interrupt status will be set.

Interrupting a thread that is not alive need not have any effect.

Annotations
@Override
processPayloadback to summary
private void processPayload(byte[] compressedPayload)
processRmiUrlsback to summary
private void processRmiUrls(final String rmiUrls)

This method forks a new executor to process the received heartbeat in a thread pool. That way each remote cache manager cannot interfere with others.

In the worst case, we have as many concurrent threads as remote cache managers.

registerNotificationback to summary
private void registerNotification(String rmiUrl)
runback to summary
public final void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Doc from java.lang.Thread.run.

This method is run by the thread when it executes. Subclasses of Thread may override this method.

This method is not intended to be invoked directly. If this thread is a platform thread created with a Runnable task then invoking this method will invoke the task's run method. If this thread is a virtual thread then invoking this method directly does nothing.

Annotations
@Override
selfback to summary
private boolean self(String rmiUrls)
Returns:boolean

true if our own hostname and listener port are found in the list. This then means we have caught our onw multicast, and should be ignored.