Package gov.usgs.earthquake.aws
Class AwsBatchIndexer
java.lang.Object
gov.usgs.earthquake.aws.AwsBatchIndexer
- All Implemented Interfaces:
Bootstrappable
Class to index a batch of products that have already been sent to the AWS
hub.
Reads a list of products to be indexed. Reads indexer from configuration
file.
For each product, fetch product information from the get_product AWS endpoint
and call indexer.onProduct.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Argument for database driverstatic final String
Argument for database URLstatic final String
Force reindex argumentstatic final String
Get product URL argumentstatic final String
Argument for indexer configuration namestatic final String
Default indexer configuration namestatic final String
Argument for indexer databasestatic final String
Default database for indexerFields inherited from interface gov.usgs.earthquake.distribution.Bootstrappable
RUN_EXCEPTION_EXIT_CODE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetProduct
(ProductId id) Get Product from endpoint.Use getProductUrl template to generate URL.void
Fetch and Index a product.void
readProductIdsFromDatabase
(String driver, String url) Read product ids (as urns) from database and submit to executor for processing.void
Read product ids (as urns) from stdin and submit to executor for processing.void
Called by Bootstrap after processing the Configurable interface.void
Submit a product id to the executor service for processing.
-
Field Details
-
FORCE_REINDEX_ARGUMENT
Force reindex argument- See Also:
-
GET_PRODUCT_URL_ARGUMENT
Get product URL argument- See Also:
-
INDEXER_CONFIG_NAME_ARGUMENT
Argument for indexer configuration name- See Also:
-
INDEXER_CONFIG_NAME_DEFAULT
Default indexer configuration name- See Also:
-
DATABASE_DRIVER_ARGUMENT
Argument for database driver- See Also:
-
DATABASE_URL_ARGUMENT
Argument for database URL- See Also:
-
INDEXER_DATABASE_ARGUMENT
Argument for indexer database- See Also:
-
INDEXER_DATABASE_DEFAULT
Default database for indexer- See Also:
-
-
Constructor Details
-
AwsBatchIndexer
public AwsBatchIndexer()
-
-
Method Details
-
run
Description copied from interface:Bootstrappable
Called by Bootstrap after processing the Configurable interface.- Specified by:
run
in interfaceBootstrappable
- Parameters:
args
- array of command line arguments.- Throws:
Exception
- Exception
-
getProductUrl
Use getProductUrl template to generate URL. Replace "{source}", "{type}", "{code}", and "{updateTime}" placeholders.- Parameters:
id
- which product.- Returns:
- URL with placeholders replaced.
- Throws:
Exception
- Exception
-
getProduct
Get Product from endpoint.- Parameters:
id
- which product.- Returns:
- Product object.
- Throws:
Exception
- Exception
-
processProductId
Fetch and Index a product. Called from executor service to process product ids.- Parameters:
id
- which product
-
readProductIdsFromDatabase
Read product ids (as urns) from database and submit to executor for processing.- Parameters:
driver
- database driverurl
- database url- Throws:
Exception
- exception
-
readProductIdsFromStdin
Read product ids (as urns) from stdin and submit to executor for processing.- Throws:
Exception
- Exception
-
submitProductId
Submit a product id to the executor service for processing. If queue is too large (500 ids), blocks until queue is smaller (100 ids).- Parameters:
id
- which product- Throws:
InterruptedException
- InterruptedException
-