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 TypeMethodDescriptionvoid
Process configuration settings.int
getPort()
long
int
void
Called with any sockets to be read.void
setPort
(int port) void
setSizeLimit
(long sizeLimit) void
setThreads
(int threads) void
shutdown()
Stop any processing/background threads.void
startup()
Start any processing/background threads.protected String
storeAndNotify
(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, 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 Details
-
Method Details
-
configure
Description copied from class:DefaultConfigurable
Process configuration settings. Called before startup().- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classDefaultNotificationReceiver
- Parameters:
config
- the Config object with settings.- Throws:
Exception
- if configuration exceptions occur.
-
startup
Description copied from class:DefaultConfigurable
Start any processing/background threads.- Specified by:
startup
in interfaceConfigurable
- Overrides:
startup
in classDefaultNotificationReceiver
- Throws:
Exception
- if exceptions occur while starting.
-
shutdown
Description copied from class:DefaultConfigurable
Stop any processing/background threads.- Specified by:
shutdown
in interfaceConfigurable
- Overrides:
shutdown
in classDefaultNotificationReceiver
- Throws:
Exception
- if exceptions occur while starting.
-
onSocket
Description copied from interface:SocketListenerInterface
Called with any sockets to be read.- Specified by:
onSocket
in 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
-