├── .ci └── scripts │ ├── upload.sh │ ├── install-deps.sh │ └── bump-version.sh ├── docs ├── _config.yml ├── dream11.jpeg └── index.md ├── .github ├── CODEOWNERS ├── PULL_REQUEST_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── workflows │ ├── release-drafter.yml │ ├── ci.yml │ └── release.yml └── release-drafter.yml ├── src ├── test │ ├── resources │ │ ├── init.aql │ │ └── logback-test.xml │ └── java │ │ └── io │ │ └── d11 │ │ └── aerospike │ │ ├── Constants.java │ │ ├── AerospikeConnectionTest.java │ │ ├── AerospikeDeleteTest.java │ │ ├── AerospikePutTest.java │ │ ├── Setup.java │ │ ├── AerospikeQueryTest.java │ │ ├── AerospikeOperateTest.java │ │ ├── AerospikeScanTest.java │ │ ├── AerospikeExistsTest.java │ │ ├── AerospikeGetHeaderTest.java │ │ ├── AerospikeAddTest.java │ │ ├── AerospikeAppendTest.java │ │ ├── AerospikePrependTest.java │ │ └── AerospikeGetTest.java └── main │ └── java │ └── io │ └── d11 │ └── aerospike │ ├── package-info.java │ ├── listeners │ ├── WriteListenerImpl.java │ ├── DeleteListenerImpl.java │ ├── ExistsListenerImpl.java │ ├── ExecuteListenerImpl.java │ ├── RecordListenerImpl.java │ ├── BatchListListenerImpl.java │ ├── ExistsArrayListenerImpl.java │ ├── RecordArrayListenerImpl.java │ └── QueryResultListenerImpl.java │ ├── util │ └── SharedDataUtils.java │ └── client │ ├── AerospikeConnectOptions.java │ ├── impl │ └── AerospikeClientImpl.java │ └── AerospikeClient.java ├── .gitignore ├── LICENSE ├── README.md ├── .editorconfig └── pom.xml /.ci/scripts/upload.sh: -------------------------------------------------------------------------------- 1 | # ToDo: Upload to maven central -------------------------------------------------------------------------------- /.ci/scripts/install-deps.sh: -------------------------------------------------------------------------------- 1 | # Todo: add deps to install 2 | 3 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal 2 | logo: ./dream11.jpeg -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @srijan02420 @dc-dream11 @akshaypatidar1999 @darshanime-d11 -------------------------------------------------------------------------------- /docs/dream11.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dream-horizon-org/vertx-aerospike-client/HEAD/docs/dream11.jpeg -------------------------------------------------------------------------------- /src/test/resources/init.aql: -------------------------------------------------------------------------------- 1 | INSERT INTO test.testset (PK, bin1, bin2) VALUES ('pkey1', 'Mumbai', 123) 2 | INSERT INTO test.testset (PK, bin1, bin2) VALUES ('pkey2', 'Delhi', 3) 3 | -------------------------------------------------------------------------------- /src/main/java/io/d11/aerospike/package-info.java: -------------------------------------------------------------------------------- 1 | @ModuleGen(groupPackage = "io.d11", name = "vertx-aerospike-client") 2 | package io.d11.aerospike; 3 | 4 | import io.vertx.codegen.annotations.ModuleGen; -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Summary 2 | 3 | SUMMARY_GOES_HERE 4 | 5 | ### Full changelog 6 | 7 | * [Implement ...] 8 | * [Add related tests] 9 | * ... 10 | 11 | ### Issues resolved 12 | 13 | Fix #XXX -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea that will improve the library 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Summary 11 | 12 | SUMMARY_GOES_HERE -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help improve the library 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Summary 11 | 12 | SUMMARY_GOES_HERE 13 | 14 | ### Steps To Reproduce 15 | 16 | 1. 17 | 2. 18 | 3. 19 | 20 | ### Additional Details & Logs 21 | 22 | - 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | .DS_Store 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | .idea/** 18 | */*.iml 19 | 20 | ### NetBeans ### 21 | build/ 22 | dist/ 23 | 24 | ### generated ### 25 | **/generated/* 26 | **/asciidoc/* -------------------------------------------------------------------------------- /src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %date %highlight(%+5level) %-26thread %logger{36} [%file:%line] %green(%msg) %n 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.ci/scripts/bump-version.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | release_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) 4 | mvn versions:set -DnextSnapshot=true 5 | bump_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) 6 | 7 | git config user.name github-actions 8 | git config user.email github-actions@github.com 9 | 10 | git add pom.xml 11 | git commit -m "chore: release version $release_version and bump version to $bump_version" 12 | git push origin HEAD:master -------------------------------------------------------------------------------- /src/test/java/io/d11/aerospike/Constants.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike; 2 | 3 | public class Constants { 4 | public static final String NAMESPACE = "NAMESPACE"; 5 | public static final String TEST_NAMESPACE = "test"; 6 | public static final String TEST_SET = "testset"; 7 | public static final String AEROSPIKE_HOST = "aerospike.host"; 8 | public static final String AEROSPIKE_PORT = "aerospike.port"; 9 | public static final String AEROSPIKE_IMAGE_KEY = "aerospike.image"; 10 | public static final String DEFAULT_AEROSPIKE_IMAGE = "aerospike/aerospike-server:6.0.0.0"; 11 | public static final String INIT_DATA_PATH = "src/test/resources/init.aql"; 12 | public static final String INIT_DATA_PATH_IN_CONTAINER = "/aerospike-seed/init.aql"; 13 | } 14 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | # This workflow broadly does 3 tasks- 2 | # (1) Create/Update Release drafts 3 | # (2) Auto Label PR's 4 | 5 | # The update_release_draft job handles these tasks, on the basis of event which triggered workflow. 6 | # (1) if push to master by merging PR. 7 | # (2) if pull request opened, reopended, or synchronized (commit push) 8 | 9 | name: Draft and Bump 10 | 11 | on: 12 | push: 13 | branches: 14 | - master 15 | # pull_request event is required only for autolabeler 16 | pull_request: 17 | types: [opened, reopened, synchronize] 18 | 19 | jobs: 20 | update-release-draft: 21 | runs-on: ubuntu-latest 22 | 23 | outputs: 24 | tag-name: ${{ steps.release-drafter.outputs.tag_name }} 25 | 26 | steps: 27 | - id: release-drafter 28 | uses: release-drafter/release-drafter@v5 29 | env: 30 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Sporta Technologies PVT LTD 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/java/io/d11/aerospike/listeners/WriteListenerImpl.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike.listeners; 2 | 3 | import com.aerospike.client.AerospikeException; 4 | import com.aerospike.client.Key; 5 | import com.aerospike.client.listener.WriteListener; 6 | import io.vertx.core.AsyncResult; 7 | import io.vertx.core.Future; 8 | import io.vertx.core.Handler; 9 | import io.vertx.core.impl.ContextInternal; 10 | 11 | import java.util.Objects; 12 | 13 | 14 | public class WriteListenerImpl implements WriteListener { 15 | final ContextInternal context; 16 | final Handler> handler; 17 | 18 | public WriteListenerImpl(ContextInternal context, Handler> handler) { 19 | Objects.requireNonNull(context, "context must not be null"); 20 | this.context = context; 21 | this.handler = handler; 22 | } 23 | 24 | public void onSuccess(Key key) { 25 | if (handler != null) { 26 | context.runOnContext((v) -> handler.handle(Future.succeededFuture(key))); 27 | } 28 | } 29 | 30 | public void onFailure(AerospikeException e) { 31 | if (handler != null) { 32 | context.runOnContext((v) -> handler.handle(Future.failedFuture(e))); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/d11/aerospike/listeners/DeleteListenerImpl.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike.listeners; 2 | 3 | import com.aerospike.client.AerospikeException; 4 | import com.aerospike.client.Key; 5 | import com.aerospike.client.listener.DeleteListener; 6 | import io.vertx.core.AsyncResult; 7 | import io.vertx.core.Future; 8 | import io.vertx.core.Handler; 9 | import io.vertx.core.impl.ContextInternal; 10 | 11 | import java.util.Objects; 12 | 13 | public class DeleteListenerImpl implements DeleteListener { 14 | final ContextInternal context; 15 | final Handler> handler; 16 | 17 | public DeleteListenerImpl(ContextInternal context, Handler> handler) { 18 | Objects.requireNonNull(context, "context must not be null"); 19 | this.context = context; 20 | this.handler = handler; 21 | } 22 | public void onSuccess(Key key, boolean b) { 23 | if (handler != null) { 24 | context.runOnContext((v) -> handler.handle(Future.succeededFuture(b))); 25 | } 26 | } 27 | 28 | public void onFailure(AerospikeException e) { 29 | if (handler != null) { 30 | context.runOnContext((v) -> handler.handle(Future.failedFuture(e))); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/d11/aerospike/listeners/ExistsListenerImpl.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike.listeners; 2 | 3 | import com.aerospike.client.AerospikeException; 4 | import com.aerospike.client.Key; 5 | import com.aerospike.client.listener.ExistsListener; 6 | import io.vertx.core.AsyncResult; 7 | import io.vertx.core.Future; 8 | import io.vertx.core.Handler; 9 | import io.vertx.core.impl.ContextInternal; 10 | 11 | import java.util.Objects; 12 | 13 | public class ExistsListenerImpl implements ExistsListener { 14 | final ContextInternal context; 15 | final Handler> handler; 16 | 17 | public ExistsListenerImpl(ContextInternal context, Handler> handler) { 18 | Objects.requireNonNull(context, "context must not be null"); 19 | this.context = context; 20 | this.handler = handler; 21 | } 22 | public void onSuccess(Key key, boolean b) { 23 | if (handler != null) { 24 | context.runOnContext((v) -> handler.handle(Future.succeededFuture(b))); 25 | } 26 | } 27 | 28 | public void onFailure(AerospikeException e) { 29 | if (handler != null) { 30 | context.runOnContext((v) -> handler.handle(Future.failedFuture(e))); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/io/d11/aerospike/listeners/ExecuteListenerImpl.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike.listeners; 2 | 3 | import com.aerospike.client.AerospikeException; 4 | import com.aerospike.client.Key; 5 | import com.aerospike.client.listener.ExecuteListener; 6 | import io.vertx.core.AsyncResult; 7 | import io.vertx.core.Future; 8 | import io.vertx.core.Handler; 9 | import io.vertx.core.impl.ContextInternal; 10 | 11 | import java.util.Objects; 12 | 13 | public class ExecuteListenerImpl implements ExecuteListener { 14 | final ContextInternal context; 15 | final Handler> handler; 16 | 17 | public ExecuteListenerImpl(ContextInternal context, Handler> handler) { 18 | Objects.requireNonNull(context, "context must not be null"); 19 | this.context = context; 20 | this.handler = handler; 21 | } 22 | 23 | public void onSuccess(Key key, Object obj) { 24 | if (handler != null) { 25 | context.runOnContext((v) -> handler.handle(Future.succeededFuture(obj))); 26 | } 27 | } 28 | 29 | public void onFailure(AerospikeException e) { 30 | if (handler != null) { 31 | context.runOnContext((v) -> handler.handle(Future.failedFuture(e))); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/d11/aerospike/listeners/RecordListenerImpl.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike.listeners; 2 | 3 | import com.aerospike.client.AerospikeException; 4 | import com.aerospike.client.Key; 5 | import com.aerospike.client.Record; 6 | import com.aerospike.client.listener.RecordListener; 7 | import io.vertx.core.AsyncResult; 8 | import io.vertx.core.Future; 9 | import io.vertx.core.Handler; 10 | import io.vertx.core.impl.ContextInternal; 11 | 12 | import java.util.Objects; 13 | 14 | 15 | public class RecordListenerImpl implements RecordListener { 16 | final ContextInternal context; 17 | final Handler> handler; 18 | 19 | public RecordListenerImpl(ContextInternal context, Handler> handler) { 20 | Objects.requireNonNull(context, "context must not be null"); 21 | this.context = context; 22 | this.handler = handler; 23 | } 24 | 25 | public void onSuccess(Key key, Record record) { 26 | if (handler != null) { 27 | context.runOnContext((v) -> handler.handle(Future.succeededFuture(record))); 28 | } 29 | } 30 | 31 | public void onFailure(AerospikeException e) { 32 | if (handler != null) { 33 | context.runOnContext((v) -> handler.handle(Future.failedFuture(e))); 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/d11/aerospike/listeners/BatchListListenerImpl.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike.listeners; 2 | 3 | import com.aerospike.client.AerospikeException; 4 | import com.aerospike.client.BatchRead; 5 | import com.aerospike.client.listener.BatchListListener; 6 | import io.vertx.core.AsyncResult; 7 | import io.vertx.core.Future; 8 | import io.vertx.core.Handler; 9 | import io.vertx.core.impl.ContextInternal; 10 | 11 | import java.util.List; 12 | import java.util.Objects; 13 | 14 | public class BatchListListenerImpl implements BatchListListener { 15 | final ContextInternal context; 16 | final Handler>> handler; 17 | 18 | public BatchListListenerImpl(io.vertx.core.impl.ContextInternal context, Handler>> handler) { 19 | Objects.requireNonNull(context, "context must not be null"); 20 | this.context = context; 21 | this.handler = handler; 22 | } 23 | 24 | public void onSuccess(List list) { 25 | if (handler != null) { 26 | context.runOnContext((v) -> handler.handle(Future.succeededFuture(list))); 27 | } 28 | } 29 | 30 | public void onFailure(AerospikeException e) { 31 | if (handler != null) { 32 | context.runOnContext((v) -> handler.handle(Future.failedFuture(e))); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/d11/aerospike/listeners/ExistsArrayListenerImpl.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike.listeners; 2 | 3 | import com.aerospike.client.AerospikeException; 4 | import com.aerospike.client.Key; 5 | import com.aerospike.client.listener.ExistsArrayListener; 6 | import com.google.common.primitives.Booleans; 7 | import io.vertx.core.AsyncResult; 8 | import io.vertx.core.Future; 9 | import io.vertx.core.Handler; 10 | import io.vertx.core.impl.ContextInternal; 11 | 12 | import java.util.List; 13 | import java.util.Objects; 14 | 15 | public class ExistsArrayListenerImpl implements ExistsArrayListener { 16 | final ContextInternal context; 17 | final Handler>> handler; 18 | 19 | public ExistsArrayListenerImpl(ContextInternal context, Handler>> handler) { 20 | Objects.requireNonNull(context, "context must not be null"); 21 | this.context = context; 22 | this.handler = handler; 23 | } 24 | public void onSuccess(Key[] keys, boolean[] b) { 25 | if (handler != null) { 26 | context.runOnContext((v) -> handler.handle(Future.succeededFuture(Booleans.asList(b)))); 27 | } 28 | } 29 | 30 | public void onFailure(AerospikeException e) { 31 | if (handler != null) { 32 | context.runOnContext((v) -> handler.handle(Future.failedFuture(e))); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/d11/aerospike/listeners/RecordArrayListenerImpl.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike.listeners; 2 | 3 | import com.aerospike.client.AerospikeException; 4 | import com.aerospike.client.Key; 5 | import com.aerospike.client.Record; 6 | import com.aerospike.client.listener.RecordArrayListener; 7 | import io.vertx.core.AsyncResult; 8 | import io.vertx.core.Future; 9 | import io.vertx.core.Handler; 10 | import io.vertx.core.impl.ContextInternal; 11 | 12 | import java.util.Arrays; 13 | import java.util.List; 14 | import java.util.Objects; 15 | 16 | public class RecordArrayListenerImpl implements RecordArrayListener { 17 | final ContextInternal context; 18 | final Handler>> handler; 19 | 20 | public RecordArrayListenerImpl(ContextInternal context, Handler>> handler) { 21 | Objects.requireNonNull(context, "context must not be null"); 22 | this.context = context; 23 | this.handler = handler; 24 | } 25 | 26 | public void onSuccess(Key[] keys, Record[] records) { 27 | if (handler != null) { 28 | context.runOnContext((v) -> handler.handle(Future.succeededFuture(Arrays.asList(records)))); 29 | } 30 | } 31 | 32 | public void onFailure(AerospikeException e) { 33 | if (handler != null) { 34 | context.runOnContext((v) -> handler.handle(Future.failedFuture(e))); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/d11/aerospike/util/SharedDataUtils.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike.util; 2 | 3 | import io.vertx.core.shareddata.LocalMap; 4 | import io.vertx.core.shareddata.Shareable; 5 | import io.vertx.core.Vertx; 6 | import lombok.val; 7 | import java.util.function.Supplier; 8 | 9 | public final class SharedDataUtils { 10 | private static final String SHARED_DATA_MAP_NAME = "__vertx.sharedDataUtils"; 11 | private static final String SHARED_INSTANCE_FORMAT = "__AerospikeClient.__for.__{}:{}"; 12 | 13 | public SharedDataUtils() { 14 | } 15 | 16 | public static String getInstanceName(String host, Integer port) { 17 | return String.format(SHARED_INSTANCE_FORMAT, host, port); 18 | } 19 | 20 | public static T getOrCreate(Vertx vertx, String name, Supplier supplier) { 21 | LocalMap singletons = vertx.sharedData().getLocalMap(SHARED_DATA_MAP_NAME); 22 | return (T) ((ThreadSafe)singletons.computeIfAbsent(name, k -> new ThreadSafe(supplier.get()))).getObject(); 23 | } 24 | 25 | public static void removeInstanceByName(Vertx vertx, String name) { 26 | val singletons = vertx.sharedData().getLocalMap(SHARED_DATA_MAP_NAME); 27 | singletons.remove(name); 28 | } 29 | 30 | static class ThreadSafe implements Shareable { 31 | T object; 32 | 33 | public ThreadSafe(T object) { 34 | this.object = object; 35 | } 36 | 37 | public T getObject() { 38 | return this.object; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: Continuous Integration 4 | 5 | # Controls when the action will run. 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the '*' branch 8 | push: 9 | branches: [ '*' ] 10 | pull_request: 11 | branches: [ '*' ] 12 | tags: [ '*' ] 13 | 14 | # Allows you to run this workflow manually from the Actions tab 15 | workflow_dispatch: 16 | 17 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 18 | jobs: 19 | # This workflow contains a single job called "build" 20 | build: 21 | name: Build and Test 22 | # The type of runner that the job will run on 23 | runs-on: ubuntu-latest 24 | 25 | # Steps represent a sequence of tasks that will be executed as part of the job 26 | steps: 27 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 28 | - name: Checkout repository 29 | uses: actions/checkout@v3 30 | with: 31 | fetch-depth: 0 32 | 33 | - name: Set up JDK 8 34 | uses: actions/setup-java@v4 35 | with: 36 | java-version: '8' 37 | distribution: 'adopt' 38 | cache: 'maven' 39 | 40 | - name: Build with Maven 41 | run: | 42 | mvn --batch-mode --update-snapshots verify 43 | 44 | - name: Upload coverage reports 45 | uses: codecov/codecov-action@v5 46 | with: 47 | file: ./target/site/jacoco/jacoco.xml 48 | fail_ci_if_error: false 49 | -------------------------------------------------------------------------------- /src/test/java/io/d11/aerospike/AerospikeConnectionTest.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike; 2 | 3 | import io.d11.aerospike.client.AerospikeConnectOptions; 4 | import io.d11.rxjava3.aerospike.client.AerospikeClient; 5 | import io.vertx.junit5.VertxExtension; 6 | import io.vertx.junit5.VertxTestContext; 7 | import io.vertx.rxjava3.core.Vertx; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.junit.jupiter.api.AfterAll; 10 | import org.junit.jupiter.api.BeforeAll; 11 | import org.junit.jupiter.api.Test; 12 | import org.junit.jupiter.api.extension.ExtendWith; 13 | 14 | @ExtendWith({VertxExtension.class, Setup.class}) 15 | @Slf4j 16 | public class AerospikeConnectionTest { 17 | 18 | private static AerospikeClient aerospikeClient; 19 | 20 | @BeforeAll 21 | public static void setup(Vertx vertx) { 22 | // Empty with vertx as parameter so that same vertx instance is used in all tests 23 | } 24 | 25 | @AfterAll 26 | public static void cleanUp() { 27 | // remove test keys 28 | aerospikeClient.close(); 29 | } 30 | 31 | @Test 32 | public void connect(Vertx vertx, VertxTestContext testContext) { 33 | AerospikeConnectOptions connectOptions = new AerospikeConnectOptions() 34 | .setHost(System.getProperty(Constants.AEROSPIKE_HOST)) 35 | .setPort(Integer.parseInt(System.getProperty(Constants.AEROSPIKE_PORT))); 36 | aerospikeClient = AerospikeClient.create(vertx, connectOptions); 37 | aerospikeClient.rxIsConnected() 38 | .doOnSuccess(res -> log.info("connect test passed!")) 39 | .subscribe(res -> testContext.completeNow(),testContext::failNow); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/d11/aerospike/listeners/QueryResultListenerImpl.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike.listeners; 2 | 3 | import com.aerospike.client.AerospikeException; 4 | import com.aerospike.client.Key; 5 | import com.aerospike.client.Record; 6 | import com.aerospike.client.listener.RecordSequenceListener; 7 | import com.aerospike.client.query.KeyRecord; 8 | import io.vertx.core.AsyncResult; 9 | import io.vertx.core.Future; 10 | import io.vertx.core.Handler; 11 | import io.vertx.core.impl.ContextInternal; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | import java.util.Objects; 16 | 17 | public class QueryResultListenerImpl implements RecordSequenceListener { 18 | 19 | final ContextInternal context; 20 | final Handler>> handler; 21 | final List keyRecords = new ArrayList(); 22 | 23 | public QueryResultListenerImpl(ContextInternal context, Handler>> handler) { 24 | Objects.requireNonNull(context, "context must not be null"); 25 | this.context = context; 26 | this.handler = handler; 27 | } 28 | 29 | 30 | @Override 31 | public void onRecord(Key key, Record record) throws AerospikeException { 32 | keyRecords.add(new KeyRecord(key, record)); 33 | } 34 | 35 | public void onSuccess() { 36 | if (handler != null) { 37 | context.runOnContext((v) -> handler.handle(Future.succeededFuture(keyRecords))); 38 | } 39 | } 40 | 41 | public void onFailure(AerospikeException e) { 42 | if (handler != null) { 43 | context.runOnContext((v) -> handler.handle(Future.failedFuture(e))); 44 | } 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name-template: 'Release v$RESOLVED_VERSION 🌈' 2 | tag-template: 'v$RESOLVED_VERSION' 3 | template: | 4 | ## Changes 5 | $CHANGES 6 | 7 | categories: 8 | - title: '🚀 Features' 9 | labels: 10 | - 'feature' 11 | - title: 'Improvements' 12 | labels: 13 | - 'enhancement' 14 | - title: 'Tests' 15 | labels: 16 | - 'test' 17 | - title: '🐛 Bug Fixes' 18 | labels: 19 | - 'fix' 20 | - 'bug' 21 | - 'hotfix' 22 | - 'revert' 23 | - title: '🧰 Maintenance' 24 | labels: 25 | - 'docs' 26 | - 'chore' 27 | - 'build' 28 | - 'ci' 29 | 30 | version-resolver: 31 | major: 32 | labels: 33 | - 'breaking' 34 | minor: 35 | labels: 36 | - 'feature' 37 | - 'enhancement' 38 | patch: 39 | labels: 40 | - 'fix' 41 | - 'test' 42 | - 'hotfix' 43 | 44 | exclude-labels: 45 | - 'skip-changelog' 46 | 47 | autolabeler: 48 | - label: 'enhancement' 49 | branch: 50 | - '/refactor\/.+/' 51 | - '/perf\/.+/' 52 | - label: 'feature' 53 | branch: 54 | - '/feat\/.+/' 55 | - label: 'fix' 56 | branch: 57 | - '/fix\/.+/' 58 | title: 59 | - '/fix/i' 60 | - label: 'maintenance' 61 | files: 62 | - '*.md' 63 | - '*.txt' 64 | - '*.png' 65 | - '*.yml' 66 | title: 67 | - '/chore/i' 68 | - '/docs/i' 69 | branch: 70 | - '/chore\/.+/' 71 | - '/docs\/.+/' 72 | - label: 'ci' 73 | files: 74 | - '.github/*' 75 | - label: 'test' 76 | branch: 77 | - '/test\/.+/' 78 | - label: 'hotfix' 79 | branch: 80 | - '/hotfix\/.+/' 81 | - label: 'code-changed' 82 | files: 83 | - '*.java' -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # This workflow publishes the module to Maven and is triggered when a Draft release is published. 2 | 3 | name: Publish Release 4 | 5 | on: 6 | release: 7 | types: [released] 8 | 9 | jobs: 10 | upload_to_maven_central: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | 15 | - name: Checkout repository 16 | uses: actions/checkout@v3 17 | with: 18 | token: ${{ secrets.COMMIT_ACCESS_TOKEN }} 19 | 20 | - name: Get version from tag 21 | id: get_version 22 | run: | 23 | releaseVersion="${GITHUB_REF/refs\/tags\//}" 24 | releaseVersion="${releaseVersion//v/}" 25 | echo "::set-output name=VERSION::$releaseVersion" 26 | 27 | - name: Set up publishing to maven central 28 | uses: actions/setup-java@v4 29 | with: 30 | java-version: '8' 31 | distribution: 'adopt' 32 | cache: 'maven' 33 | server-id: ossrh 34 | server-username: MAVEN_USERNAME 35 | server-password: MAVEN_PASSWORD 36 | 37 | - name: Update version pom.xml 38 | run: mvn versions:set -DnewVersion=${{ steps.get_version.outputs.VERSION }} 39 | 40 | - name: Install gpg key 41 | run: | 42 | cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | base64 --decode | gpg --batch --import 43 | 44 | - name: Publish 45 | run: | 46 | mvn --no-transfer-progress --batch-mode \ 47 | -Dgpg.passphrase='${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}' \ 48 | -DskipTests deploy -P release 49 | env: 50 | MAVEN_USERNAME: ${{ secrets.D11_NEXUS_USERNAME }} 51 | MAVEN_PASSWORD: ${{ secrets.D11_NEXUS_PASSWORD }} 52 | 53 | - name: Bump version 54 | run: .ci/scripts/bump-version.sh 55 | -------------------------------------------------------------------------------- /src/test/java/io/d11/aerospike/AerospikeDeleteTest.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike; 2 | 3 | import com.aerospike.client.Bin; 4 | import com.aerospike.client.Key; 5 | import io.d11.aerospike.client.AerospikeConnectOptions; 6 | import io.d11.rxjava3.aerospike.client.AerospikeClient; 7 | import io.vertx.junit5.VertxExtension; 8 | import io.vertx.junit5.VertxTestContext; 9 | import io.vertx.rxjava3.core.Vertx; 10 | import lombok.extern.slf4j.Slf4j; 11 | import org.hamcrest.MatcherAssert; 12 | import org.hamcrest.Matchers; 13 | import org.junit.jupiter.api.AfterAll; 14 | import org.junit.jupiter.api.BeforeAll; 15 | import org.junit.jupiter.api.Test; 16 | import org.junit.jupiter.api.extension.ExtendWith; 17 | 18 | @ExtendWith({VertxExtension.class, Setup.class}) 19 | @Slf4j 20 | public class AerospikeDeleteTest { 21 | 22 | private static final String testSet = "deleteTestSet"; 23 | private static final Bin[] bins = {new Bin("bin1", 8), new Bin("bin3", "value2")}; 24 | private static final Key testKey = new Key(Constants.TEST_NAMESPACE, testSet, "delete"); 25 | private static AerospikeClient aerospikeClient; 26 | 27 | @BeforeAll 28 | public static void setup(Vertx vertx) { 29 | AerospikeConnectOptions connectOptions = new AerospikeConnectOptions() 30 | .setHost(System.getProperty(Constants.AEROSPIKE_HOST)) 31 | .setPort(Integer.parseInt(System.getProperty(Constants.AEROSPIKE_PORT))); 32 | aerospikeClient = AerospikeClient.create(vertx, connectOptions); 33 | aerospikeClient.getAerospikeClient().put(null, testKey, bins); 34 | } 35 | 36 | @AfterAll 37 | public static void cleanUp() { 38 | // remove test keys 39 | aerospikeClient.getAerospikeClient().truncate(null, Constants.TEST_NAMESPACE, testSet, null); 40 | aerospikeClient.close(); 41 | } 42 | 43 | @Test 44 | public void delete(VertxTestContext testContext) { 45 | aerospikeClient.rxDelete(null, testKey) 46 | .ignoreElement() 47 | .andThen(aerospikeClient.rxExists(null, testKey)) 48 | .doOnSuccess(bool -> MatcherAssert.assertThat(bool, Matchers.equalTo(false))) 49 | .doOnSuccess(record -> log.info("delete test passed!")) 50 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/io/d11/aerospike/AerospikePutTest.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike; 2 | 3 | import com.aerospike.client.Bin; 4 | import com.aerospike.client.Key; 5 | import io.d11.aerospike.client.AerospikeConnectOptions; 6 | import io.d11.rxjava3.aerospike.client.AerospikeClient; 7 | import io.vertx.junit5.VertxExtension; 8 | import io.vertx.junit5.VertxTestContext; 9 | import io.vertx.rxjava3.core.Vertx; 10 | import lombok.extern.slf4j.Slf4j; 11 | import org.hamcrest.MatcherAssert; 12 | import org.hamcrest.Matchers; 13 | import org.junit.jupiter.api.AfterAll; 14 | import org.junit.jupiter.api.BeforeAll; 15 | import org.junit.jupiter.api.Test; 16 | import org.junit.jupiter.api.extension.ExtendWith; 17 | 18 | @ExtendWith({VertxExtension.class, Setup.class}) 19 | @Slf4j 20 | public class AerospikePutTest { 21 | private static final String testSet = "putTestSet"; 22 | private static final Bin[] bins = {new Bin("bin1", "aaa"), new Bin("bin2", 111)}; 23 | private static final Key testKey = new Key(Constants.TEST_NAMESPACE, testSet, "putAllBins"); 24 | private static AerospikeClient aerospikeClient; 25 | 26 | @BeforeAll 27 | public static void setup(Vertx vertx) { 28 | AerospikeConnectOptions connectOptions = new AerospikeConnectOptions() 29 | .setHost(System.getProperty(Constants.AEROSPIKE_HOST)) 30 | .setPort(Integer.parseInt(System.getProperty(Constants.AEROSPIKE_PORT))); 31 | aerospikeClient = AerospikeClient.create(vertx, connectOptions); 32 | } 33 | 34 | @AfterAll 35 | public static void cleanUp() { 36 | aerospikeClient.getAerospikeClient().delete(null, testKey); 37 | aerospikeClient.close(); 38 | } 39 | 40 | @Test 41 | public void putAllBins(VertxTestContext testContext) { 42 | aerospikeClient.rxPut(null, testKey, bins) 43 | .ignoreElement() 44 | .andThen(aerospikeClient.rxGet(null, testKey)) 45 | .doOnSuccess(record -> { 46 | MatcherAssert.assertThat(record.getString("bin1"), Matchers.equalTo("aaa")); 47 | MatcherAssert.assertThat(record.getInt("bin2"), Matchers.equalTo(111)); 48 | }) 49 | .doOnSuccess(record -> log.info("putAllBins test passed!")) 50 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/io/d11/aerospike/Setup.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike; 2 | 3 | import java.io.IOException; 4 | import java.time.Duration; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.junit.jupiter.api.extension.AfterAllCallback; 7 | import org.junit.jupiter.api.extension.BeforeAllCallback; 8 | import org.junit.jupiter.api.extension.ExtensionContext; 9 | import org.testcontainers.containers.BindMode; 10 | import org.testcontainers.containers.GenericContainer; 11 | import org.testcontainers.containers.startupcheck.MinimumDurationRunningStartupCheckStrategy; 12 | 13 | @Slf4j 14 | public class Setup implements BeforeAllCallback, AfterAllCallback, ExtensionContext.Store.CloseableResource { 15 | public static final String AEROSPIKE_IMAGE = System.getProperty(Constants.AEROSPIKE_IMAGE_KEY, Constants.DEFAULT_AEROSPIKE_IMAGE); 16 | private static boolean started = false; 17 | private GenericContainer aerospikeContainer; 18 | 19 | @Override 20 | public void afterAll(ExtensionContext extensionContext) { 21 | } 22 | 23 | @Override 24 | public void beforeAll(ExtensionContext extensionContext) throws IOException, InterruptedException { 25 | if (!started) { 26 | started = true; 27 | aerospikeContainer = new GenericContainer<>(AEROSPIKE_IMAGE); 28 | log.info("Starting aerospike container from image:{}", AEROSPIKE_IMAGE); 29 | aerospikeContainer 30 | .withEnv(Constants.NAMESPACE, Constants.TEST_NAMESPACE) 31 | .withExposedPorts(3000) 32 | .withStartupTimeout(Duration.ofSeconds(1000)) 33 | .withStartupCheckStrategy(new MinimumDurationRunningStartupCheckStrategy(Duration.ofSeconds(10))) 34 | .addFileSystemBind(Constants.INIT_DATA_PATH, Constants.INIT_DATA_PATH_IN_CONTAINER, BindMode.READ_ONLY); 35 | aerospikeContainer.start(); 36 | // add seed data in containers 37 | aerospikeContainer.execInContainer("aql", "-f", Constants.INIT_DATA_PATH_IN_CONTAINER); 38 | System.setProperty(Constants.AEROSPIKE_HOST, aerospikeContainer.getHost()); 39 | System.setProperty(Constants.AEROSPIKE_PORT, String.valueOf(aerospikeContainer.getFirstMappedPort())); 40 | } 41 | } 42 | 43 | @Override 44 | public void close() { 45 | aerospikeContainer.close(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/io/d11/aerospike/AerospikeQueryTest.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike; 2 | 3 | import com.aerospike.client.query.Statement; 4 | import io.d11.aerospike.client.AerospikeConnectOptions; 5 | import io.d11.rxjava3.aerospike.client.AerospikeClient; 6 | import io.vertx.junit5.VertxExtension; 7 | import io.vertx.junit5.VertxTestContext; 8 | import io.vertx.rxjava3.core.Vertx; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.hamcrest.MatcherAssert; 11 | import org.hamcrest.Matchers; 12 | import org.junit.jupiter.api.AfterAll; 13 | import org.junit.jupiter.api.BeforeAll; 14 | import org.junit.jupiter.api.Test; 15 | import org.junit.jupiter.api.extension.ExtendWith; 16 | 17 | @ExtendWith({VertxExtension.class, Setup.class}) 18 | @Slf4j 19 | public class AerospikeQueryTest { 20 | private static AerospikeClient aerospikeClient; 21 | 22 | @BeforeAll 23 | public static void setup(Vertx vertx) { 24 | AerospikeConnectOptions connectOptions = new AerospikeConnectOptions() 25 | .setHost(System.getProperty(Constants.AEROSPIKE_HOST)) 26 | .setPort(Integer.parseInt(System.getProperty(Constants.AEROSPIKE_PORT))); 27 | aerospikeClient = AerospikeClient.create(vertx, connectOptions); 28 | } 29 | 30 | @AfterAll 31 | public static void cleanUp() { 32 | aerospikeClient.close(); 33 | } 34 | 35 | @Test 36 | public void query(VertxTestContext testContext) { 37 | Statement statement = new Statement(); 38 | statement.setNamespace(Constants.TEST_NAMESPACE); 39 | statement.setSetName(Constants.TEST_SET); 40 | statement.setBinNames("bin1", "bin2"); 41 | aerospikeClient.rxQuery(null, statement) 42 | .doOnSuccess(keyRecords -> { 43 | MatcherAssert.assertThat(keyRecords.size(), Matchers.equalTo(2)); 44 | keyRecords.forEach(keyRecord -> { 45 | MatcherAssert.assertThat(keyRecord.record.getString("bin1"), Matchers.in(new String[]{"Mumbai", "Delhi"})); 46 | if (keyRecord.record.getString("bin1").equals("Mumbai")) { 47 | MatcherAssert.assertThat(keyRecord.record.getInt("bin2"), Matchers.equalTo(123)); 48 | } else { 49 | MatcherAssert.assertThat(keyRecord.record.getInt("bin2"), Matchers.equalTo(3)); 50 | } 51 | }); 52 | }) 53 | .doOnSuccess(record -> log.info("query test passed!")) 54 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/io/d11/aerospike/AerospikeOperateTest.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike; 2 | 3 | import com.aerospike.client.Bin; 4 | import com.aerospike.client.Key; 5 | import com.aerospike.client.Operation; 6 | import io.d11.aerospike.client.AerospikeConnectOptions; 7 | import io.d11.rxjava3.aerospike.client.AerospikeClient; 8 | import io.vertx.junit5.VertxExtension; 9 | import io.vertx.junit5.VertxTestContext; 10 | import io.vertx.rxjava3.core.Vertx; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.hamcrest.MatcherAssert; 13 | import org.hamcrest.Matchers; 14 | import org.junit.jupiter.api.AfterAll; 15 | import org.junit.jupiter.api.BeforeAll; 16 | import org.junit.jupiter.api.Test; 17 | import org.junit.jupiter.api.extension.ExtendWith; 18 | 19 | @ExtendWith({VertxExtension.class, Setup.class}) 20 | @Slf4j 21 | public class AerospikeOperateTest { 22 | 23 | private static AerospikeClient aerospikeClient; 24 | private static final String testSet = "operateTestSet"; 25 | private static final Key operateKey = new Key(Constants.TEST_NAMESPACE, testSet, "operate"); 26 | private static final Bin[] bins = {new Bin("bin1", "Bangalore"), new Bin("bin2", 1)}; 27 | private static final Bin[] appendBins = {new Bin("bin1", "Hyderabad"), new Bin("bin2", 2)}; 28 | 29 | @BeforeAll 30 | public static void setup(Vertx vertx) { 31 | AerospikeConnectOptions connectOptions = new AerospikeConnectOptions() 32 | .setHost(System.getProperty(Constants.AEROSPIKE_HOST)) 33 | .setPort(Integer.parseInt(System.getProperty(Constants.AEROSPIKE_PORT))); 34 | aerospikeClient = AerospikeClient.create(vertx, connectOptions); 35 | 36 | aerospikeClient.getAerospikeClient().put(null, operateKey, bins); 37 | } 38 | 39 | @AfterAll 40 | public static void cleanUp() { 41 | // remove test keys 42 | aerospikeClient.getAerospikeClient().truncate(null, Constants.TEST_NAMESPACE, testSet, null); 43 | aerospikeClient.close(); 44 | } 45 | 46 | @Test 47 | public void operate(VertxTestContext testContext) { 48 | Operation[] operations = { 49 | Operation.append(appendBins[0]), 50 | Operation.add(appendBins[1]), 51 | Operation.get() 52 | }; 53 | aerospikeClient.rxOperate(null, operateKey, operations) 54 | .doOnSuccess(record -> { 55 | MatcherAssert.assertThat(record.getString("bin1"), Matchers.equalTo("BangaloreHyderabad")); 56 | MatcherAssert.assertThat(record.getInt("bin2"), Matchers.equalTo(3)); 57 | }) 58 | .doOnSuccess(record -> log.info("operate test passed!")) 59 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/test/java/io/d11/aerospike/AerospikeScanTest.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike; 2 | 3 | import com.aerospike.client.query.PartitionFilter; 4 | import io.d11.aerospike.client.AerospikeConnectOptions; 5 | import io.d11.rxjava3.aerospike.client.AerospikeClient; 6 | import io.vertx.junit5.VertxExtension; 7 | import io.vertx.junit5.VertxTestContext; 8 | import io.vertx.rxjava3.core.Vertx; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.hamcrest.MatcherAssert; 11 | import org.hamcrest.Matchers; 12 | import org.junit.jupiter.api.AfterAll; 13 | import org.junit.jupiter.api.BeforeAll; 14 | import org.junit.jupiter.api.Test; 15 | import org.junit.jupiter.api.extension.ExtendWith; 16 | 17 | @ExtendWith({VertxExtension.class, Setup.class}) 18 | @Slf4j 19 | public class AerospikeScanTest { 20 | private static AerospikeClient aerospikeClient; 21 | 22 | @BeforeAll 23 | public static void setup(Vertx vertx) { 24 | AerospikeConnectOptions connectOptions = new AerospikeConnectOptions() 25 | .setHost(System.getProperty(Constants.AEROSPIKE_HOST)) 26 | .setPort(Integer.parseInt(System.getProperty(Constants.AEROSPIKE_PORT))); 27 | aerospikeClient = AerospikeClient.create(vertx, connectOptions); 28 | } 29 | 30 | @AfterAll 31 | public static void cleanUp() { 32 | aerospikeClient.close(); 33 | } 34 | 35 | @Test 36 | public void scanAll(VertxTestContext testContext) { 37 | aerospikeClient.rxScanAll(null, Constants.TEST_NAMESPACE, Constants.TEST_SET, new String[]{"bin1"}) 38 | .doOnSuccess(keyRecords -> { 39 | MatcherAssert.assertThat(keyRecords.size(), Matchers.equalTo(2)); 40 | keyRecords.forEach(keyRecord -> 41 | MatcherAssert.assertThat(keyRecord.record.getString("bin1"), Matchers.in(new String[]{"Mumbai", "Delhi"}))); 42 | }) 43 | .doOnSuccess(record -> log.info("scanAll test passed!")) 44 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 45 | } 46 | 47 | @Test 48 | public void scanPartitions(VertxTestContext testContext) { 49 | aerospikeClient.rxScanPartitions(null, PartitionFilter.range(0, 4095), 50 | Constants.TEST_NAMESPACE, Constants.TEST_SET, new String[]{"bin1"}) 51 | .doOnSuccess(keyRecords -> { 52 | MatcherAssert.assertThat(keyRecords.size(), Matchers.equalTo(2)); 53 | keyRecords.forEach(keyRecord -> 54 | MatcherAssert.assertThat(keyRecord.record.getString("bin1"), Matchers.in(new String[]{"Mumbai", "Delhi"}))); 55 | }) 56 | .doOnSuccess(record -> log.info("scanPartitions test passed!")) 57 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/test/java/io/d11/aerospike/AerospikeExistsTest.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike; 2 | 3 | import com.aerospike.client.Bin; 4 | import com.aerospike.client.Key; 5 | import io.d11.aerospike.client.AerospikeConnectOptions; 6 | import io.d11.rxjava3.aerospike.client.AerospikeClient; 7 | import io.vertx.junit5.VertxExtension; 8 | import io.vertx.junit5.VertxTestContext; 9 | import io.vertx.rxjava3.core.Vertx; 10 | import lombok.extern.slf4j.Slf4j; 11 | import org.hamcrest.MatcherAssert; 12 | import org.hamcrest.Matchers; 13 | import org.junit.jupiter.api.AfterAll; 14 | import org.junit.jupiter.api.BeforeAll; 15 | import org.junit.jupiter.api.Test; 16 | import org.junit.jupiter.api.extension.ExtendWith; 17 | 18 | @ExtendWith({VertxExtension.class, Setup.class}) 19 | @Slf4j 20 | public class AerospikeExistsTest { 21 | private static final String testSet = "existsTestSet"; 22 | private static final Key existingTestKey = new Key(Constants.TEST_NAMESPACE, testSet, "existingKey"); 23 | private static final Key nonExistingTestKey = new Key(Constants.TEST_NAMESPACE, testSet, "nonExistingKey"); 24 | private static final Bin[] bins = {new Bin("bin1", 8), new Bin("bin2", "value2")}; 25 | private static AerospikeClient aerospikeClient; 26 | 27 | @BeforeAll 28 | public static void setup(Vertx vertx) { 29 | AerospikeConnectOptions connectOptions = new AerospikeConnectOptions() 30 | .setHost(System.getProperty(Constants.AEROSPIKE_HOST)) 31 | .setPort(Integer.parseInt(System.getProperty(Constants.AEROSPIKE_PORT))); 32 | aerospikeClient = AerospikeClient.create(vertx, connectOptions); 33 | // add test keys 34 | aerospikeClient.getAerospikeClient().put(null, existingTestKey, bins); 35 | } 36 | 37 | @AfterAll 38 | public static void cleanUp() { 39 | // remove test keys 40 | aerospikeClient.getAerospikeClient().truncate(null, Constants.TEST_NAMESPACE, testSet, null); 41 | aerospikeClient.close(); 42 | } 43 | 44 | @Test 45 | public void existingKey(VertxTestContext testContext) { 46 | aerospikeClient.rxExists(null, existingTestKey) 47 | .doOnSuccess(bool -> MatcherAssert.assertThat(bool, Matchers.equalTo(true))) 48 | .doOnSuccess(record -> log.info("existingKey test passed!")) 49 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 50 | } 51 | 52 | @Test 53 | public void nonExistingKey(VertxTestContext testContext) { 54 | aerospikeClient.rxExists(null, nonExistingTestKey) 55 | .doOnSuccess(bool -> MatcherAssert.assertThat(bool, Matchers.equalTo(false))) 56 | .doOnSuccess(record -> log.info("nonExistingKey test passed!")) 57 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 58 | } 59 | 60 | @Test 61 | public void checkMultipleKeys(VertxTestContext testContext) { 62 | aerospikeClient.rxExists(null, new Key[] {existingTestKey, nonExistingTestKey}) 63 | .doOnSuccess(booleans -> { 64 | MatcherAssert.assertThat(booleans.get(0), Matchers.equalTo(true)); 65 | MatcherAssert.assertThat(booleans.get(1), Matchers.equalTo(false)); 66 | }) 67 | .doOnSuccess(record -> log.info("checkMultipleKeys test passed!")) 68 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # The Reactive Aerospike Client 2 | 3 | [![Continuous Integration](https://github.com/dream11/vertx-aerospike-client/actions/workflows/ci.yml/badge.svg)](https://github.com/dream11/vertx-aerospike-client/actions/workflows/ci.yml) 4 | [![Code Coverage](https://codecov.io/gh/dream11/vertx-aerospike-client/branch/master/graph/badge.svg)](https://codecov.io/gh/dream11/vertx-aerospike-client) 5 | ![License](https://img.shields.io/badge/license-MIT-green.svg) 6 | 7 | ## Overview 8 | 9 | The Vert.x Aerospike client provides an asynchronous API to interact aerospike server. 10 | 11 | ## Usage 12 | 13 | Add the following dependency to the *dependencies* section of your build descriptor: 14 | 15 | - Maven (in your `pom.xml`): 16 | ```xml 17 | 18 | io.d11 19 | vertx-aerospike-client 20 | LATEST 21 | 22 | ``` 23 | 24 | - Gradle (in your `build.gradle` file): 25 | ``` 26 | dependencies { 27 | compile 'io.d11:vertx-aerospike-client:x.y.z' 28 | } 29 | ``` 30 | 31 | ## Connecting to Aerospike 32 | 33 | ```java 34 | AerospikeConnectOptions connectOptions = new AerospikeConnectOptions() 35 | .setHosts("my-host") 36 | .setEventLoopSize(16); 37 | 38 | // create a shared aerospike client across vertx instance 39 | AerospikeClient client = AerospikeClient.create(vertx, connectOptions); 40 | 41 | // create non shared aerospike client 42 | AerospikeClient client = AerospikeClient.createNonShared(vertx, connectOptions); 43 | ``` 44 | 45 | ## Configuration 46 | 47 | Configuration options for `AerospikeConnectOptions` 48 | 49 | | Key | Default | Type | Required | Description | 50 | | --- | --- | --- | --- | --- | 51 | | host | localhost | String | false | Aerospike server host | 52 | | port | 3000 | Integer | false | Aerospike server port | 53 | | eventLoopSize | 2*<#cores> | Integer | false | Number of EventLoop threads | 54 | | maxCommandsInProcess | 100 | Integer | false | Maximum number of commands in process on each EventLoop thread | 55 | | maxCommandsInQueue | 0 | Integer | false | Maximum number of commands in each EventLoop's queue | 56 | | maxConnsPerNode | 2*<#cores>*100 | Integer | false | Maximum number of connections to one server node | 57 | | maxConnectRetries | 2 | Integer | false | Maximum number of retries to connect | 58 | | clientPolicy | | ClientPolicy | false | Aerospike client policy | 59 | 60 | ### Note on Configuration options: 61 | * Do not set the clientPolicy.eventLoops. Use AerospikeConnectOptions to configure them. 62 | 63 | ## Running queries 64 | 65 | ```java 66 | AerospikeClient client = AerospikeClient.create(vertx, connectOptions); 67 | client 68 | .rxGet(policy, key) 69 | .map(record -> { 70 | // Handle record 71 | })... 72 | ``` 73 | 74 | Detailed documentation can be found [here](https://javadoc.io/doc/io.d11/vertx-aerospike-client/latest/index.html). 75 | 76 | ## Running the tests 77 | 78 | To run the test suite: 79 | ```shell 80 | mvn clean verify 81 | ``` 82 | The test suite runs a Docker container from image `aerospike/aerospike-server` using [TestContainers](https://www.testcontainers.org/) 83 | by default. 84 | 85 | To run the test suite on a container built from a different docker image: 86 | ```shell 87 | mvn clean verify -Daerospike.image= 88 | ``` 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Reactive Aerospike Client 2 | 3 | [![Continuous Integration](https://github.com/dream11/vertx-aerospike-client/actions/workflows/ci.yml/badge.svg)](https://github.com/dream11/vertx-aerospike-client/actions/workflows/ci.yml) 4 | [![Code Coverage](https://codecov.io/gh/dream11/vertx-aerospike-client/branch/master/graph/badge.svg)](https://codecov.io/gh/dream11/vertx-aerospike-client) 5 | ![License](https://img.shields.io/badge/license-MIT-green.svg) 6 | 7 | ## Overview 8 | 9 | The Vert.x Aerospike client provides an asynchronous API to interact with aerospike server. 10 | (Internally uses [AerospikeClient's](https://www.aerospike.com/docs/client/java/) async commands and handles the result on vertx-context) 11 | 12 | ## Usage 13 | 14 | Add the following dependency to the *dependencies* section of your build descriptor: 15 | 16 | - Maven (in your `pom.xml`): 17 | ```xml 18 | 19 | io.d11 20 | vertx-aerospike-client 21 | LATEST 22 | 23 | ``` 24 | 25 | - Gradle (in your `build.gradle` file): 26 | ``` 27 | dependencies { 28 | compile 'io.d11:vertx-aerospike-client:x.y.z' 29 | } 30 | ``` 31 | 32 | ## Connecting to Aerospike 33 | 34 | ```java 35 | AerospikeConnectOptions connectOptions = new AerospikeConnectOptions() 36 | .setHosts("my-host") 37 | .setEventLoopSize(16); 38 | 39 | // create a shared aerospike client across vertx instance 40 | AerospikeClient client = AerospikeClient.create(vertx, connectOptions); 41 | 42 | // create non shared aerospike client 43 | AerospikeClient client = AerospikeClient.createNonShared(vertx, connectOptions); 44 | ``` 45 | 46 | ## Configuration 47 | 48 | Configuration options for `AerospikeConnectOptions` 49 | 50 | | Key | Default | Type | Required | Description | 51 | | --- | --- | --- | --- | --- | 52 | | host | localhost | String | false | Aerospike server host | 53 | | port | 3000 | Integer | false | Aerospike server port | 54 | | eventLoopSize | 2*<#cores> | Integer | false | Number of EventLoop threads | 55 | | maxCommandsInProcess | 100 | Integer | false | Maximum number of commands in process on each EventLoop thread | 56 | | maxCommandsInQueue | 0 | Integer | false | Maximum number of commands in each EventLoop's queue | 57 | | maxConnsPerNode | 2*<#cores>*100 | Integer | false | Maximum number of connections to one server node | 58 | | maxConnectRetries | 2 | Integer | false | Maximum number of retries to connect | 59 | | clientPolicy | | ClientPolicy | false | Aerospike client policy | 60 | 61 | ### Note on Configuration options: 62 | * Do not set the clientPolicy.eventLoops. Use AerospikeConnectOptions to configure them. 63 | 64 | ## Running queries 65 | 66 | ```java 67 | AerospikeClient client = AerospikeClient.create(vertx, connectOptions); 68 | client 69 | .rxGet(policy, key) 70 | .map(record -> { 71 | // Handle record 72 | })... 73 | ``` 74 | 75 | Detailed documentation can be found [here](https://javadoc.io/doc/io.d11/vertx-aerospike-client/latest/index.html). 76 | 77 | ## Running the tests 78 | 79 | To run the test suite: 80 | ```shell 81 | mvn clean verify 82 | ``` 83 | The test suite runs a Docker container from image `aerospike/aerospike-server` using [TestContainers](https://www.testcontainers.org/) 84 | by default. 85 | 86 | To run the test suite on a container built from a different docker image: 87 | ```shell 88 | mvn clean verify -Daerospike.image= 89 | ``` 90 | -------------------------------------------------------------------------------- /src/test/java/io/d11/aerospike/AerospikeGetHeaderTest.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike; 2 | 3 | import com.aerospike.client.Bin; 4 | import com.aerospike.client.Key; 5 | import com.aerospike.client.policy.WritePolicy; 6 | import io.d11.aerospike.client.AerospikeConnectOptions; 7 | import io.d11.rxjava3.aerospike.client.AerospikeClient; 8 | import io.vertx.junit5.VertxExtension; 9 | import io.vertx.junit5.VertxTestContext; 10 | import io.vertx.rxjava3.core.Vertx; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.hamcrest.MatcherAssert; 13 | import org.hamcrest.Matchers; 14 | import org.junit.jupiter.api.AfterAll; 15 | import org.junit.jupiter.api.BeforeAll; 16 | import org.junit.jupiter.api.Test; 17 | import org.junit.jupiter.api.extension.ExtendWith; 18 | 19 | @ExtendWith({VertxExtension.class, Setup.class}) 20 | @Slf4j 21 | public class AerospikeGetHeaderTest { 22 | 23 | private static AerospikeClient aerospikeClient; 24 | private static final String testSet = "getHeaderTestSet"; 25 | private static final Key key3 = new Key(Constants.TEST_NAMESPACE, testSet, "pkey3"); 26 | private static final Key key4 = new Key(Constants.TEST_NAMESPACE, testSet, "pkey4"); 27 | 28 | @BeforeAll 29 | public static void setup(Vertx vertx) { 30 | AerospikeConnectOptions connectOptions = new AerospikeConnectOptions() 31 | .setHost(System.getProperty(Constants.AEROSPIKE_HOST)) 32 | .setPort(Integer.parseInt(System.getProperty(Constants.AEROSPIKE_PORT))); 33 | aerospikeClient = AerospikeClient.create(vertx, connectOptions); 34 | 35 | WritePolicy policy = new WritePolicy(); 36 | policy.expiration = -1; 37 | Bin[] bins3 = {new Bin("bin1", "Bangalore"), new Bin("bin2", "235")}; 38 | Bin[] bins4 = {new Bin("bin1", "Hyderabad"), new Bin("bin2", "246")}; 39 | aerospikeClient.getAerospikeClient().put(policy, key3, bins3); 40 | aerospikeClient.getAerospikeClient().append(policy, key3, bins4); 41 | policy.expiration = 0; 42 | aerospikeClient.getAerospikeClient().put(policy, key4, bins4); 43 | } 44 | 45 | @AfterAll 46 | public static void cleanUp() { 47 | // remove test keys 48 | aerospikeClient.getAerospikeClient().truncate(null, Constants.TEST_NAMESPACE, testSet, null); 49 | aerospikeClient.close(); 50 | } 51 | 52 | @Test 53 | public void getHeader(VertxTestContext testContext) { 54 | aerospikeClient.rxGetHeader(null, key3) 55 | .doOnSuccess(record -> { 56 | MatcherAssert.assertThat(record.generation, Matchers.equalTo(2)); 57 | MatcherAssert.assertThat(record.expiration, Matchers.equalTo(0)); 58 | MatcherAssert.assertThat(record.bins, Matchers.equalTo(null)); 59 | }) 60 | .doOnSuccess(record -> log.info("getHeader test passed!")) 61 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 62 | } 63 | 64 | @Test 65 | public void getHeaderFromMultipleKeys(VertxTestContext testContext) { 66 | aerospikeClient.rxGetHeader(null, new Key[] {key3, key4}) 67 | .doOnSuccess(records -> { 68 | MatcherAssert.assertThat(records.get(0).generation, Matchers.equalTo(2)); 69 | MatcherAssert.assertThat(records.get(0).expiration, Matchers.equalTo(0)); 70 | MatcherAssert.assertThat(records.get(0).bins, Matchers.equalTo(null)); 71 | 72 | MatcherAssert.assertThat(records.get(1).generation, Matchers.equalTo(1)); 73 | MatcherAssert.assertThat(records.get(1).expiration, Matchers.greaterThan(10000)); 74 | MatcherAssert.assertThat(records.get(1).bins, Matchers.equalTo(null)); 75 | }) 76 | .doOnSuccess(record -> log.info("getHeaderFromMultipleKeys test passed!")) 77 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/io/d11/aerospike/client/AerospikeConnectOptions.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike.client; 2 | 3 | import com.aerospike.client.async.EventPolicy; 4 | import com.aerospike.client.async.NettyEventLoops; 5 | import com.aerospike.client.policy.ClientPolicy; 6 | import com.aerospike.client.policy.Replica; 7 | import io.netty.channel.EventLoopGroup; 8 | import io.netty.channel.epoll.EpollEventLoopGroup; 9 | import io.netty.channel.nio.NioEventLoopGroup; 10 | import io.vertx.codegen.annotations.Fluent; 11 | import lombok.Data; 12 | 13 | @Data 14 | public class AerospikeConnectOptions { 15 | static final String OS = System.getProperty("os.name"); 16 | static final String DEFAULT_HOST = "localhost"; 17 | static final int DEFAULT_PORT = 3000; 18 | static final int DEFAULT_EVENT_LOOP_SIZE = 2 * Runtime.getRuntime().availableProcessors(); 19 | static final int DEFAULT_MAX_COMMANDS_IN_PROCESS = 100; 20 | static final int DEFAULT_MAX_CONNS_PER_NODE = DEFAULT_MAX_COMMANDS_IN_PROCESS * DEFAULT_EVENT_LOOP_SIZE; 21 | static final int DEFAULT_MAX_CONNECT_RETRIES = 2; 22 | 23 | private String host; 24 | private int port; 25 | private int maxConnsPerNode; 26 | private int eventLoopSize; 27 | private int maxCommandsInProcess; 28 | private int maxCommandsInQueue; 29 | private ClientPolicy clientPolicy; 30 | private int maxConnectRetries; 31 | 32 | public AerospikeConnectOptions() { 33 | ClientPolicy clientPolicy = new ClientPolicy(); 34 | clientPolicy.readPolicyDefault.replica = Replica.MASTER_PROLES; 35 | this.clientPolicy = clientPolicy; 36 | this.host = DEFAULT_HOST; 37 | this.port = DEFAULT_PORT; 38 | this.maxConnsPerNode = DEFAULT_MAX_CONNS_PER_NODE; 39 | this.eventLoopSize = DEFAULT_EVENT_LOOP_SIZE; 40 | this.maxCommandsInProcess = DEFAULT_MAX_COMMANDS_IN_PROCESS; 41 | this.maxConnectRetries = DEFAULT_MAX_CONNECT_RETRIES; 42 | } 43 | 44 | @Fluent 45 | public AerospikeConnectOptions setMaxConnectRetries(int maxConnectRetries) { 46 | this.maxConnectRetries = maxConnectRetries; 47 | return this; 48 | } 49 | 50 | @Fluent 51 | public AerospikeConnectOptions setClientPolicy(ClientPolicy clientPolicy) { 52 | this.clientPolicy = clientPolicy; 53 | return this; 54 | } 55 | 56 | @Fluent 57 | public AerospikeConnectOptions setHost(String host) { 58 | this.host = host; 59 | return this; 60 | } 61 | 62 | @Fluent 63 | public AerospikeConnectOptions setPort(int port) { 64 | this.port = port; 65 | return this; 66 | } 67 | 68 | @Fluent 69 | public AerospikeConnectOptions setMaxConnsPerNode(int maxConnsPerNode) { 70 | this.maxConnsPerNode = maxConnsPerNode; 71 | return this; 72 | } 73 | 74 | @Fluent 75 | public AerospikeConnectOptions setEventLoopSize(int eventLoopSize) { 76 | this.eventLoopSize = eventLoopSize; 77 | return this; 78 | } 79 | 80 | @Fluent 81 | public AerospikeConnectOptions setMaxCommandsInProcess(int maxCommandsInProcess) { 82 | this.maxCommandsInProcess = maxCommandsInProcess; 83 | return this; 84 | } 85 | 86 | @Fluent 87 | public AerospikeConnectOptions setMaxCommandsInQueue(int maxCommandsInQueue) { 88 | this.maxCommandsInQueue = maxCommandsInQueue; 89 | return this; 90 | } 91 | 92 | @Fluent 93 | public AerospikeConnectOptions updateClientPolicy() { 94 | EventPolicy eventPolicy = new EventPolicy(); 95 | eventPolicy.maxCommandsInProcess = this.getMaxCommandsInProcess(); 96 | eventPolicy.maxCommandsInQueue = this.getMaxCommandsInQueue(); 97 | EventLoopGroup group = getEventLoopGroup(this.getEventLoopSize()); 98 | this.clientPolicy.eventLoops = new NettyEventLoops(eventPolicy, group); 99 | this.clientPolicy.maxConnsPerNode = this.getMaxConnsPerNode(); 100 | return this; 101 | } 102 | 103 | private EventLoopGroup getEventLoopGroup(int size) { 104 | return OS.contains("linux") || OS.contains("unix") ? 105 | new EpollEventLoopGroup(size) : new NioEventLoopGroup(size); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/test/java/io/d11/aerospike/AerospikeAddTest.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike; 2 | 3 | import com.aerospike.client.Bin; 4 | import com.aerospike.client.Key; 5 | import io.d11.aerospike.client.AerospikeConnectOptions; 6 | import io.d11.rxjava3.aerospike.client.AerospikeClient; 7 | import io.vertx.junit5.VertxExtension; 8 | import io.vertx.junit5.VertxTestContext; 9 | import io.vertx.rxjava3.core.Vertx; 10 | import lombok.extern.slf4j.Slf4j; 11 | import org.hamcrest.MatcherAssert; 12 | import org.hamcrest.Matchers; 13 | import org.junit.jupiter.api.AfterAll; 14 | import org.junit.jupiter.api.BeforeAll; 15 | import org.junit.jupiter.api.Test; 16 | import org.junit.jupiter.api.extension.ExtendWith; 17 | 18 | @ExtendWith({VertxExtension.class, Setup.class}) 19 | @Slf4j 20 | public class AerospikeAddTest { 21 | private static final String testSet = "appendTestSet"; 22 | private static final Bin[] bins = {new Bin("bin1", 10), new Bin("bin2", 20)}; 23 | private static final Key addAllBinsTestKey = new Key(Constants.TEST_NAMESPACE, testSet, "addAllBins"); 24 | private static final Key addSomeBinsTestKey = new Key(Constants.TEST_NAMESPACE, testSet, "addSomeBins"); 25 | private static final Key addNonExistingBinTestKey = new Key(Constants.TEST_NAMESPACE, testSet, "addNonExistingBin"); 26 | private static AerospikeClient aerospikeClient; 27 | 28 | @BeforeAll 29 | public static void setup(Vertx vertx) { 30 | AerospikeConnectOptions connectOptions = new AerospikeConnectOptions() 31 | .setHost(System.getProperty(Constants.AEROSPIKE_HOST)) 32 | .setPort(Integer.parseInt(System.getProperty(Constants.AEROSPIKE_PORT))); 33 | aerospikeClient = AerospikeClient.create(vertx, connectOptions); 34 | // add test keys 35 | aerospikeClient.getAerospikeClient().put(null, addAllBinsTestKey, bins); 36 | aerospikeClient.getAerospikeClient().put(null, addSomeBinsTestKey, bins); 37 | aerospikeClient.getAerospikeClient().put(null, addNonExistingBinTestKey, bins); 38 | } 39 | 40 | @AfterAll 41 | public static void cleanUp() { 42 | // remove test keys 43 | aerospikeClient.getAerospikeClient().truncate(null, Constants.TEST_NAMESPACE, testSet, null); 44 | aerospikeClient.close(); 45 | } 46 | 47 | @Test 48 | public void addAllBins(VertxTestContext testContext) { 49 | Bin[] addBins = {new Bin("bin1", 5), new Bin("bin2", -5)}; 50 | aerospikeClient.rxAdd(null, addAllBinsTestKey, addBins) 51 | .ignoreElement() 52 | .andThen(aerospikeClient.rxGet(null, addAllBinsTestKey)) 53 | .doOnSuccess(record -> { 54 | MatcherAssert.assertThat(record.getInt("bin1"), Matchers.equalTo(15)); 55 | MatcherAssert.assertThat(record.getInt("bin2"), Matchers.equalTo(15)); 56 | }) 57 | .doOnSuccess(record -> log.info("addAllBins test passed!")) 58 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 59 | } 60 | 61 | @Test 62 | public void addSomeBins(VertxTestContext testContext) { 63 | Bin[] addBins = {new Bin("bin1", 6)}; 64 | aerospikeClient.rxAdd(null, addSomeBinsTestKey, addBins) 65 | .ignoreElement() 66 | .andThen(aerospikeClient.rxGet(null, addSomeBinsTestKey)) 67 | .doOnSuccess(record -> { 68 | MatcherAssert.assertThat(record.getInt("bin1"), Matchers.equalTo(16)); 69 | MatcherAssert.assertThat(record.getInt("bin2"), Matchers.equalTo(20)); 70 | }) 71 | .doOnSuccess(record -> log.info("addSomeBins test passed!")) 72 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 73 | } 74 | 75 | @Test 76 | public void addNonExistingBin(VertxTestContext testContext) { 77 | Bin[] addBins = {new Bin("bin1", 8), new Bin("bin3", -5)}; 78 | aerospikeClient.rxAdd(null, addNonExistingBinTestKey, addBins) 79 | .ignoreElement() 80 | .andThen(aerospikeClient.rxGet(null, addNonExistingBinTestKey)) 81 | .doOnSuccess(record -> { 82 | MatcherAssert.assertThat(record.getInt("bin1"), Matchers.equalTo(18)); 83 | MatcherAssert.assertThat(record.getInt("bin2"), Matchers.equalTo(20)); 84 | MatcherAssert.assertThat(record.getInt("bin3"), Matchers.equalTo(-5)); 85 | }) 86 | .doOnSuccess(record -> log.info("addNonExistingBin test passed!")) 87 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/test/java/io/d11/aerospike/AerospikeAppendTest.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike; 2 | 3 | import com.aerospike.client.Bin; 4 | import com.aerospike.client.Key; 5 | import io.d11.aerospike.client.AerospikeConnectOptions; 6 | import io.d11.rxjava3.aerospike.client.AerospikeClient; 7 | import io.vertx.junit5.VertxExtension; 8 | import io.vertx.junit5.VertxTestContext; 9 | import io.vertx.rxjava3.core.Vertx; 10 | import lombok.extern.slf4j.Slf4j; 11 | import org.hamcrest.MatcherAssert; 12 | import org.hamcrest.Matchers; 13 | import org.junit.jupiter.api.AfterAll; 14 | import org.junit.jupiter.api.BeforeAll; 15 | import org.junit.jupiter.api.Test; 16 | import org.junit.jupiter.api.extension.ExtendWith; 17 | 18 | @ExtendWith({VertxExtension.class, Setup.class}) 19 | @Slf4j 20 | public class AerospikeAppendTest { 21 | 22 | private static final String testSet = "appendTestSet"; 23 | private static final Bin[] bins = {new Bin("bin1", "value1"), new Bin("bin2", "value2")}; 24 | private static final Key appendAllBinsTestKey = new Key(Constants.TEST_NAMESPACE, testSet, "appendAllBins"); 25 | private static final Key appendSomeBinsTestKey = new Key(Constants.TEST_NAMESPACE, testSet, "appendSomeBins"); 26 | private static final Key appendNonExistingBinTestKey = new Key(Constants.TEST_NAMESPACE, testSet, "appendNonExistingBin"); 27 | private static AerospikeClient aerospikeClient; 28 | 29 | @BeforeAll 30 | public static void setup(Vertx vertx) { 31 | AerospikeConnectOptions connectOptions = new AerospikeConnectOptions() 32 | .setHost(System.getProperty(Constants.AEROSPIKE_HOST)) 33 | .setPort(Integer.parseInt(System.getProperty(Constants.AEROSPIKE_PORT))); 34 | aerospikeClient = AerospikeClient.create(vertx, connectOptions); 35 | // add test keys 36 | aerospikeClient.getAerospikeClient().put(null, appendAllBinsTestKey, bins); 37 | aerospikeClient.getAerospikeClient().put(null, appendSomeBinsTestKey, bins); 38 | aerospikeClient.getAerospikeClient().put(null, appendNonExistingBinTestKey, bins); 39 | } 40 | 41 | @AfterAll 42 | public static void cleanUp() { 43 | // remove test keys 44 | aerospikeClient.getAerospikeClient().truncate(null, Constants.TEST_NAMESPACE, testSet, null); 45 | aerospikeClient.close(); 46 | } 47 | 48 | @Test 49 | public void appendAllBins(VertxTestContext testContext) { 50 | Bin[] appendBins = {new Bin("bin1", "-append1"), new Bin("bin2", "-append2")}; 51 | aerospikeClient.rxAppend(null, appendAllBinsTestKey, appendBins) 52 | .ignoreElement() 53 | .andThen(aerospikeClient.rxGet(null, appendAllBinsTestKey)) 54 | .doOnSuccess(record -> { 55 | MatcherAssert.assertThat(record.getString("bin1"), Matchers.equalTo("value1-append1")); 56 | MatcherAssert.assertThat(record.getString("bin2"), Matchers.equalTo("value2-append2")); 57 | }) 58 | .doOnSuccess(record -> log.info("appendAllBins test passed!")) 59 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 60 | } 61 | 62 | @Test 63 | public void appendSomeBins(VertxTestContext testContext) { 64 | Bin[] appendBins = {new Bin("bin1", "-append1")}; 65 | aerospikeClient.rxAppend(null, appendSomeBinsTestKey, appendBins) 66 | .ignoreElement() 67 | .andThen(aerospikeClient.rxGet(null, appendSomeBinsTestKey)) 68 | .doOnSuccess(record -> { 69 | MatcherAssert.assertThat(record.getString("bin1"), Matchers.equalTo("value1-append1")); 70 | MatcherAssert.assertThat(record.getString("bin2"), Matchers.equalTo("value2")); 71 | }) 72 | .doOnSuccess(record -> log.info("appendSomeBins test passed!")) 73 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 74 | } 75 | 76 | @Test 77 | public void appendNonExistingBin(VertxTestContext testContext) { 78 | Bin[] appendBins = {new Bin("bin1", "-append1"), new Bin("bin3", "value3")}; 79 | aerospikeClient.rxAppend(null, appendNonExistingBinTestKey, appendBins) 80 | .ignoreElement() 81 | .andThen(aerospikeClient.rxGet(null, appendNonExistingBinTestKey)) 82 | .doOnSuccess(record -> { 83 | MatcherAssert.assertThat(record.getString("bin1"), Matchers.equalTo("value1-append1")); 84 | MatcherAssert.assertThat(record.getString("bin2"), Matchers.equalTo("value2")); 85 | MatcherAssert.assertThat(record.getString("bin3"), Matchers.equalTo("value3")); 86 | }) 87 | .doOnSuccess(record -> log.info("appendNonExistingBin test passed!")) 88 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/test/java/io/d11/aerospike/AerospikePrependTest.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike; 2 | 3 | import com.aerospike.client.Bin; 4 | import com.aerospike.client.Key; 5 | import io.d11.aerospike.client.AerospikeConnectOptions; 6 | import io.d11.rxjava3.aerospike.client.AerospikeClient; 7 | import io.vertx.junit5.VertxExtension; 8 | import io.vertx.junit5.VertxTestContext; 9 | import io.vertx.rxjava3.core.Vertx; 10 | import lombok.extern.slf4j.Slf4j; 11 | import org.hamcrest.MatcherAssert; 12 | import org.hamcrest.Matchers; 13 | import org.junit.jupiter.api.AfterAll; 14 | import org.junit.jupiter.api.BeforeAll; 15 | import org.junit.jupiter.api.Test; 16 | import org.junit.jupiter.api.extension.ExtendWith; 17 | 18 | @ExtendWith({VertxExtension.class, Setup.class}) 19 | @Slf4j 20 | public class AerospikePrependTest { 21 | private static final String testSet = "prependTestSet"; 22 | private static final Bin[] bins = {new Bin("bin1", "value1"), new Bin("bin2", "value2")}; 23 | private static final Key prependAllBinsTestKey = new Key(Constants.TEST_NAMESPACE, testSet, "appendAllBins"); 24 | private static final Key prependSomeBinsTestKey = new Key(Constants.TEST_NAMESPACE, testSet, "appendSomeBins"); 25 | private static final Key prependNonExistingBinTestKey = new Key(Constants.TEST_NAMESPACE, testSet, "appendNonExistingBin"); 26 | private static AerospikeClient aerospikeClient; 27 | 28 | @BeforeAll 29 | public static void setup(Vertx vertx) { 30 | AerospikeConnectOptions connectOptions = new AerospikeConnectOptions() 31 | .setHost(System.getProperty(Constants.AEROSPIKE_HOST)) 32 | .setPort(Integer.parseInt(System.getProperty(Constants.AEROSPIKE_PORT))); 33 | aerospikeClient = AerospikeClient.create(vertx, connectOptions); 34 | // add test keys 35 | aerospikeClient.getAerospikeClient().put(null, prependAllBinsTestKey, bins); 36 | aerospikeClient.getAerospikeClient().put(null, prependSomeBinsTestKey, bins); 37 | aerospikeClient.getAerospikeClient().put(null, prependNonExistingBinTestKey, bins); 38 | } 39 | 40 | @AfterAll 41 | public static void cleanUp() { 42 | // remove test keys 43 | aerospikeClient.getAerospikeClient().truncate(null, Constants.TEST_NAMESPACE, testSet, null); 44 | aerospikeClient.close(); 45 | } 46 | 47 | @Test 48 | public void prependAllBins(VertxTestContext testContext) { 49 | Bin[] prependBins = {new Bin("bin1", "prepend1-"), new Bin("bin2", "prepend2-")}; 50 | aerospikeClient.rxPrepend(null, prependAllBinsTestKey, prependBins) 51 | .ignoreElement() 52 | .andThen(aerospikeClient.rxGet(null, prependAllBinsTestKey)) 53 | .doOnSuccess(record -> { 54 | MatcherAssert.assertThat(record.getString("bin1"), Matchers.equalTo("prepend1-value1")); 55 | MatcherAssert.assertThat(record.getString("bin2"), Matchers.equalTo("prepend2-value2")); 56 | }) 57 | .doOnSuccess(record -> log.info("prependAllBins test passed!")) 58 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 59 | } 60 | 61 | @Test 62 | public void prependSomeBins(VertxTestContext testContext) { 63 | Bin[] prependBins = {new Bin("bin1", "prepend1-")}; 64 | aerospikeClient.rxPrepend(null, prependSomeBinsTestKey, prependBins) 65 | .ignoreElement() 66 | .andThen(aerospikeClient.rxGet(null, prependSomeBinsTestKey)) 67 | .doOnSuccess(record -> { 68 | MatcherAssert.assertThat(record.getString("bin1"), Matchers.equalTo("prepend1-value1")); 69 | MatcherAssert.assertThat(record.getString("bin2"), Matchers.equalTo("value2")); 70 | }) 71 | .doOnSuccess(record -> log.info("prependSomeBins test passed!")) 72 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 73 | } 74 | 75 | @Test 76 | public void prependNonExistingBin(VertxTestContext testContext) { 77 | Bin[] prependBins = {new Bin("bin1", "prepend1-"), new Bin("bin3", "value3")}; 78 | aerospikeClient.rxPrepend(null, prependNonExistingBinTestKey, prependBins) 79 | .ignoreElement() 80 | .andThen(aerospikeClient.rxGet(null, prependNonExistingBinTestKey)) 81 | .doOnSuccess(record -> { 82 | MatcherAssert.assertThat(record.getString("bin1"), Matchers.equalTo("prepend1-value1")); 83 | MatcherAssert.assertThat(record.getString("bin2"), Matchers.equalTo("value2")); 84 | MatcherAssert.assertThat(record.getString("bin3"), Matchers.equalTo("value3")); 85 | }) 86 | .doOnSuccess(record -> log.info("prependNonExistingBin test passed!")) 87 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/test/java/io/d11/aerospike/AerospikeGetTest.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike; 2 | 3 | import com.aerospike.client.BatchRead; 4 | import com.aerospike.client.Key; 5 | import io.d11.aerospike.client.AerospikeConnectOptions; 6 | import io.d11.rxjava3.aerospike.client.AerospikeClient; 7 | import io.vertx.junit5.VertxExtension; 8 | import io.vertx.junit5.VertxTestContext; 9 | import io.vertx.rxjava3.core.Vertx; 10 | import java.util.Arrays; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.hamcrest.MatcherAssert; 13 | import org.hamcrest.Matchers; 14 | import org.junit.jupiter.api.AfterAll; 15 | import org.junit.jupiter.api.BeforeAll; 16 | import org.junit.jupiter.api.Test; 17 | import org.junit.jupiter.api.extension.ExtendWith; 18 | 19 | @ExtendWith({VertxExtension.class, Setup.class}) 20 | @Slf4j 21 | public class AerospikeGetTest { 22 | 23 | private static AerospikeClient aerospikeClient; 24 | private final Key key1 = new Key(Constants.TEST_NAMESPACE, Constants.TEST_SET, "pkey1"); 25 | private final Key key2 = new Key(Constants.TEST_NAMESPACE, Constants.TEST_SET, "pkey2"); 26 | 27 | @BeforeAll 28 | public static void setup(Vertx vertx) { 29 | AerospikeConnectOptions connectOptions = new AerospikeConnectOptions() 30 | .setHost(System.getProperty(Constants.AEROSPIKE_HOST)) 31 | .setPort(Integer.parseInt(System.getProperty(Constants.AEROSPIKE_PORT))); 32 | aerospikeClient = AerospikeClient.create(vertx, connectOptions); 33 | } 34 | 35 | @AfterAll 36 | public static void cleanUp() { 37 | // remove test keys 38 | aerospikeClient.close(); 39 | } 40 | 41 | @Test 42 | public void getAllBins(VertxTestContext testContext) { 43 | aerospikeClient.rxGet(null, key1) 44 | .doOnSuccess(record -> { 45 | MatcherAssert.assertThat(record.getString("bin1"), Matchers.equalTo("Mumbai")); 46 | MatcherAssert.assertThat(record.getInt("bin2"), Matchers.equalTo(123)); 47 | }) 48 | .doOnSuccess(record -> log.info("getAllBins test passed!")) 49 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 50 | } 51 | 52 | @Test 53 | public void getSelectedBins(VertxTestContext testContext) { 54 | aerospikeClient.rxGet(null, key1, new String[] {"bin1"}) 55 | .doOnSuccess(record -> { 56 | MatcherAssert.assertThat(record.bins.size(), Matchers.equalTo(1)); 57 | MatcherAssert.assertThat(record.getString("bin1"), Matchers.equalTo("Mumbai")); 58 | }) 59 | .doOnSuccess(record -> log.info("getSelectedBins test passed!")) 60 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 61 | } 62 | 63 | @Test 64 | public void getAllBinsFromMultipleKeys(VertxTestContext testContext) { 65 | aerospikeClient.rxGet(null, new Key[] {key1, key2}) 66 | .doOnSuccess(records -> { 67 | MatcherAssert.assertThat(records.get(0).getString("bin1"), Matchers.equalTo("Mumbai")); 68 | MatcherAssert.assertThat(records.get(0).getInt("bin2"), Matchers.equalTo(123)); 69 | 70 | MatcherAssert.assertThat(records.get(1).getString("bin1"), Matchers.equalTo("Delhi")); 71 | MatcherAssert.assertThat(records.get(1).getInt("bin2"), Matchers.equalTo(3)); 72 | }) 73 | .doOnSuccess(record -> log.info("getAllBinsFromMultipleKeys test passed!")) 74 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 75 | } 76 | 77 | @Test 78 | public void getSelectedBinsFromMultipleKeys(VertxTestContext testContext) { 79 | aerospikeClient.rxGet(null, new Key[] {key1, key2}, new String[] {"bin1"}) 80 | .doOnSuccess(record -> { 81 | MatcherAssert.assertThat(record.get(0).bins.size(), Matchers.equalTo(1)); 82 | MatcherAssert.assertThat(record.get(0).getString("bin1"), Matchers.equalTo("Mumbai")); 83 | 84 | MatcherAssert.assertThat(record.get(1).bins.size(), Matchers.equalTo(1)); 85 | MatcherAssert.assertThat(record.get(1).getString("bin1"), Matchers.equalTo("Delhi")); 86 | }) 87 | .doOnSuccess(record -> log.info("getSelectedBinsFromMultipleKeys test passed!")) 88 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 89 | } 90 | 91 | @Test 92 | public void getDifferentBinsFromMultipleKeys(VertxTestContext testContext) { 93 | BatchRead batchRead1 = new BatchRead(key1, true); 94 | BatchRead batchRead2 = new BatchRead(key2, new String[] {"bin1"}); 95 | aerospikeClient.rxGet(null, Arrays.asList(batchRead1, batchRead2)) 96 | .doOnSuccess(record -> { 97 | MatcherAssert.assertThat(record.get(0).record.getString("bin1"), Matchers.equalTo("Mumbai")); 98 | MatcherAssert.assertThat(record.get(0).record.getInt("bin2"), Matchers.equalTo(123)); 99 | 100 | MatcherAssert.assertThat(record.get(1).record.bins.size(), Matchers.equalTo(1)); 101 | MatcherAssert.assertThat(record.get(1).record.getString("bin1"), Matchers.equalTo("Delhi")); 102 | }) 103 | .doOnSuccess(record -> log.info("getDifferentBinsFromMultipleKeys test passed!")) 104 | .subscribe(record -> testContext.completeNow(), testContext::failNow); 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | charset = utf-8 3 | end_of_line = lf 4 | indent_size = 2 5 | indent_style = space 6 | insert_final_newline = false 7 | max_line_length = 140 8 | tab_width = 2 9 | ij_continuation_indent_size = 8 10 | ij_formatter_off_tag = @formatter:off 11 | ij_formatter_on_tag = @formatter:on 12 | ij_formatter_tags_enabled = true 13 | ij_smart_tabs = false 14 | ij_visual_guides = 140 15 | ij_wrap_on_typing = true 16 | 17 | [*.conf] 18 | ij_continuation_indent_size = 2 19 | ij_hocon_keep_blank_lines_before_right_brace = 2 20 | ij_hocon_keep_indents_on_empty_lines = false 21 | ij_hocon_keep_line_breaks = true 22 | ij_hocon_space_after_colon = true 23 | ij_hocon_space_after_comma = true 24 | ij_hocon_space_before_colon = true 25 | ij_hocon_space_before_comma = false 26 | ij_hocon_spaces_within_braces = false 27 | ij_hocon_spaces_within_brackets = false 28 | ij_hocon_spaces_within_method_call_parentheses = false 29 | 30 | [*.java] 31 | ij_continuation_indent_size = 4 32 | ij_java_align_consecutive_assignments = false 33 | ij_java_align_consecutive_variable_declarations = false 34 | ij_java_align_group_field_declarations = false 35 | ij_java_align_multiline_annotation_parameters = false 36 | ij_java_align_multiline_array_initializer_expression = false 37 | ij_java_align_multiline_assignment = false 38 | ij_java_align_multiline_binary_operation = false 39 | ij_java_align_multiline_chained_methods = false 40 | ij_java_align_multiline_extends_list = false 41 | ij_java_align_multiline_for = true 42 | ij_java_align_multiline_method_parentheses = false 43 | ij_java_align_multiline_parameters = true 44 | ij_java_align_multiline_parameters_in_calls = false 45 | ij_java_align_multiline_parenthesized_expression = false 46 | ij_java_align_multiline_records = true 47 | ij_java_align_multiline_resources = true 48 | ij_java_align_multiline_ternary_operation = false 49 | ij_java_align_multiline_text_blocks = false 50 | ij_java_align_multiline_throws_list = false 51 | ij_java_align_subsequent_simple_methods = false 52 | ij_java_align_throws_keyword = false 53 | ij_java_annotation_parameter_wrap = off 54 | ij_java_array_initializer_new_line_after_left_brace = false 55 | ij_java_array_initializer_right_brace_on_new_line = false 56 | ij_java_array_initializer_wrap = normal 57 | ij_java_assert_statement_colon_on_next_line = false 58 | ij_java_assert_statement_wrap = normal 59 | ij_java_assignment_wrap = normal 60 | ij_java_binary_operation_sign_on_next_line = true 61 | ij_java_binary_operation_wrap = normal 62 | ij_java_blank_lines_after_anonymous_class_header = 0 63 | ij_java_blank_lines_after_class_header = 0 64 | ij_java_blank_lines_after_imports = 1 65 | ij_java_blank_lines_after_package = 1 66 | ij_java_blank_lines_around_class = 1 67 | ij_java_blank_lines_around_field = 0 68 | ij_java_blank_lines_around_field_in_interface = 0 69 | ij_java_blank_lines_around_initializer = 1 70 | ij_java_blank_lines_around_method = 1 71 | ij_java_blank_lines_around_method_in_interface = 1 72 | ij_java_blank_lines_before_class_end = 0 73 | ij_java_blank_lines_before_imports = 1 74 | ij_java_blank_lines_before_method_body = 0 75 | ij_java_blank_lines_before_package = 1 76 | ij_java_block_brace_style = end_of_line 77 | ij_java_block_comment_at_first_column = true 78 | ij_java_call_parameters_new_line_after_left_paren = false 79 | ij_java_call_parameters_right_paren_on_new_line = false 80 | ij_java_call_parameters_wrap = normal 81 | ij_java_case_statement_on_separate_line = true 82 | ij_java_catch_on_new_line = false 83 | ij_java_class_annotation_wrap = split_into_lines 84 | ij_java_class_brace_style = end_of_line 85 | ij_java_class_count_to_use_import_on_demand = 999 86 | ij_java_class_names_in_javadoc = 1 87 | ij_java_do_not_indent_top_level_class_members = false 88 | ij_java_do_not_wrap_after_single_annotation = false 89 | ij_java_do_while_brace_force = always 90 | ij_java_doc_add_blank_line_after_description = true 91 | ij_java_doc_add_blank_line_after_param_comments = false 92 | ij_java_doc_add_blank_line_after_return = false 93 | ij_java_doc_add_p_tag_on_empty_lines = true 94 | ij_java_doc_align_exception_comments = true 95 | ij_java_doc_align_param_comments = true 96 | ij_java_doc_do_not_wrap_if_one_line = false 97 | ij_java_doc_enable_formatting = true 98 | ij_java_doc_enable_leading_asterisks = true 99 | ij_java_doc_indent_on_continuation = false 100 | ij_java_doc_keep_empty_lines = true 101 | ij_java_doc_keep_empty_parameter_tag = true 102 | ij_java_doc_keep_empty_return_tag = true 103 | ij_java_doc_keep_empty_throws_tag = true 104 | ij_java_doc_keep_invalid_tags = true 105 | ij_java_doc_param_description_on_new_line = false 106 | ij_java_doc_preserve_line_breaks = false 107 | ij_java_doc_use_throws_not_exception_tag = true 108 | ij_java_else_on_new_line = false 109 | ij_java_entity_dd_suffix = EJB 110 | ij_java_entity_eb_suffix = Bean 111 | ij_java_entity_hi_suffix = Home 112 | ij_java_entity_lhi_prefix = Local 113 | ij_java_entity_lhi_suffix = Home 114 | ij_java_entity_li_prefix = Local 115 | ij_java_entity_pk_class = java.lang.String 116 | ij_java_entity_vo_suffix = VO 117 | ij_java_enum_constants_wrap = normal 118 | ij_java_extends_keyword_wrap = normal 119 | ij_java_extends_list_wrap = normal 120 | ij_java_field_annotation_wrap = split_into_lines 121 | ij_java_finally_on_new_line = false 122 | ij_java_for_brace_force = always 123 | ij_java_for_statement_new_line_after_left_paren = false 124 | ij_java_for_statement_right_paren_on_new_line = false 125 | ij_java_for_statement_wrap = normal 126 | ij_java_generate_final_locals = false 127 | ij_java_generate_final_parameters = false 128 | ij_java_if_brace_force = always 129 | ij_java_imports_layout = $*,|,*,|,* 130 | ij_java_indent_case_from_switch = true 131 | ij_java_insert_inner_class_imports = false 132 | ij_java_insert_override_annotation = true 133 | ij_java_keep_blank_lines_before_right_brace = 2 134 | ij_java_keep_blank_lines_between_package_declaration_and_header = 2 135 | ij_java_keep_blank_lines_in_code = 2 136 | ij_java_keep_blank_lines_in_declarations = 2 137 | ij_java_keep_control_statement_in_one_line = true 138 | ij_java_keep_first_column_comment = true 139 | ij_java_keep_indents_on_empty_lines = false 140 | ij_java_keep_line_breaks = true 141 | ij_java_keep_multiple_expressions_in_one_line = false 142 | ij_java_keep_simple_blocks_in_one_line = false 143 | ij_java_keep_simple_classes_in_one_line = false 144 | ij_java_keep_simple_lambdas_in_one_line = false 145 | ij_java_keep_simple_methods_in_one_line = false 146 | ij_java_label_indent_absolute = false 147 | ij_java_label_indent_size = 0 148 | ij_java_lambda_brace_style = end_of_line 149 | ij_java_layout_static_imports_separately = true 150 | ij_java_line_comment_add_space = false 151 | ij_java_line_comment_at_first_column = true 152 | ij_java_message_dd_suffix = EJB 153 | ij_java_message_eb_suffix = Bean 154 | ij_java_method_annotation_wrap = split_into_lines 155 | ij_java_method_brace_style = end_of_line 156 | ij_java_method_call_chain_wrap = normal 157 | ij_java_method_parameters_new_line_after_left_paren = false 158 | ij_java_method_parameters_right_paren_on_new_line = false 159 | ij_java_method_parameters_wrap = normal 160 | ij_java_modifier_list_wrap = false 161 | ij_java_names_count_to_use_import_on_demand = 999 162 | ij_java_new_line_after_lparen_in_record_header = false 163 | ij_java_parameter_annotation_wrap = normal 164 | ij_java_parentheses_expression_new_line_after_left_paren = false 165 | ij_java_parentheses_expression_right_paren_on_new_line = false 166 | ij_java_place_assignment_sign_on_next_line = false 167 | ij_java_prefer_longer_names = true 168 | ij_java_prefer_parameters_wrap = false 169 | ij_java_record_components_wrap = normal 170 | ij_java_repeat_synchronized = true 171 | ij_java_replace_instanceof_and_cast = false 172 | ij_java_replace_null_check = true 173 | ij_java_replace_sum_lambda_with_method_ref = true 174 | ij_java_resource_list_new_line_after_left_paren = false 175 | ij_java_resource_list_right_paren_on_new_line = false 176 | ij_java_resource_list_wrap = normal 177 | ij_java_rparen_on_new_line_in_record_header = false 178 | ij_java_session_dd_suffix = EJB 179 | ij_java_session_eb_suffix = Bean 180 | ij_java_session_hi_suffix = Home 181 | ij_java_session_lhi_prefix = Local 182 | ij_java_session_lhi_suffix = Home 183 | ij_java_session_li_prefix = Local 184 | ij_java_session_si_suffix = Service 185 | ij_java_space_after_closing_angle_bracket_in_type_argument = false 186 | ij_java_space_after_colon = true 187 | ij_java_space_after_comma = true 188 | ij_java_space_after_comma_in_type_arguments = true 189 | ij_java_space_after_for_semicolon = true 190 | ij_java_space_after_quest = true 191 | ij_java_space_after_type_cast = true 192 | ij_java_space_before_annotation_array_initializer_left_brace = false 193 | ij_java_space_before_annotation_parameter_list = false 194 | ij_java_space_before_array_initializer_left_brace = true 195 | ij_java_space_before_catch_keyword = true 196 | ij_java_space_before_catch_left_brace = true 197 | ij_java_space_before_catch_parentheses = true 198 | ij_java_space_before_class_left_brace = true 199 | ij_java_space_before_colon = true 200 | ij_java_space_before_colon_in_foreach = true 201 | ij_java_space_before_comma = false 202 | ij_java_space_before_do_left_brace = true 203 | ij_java_space_before_else_keyword = true 204 | ij_java_space_before_else_left_brace = true 205 | ij_java_space_before_finally_keyword = true 206 | ij_java_space_before_finally_left_brace = true 207 | ij_java_space_before_for_left_brace = true 208 | ij_java_space_before_for_parentheses = true 209 | ij_java_space_before_for_semicolon = false 210 | ij_java_space_before_if_left_brace = true 211 | ij_java_space_before_if_parentheses = true 212 | ij_java_space_before_method_call_parentheses = false 213 | ij_java_space_before_method_left_brace = true 214 | ij_java_space_before_method_parentheses = false 215 | ij_java_space_before_opening_angle_bracket_in_type_parameter = false 216 | ij_java_space_before_quest = true 217 | ij_java_space_before_switch_left_brace = true 218 | ij_java_space_before_switch_parentheses = true 219 | ij_java_space_before_synchronized_left_brace = true 220 | ij_java_space_before_synchronized_parentheses = true 221 | ij_java_space_before_try_left_brace = true 222 | ij_java_space_before_try_parentheses = true 223 | ij_java_space_before_type_parameter_list = false 224 | ij_java_space_before_while_keyword = true 225 | ij_java_space_before_while_left_brace = true 226 | ij_java_space_before_while_parentheses = true 227 | ij_java_space_inside_one_line_enum_braces = false 228 | ij_java_space_within_empty_array_initializer_braces = false 229 | ij_java_space_within_empty_method_call_parentheses = false 230 | ij_java_space_within_empty_method_parentheses = false 231 | ij_java_spaces_around_additive_operators = true 232 | ij_java_spaces_around_assignment_operators = true 233 | ij_java_spaces_around_bitwise_operators = true 234 | ij_java_spaces_around_equality_operators = true 235 | ij_java_spaces_around_lambda_arrow = true 236 | ij_java_spaces_around_logical_operators = true 237 | ij_java_spaces_around_method_ref_dbl_colon = false 238 | ij_java_spaces_around_multiplicative_operators = true 239 | ij_java_spaces_around_relational_operators = true 240 | ij_java_spaces_around_shift_operators = true 241 | ij_java_spaces_around_type_bounds_in_type_parameters = true 242 | ij_java_spaces_around_unary_operator = false 243 | ij_java_spaces_within_angle_brackets = false 244 | ij_java_spaces_within_annotation_parentheses = false 245 | ij_java_spaces_within_array_initializer_braces = false 246 | ij_java_spaces_within_braces = false 247 | ij_java_spaces_within_brackets = false 248 | ij_java_spaces_within_cast_parentheses = false 249 | ij_java_spaces_within_catch_parentheses = false 250 | ij_java_spaces_within_for_parentheses = false 251 | ij_java_spaces_within_if_parentheses = false 252 | ij_java_spaces_within_method_call_parentheses = false 253 | ij_java_spaces_within_method_parentheses = false 254 | ij_java_spaces_within_parentheses = false 255 | ij_java_spaces_within_switch_parentheses = false 256 | ij_java_spaces_within_synchronized_parentheses = false 257 | ij_java_spaces_within_try_parentheses = false 258 | ij_java_spaces_within_while_parentheses = false 259 | ij_java_special_else_if_treatment = true 260 | ij_java_subclass_name_suffix = Impl 261 | ij_java_ternary_operation_signs_on_next_line = false 262 | ij_java_ternary_operation_wrap = normal 263 | ij_java_test_name_suffix = Test 264 | ij_java_throws_keyword_wrap = normal 265 | ij_java_throws_list_wrap = normal 266 | ij_java_use_external_annotations = false 267 | ij_java_use_fq_class_names = false 268 | ij_java_use_relative_indents = false 269 | ij_java_use_single_class_imports = true 270 | ij_java_variable_annotation_wrap = normal 271 | ij_java_visibility = public 272 | ij_java_while_brace_force = always 273 | ij_java_while_on_new_line = false 274 | ij_java_wrap_comments = false 275 | ij_java_wrap_first_method_in_call_chain = false 276 | ij_java_wrap_long_lines = false 277 | 278 | [*.properties] 279 | ij_properties_align_group_field_declarations = false 280 | ij_properties_keep_blank_lines = false 281 | ij_properties_key_value_delimiter = equals 282 | ij_properties_spaces_around_key_value_delimiter = false -------------------------------------------------------------------------------- /src/main/java/io/d11/aerospike/client/impl/AerospikeClientImpl.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike.client.impl; 2 | 3 | import com.aerospike.client.AerospikeException; 4 | import com.aerospike.client.BatchRead; 5 | import com.aerospike.client.Bin; 6 | import com.aerospike.client.Host; 7 | import com.aerospike.client.Key; 8 | import com.aerospike.client.Operation; 9 | import com.aerospike.client.Record; 10 | import com.aerospike.client.ResultCode; 11 | import com.aerospike.client.Value; 12 | import com.aerospike.client.async.EventLoops; 13 | import com.aerospike.client.cluster.ClusterStats; 14 | import com.aerospike.client.policy.BatchPolicy; 15 | import com.aerospike.client.policy.Policy; 16 | import com.aerospike.client.policy.QueryPolicy; 17 | import com.aerospike.client.policy.ScanPolicy; 18 | import com.aerospike.client.policy.WritePolicy; 19 | import com.aerospike.client.query.KeyRecord; 20 | import com.aerospike.client.query.PartitionFilter; 21 | import com.aerospike.client.query.Statement; 22 | import io.d11.aerospike.client.AerospikeClient; 23 | import io.d11.aerospike.client.AerospikeConnectOptions; 24 | import io.d11.aerospike.listeners.BatchListListenerImpl; 25 | import io.d11.aerospike.listeners.DeleteListenerImpl; 26 | import io.d11.aerospike.listeners.ExecuteListenerImpl; 27 | import io.d11.aerospike.listeners.ExistsArrayListenerImpl; 28 | import io.d11.aerospike.listeners.ExistsListenerImpl; 29 | import io.d11.aerospike.listeners.QueryResultListenerImpl; 30 | import io.d11.aerospike.listeners.RecordArrayListenerImpl; 31 | import io.d11.aerospike.listeners.RecordListenerImpl; 32 | import io.d11.aerospike.listeners.WriteListenerImpl; 33 | import io.d11.aerospike.util.SharedDataUtils; 34 | import io.vertx.core.AsyncResult; 35 | import io.vertx.core.Handler; 36 | import io.vertx.core.Vertx; 37 | import io.vertx.core.impl.VertxInternal; 38 | import java.util.List; 39 | import java.util.concurrent.Callable; 40 | 41 | import lombok.extern.slf4j.Slf4j; 42 | 43 | @Slf4j 44 | public class AerospikeClientImpl implements AerospikeClient { 45 | private final VertxInternal vertx; 46 | private final EventLoops eventLoops; 47 | private final AerospikeConnectOptions connectOptions; 48 | private com.aerospike.client.AerospikeClient aerospikeClient; 49 | 50 | public AerospikeClientImpl(Vertx vertx, AerospikeConnectOptions connectOptions) { 51 | this.vertx = (VertxInternal) vertx; 52 | this.connectOptions = connectOptions; 53 | this.aerospikeClient = connectClientWithRetry(0); 54 | eventLoops = connectOptions.getClientPolicy().eventLoops; 55 | } 56 | 57 | public com.aerospike.client.AerospikeClient getAerospikeClient() { 58 | return this.aerospikeClient; 59 | } 60 | 61 | private void schedule(Callable blockingCodeHandler, Handler> resultHandler) { 62 | vertx.executeBlocking(blockingCodeHandler).onComplete(resultHandler); 63 | } 64 | 65 | private com.aerospike.client.AerospikeClient connectClientWithRetry(int retryCount) { 66 | if (this.connectOptions.getMaxConnectRetries() != -1 && retryCount > this.connectOptions.getMaxConnectRetries()) { 67 | log.error("Exhausted max connection retries after {} attempts", retryCount); 68 | throw new AerospikeException(ResultCode.MAX_RETRIES_EXCEEDED, "Cannot connect to Aerospike"); 69 | } else { 70 | try { 71 | Thread.sleep(2); 72 | return new com.aerospike.client.AerospikeClient(connectOptions.getClientPolicy(), new Host(connectOptions.getHost(), 73 | connectOptions.getPort())); 74 | } catch (Exception e) { 75 | log.error("Error while connecting to aerospike", e); 76 | log.info("Retrying to connect to aerospike"); 77 | return connectClientWithRetry(retryCount + 1); 78 | } 79 | } 80 | } 81 | 82 | @Override 83 | public AerospikeClient isConnected(Handler> handler) { 84 | this.schedule(() -> this.aerospikeClient.isConnected(), handler); 85 | return this; 86 | } 87 | 88 | @Override 89 | public AerospikeClient getClusterStats(Handler> handler) { 90 | this.schedule(() -> this.aerospikeClient.getClusterStats(), handler); 91 | return this; 92 | } 93 | 94 | public void close() { 95 | if (aerospikeClient != null) { 96 | aerospikeClient.close(); 97 | SharedDataUtils.removeInstanceByName(vertx, SharedDataUtils.getInstanceName(connectOptions.getHost(), connectOptions.getPort())); 98 | aerospikeClient = null; 99 | } 100 | } 101 | 102 | public AerospikeClient put(WritePolicy writePolicy, Key key, Bin[] bins, Handler> handler) 103 | throws AerospikeException { 104 | this.aerospikeClient.put( 105 | this.eventLoops.next(), 106 | new WriteListenerImpl(this.vertx.getOrCreateContext(), handler), 107 | writePolicy, 108 | key, 109 | bins); 110 | return this; 111 | } 112 | 113 | public AerospikeClient append(WritePolicy writePolicy, Key key, Bin[] bins, Handler> handler) 114 | throws AerospikeException { 115 | this.aerospikeClient.append( 116 | this.eventLoops.next(), 117 | new WriteListenerImpl(this.vertx.getOrCreateContext(), handler), 118 | writePolicy, 119 | key, 120 | bins); 121 | return this; 122 | } 123 | 124 | public AerospikeClient prepend( 125 | WritePolicy writePolicy, Key key, Bin[] bins, Handler> handler) 126 | throws AerospikeException { 127 | this.aerospikeClient.prepend( 128 | this.eventLoops.next(), 129 | new WriteListenerImpl(this.vertx.getOrCreateContext(), handler), 130 | writePolicy, 131 | key, 132 | bins); 133 | return this; 134 | } 135 | 136 | public AerospikeClient add(WritePolicy writePolicy, Key key, Bin[] bins, Handler> handler) 137 | throws AerospikeException { 138 | this.aerospikeClient.add( 139 | this.eventLoops.next(), 140 | new WriteListenerImpl(this.vertx.getOrCreateContext(), handler), 141 | writePolicy, 142 | key, 143 | bins); 144 | return this; 145 | } 146 | 147 | public AerospikeClient delete(WritePolicy writePolicy, Key key, Handler> handler) 148 | throws AerospikeException { 149 | this.aerospikeClient.delete( 150 | this.eventLoops.next(), 151 | new DeleteListenerImpl(this.vertx.getOrCreateContext(), handler), 152 | writePolicy, 153 | key); 154 | return this; 155 | } 156 | 157 | public AerospikeClient touch(WritePolicy writePolicy, Key key, Handler> handler) 158 | throws AerospikeException { 159 | this.aerospikeClient.touch( 160 | this.eventLoops.next(), 161 | new WriteListenerImpl(this.vertx.getOrCreateContext(), handler), 162 | writePolicy, 163 | key); 164 | return this; 165 | } 166 | 167 | public AerospikeClient exists(Policy policy, Key key, Handler> handler) 168 | throws AerospikeException { 169 | this.aerospikeClient.exists( 170 | this.eventLoops.next(), 171 | new ExistsListenerImpl(this.vertx.getOrCreateContext(), handler), 172 | policy, 173 | key); 174 | return this; 175 | } 176 | 177 | public AerospikeClient exists( 178 | BatchPolicy batchPolicy, Key[] keys, Handler>> handler) 179 | throws AerospikeException { 180 | this.aerospikeClient.exists( 181 | this.eventLoops.next(), 182 | new ExistsArrayListenerImpl(this.vertx.getOrCreateContext(), handler), 183 | batchPolicy, 184 | keys); 185 | return this; 186 | } 187 | 188 | public AerospikeClient get(Policy policy, Key key, Handler> handler) 189 | throws AerospikeException { 190 | this.aerospikeClient.get( 191 | this.eventLoops.next(), 192 | new RecordListenerImpl(this.vertx.getOrCreateContext(), handler), 193 | policy, 194 | key); 195 | return this; 196 | } 197 | 198 | public AerospikeClient get(Policy policy, Key key, String[] binNames, Handler> handler) 199 | throws AerospikeException { 200 | this.aerospikeClient.get( 201 | this.eventLoops.next(), 202 | new RecordListenerImpl(this.vertx.getOrCreateContext(), handler), 203 | policy, 204 | key, 205 | binNames); 206 | return this; 207 | } 208 | 209 | public AerospikeClient getHeader(Policy policy, Key key, Handler> handler) 210 | throws AerospikeException { 211 | this.aerospikeClient.getHeader( 212 | this.eventLoops.next(), 213 | new RecordListenerImpl(this.vertx.getOrCreateContext(), handler), 214 | policy, 215 | key); 216 | return this; 217 | } 218 | 219 | public AerospikeClient get( 220 | BatchPolicy batchPolicy, List records, Handler>> handler) 221 | throws AerospikeException { 222 | this.aerospikeClient.get( 223 | this.eventLoops.next(), 224 | new BatchListListenerImpl(this.vertx.getOrCreateContext(), handler), 225 | batchPolicy, 226 | records); 227 | return this; 228 | } 229 | 230 | public AerospikeClient get(BatchPolicy batchPolicy, Key[] keys, Handler>> handler) 231 | throws AerospikeException { 232 | this.aerospikeClient.get( 233 | this.eventLoops.next(), 234 | new RecordArrayListenerImpl(this.vertx.getOrCreateContext(), handler), 235 | batchPolicy, 236 | keys); 237 | return this; 238 | } 239 | 240 | public AerospikeClient get( 241 | BatchPolicy batchPolicy, 242 | Key[] keys, 243 | String[] binNames, 244 | Handler>> handler) 245 | throws AerospikeException { 246 | this.aerospikeClient.get( 247 | this.eventLoops.next(), 248 | new RecordArrayListenerImpl(this.vertx.getOrCreateContext(), handler), 249 | batchPolicy, 250 | keys, 251 | binNames); 252 | return this; 253 | } 254 | 255 | public AerospikeClient getHeader(BatchPolicy batchPolicy, Key[] keys, Handler>> handler) 256 | throws AerospikeException { 257 | this.aerospikeClient.getHeader( 258 | this.eventLoops.next(), 259 | new RecordArrayListenerImpl(this.vertx.getOrCreateContext(), handler), 260 | batchPolicy, 261 | keys); 262 | return this; 263 | } 264 | 265 | public AerospikeClient operate( 266 | WritePolicy writePolicy, 267 | Key key, 268 | Operation[] operations, 269 | Handler> handler) 270 | throws AerospikeException { 271 | this.aerospikeClient.operate( 272 | this.eventLoops.next(), 273 | new RecordListenerImpl(this.vertx.getOrCreateContext(), handler), 274 | writePolicy, 275 | key, 276 | operations); 277 | return this; 278 | } 279 | 280 | public AerospikeClient scanAll(ScanPolicy policy, String namespace, String setName, 281 | String[] binNames, Handler>> handler) 282 | throws AerospikeException { 283 | this.aerospikeClient.scanAll( 284 | this.eventLoops.next(), 285 | new QueryResultListenerImpl(this.vertx.getOrCreateContext(), handler), 286 | policy, 287 | namespace, 288 | setName, 289 | binNames); 290 | return this; 291 | } 292 | 293 | public AerospikeClient scanPartitions(ScanPolicy policy, PartitionFilter partitionFilter, String namespace, 294 | String setName, String[] binNames, Handler>> handler) 295 | throws AerospikeException { 296 | this.aerospikeClient.scanPartitions( 297 | this.eventLoops.next(), 298 | new QueryResultListenerImpl(this.vertx.getOrCreateContext(), handler), 299 | policy, 300 | partitionFilter, 301 | namespace, 302 | setName, 303 | binNames); 304 | return this; 305 | } 306 | 307 | public AerospikeClient execute( 308 | WritePolicy writePolicy, 309 | Key key, 310 | String packageName, 311 | String functionName, 312 | Value[] functionArgs, 313 | Handler> handler) 314 | throws AerospikeException { 315 | this.aerospikeClient.execute( 316 | this.eventLoops.next(), 317 | new ExecuteListenerImpl(this.vertx.getOrCreateContext(), handler), 318 | writePolicy, 319 | key, 320 | packageName, 321 | functionName, 322 | functionArgs); 323 | return this; 324 | } 325 | 326 | public AerospikeClient query(QueryPolicy queryPolicy, Statement statement, Handler>> handler) 327 | throws AerospikeException { 328 | this.aerospikeClient.query( 329 | this.eventLoops.next(), 330 | new QueryResultListenerImpl(this.vertx.getOrCreateContext(), handler), 331 | queryPolicy, 332 | statement); 333 | return this; 334 | } 335 | 336 | } 337 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | io.d11 6 | vertx-aerospike-client 7 | 2.0.2-SNAPSHOT 8 | 9 | ${project.groupId}:${project.artifactId} 10 | Vertx aerospike module to be in vert.x projects. 11 | https://github.com/dream11/vertx-aerospike-client 12 | 13 | 14 | scm:git:https://github.com/dream11/vertx-aerospike-client.git 15 | scm:git:https://github.com/dream11/vertx-aerospike-client.git 16 | https://github.com/dream11/vertx-aerospike-client 17 | HEAD 18 | 19 | 20 | 21 | 22 | MIT License 23 | https://github.com/dream11/vertx-aerospike-client/raw/master/LICENSE 24 | 25 | 26 | 27 | 28 | 29 | Deepak Chougule 30 | deepak.chougule@dream11.com 31 | Dream11 32 | https://www.dream11.com/ 33 | 34 | 35 | 36 | Akshay Patidar 37 | akshay.patidar@dream11.com 38 | Dream11 39 | https://www.dream11.com/ 40 | 41 | 42 | 43 | Karan Kumar 44 | karan.kumar@dream11.com 45 | Dream11 46 | https://www.dream11.com/ 47 | 48 | 49 | 50 | Srijan Gupta 51 | srijan@dream11.com 52 | Dream11 53 | https://www.dream11.com/ 54 | 55 | 56 | 57 | 58 | 59 | ossrh 60 | https://s01.oss.sonatype.org/content/repositories/snapshots 61 | 62 | 63 | ossrh 64 | https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ 65 | 66 | 67 | 68 | 69 | 4.4.18 70 | 4.5.13 71 | 4.1.49.Final 72 | 4.2.2 73 | 1.8.0-beta2 74 | 1.3.0-alpha4 75 | UTF-8 76 | 1.18.12 77 | 1.15.3 78 | 5.8.0-M1 79 | 4.13.2 80 | 2.2 81 | 82 | 3.8.1 83 | 1.8 84 | 1.8 85 | 1.8 86 | 3.1.0 87 | 3.2.0 88 | 3.0.0-M5 89 | 0.8.6 90 | 3.2.1 91 | 3.0.1 92 | 1.6.7 93 | 3.0.0-M1 94 | 95 | 96 | 97 | 98 | com.aerospike 99 | aerospike-client 100 | ${aerospike-driver.version} 101 | 102 | 103 | 104 | org.projectlombok 105 | lombok 106 | ${lombok.version} 107 | provided 108 | 109 | 110 | 111 | 112 | io.vertx 113 | vertx-core 114 | 115 | 116 | 117 | io.vertx 118 | vertx-codegen 119 | 120 | 121 | 122 | io.vertx 123 | vertx-rx-java2-gen 124 | ${vertx.version} 125 | 126 | 127 | 128 | io.vertx 129 | vertx-rx-java3-gen 130 | ${vertx.version} 131 | 132 | 133 | 134 | io.vertx 135 | vertx-rx-java2 136 | ${vertx.version} 137 | 138 | 139 | 140 | io.vertx 141 | vertx-rx-java3 142 | ${vertx.version} 143 | 144 | 145 | 146 | io.vertx 147 | vertx-junit5 148 | test 149 | 150 | 151 | 152 | io.vertx 153 | vertx-junit5-rx-java3 154 | ${vertx.version} 155 | test 156 | 157 | 158 | 159 | 160 | org.slf4j 161 | slf4j-api 162 | ${slf4j.version} 163 | 164 | 165 | 166 | ch.qos.logback 167 | logback-core 168 | ${logback.version} 169 | 170 | 171 | 172 | ch.qos.logback 173 | logback-classic 174 | ${logback.version} 175 | 176 | 177 | 178 | com.google.inject 179 | guice 180 | 181 | 182 | 183 | io.netty 184 | netty-transport-native-kqueue 185 | ${netty.version} 186 | osx-x86_64 187 | 188 | 189 | 190 | io.netty 191 | netty-transport-native-epoll 192 | ${netty.version} 193 | linux-x86_64 194 | 195 | 196 | 197 | 198 | org.junit.jupiter 199 | junit-jupiter 200 | ${junit-jupiter.version} 201 | test 202 | 203 | 204 | 205 | org.junit.jupiter 206 | junit-jupiter-engine 207 | ${junit-jupiter.version} 208 | test 209 | 210 | 211 | 212 | org.testcontainers 213 | junit-jupiter 214 | ${testcontainers.version} 215 | test 216 | 217 | 218 | 219 | junit 220 | junit 221 | ${junit.version} 222 | test 223 | 224 | 225 | 226 | org.hamcrest 227 | hamcrest 228 | ${hamcrest.version} 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | io.vertx 237 | vertx-stack-depchain 238 | ${vertx.version} 239 | pom 240 | import 241 | 242 | 243 | com.google.inject 244 | guice-bom 245 | ${guice.version} 246 | pom 247 | import 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | maven-javadoc-plugin 257 | ${maven.javadoc.plugin.version} 258 | 259 | all 260 | false 261 | none 262 | 263 | 264 | 265 | 266 | target 267 | 268 | aggregate 269 | 270 | aggregate 271 | 272 | verify 273 | 274 | 275 | attach-javadocs 276 | 277 | jar 278 | 279 | package 280 | 281 | 282 | 283 | 284 | org.apache.maven.plugins 285 | maven-compiler-plugin 286 | ${maven.compiler.plugin.version} 287 | 288 | ${maven.compile.version} 289 | ${maven.compile.source} 290 | ${maven.compile.target} 291 | ${project.build.sourceEncoding} 292 | false 293 | 294 | 295 | lombok.launch.AnnotationProcessorHider$AnnotationProcessor 296 | io.vertx.codegen.CodeGenProcessor 297 | 298 | ${project.basedir}/src/main/generated 299 | 300 | -Acodegen.output=${project.basedir}/src/main 301 | 302 | 303 | 304 | 305 | 306 | maven-clean-plugin 307 | ${maven.clean.plugin.version} 308 | 309 | 310 | 311 | ${project.basedir}/src/main/generated 312 | 313 | 314 | 315 | 316 | 317 | 318 | org.apache.maven.plugins 319 | maven-surefire-plugin 320 | ${maven.surefire.plugin.version} 321 | 322 | 323 | false 324 | 325 | 326 | 327 | 328 | org.jacoco 329 | jacoco-maven-plugin 330 | ${maven.jacoco.plugin.version} 331 | 332 | 333 | pre-unit-test 334 | 335 | prepare-agent 336 | 337 | 338 | 339 | post-unit-test 340 | prepare-package 341 | 342 | report 343 | 344 | 345 | 346 | 347 | 348 | 349 | org.apache.maven.plugins 350 | maven-source-plugin 351 | ${maven.source.plugin.version} 352 | 353 | 354 | attach-sources 355 | verify 356 | 357 | jar-no-fork 358 | 359 | 360 | 361 | 362 | 363 | 364 | org.sonatype.plugins 365 | nexus-staging-maven-plugin 366 | ${maven.nexus.plugin.version} 367 | true 368 | 369 | ossrh 370 | https://s01.oss.sonatype.org/ 371 | true 372 | 373 | 374 | 375 | 376 | org.apache.maven.plugins 377 | maven-release-plugin 378 | ${maven.release.plugin.version} 379 | 380 | true 381 | false 382 | release 383 | deploy 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | release 393 | 394 | 395 | 396 | org.apache.maven.plugins 397 | maven-gpg-plugin 398 | ${maven.gpg.plugin.version} 399 | 400 | 401 | --pinentry-mode 402 | loopback 403 | 404 | 405 | 406 | 407 | sign-artifacts 408 | verify 409 | 410 | sign 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | -------------------------------------------------------------------------------- /src/main/java/io/d11/aerospike/client/AerospikeClient.java: -------------------------------------------------------------------------------- 1 | package io.d11.aerospike.client; 2 | 3 | import com.aerospike.client.AerospikeException; 4 | import com.aerospike.client.BatchRead; 5 | import com.aerospike.client.Bin; 6 | import com.aerospike.client.Key; 7 | import com.aerospike.client.Operation; 8 | import com.aerospike.client.Record; 9 | import com.aerospike.client.Value; 10 | import com.aerospike.client.async.EventLoop; 11 | import com.aerospike.client.cluster.ClusterStats; 12 | import com.aerospike.client.listener.BatchListListener; 13 | import com.aerospike.client.listener.DeleteListener; 14 | import com.aerospike.client.listener.ExecuteListener; 15 | import com.aerospike.client.listener.ExistsArrayListener; 16 | import com.aerospike.client.listener.ExistsListener; 17 | import com.aerospike.client.listener.RecordArrayListener; 18 | import com.aerospike.client.listener.RecordListener; 19 | import com.aerospike.client.listener.RecordSequenceListener; 20 | import com.aerospike.client.listener.WriteListener; 21 | import com.aerospike.client.policy.BatchPolicy; 22 | import com.aerospike.client.policy.Policy; 23 | import com.aerospike.client.policy.QueryPolicy; 24 | import com.aerospike.client.policy.ScanPolicy; 25 | import com.aerospike.client.policy.WritePolicy; 26 | import com.aerospike.client.query.KeyRecord; 27 | import com.aerospike.client.query.PartitionFilter; 28 | import com.aerospike.client.query.Statement; 29 | import io.d11.aerospike.client.impl.AerospikeClientImpl; 30 | import io.d11.aerospike.util.SharedDataUtils; 31 | import io.vertx.codegen.annotations.Fluent; 32 | import io.vertx.codegen.annotations.GenIgnore; 33 | import io.vertx.codegen.annotations.VertxGen; 34 | import io.vertx.core.AsyncResult; 35 | import io.vertx.core.Handler; 36 | import io.vertx.core.Vertx; 37 | import java.util.List; 38 | 39 | 40 | /** 41 | * The {@code AerospikeClient} interface provides an abstraction on top of {@link com.aerospike.client.AerospikeClient aerospike's client} 42 | * for integrating its asynchronous commands in Vert.x-based Applications. 43 | */ 44 | @VertxGen 45 | public interface AerospikeClient extends AutoCloseable { 46 | 47 | /** 48 | * Create a shared aerospike client using the given connect options. 49 | * The client will be shared across a vertx instance 50 | * @param vertx the vertx instance 51 | * @param connectOptions user provided connection options 52 | * @return the client 53 | */ 54 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 55 | static AerospikeClient create(Vertx vertx, AerospikeConnectOptions connectOptions) { 56 | return SharedDataUtils.getOrCreate(vertx, SharedDataUtils.getInstanceName(connectOptions.getHost(), connectOptions.getPort()), 57 | () -> new AerospikeClientImpl(vertx, connectOptions.updateClientPolicy())); 58 | } 59 | 60 | /** 61 | * Like {@link AerospikeClient#create(Vertx, AerospikeConnectOptions)} with default options. 62 | * @param vertx the vertx instance 63 | * @return the client 64 | */ 65 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 66 | static AerospikeClient create(Vertx vertx) { 67 | return create(vertx, new AerospikeConnectOptions()); 68 | } 69 | 70 | /** 71 | * Create a non shared aerospike client using the given connect options. 72 | * It is not recommended to create several non shared clients in an application. 73 | * @param vertx the vertx instance 74 | * @param connectOptions user provided connection options 75 | * @return the client 76 | */ 77 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 78 | static AerospikeClient createNonShared(Vertx vertx, AerospikeConnectOptions connectOptions) { 79 | return new AerospikeClientImpl(vertx, connectOptions.updateClientPolicy()); 80 | } 81 | 82 | /** 83 | * Like {@link AerospikeClient#createNonShared(Vertx, AerospikeConnectOptions)} with default options. 84 | * @param vertx the vertx instance 85 | * @return the client 86 | */ 87 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 88 | static AerospikeClient createNonShared(Vertx vertx) { 89 | return createNonShared(vertx, new AerospikeConnectOptions()); 90 | } 91 | 92 | /** 93 | * Determine if we are ready to talk to the database server cluster. 94 | * @see com.aerospike.client.AerospikeClient#isConnected() 95 | * 96 | * @param handler the handler that will handle response 97 | * @return current Aerospike client instance 98 | */ 99 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 100 | @Fluent 101 | AerospikeClient isConnected(Handler> handler); 102 | 103 | /** 104 | * Return operating cluster statistics. 105 | * @see com.aerospike.client.AerospikeClient#getClusterStats() 106 | * 107 | * @param handler the handler that will handle the received cluster statistics 108 | * @return current Aerospike client instance 109 | */ 110 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 111 | @Fluent 112 | AerospikeClient getClusterStats(Handler> handler); 113 | 114 | 115 | /** 116 | * Close all client connections to database server nodes. 117 | * @see com.aerospike.client.AerospikeClient#close() 118 | */ 119 | void close(); 120 | 121 | 122 | /** 123 | * Get the underlying {@link com.aerospike.client.AerospikeClient} 124 | * @return the {@code com.aerospike.client.AerospikeClient} instance which is used internally. 125 | */ 126 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 127 | com.aerospike.client.AerospikeClient getAerospikeClient(); 128 | 129 | /** 130 | * Asynchronously write record bin(s). 131 | * @see com.aerospike.client.AerospikeClient#put(EventLoop, WriteListener, WritePolicy, Key, Bin...) 132 | * 133 | * @param writePolicy write configuration parameters, pass in null for defaults 134 | * @param key unique record identifier 135 | * @param bins array of bin name/value pairs 136 | * @param handler the handler that will handle the result 137 | * @return current Aerospike client instance 138 | * @throws AerospikeException if event loop registration fails 139 | */ 140 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 141 | @Fluent 142 | AerospikeClient put(WritePolicy writePolicy, Key key, Bin[] bins, Handler> handler) 143 | throws AerospikeException; 144 | 145 | /** 146 | * Asynchronously append bin string values to existing record bin values. 147 | * @see com.aerospike.client.AerospikeClient#append(EventLoop, WriteListener, WritePolicy, Key, Bin...) 148 | * 149 | * @param writePolicy write configuration parameters, pass in null for defaults 150 | * @param key unique record identifier 151 | * @param bins array of bin name/value pairs 152 | * @param handler the handler that will handle the result 153 | * @return current Aerospike client instance 154 | * @throws AerospikeException if event loop registration fails 155 | */ 156 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 157 | @Fluent 158 | AerospikeClient append(WritePolicy writePolicy, Key key, Bin[] bins, Handler> handler) 159 | throws AerospikeException; 160 | 161 | /** 162 | * Asynchronously prepend bin string values to existing record bin values. 163 | * @see com.aerospike.client.AerospikeClient#prepend(WritePolicy, Key, Bin...) 164 | * 165 | * @param writePolicy write configuration parameters, pass in null for defaults 166 | * @param key unique record identifier 167 | * @param bins array of bin name/value pairs 168 | * @param handler the handler that will handle the result 169 | * @return current Aerospike client instance 170 | * @throws AerospikeException if event loop registration fails 171 | */ 172 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 173 | @Fluent 174 | AerospikeClient prepend(WritePolicy writePolicy, Key key, Bin[] bins, Handler> handler) 175 | throws AerospikeException; 176 | 177 | /** 178 | * Asynchronously add integer/double bin values to existing record bin values. 179 | * @see com.aerospike.client.AerospikeClient#add(EventLoop, WriteListener, WritePolicy, Key, Bin...) 180 | * 181 | * @param writePolicy write configuration parameters, pass in null for defaults 182 | * @param key unique record identifier 183 | * @param bins array of bin name/value pairs 184 | * @param handler the handler that will handle the result 185 | * @return current Aerospike client instance 186 | * @throws AerospikeException if event loop registration fails 187 | */ 188 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 189 | @Fluent 190 | AerospikeClient add(WritePolicy writePolicy, Key key, Bin[] bins, Handler> handler) 191 | throws AerospikeException; 192 | 193 | /** 194 | * Asynchronously delete record for specified key. 195 | * @see com.aerospike.client.AerospikeClient#delete(EventLoop, DeleteListener, WritePolicy, Key) 196 | * 197 | * @param writePolicy write configuration parameters, pass in null for defaults 198 | * @param key unique record identifier 199 | * @param handler the handler that will handle the result 200 | * @return current Aerospike client instance 201 | * @throws AerospikeException if event loop registration fails 202 | */ 203 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 204 | @Fluent 205 | AerospikeClient delete(WritePolicy writePolicy, Key key, Handler> handler) 206 | throws AerospikeException; 207 | 208 | /** 209 | * Asynchronously reset record's time to expiration using the policy's expiration. 210 | * @see com.aerospike.client.AerospikeClient#touch(EventLoop, WriteListener, WritePolicy, Key) 211 | * 212 | * @param writePolicy write configuration parameters, pass in null for defaults 213 | * @param key unique record identifier 214 | * @param handler the handler that will handle the result 215 | * @return current Aerospike client instance 216 | * @throws AerospikeException if event loop registration fails 217 | */ 218 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 219 | @Fluent 220 | AerospikeClient touch(WritePolicy writePolicy, Key key, Handler> handler) 221 | throws AerospikeException; 222 | 223 | 224 | /** 225 | * Asynchronously determine if a record key exists. 226 | * @see com.aerospike.client.AerospikeClient#exists(EventLoop, ExistsListener, Policy, Key) 227 | * 228 | * @param policy generic configuration parameters, pass in null for defaults 229 | * @param key unique record identifier 230 | * @param handler the handler that will handle the result 231 | * @return current Aerospike client instance 232 | * @throws AerospikeException if event loop registration fails 233 | */ 234 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 235 | @Fluent 236 | AerospikeClient exists(Policy policy, Key key, Handler> handler) 237 | throws AerospikeException; 238 | 239 | /** 240 | * Asynchronously check if multiple record keys exist in one batch call. 241 | * @see com.aerospike.client.AerospikeClient#exists(EventLoop, ExistsArrayListener, BatchPolicy, Key[]) 242 | * 243 | * @param batchPolicy batch configuration parameters, pass in null for defaults 244 | * @param keys unique record identifiers 245 | * @param handler the handler that will handle the result 246 | * @return current Aerospike client instance 247 | * @throws AerospikeException if event loop registration fails 248 | */ 249 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 250 | @Fluent 251 | AerospikeClient exists(BatchPolicy batchPolicy, Key[] keys, Handler>> handler) 252 | throws AerospikeException; 253 | 254 | /** 255 | * Asynchronously read entire record for specified key. 256 | * @see com.aerospike.client.AerospikeClient#get(EventLoop, RecordListener, Policy, Key) 257 | * 258 | * @param policy generic configuration parameters, pass in null for defaults 259 | * @param key unique record identifier 260 | * @param handler the handler that will handle the result 261 | * @return current Aerospike client instance 262 | * @throws AerospikeException if event loop registration fails 263 | */ 264 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 265 | @Fluent 266 | AerospikeClient get(Policy policy, Key key, Handler> handler) throws AerospikeException; 267 | 268 | /** 269 | * Asynchronously read record header and bins for specified key. 270 | * @see com.aerospike.client.AerospikeClient#get(EventLoop, RecordListener, Policy, Key, String...) 271 | * 272 | * @param policy generic configuration parameters, pass in null for defaults 273 | * @param key unique record identifier 274 | * @param binNames bins to retrieve 275 | * @param handler the handler that will handle the result 276 | * @return current Aerospike client instance 277 | * @throws AerospikeException if event loop registration fails 278 | */ 279 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 280 | @Fluent 281 | AerospikeClient get(Policy policy, Key key, String[] binNames, Handler> handler) 282 | throws AerospikeException; 283 | 284 | /** 285 | * Asynchronously read record generation and expiration only for specified key. Bins are not read. 286 | * @see com.aerospike.client.AerospikeClient#getHeader(EventLoop, RecordListener, Policy, Key) 287 | * 288 | * @param policy generic configuration parameters, pass in null for defaults 289 | * @param key unique record identifier 290 | * @param handler the handler that will handle the result 291 | * @return current Aerospike client instance 292 | * @throws AerospikeException if event loop registration fails 293 | */ 294 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 295 | @Fluent 296 | AerospikeClient getHeader(Policy policy, Key key, Handler> handler) 297 | throws AerospikeException; 298 | 299 | /** 300 | * Asynchronously read multiple records for specified batch keys in one batch call. 301 | * @see com.aerospike.client.AerospikeClient#get(EventLoop, BatchListListener, BatchPolicy, List) 302 | * 303 | * @param batchPolicy batch configuration parameters, pass in null for defaults 304 | * @param records list of unique record identifiers and the bins to retrieve. 305 | * The returned records are located in the same list. 306 | * @param handler the handler that will handle the result 307 | * @return current Aerospike client instance 308 | * @throws AerospikeException if event loop registration fails 309 | */ 310 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 311 | @Fluent 312 | AerospikeClient get( 313 | BatchPolicy batchPolicy, List records, Handler>> handler) 314 | throws AerospikeException; 315 | 316 | /** 317 | * Asynchronously read multiple records for specified keys in one batch call. 318 | * @see com.aerospike.client.AerospikeClient#get(EventLoop, RecordArrayListener, BatchPolicy, Key[]) 319 | * 320 | * @param batchPolicy batch configuration parameters, pass in null for defaults 321 | * @param keys array of unique record identifiers 322 | * @param handler the handler that will handle the result 323 | * @return current Aerospike client instance 324 | * @throws AerospikeException if event loop registration fails 325 | */ 326 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 327 | @Fluent 328 | AerospikeClient get(BatchPolicy batchPolicy, Key[] keys, Handler>> handler) 329 | throws AerospikeException; 330 | 331 | /** 332 | * Asynchronously read multiple record headers and bins for specified keys in one batch call. 333 | * @see com.aerospike.client.AerospikeClient#get(EventLoop, RecordArrayListener, BatchPolicy, Key[], String...) 334 | * @param batchPolicy batch configuration parameters, pass in null for defaults 335 | * @param keys array of unique record identifiers 336 | * @param binNames array of bins to retrieve 337 | * @param handler the handler that will handle the result 338 | * @return current Aerospike client instance 339 | * @throws AerospikeException if event loop registration fails 340 | */ 341 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 342 | @Fluent 343 | AerospikeClient get( 344 | BatchPolicy batchPolicy, 345 | Key[] keys, 346 | String[] binNames, 347 | Handler>> handler) 348 | throws AerospikeException; 349 | 350 | /** 351 | * Asynchronously read multiple record header data for specified keys in one batch call. 352 | * @see com.aerospike.client.AerospikeClient#getHeader(EventLoop, RecordArrayListener, BatchPolicy, Key[]) 353 | * 354 | * @param batchPolicy batch configuration parameters, pass in null for defaults 355 | * @param keys array of unique record identifiers 356 | * @param handler the handler that will handle the result 357 | * @return current Aerospike client instance 358 | * @throws AerospikeException if event loop registration fails 359 | */ 360 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 361 | @Fluent 362 | AerospikeClient getHeader(BatchPolicy batchPolicy, Key[] keys, Handler>> handler) 363 | throws AerospikeException; 364 | 365 | /** 366 | * Asynchronously perform multiple read/write operations on a single key in one batch call. 367 | * @see com.aerospike.client.AerospikeClient#operate(EventLoop, RecordListener, WritePolicy, Key, Operation...) 368 | * 369 | * @param writePolicy write configuration parameters, pass in null for defaults 370 | * @param key unique record identifier 371 | * @param operations database operations to perform 372 | * @param handler the handler that will handle the result 373 | * @return current Aerospike client instance 374 | * @throws AerospikeException if event loop registration fails 375 | */ 376 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 377 | @Fluent 378 | AerospikeClient operate( 379 | WritePolicy writePolicy, 380 | Key key, 381 | Operation[] operations, 382 | Handler> handler) 383 | throws AerospikeException; 384 | 385 | /** 386 | * Asynchronously read all records in specified namespace and set 387 | * @see com.aerospike.client.AerospikeClient#scanAll(EventLoop, RecordSequenceListener, ScanPolicy, String, String, String...) 388 | * 389 | * @param policy scan configuration parameters, pass in null for defaults 390 | * @param namespace namespace - equivalent to database name 391 | * @param setName optional set name - equivalent to database table 392 | * @param binNames optional bins to retrieve. All bins will be returned if empty. 393 | * @param handler the handler that will handle the result 394 | * @return current Aerospike client instance 395 | * @throws AerospikeException if event loop registration fails 396 | */ 397 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 398 | @Fluent 399 | AerospikeClient scanAll(ScanPolicy policy, String namespace, String setName, 400 | String[] binNames, Handler>> handler) 401 | throws AerospikeException; 402 | 403 | /** 404 | * Asynchronously read records in specified namespace, set and partition filter. 405 | * @see com.aerospike.client.AerospikeClient#scanPartitions(EventLoop, RecordSequenceListener, ScanPolicy, PartitionFilter, String, String, String...) 406 | * 407 | * @param policy scan configuration parameters, pass in null for defaults 408 | * @param partitionFilter filter on a subset of data partitions 409 | * @param namespace namespace - equivalent to database name 410 | * @param setName optional set name - equivalent to database table 411 | * @param binNames optional bins to retrieve. All bins will be returned if empty. 412 | * @param handler the handler that will handle the result 413 | * @return current Aerospike client instance 414 | * @throws AerospikeException if event loop registration fails 415 | */ 416 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 417 | @Fluent 418 | AerospikeClient scanPartitions(ScanPolicy policy, PartitionFilter partitionFilter, String namespace, 419 | String setName, String[] binNames, Handler>> handler) 420 | throws AerospikeException; 421 | 422 | /** 423 | * Asynchronously execute user defined function on server. 424 | * @see com.aerospike.client.AerospikeClient#execute(EventLoop, ExecuteListener, WritePolicy, Key, String, String, Value...) 425 | * 426 | * @param writePolicy write configuration parameters, pass in null for defaults 427 | * @param key unique record identifier 428 | * @param packageName server package name where user defined function resides 429 | * @param functionName user defined function 430 | * @param functionArgs arguments passed in to user defined function 431 | * @param handler the handler that will handle the result 432 | * @return current Aerospike client instance 433 | * @throws AerospikeException if event loop registration fails 434 | */ 435 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 436 | @Fluent 437 | AerospikeClient execute( 438 | WritePolicy writePolicy, 439 | Key key, 440 | String packageName, 441 | String functionName, 442 | Value[] functionArgs, 443 | Handler> handler) 444 | throws AerospikeException; 445 | 446 | /** 447 | * Asynchronously execute query on all server nodes. 448 | * @see com.aerospike.client.AerospikeClient#query(EventLoop, RecordSequenceListener, QueryPolicy, Statement) 449 | * 450 | * @param queryPolicy query configuration parameters, pass in null for defaults 451 | * @param statement query filter. Statement instance is not suitable for reuse since it's modified in this method. 452 | * @param handler the handler that will handle the result 453 | * @return current Aerospike client instance 454 | * @throws AerospikeException if event loop registration fails 455 | */ 456 | @GenIgnore(GenIgnore.PERMITTED_TYPE) 457 | @Fluent 458 | AerospikeClient query( 459 | QueryPolicy queryPolicy, Statement statement, Handler>> handler) 460 | throws AerospikeException; 461 | } 462 | --------------------------------------------------------------------------------