ablog

不器用で落着きのない技術者のメモ

amazon-keyspaces-java-driver-helpers を使ってみる

  • 必要なファイルを取得
$ git clone https://github.com/aws-samples/amazon-keyspaces-java-driver-helpers.git
  • リージョンを ap-norhtaset-1 に書換え
$ find . -type f -regex '.*\.\(conf\|java\).*'  -print0|xargs -0 perl -i.org -pe 's/us-east-[0-9]/ap-northeast-1/gi'
$ mvn clean package

トラブルシューティング

  • mvn clean package で以下のエラーが発生。
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.412 s
[INFO] Finished at: 2023-08-22T06:46:03+00:00
[INFO] Final Memory: 20M/70M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project amazon-keyspaces-helpers: There are test failures.
[ERROR]
[ERROR] Please refer to /home/ec2-user/amazon-keyspaces-java-driver-helpers/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
  • /home/ec2-user/amazon-keyspaces-java-driver-helpers/target/surefire-reports 以下のレポートを確認する。
$ pwd
/home/ec2-user/amazon-keyspaces-java-driver-helpers/target/surefire-reports
$ ls -1
TEST-com.aws.ssa.keyspaces.loadbalancing.AmazonKeyspacesLoadbalancingPolicyTest.xml
TEST-com.aws.ssa.keyspaces.retry.AmazonKeyspacesExponentialRetryPolicyTest.xml
TEST-com.aws.ssa.keyspaces.retry.AmazonKeyspacesRetryPolicyTest.xml
TEST-com.aws.ssa.keyspaces.retry.KeyspacesRetryOptionTest.xml
TEST-com.aws.ssa.keyspaces.throttler.AmazonKeyspacesFixedRateThrottlerTest.xml
TEST-com.aws.ssa.keyspaces.validation.ValidationTest.xml
com.aws.ssa.keyspaces.loadbalancing.AmazonKeyspacesLoadbalancingPolicyTest.txt
com.aws.ssa.keyspaces.retry.AmazonKeyspacesExponentialRetryPolicyTest.txt
com.aws.ssa.keyspaces.retry.AmazonKeyspacesRetryPolicyTest.txt
com.aws.ssa.keyspaces.retry.KeyspacesRetryOptionTest.txt
com.aws.ssa.keyspaces.throttler.AmazonKeyspacesFixedRateThrottlerTest.txt
com.aws.ssa.keyspaces.validation.ValidationTest.txt
  • AmazonKeyspacesExponentialRetryPolicyTest、AmazonKeyspacesFixedRateThrottlerTest 以外は成功している。
$ head -4  *.txt
==> com.aws.ssa.keyspaces.loadbalancing.AmazonKeyspacesLoadbalancingPolicyTest.txt <==
-------------------------------------------------------------------------------
Test set: com.aws.ssa.keyspaces.loadbalancing.AmazonKeyspacesLoadbalancingPolicyTest
-------------------------------------------------------------------------------
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.088 sec

==> com.aws.ssa.keyspaces.retry.AmazonKeyspacesExponentialRetryPolicyTest.txt <==
-------------------------------------------------------------------------------
Test set: com.aws.ssa.keyspaces.retry.AmazonKeyspacesExponentialRetryPolicyTest
-------------------------------------------------------------------------------
Tests run: 16, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.942 sec <<< FAILURE! ★失敗

==> com.aws.ssa.keyspaces.retry.AmazonKeyspacesRetryPolicyTest.txt <==
-------------------------------------------------------------------------------
Test set: com.aws.ssa.keyspaces.retry.AmazonKeyspacesRetryPolicyTest
-------------------------------------------------------------------------------
Tests run: 13, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.168 sec

==> com.aws.ssa.keyspaces.retry.KeyspacesRetryOptionTest.txt <==
-------------------------------------------------------------------------------
Test set: com.aws.ssa.keyspaces.retry.KeyspacesRetryOptionTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec

==> com.aws.ssa.keyspaces.throttler.AmazonKeyspacesFixedRateThrottlerTest.txt <==
-------------------------------------------------------------------------------
Test set: com.aws.ssa.keyspaces.throttler.AmazonKeyspacesFixedRateThrottlerTest
-------------------------------------------------------------------------------
Tests run: 8, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 8.143 sec <<< FAILURE! ★失敗

