use of io.datarouter.storage.node.NodeTool in project datarouter by hotpads.
the class SqsQueueRegistryService method getSqsQueuesForClient.
public Pair<List<Twin<String>>, List<String>> getSqsQueuesForClient(ClientId clientId) {
Set<String> knownQueuesUrls = new HashSet<>();
AmazonSQS sqs = sqsClientManager.getAmazonSqs(clientId);
List<? extends BaseSqsNode<?, ?, ?>> sqsNodes = Scanner.of(nodes.getPhysicalNodesForClient(clientId.getName())).map(NodeTool::extractSinglePhysicalNode).map(physicalNode -> (BaseSqsNode<?, ?, ?>) physicalNode).list();
List<Twin<String>> knownQueueUrlByName = Scanner.of(sqsNodes).map(BaseSqsNode::getQueueUrlAndName).map(Supplier::get).each(twin -> knownQueuesUrls.add(twin.getLeft())).list();
List<String> unreferencedQueues = Scanner.of(sqsNodes).map(BaseSqsNode::buildNamespace).distinct().map(sqs::listQueues).concatIter(ListQueuesResult::getQueueUrls).exclude(knownQueuesUrls::contains).map(queueUrl -> StringTool.getStringAfterLastOccurrence("/", queueUrl)).include(queueName -> sqsQueueExists(sqs, queueName)).list();
return new Pair<>(knownQueueUrlByName, unreferencedQueues);
}
Aggregations