diff --git a/athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/NeptuneConnection.java b/athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/NeptuneConnection.java index ef1ba9ef02..311541b098 100644 --- a/athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/NeptuneConnection.java +++ b/athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/NeptuneConnection.java @@ -19,6 +19,7 @@ */ package com.amazonaws.athena.connectors.neptune; +import com.amazonaws.auth.AWSCredentialsProvider; import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; import com.amazonaws.neptune.auth.NeptuneNettyHttpSigV4Signer; import com.amazonaws.neptune.auth.NeptuneSigV4SignerException; @@ -27,10 +28,13 @@ import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection; import org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class NeptuneConnection { private static Cluster cluster = null; + private static final Logger logger = LoggerFactory.getLogger(NeptuneConnection.class); private String neptuneEndpoint; private String neptunePort; @@ -45,14 +49,17 @@ protected NeptuneConnection(String neptuneEndpoint, String neptunePort, boolean .enableSsl(true); if (enabledIAM) { + logger.info("Connecting with IAM auth to https://" + neptuneEndpoint + ":" + neptunePort + " in " + region); + final AWSCredentialsProvider awsCredentialsProvider = new DefaultAWSCredentialsProviderChain(); builder.handshakeInterceptor(r -> { try { NeptuneNettyHttpSigV4Signer sigV4Signer = - new NeptuneNettyHttpSigV4Signer(region, new DefaultAWSCredentialsProviderChain()); + new NeptuneNettyHttpSigV4Signer(region, awsCredentialsProvider); sigV4Signer.signRequest(r); } catch (NeptuneSigV4SignerException e) { + logger.error("SIGV4 exception", e); throw new RuntimeException("Exception occurred while signing the request", e); } return r; diff --git a/athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/propertygraph/NeptuneGremlinConnection.java b/athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/propertygraph/NeptuneGremlinConnection.java index 734f8aac72..55b77a3d9e 100644 --- a/athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/propertygraph/NeptuneGremlinConnection.java +++ b/athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/propertygraph/NeptuneGremlinConnection.java @@ -20,6 +20,7 @@ package com.amazonaws.athena.connectors.neptune.propertygraph; import com.amazonaws.athena.connectors.neptune.NeptuneConnection; +import com.amazonaws.auth.AWSCredentialsProvider; import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; import com.amazonaws.neptune.auth.NeptuneNettyHttpSigV4Signer; import com.amazonaws.neptune.auth.NeptuneSigV4SignerException; @@ -28,9 +29,12 @@ import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection; import org.apache.tinkerpop.gremlin.process.traversal.AnonymousTraversalSource; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class NeptuneGremlinConnection extends NeptuneConnection { + private static final Logger logger = LoggerFactory.getLogger(NeptuneGremlinConnection.class); private static Cluster cluster = null; public NeptuneGremlinConnection(String neptuneEndpoint, String neptunePort, boolean enabledIAM, String region) @@ -42,14 +46,17 @@ public NeptuneGremlinConnection(String neptuneEndpoint, String neptunePort, bool .enableSsl(true); if (enabledIAM) { + logger.info("Connecting with IAM auth to https://" + neptuneEndpoint + ":" + neptunePort + " in " + region); + final AWSCredentialsProvider awsCredentialsProvider = new DefaultAWSCredentialsProviderChain(); builder.handshakeInterceptor(r -> { try { NeptuneNettyHttpSigV4Signer sigV4Signer = - new NeptuneNettyHttpSigV4Signer(region, new DefaultAWSCredentialsProviderChain()); + new NeptuneNettyHttpSigV4Signer(region, awsCredentialsProvider); sigV4Signer.signRequest(r); } catch (NeptuneSigV4SignerException e) { + logger.error("SIGV4 exception", e); throw new RuntimeException("Exception occurred while signing the request", e); } return r; diff --git a/athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/propertygraph/rowwriters/CustomSchemaRowWriter.java b/athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/propertygraph/rowwriters/CustomSchemaRowWriter.java index 8dc991a741..5538bfc2c6 100644 --- a/athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/propertygraph/rowwriters/CustomSchemaRowWriter.java +++ b/athena-neptune/src/main/java/com/amazonaws/athena/connectors/neptune/propertygraph/rowwriters/CustomSchemaRowWriter.java @@ -78,7 +78,7 @@ public static void writeRowTemplate(RowWriterBuilder rowWriterBuilder, Field fie Object fieldValue = obj.get(fieldName); logger.debug("writeRowTemplate BIT*" + field.getName() + "*" + minorType + "*" - + fieldValue + "*" + (fieldValue == null ? "" : fieldValue.getClass()) + "*"); + + (fieldValue == null ? "" : fieldValue.getClass()) + "*"); if (fieldValue.getClass().equals(Boolean.class)) { Boolean booleanValue = Boolean.parseBoolean(fieldValue.toString()); @@ -114,7 +114,7 @@ public static void writeRowTemplate(RowWriterBuilder rowWriterBuilder, Field fie else { Object fieldValue = obj.get(fieldName); logger.debug("writeRowTemplate VARCHAR*" + field.getName() + "*" + minorType + "*" - + fieldValue + "*" + (fieldValue == null ? "" : fieldValue.getClass()) + "*"); + + (fieldValue == null ? "" : fieldValue.getClass()) + "*"); if (fieldValue != null) { if (fieldValue.getClass().equals(String.class)) { @@ -146,7 +146,7 @@ else if (fieldValue instanceof ArrayList) { Object fieldValue = obj.get(fieldName); logger.debug("writeRowTemplate DATEMILLI*" + field.getName() + "*" + minorType + "*" - + fieldValue + "*" + (fieldValue == null ? "" : fieldValue.getClass()) + "*"); + + (fieldValue == null ? "" : fieldValue.getClass()) + "*"); if (fieldValue.getClass().equals(Date.class)) { value.value = ((Date) fieldValue).getTime(); value.isSet = 1; @@ -170,7 +170,7 @@ else if (fieldValue instanceof ArrayList) { Object fieldValue = obj.get(fieldName); logger.debug("writeRowTemplate INT*" + field.getName() + "*" + minorType + "*" - + fieldValue + "*" + (fieldValue == null ? "" : fieldValue.getClass()) + "*"); + + (fieldValue == null ? "" : fieldValue.getClass()) + "*"); if (fieldValue.getClass().equals(Integer.class)) { value.value = Integer.parseInt(fieldValue.toString()); value.isSet = 1; @@ -194,7 +194,7 @@ else if (fieldValue instanceof ArrayList) { Object fieldValue = obj.get(fieldName); logger.debug("writeRowTemplate BIGINT*" + field.getName() + "*" + minorType + "*" - + fieldValue + "*" + (fieldValue == null ? "" : fieldValue.getClass()) + "*"); + + (fieldValue == null ? "" : fieldValue.getClass()) + "*"); if (fieldValue.getClass().equals(Long.class)) { value.value = Long.parseLong(fieldValue.toString()); value.isSet = 1; @@ -218,7 +218,7 @@ else if (fieldValue instanceof ArrayList) { Object fieldValue = obj.get(fieldName); logger.debug("writeRowTemplate FLOAT4*" + field.getName() + "*" + minorType + "*" - + fieldValue + "*" + (fieldValue == null ? "" : fieldValue.getClass()) + "*"); + + (fieldValue == null ? "" : fieldValue.getClass()) + "*"); if (fieldValue.getClass().equals(Float.class)) { value.value = Float.parseFloat(fieldValue.toString()); value.isSet = 1; @@ -242,7 +242,7 @@ else if (fieldValue instanceof ArrayList) { Object fieldValue = obj.get(fieldName); logger.debug("writeRowTemplate FLOAT8*" + field.getName() + "*" + minorType + "*" - + fieldValue + "*" + (fieldValue == null ? "" : fieldValue.getClass()) + "*"); + + (fieldValue == null ? "" : fieldValue.getClass()) + "*"); if (fieldValue.getClass().equals(Double.class)) { value.value = Double.parseDouble(fieldValue.toString()); value.isSet = 1; @@ -261,7 +261,7 @@ else if (fieldValue instanceof ArrayList) { } catch (Throwable e) { logger.error("writeRowTemplate exception for *" + field.getName() + "*" + minorType + "*", e); - //throw new RuntimeException(e); + throw new RuntimeException(e); } }