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 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
ConstructorsConstructorDescriptionDefault constructor setting port, threads, and sizeLimit to defaultSocketProductReceiver(Config config) Constructor based on config file -
Method Summary
Modifier and TypeMethodDescriptionvoidProcess configuration settings.intgetPort()longintvoidCalled 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 StringstoreAndNotify(ProductSource source) Stores ProductSource as a notification, and notifies ListenersMethods 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, throttleQueuesMethods inherited from class gov.usgs.util.DefaultConfigurable
getName, setNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface gov.usgs.util.Configurable
getName, setName
-
Constructor Details
-
Method Details
-
configure
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:
Exception- if configuration exceptions occur.
-
startup
Description copied from class:DefaultConfigurableStart any processing/background threads.- Specified by:
startupin interfaceConfigurable- Overrides:
startupin classDefaultNotificationReceiver- Throws:
Exception- if exceptions occur while starting.
-
shutdown
Description copied from class:DefaultConfigurableStop any processing/background threads.- Specified by:
shutdownin interfaceConfigurable- Overrides:
shutdownin classDefaultNotificationReceiver- Throws:
Exception- if exceptions occur while starting.
-
onSocket
Description copied from interface:SocketListenerInterfaceCalled with any sockets to be read.- Specified by:
onSocketin interfaceSocketListenerInterface- Parameters:
socket- socket to be processed.
-
storeAndNotify
Stores ProductSource as a notification, and notifies Listeners- Parameters:
source- ProductSource- Returns:
- String note for log file
- Throws:
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
-