==> com.aws.ssa.keyspaces.validation.ValidationTest.txt <==
-------------------------------------------------------------------------------
Test set: com.aws.ssa.keyspaces.validation.ValidationTest
-------------------------------------------------------------------------------
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.336 sec
  • エラーの詳細を確認
$ less com.aws.ssa.keyspaces.throttler.AmazonKeyspacesFixedRateThrottlerTest.txt
-------------------------------------------------------------------------------
Test set: com.aws.ssa.keyspaces.throttler.AmazonKeyspacesFixedRateThrottlerTest
-------------------------------------------------------------------------------
Tests run: 8, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 7.674 sec <<< FAILURE!
simpleConnectionReconmendationTest(com.aws.ssa.keyspaces.throttler.AmazonKeyspacesFixedRateThrottlerTest)  Time elapsed: 2.883 sec  <<< ERROR!
java.lang.IllegalArgumentException: Error instantiating class com.aws.ssa.keyspaces.throttler.AmazonKeyspacesFixedRateThrottler (specified by advanced.throttler.class): Detected a synchronous API call on a driver thread, failing because this can cause deadlocks.
        at com.datastax.oss.driver.internal.core.util.Reflection.buildFromConfig(Reflection.java:253)
        at com.datastax.oss.driver.internal.core.util.Reflection.buildFromConfig(Reflection.java:108)
        at com.datastax.oss.driver.internal.core.context.DefaultDriverContext.buildRequestThrottler(DefaultDriverContext.java:573)
        at com.datastax.oss.driver.internal.core.util.concurrent.LazyReference.get(LazyReference.java:55)
        at com.datastax.oss.driver.internal.core.context.DefaultDriverContext.getRequestThrottler(DefaultDriverContext.java:891)
        at com.datastax.oss.driver.internal.core.session.DefaultSession$SingleThreaded.init(DefaultSession.java:346)
        at com.datastax.oss.driver.internal.core.session.DefaultSession$SingleThreaded.access$1100(DefaultSession.java:300)
        at com.datastax.oss.driver.internal.core.session.DefaultSession.lambda$init$0(DefaultSession.java:146)
        at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98)
        at io.netty.util.concurrent.PromiseTask.run(PromiseTask.java:106)
        at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalStateException: Detected a synchronous API call on a driver thread, failing because this can cause deadlocks.
        at com.datastax.oss.driver.internal.core.util.concurrent.BlockingOperation.checkNotDriverThread(BlockingOperation.java:45)
        at com.datastax.oss.driver.api.core.session.SessionBuilder.build(SessionBuilder.java:772)
        at com.aws.ssa.keyspaces.throttler.AmazonKeyspacesFixedRateThrottler.<init>(AmazonKeyspacesFixedRateThrottler.java:220)
        at com.aws.ssa.keyspaces.throttler.AmazonKeyspacesFixedRateThrottler.<init>(AmazonKeyspacesFixedRateThrottler.java:111)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at com.datastax.oss.driver.internal.core.util.Reflection.buildFromConfig(Reflection.java:246)
$ less com.aws.ssa.keyspaces.retry.AmazonKeyspacesExponentialRetryPolicyTest.txt
-------------------------------------------------------------------------------
Test set: com.aws.ssa.keyspaces.retry.AmazonKeyspacesExponentialRetryPolicyTest
-------------------------------------------------------------------------------
Tests run: 16, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.752 sec <<< FAILURE!
determineRetryTimeToWaitMax(com.aws.ssa.keyspaces.retry.AmazonKeyspacesExponentialRetryPolicyTest)  Time elapsed: 0.507 sec  <<< FAILURE!
java.lang.AssertionError
        at org.junit.Assert.fail(Assert.java:87)
        at org.junit.Assert.assertTrue(Assert.java:42)
        at org.junit.Assert.assertTrue(Assert.java:53)
        at com.aws.ssa.keyspaces.retry.AmazonKeyspacesExponentialRetryPolicyTest.determineRetryTimeToWaitMax(AmazonKeyspacesExponentialRetryPolicyTest.java:101)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
        at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
        at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)