Package gov.usgs.earthquake.distribution
Class SocketProductReceiver
- java.lang.Object
-
- gov.usgs.util.DefaultConfigurable
-
- gov.usgs.earthquake.distribution.DefaultNotificationReceiver
-
- gov.usgs.earthquake.distribution.SocketProductReceiver
-
- All Implemented Interfaces:
NotificationIndexCleanup.Listener,NotificationReceiver,Configurable,SocketListenerInterface
public class SocketProductReceiver extends DefaultNotificationReceiver implements SocketListenerInterface
Receive Products directly via a Socket. The received products are sent using a SocketProductSender. A SocketProductReceiver receives products directly and notifies listeners of received notifications. These are typically used on hubs with an EIDSNotificationSender or RelayProductReceiver. The NotificationReceiver uses a NotificationIndex to track received notifications, and a ProductStorage to store retrieved products. The DefaultNotificationReceiver implements the Configurable interface and uses the following configuration parameters: Each listener has a separate queue of notifications. Each listener is allocated one thread to process notifications from this queue.
-
-
Field Summary
-
Fields inherited from class gov.usgs.earthquake.distribution.DefaultNotificationReceiver
CONNECT_TIMEOUT_PROPERTY, DEFAULT_CONNECT_TIMEOUT, DEFAULT_PRODUCT_STORAGE_MAX_AGE, DEFAULT_READ_TIMEOUT, DEFAULT_RECEIVER_CLEANUP, EXECUTOR_LISTENER_NOTIFIER, FUTURE_LISTENER_NOTIFIER, INDEX_FILE_PROPERTY, LISTENER_NOTIFIER_PROPERTY, NOTIFICATION_INDEX_PROPERTY, PRODUCT_STORAGE_MAX_AGE_PROPERTY, PRODUCT_STORAGE_PROPERTY, READ_TIMEOUT_PROPERTY, RECEIVER_CLEANUP_PROPERTY, ROUNDROBIN_LISTENER_NOTIFIER, STORAGE_DIRECTORY_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description SocketProductReceiver()Default constructor setting port, threads, and sizeLimit to defaultSocketProductReceiver(Config config)Constructor based on config file
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(Config config)Process configuration settings.intgetPort()longgetSizeLimit()intgetThreads()voidonSocket(java.net.Socket socket)Called with any sockets to be read.voidsetPort(int port)voidsetSizeLimit(long sizeLimit)voidsetThreads(int threads)voidshutdown()Stop any processing/background threads.voidstartup()Start any processing/background threads.protected java.lang.StringstoreAndNotify(ProductSource source)Stores ProductSource as a notification, tracks it, and notifies Listeners-
Methods inherited from class gov.usgs.earthquake.distribution.DefaultNotificationReceiver
addNotificationListener, getConnectTimeout, getListenerQueueStatus, getNotificationIndex, getNotifier, getProductStorage, getProductStorageMaxAge, getQueueStatus, getReadTimeout, getReceiverCleanupInterval, notifyListeners, onExpiredNotification, receiveNotification, removeExpiredNotifications, removeNotificationListener, retrieveProduct, sendNotifications, setConnectTimeout, setNotificationIndex, setNotifier, setProductStorage, setProductStorageMaxAge, setReadTimeout, setReceiverCleanupInterval, storeProductSource, throttleQueues
-
Methods inherited from class gov.usgs.util.DefaultConfigurable
getName, setName
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.usgs.util.Configurable
getName, setName
-
-
-
-
Constructor Detail
-
SocketProductReceiver
public SocketProductReceiver() throws java.lang.ExceptionDefault constructor setting port, threads, and sizeLimit to default- Throws:
java.lang.Exception- if error occurs
-
SocketProductReceiver
public SocketProductReceiver(Config config) throws java.lang.Exception
Constructor based on config file- Parameters:
config- Configuration file- Throws:
java.lang.Exception- if error occurs
-
-
Method Detail
-
configure
public void configure(Config config) throws java.lang.Exception
Description copied from class:DefaultConfigurableProcess configuration settings. Called before startup().- Specified by:
configurein interfaceConfigurable- Overrides:
configurein classDefaultNotificationReceiver- Parameters:
config- the Config object with settings.- Throws:
java.lang.Exception- if configuration exceptions occur.
-
startup
public void startup() throws java.lang.ExceptionDescription copied from class:DefaultConfigurableStart any processing/background threads.- Specified by:
startupin interfaceConfigurable- Overrides:
startupin classDefaultNotificationReceiver- Throws:
java.lang.Exception- if exceptions occur while starting.
-
shutdown
public void shutdown() throws java.lang.ExceptionDescription copied from class:DefaultConfigurableStop any processing/background threads.- Specified by:
shutdownin interfaceConfigurable- Overrides:
shutdownin classDefaultNotificationReceiver- Throws:
java.lang.Exception- if exceptions occur while starting.
-
onSocket
public void onSocket(java.net.Socket socket)
Description copied from interface:SocketListenerInterfaceCalled with any sockets to be read.- Specified by:
onSocketin interfaceSocketListenerInterface- Parameters:
socket- socket to be processed.
-
storeAndNotify
protected java.lang.String storeAndNotify(ProductSource source) throws java.lang.Exception
Stores ProductSource as a notification, tracks it, and notifies Listeners- Parameters:
source- ProductSource- Returns:
- String note for log file
- Throws:
java.lang.Exception- if error occurs
-
getPort
public int getPort()
- Returns:
- port
-
setPort
public void setPort(int port)
- Parameters:
port- int to set
-
getSizeLimit
public long getSizeLimit()
- Returns:
- sizeLimit
-
setSizeLimit
public void setSizeLimit(long sizeLimit)
- Parameters:
sizeLimit- long to set
-
getThreads
public int getThreads()
- Returns:
- threads
-
setThreads
public void setThreads(int threads)
- Parameters:
threads- int to set
-
-