Skip to content
Snippets Groups Projects
Commit 71df01c8 authored by MIchael Nguyen's avatar MIchael Nguyen
Browse files

Merge branch 'dockerfile' of...

Merge branch 'dockerfile' of https://git-codecommit.us-east-1.amazonaws.com/v1/repos/os-indexer into dockerfile
parents 14f85aac b4c93a7f
No related branches found
No related tags found
1 merge request!6Trusted ibm
......@@ -81,6 +81,16 @@
<artifactId>log4j-api</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.28</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
......
......@@ -49,57 +49,62 @@ public class IndexerQueue {
AWSLogs log = logConfig.AmazonLog();
PutLogEventsRequest logRequest = new PutLogEventsRequest("ECSLogGroup-indexer-queue", "indexer-queue", new ArrayList<>());
try {
// Logger log = LogManager.getLogger(IndexerQueue.class);
InputLogEvent logEvent = new InputLogEvent().withMessage("Starting Indexer Queue and obtaining Arguments");
logRequest.getLogEvents().add(logEvent);
// log.debug("Retrieving indexer service account JWT");
try {
// log.debug("Starting Indexer Queue and obtaining Arguments");
// log.debug("Retrieving indexer service account JWT");
AWSCognitoClient cognitoClient = new AWSCognitoClient(environmentVariables.cognitoClientId, environmentVariables.cognitoAuthFlow,
environmentVariables.cognitoUser, environmentVariables.cognitoPassword);
String indexerServiceAccountJWT = cognitoClient.getToken();
if(indexerServiceAccountJWT == null){
// log.error("Indexer service account not set up correctly");
// log.error("Indexer service account not set up correctly");
}
// log.debug(String.format("Connecting to the SQS Queue: %s", environmentVariables.queueName));
// log.debug(String.format("Connecting to the SQS Queue: %s", environmentVariables.queueName));
AmazonSQSConfig sqsConfig = new AmazonSQSConfig(environmentVariables.region);
AmazonSQS sqsClient = sqsConfig.AmazonSQS();
// log.debug(String.format("Creating a thread pool with %s threads", environmentVariables.maxIndexThreads));
// log.debug(String.format("Creating a thread pool with %s threads", environmentVariables.maxIndexThreads));
ThreadPoolExecutor executorPool = (ThreadPoolExecutor) Executors.newFixedThreadPool(environmentVariables.maxIndexThreads);
final String deadLetterQueueUrl = sqsClient.getQueueUrl(environmentVariables.deadLetterQueueName).getQueueUrl();
List<Message> messages = IndexerQueueService.getMessages(sqsClient, environmentVariables.queueName, environmentVariables.maxBatchRequestCount, environmentVariables.maxMessagesAllowed);
// log.debug(String.format("Processing %s messages from storage queue", messages.size()));
// log.debug(String.format("Processing %s messages from storage queue", messages.size()));
if (!messages.isEmpty()) {
List<IndexProcessor> indexProcessors = IndexerQueueService.processQueue(messages, environmentVariables.targetURL, executorPool, indexerServiceAccountJWT);
// log.debug(String.format("%s Messages Processed", indexProcessors.size()));
// log.debug(String.format("%s Messages Processed", indexProcessors.size()));
List<IndexProcessor> failedProcessors = indexProcessors.stream().filter(indexProcessor -> indexProcessor.result == CallableResult.Fail || indexProcessor.exception != null).collect(Collectors.toList());
// log.debug(String.format("%s Messages Failed", failedProcessors.size()));
// log.debug(String.format("%s Messages Failed", failedProcessors.size()));
List<SendMessageResult> deadLetterResults = IndexerQueueService.sendMsgsToDeadLetterQueue(deadLetterQueueUrl, failedProcessors, sqsClient);
// log.debug(String.format("%s Messages Dead Lettered", deadLetterResults.size()));
// log.debug(String.format("%s Messages Dead Lettered", deadLetterResults.size()));
List<DeleteMessageBatchRequestEntry> deleteEntries = indexProcessors.stream().map(indexProcessor -> new DeleteMessageBatchRequestEntry(indexProcessor.messageId, indexProcessor.receiptHandle)).collect(Collectors.toList());
// log.debug(String.format("%s Messages Deleting", deleteEntries.size()));
// log.debug(String.format("%s Messages Deleting", deleteEntries.size()));
final String sqsQueueUrl = sqsClient.getQueueUrl(environmentVariables.queueName).getQueueUrl();
List<DeleteMessageBatchRequest> deleteBatchRequests = IndexerQueueService.createMultipleBatchDeleteRequest(sqsQueueUrl, deleteEntries, environmentVariables.maxBatchRequestCount);
// log.debug(String.format("%s Delete Batch Request Created", deleteBatchRequests.size()));
// log.debug(String.format("%s Delete Batch Request Created", deleteBatchRequests.size()));
List<DeleteMessageBatchResult> deleteMessageBatchResults = IndexerQueueService.deleteMessages(deleteBatchRequests, sqsClient);
// log.debug(String.format("%s Requests Deleted", deleteMessageBatchResults.size()));
// log.debug(String.format("%s Requests Deleted", deleteMessageBatchResults.size()));
}
} catch (ExecutionException e) {
// log.error(e.getMessage(), e);
// log.error(e.getMessage(), e);
} catch (InterruptedException e) {
// log.error(e.getMessage(), e);
// log.error(e.getMessage(), e);
} catch (NullPointerException e) {
// log.error(e.getMessage(), e);
// log.error(e.getMessage(), e);
}catch (Exception e) {
// log.error(e.getMessage(), e);
} finally {
......@@ -107,6 +112,4 @@ public class IndexerQueue {
log.putLogEvents(logRequest);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment