Package gov.usgs.earthquake.indexer
Class SearchServerSocket
- java.lang.Object
-
- gov.usgs.util.DefaultConfigurable
-
- gov.usgs.earthquake.indexer.SearchServerSocket
-
- All Implemented Interfaces:
Configurable,SocketListenerInterface
public class SearchServerSocket extends DefaultConfigurable implements SocketListenerInterface
Server side of socket search interface.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_SEARCH_PORTThe default listen port, as a string.static java.lang.StringDEFAULT_THREAD_POOL_SIZEThe default number of threads, as a string.static java.lang.StringPRODUCT_INDEXER_PROPERTYThe configuration property used to reference a ProductIndex.static java.lang.StringPRODUCT_STORAGE_PROPERTYThe configuration property used to reference a URLProductStorage.static java.lang.StringSEARCH_PORT_PROPERTYThe configuration property used for listen port.static java.lang.StringTHREAD_POOL_SIZE_PROPERTYThe configuration property used for listen thread count.
-
Constructor Summary
Constructors Constructor Description SearchServerSocket()Construct a new SearchServerSocket using defaults.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(Config config)Process configuration settings.IndexergetIndexer()intgetPort()intgetThreads()voidonSocket(java.net.Socket socket)This method is called each time a SearchSocket connects.protected SearchResponsesearch(SearchRequest request)Method to perform search.voidsetIndex(Indexer indexer)voidsetPort(int port)voidsetThreads(int threads)voidshutdown()Stop any processing/background threads.voidstartup()Start any processing/background threads.-
Methods inherited from class gov.usgs.util.DefaultConfigurable
getName, setName
-
-
-
-
Field Detail
-
SEARCH_PORT_PROPERTY
public static final java.lang.String SEARCH_PORT_PROPERTY
The configuration property used for listen port.- See Also:
- Constant Field Values
-
DEFAULT_SEARCH_PORT
public static final java.lang.String DEFAULT_SEARCH_PORT
The default listen port, as a string.- See Also:
- Constant Field Values
-
THREAD_POOL_SIZE_PROPERTY
public static final java.lang.String THREAD_POOL_SIZE_PROPERTY
The configuration property used for listen thread count.- See Also:
- Constant Field Values
-
DEFAULT_THREAD_POOL_SIZE
public static final java.lang.String DEFAULT_THREAD_POOL_SIZE
The default number of threads, as a string.- See Also:
- Constant Field Values
-
PRODUCT_INDEXER_PROPERTY
public static final java.lang.String PRODUCT_INDEXER_PROPERTY
The configuration property used to reference a ProductIndex.- See Also:
- Constant Field Values
-
PRODUCT_STORAGE_PROPERTY
public static final java.lang.String PRODUCT_STORAGE_PROPERTY
The configuration property used to reference a URLProductStorage.- See Also:
- Constant Field Values
-
-
Method Detail
-
search
protected SearchResponse search(SearchRequest request) throws java.lang.Exception
Method to perform search. Calls Indexer.search(SearchRequest). Simplifies testing.- Parameters:
request- the search to execute.- Returns:
- the search response.
- Throws:
java.lang.Exception- if error occurs
-
onSocket
public void onSocket(java.net.Socket socket)
This method is called each time a SearchSocket connects.- Specified by:
onSocketin interfaceSocketListenerInterface- Parameters:
socket- socket to be processed.
-
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 classDefaultConfigurable- Parameters:
config- the Config object with settings.- Throws:
java.lang.Exception- if configuration exceptions occur.
-
shutdown
public void shutdown() throws java.lang.ExceptionDescription copied from class:DefaultConfigurableStop any processing/background threads.- Specified by:
shutdownin interfaceConfigurable- Overrides:
shutdownin classDefaultConfigurable- Throws:
java.lang.Exception- if exceptions occur while starting.
-
startup
public void startup() throws java.lang.ExceptionDescription copied from class:DefaultConfigurableStart any processing/background threads.- Specified by:
startupin interfaceConfigurable- Overrides:
startupin classDefaultConfigurable- Throws:
java.lang.Exception- if exceptions occur while starting.
-
getPort
public int getPort()
- Returns:
- int port
-
setPort
public void setPort(int port)
- Parameters:
port- int to set
-
getThreads
public int getThreads()
- Returns:
- int threads
-
setThreads
public void setThreads(int threads)
- Parameters:
threads- into to set
-
getIndexer
public Indexer getIndexer()
- Returns:
- indexer
-
setIndex
public void setIndex(Indexer indexer)
- Parameters:
indexer- to set
-
-