Search in sources :

Example 1 with EndpointsType

use of software.amazon.neptune.cluster.EndpointsType in project amazon-neptune-tools by awslabs.

the class NeptuneEndpointsInfoLambda method handleRequest.

@Override
public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException {
    LambdaLogger logger = context.getLogger();
    EndpointsType endpointsType = EndpointsType.ReadReplicas;
    Scanner scanner = new Scanner(input);
    if (scanner.hasNext()) {
        String param = scanner.next().replace("\"", "");
        if (!param.isEmpty()) {
            endpointsType = EndpointsType.valueOf(param);
        }
    }
    logger.log("EndpointsType: " + endpointsType);
    Map<EndpointsSelector, Collection<String>> addressesMap = addresses.get();
    for (Map.Entry<EndpointsSelector, Collection<String>> entry : addressesMap.entrySet()) {
        logger.log(entry.getKey() + ": " + entry.getValue());
    }
    String results = String.join(",", addressesMap.get(endpointsType));
    logger.log("Results: " + results);
    try (Writer writer = new BufferedWriter(new OutputStreamWriter(output, UTF_8))) {
        writer.write(results);
        writer.flush();
    }
}
Also used : Scanner(java.util.Scanner) EndpointsSelector(software.amazon.neptune.cluster.EndpointsSelector) EndpointsType(software.amazon.neptune.cluster.EndpointsType) Collection(java.util.Collection) LambdaLogger(com.amazonaws.services.lambda.runtime.LambdaLogger) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

LambdaLogger (com.amazonaws.services.lambda.runtime.LambdaLogger)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Scanner (java.util.Scanner)1 EndpointsSelector (software.amazon.neptune.cluster.EndpointsSelector)1 EndpointsType (software.amazon.neptune.cluster.EndpointsType)1