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.String
DEFAULT_SEARCH_PORT
The default listen port, as a string.static java.lang.String
DEFAULT_THREAD_POOL_SIZE
The default number of threads, as a string.static java.lang.String
PRODUCT_INDEXER_PROPERTY
The configuration property used to reference a ProductIndex.static java.lang.String
PRODUCT_STORAGE_PROPERTY
The configuration property used to reference a URLProductStorage.static java.lang.String
SEARCH_PORT_PROPERTY
The configuration property used for listen port.static java.lang.String
THREAD_POOL_SIZE_PROPERTY
The 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 void
configure(Config config)
Process configuration settings.Indexer
getIndexer()
int
getPort()
int
getThreads()
void
onSocket(java.net.Socket socket)
This method is called each time a SearchSocket connects.protected SearchResponse
search(SearchRequest request)
Method to perform search.void
setIndex(Indexer indexer)
void
setPort(int port)
void
setThreads(int threads)
void
shutdown()
Stop any processing/background threads.void
startup()
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:
onSocket
in interfaceSocketListenerInterface
- Parameters:
socket
- socket to be processed.
-
configure
public void configure(Config config) throws java.lang.Exception
Description copied from class:DefaultConfigurable
Process configuration settings. Called before startup().- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classDefaultConfigurable
- Parameters:
config
- the Config object with settings.- Throws:
java.lang.Exception
- if configuration exceptions occur.
-
shutdown
public void shutdown() throws java.lang.Exception
Description copied from class:DefaultConfigurable
Stop any processing/background threads.- Specified by:
shutdown
in interfaceConfigurable
- Overrides:
shutdown
in classDefaultConfigurable
- Throws:
java.lang.Exception
- if exceptions occur while starting.
-
startup
public void startup() throws java.lang.Exception
Description copied from class:DefaultConfigurable
Start any processing/background threads.- Specified by:
startup
in interfaceConfigurable
- Overrides:
startup
in 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
-
-