You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2023/03/24 02:13:29 UTC

[skywalking-banyandb-java-client] branch property created (now 80d5a3b)

This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a change to branch property
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb-java-client.git


      at 80d5a3b  Add multi-ID and multi-tag filters to property list operation

This branch includes the following new commits:

     new 80d5a3b  Add multi-ID and multi-tag filters to property list operation

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[skywalking-banyandb-java-client] 01/01: Add multi-ID and multi-tag filters to property list operation

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a commit to branch property
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb-java-client.git

commit 80d5a3bc0ff6c35c14a32c029416c0d45a58f8c4
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Fri Mar 24 10:13:13 2023 +0800

    Add multi-ID and multi-tag filters to property list operation
    
    This update introduces two filters in the property client that enable
    property selection based on multiple IDs and multiple tags. These
    filters are fully supported by the server.
---
 .../banyandb/v1/client/BanyanDBClient.java         | 16 ++++++++++++-
 .../banyandb/v1/client/metadata/PropertyStore.java | 20 ++++++++++------
 .../v1/client/ITBanyanDBPropertyTests.java         | 28 ++++++++++++++++++++++
 .../v1/client/metadata/PropertyStoreTest.java      |  2 +-
 4 files changed, 57 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClient.java b/src/main/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClient.java
index 5c5e902..c6abc80 100644
--- a/src/main/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClient.java
+++ b/src/main/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClient.java
@@ -361,8 +361,22 @@ public class BanyanDBClient implements Closeable {
      * @return all properties belonging to the group and the name
      */
     public List<Property> findProperties(String group, String name) throws BanyanDBException {
+        return findProperties(group, name, null, null);
+
+    }
+
+    /**
+     * List Properties
+     *
+     * @param group group of the metadata
+     * @param name  name of the metadata
+     * @param ids   identities of the properties
+     * @param tags  tags to be returned
+     * @return all properties belonging to the group and the name
+     */
+    public List<Property> findProperties(String group, String name, List<String> ids, List<String> tags) throws BanyanDBException {
         PropertyStore store = new PropertyStore(checkNotNull(this.channel));
-        return store.list(group, name);
+        return store.list(group, name, ids, tags);
     }
 
     /**
diff --git a/src/main/java/org/apache/skywalking/banyandb/v1/client/metadata/PropertyStore.java b/src/main/java/org/apache/skywalking/banyandb/v1/client/metadata/PropertyStore.java
index 8758746..c75ebf8 100644
--- a/src/main/java/org/apache/skywalking/banyandb/v1/client/metadata/PropertyStore.java
+++ b/src/main/java/org/apache/skywalking/banyandb/v1/client/metadata/PropertyStore.java
@@ -97,14 +97,20 @@ public class PropertyStore {
         return Property.fromProtobuf(resp.getProperty());
     }
 
-    public List<Property> list(String group, String name) throws BanyanDBException {
+    public List<Property> list(String group, String name, List<String> ids, List<String> tags) throws BanyanDBException {
+        BanyandbProperty.ListRequest.Builder builder = BanyandbProperty.ListRequest.newBuilder()
+                .setContainer(BanyandbCommon.Metadata.newBuilder()
+                .setGroup(group)
+                .setName(name)
+                .build());
+        if (ids != null && ids.size() > 0) {
+            builder.addAllIds(ids);
+        }
+        if (tags != null && tags.size() > 0) {
+            builder.addAllTags(tags);
+        }
         BanyandbProperty.ListResponse resp = HandleExceptionsWith.callAndTranslateApiException(() ->
-                this.stub.list(BanyandbProperty.ListRequest.newBuilder()
-                        .setContainer(BanyandbCommon.Metadata.newBuilder()
-                                .setGroup(group)
-                                .setName(name)
-                                .build())
-                        .build()));
+                this.stub.list(builder.build()));
 
         return resp.getPropertyList().stream().map(Property::fromProtobuf).collect(Collectors.toList());
     }
diff --git a/src/test/java/org/apache/skywalking/banyandb/v1/client/ITBanyanDBPropertyTests.java b/src/test/java/org/apache/skywalking/banyandb/v1/client/ITBanyanDBPropertyTests.java
index b2eaf03..f3524d4 100644
--- a/src/test/java/org/apache/skywalking/banyandb/v1/client/ITBanyanDBPropertyTests.java
+++ b/src/test/java/org/apache/skywalking/banyandb/v1/client/ITBanyanDBPropertyTests.java
@@ -28,6 +28,8 @@ import org.junit.Before;
 import org.junit.Test;
 
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 import static org.awaitility.Awaitility.await;
@@ -100,4 +102,30 @@ public class ITBanyanDBPropertyTests extends BanyanDBClientTestCI {
             Assert.assertEquals(property2, gotProperty);
         });
     }
+
+    @Test
+    public void test_PropertyList() throws BanyanDBException {
+        Property property = Property.create("default", "sw", "id1")
+                .addTag(TagAndValue.newStringTag("name", "bar"))
+                .build();
+        Assert.assertTrue(this.client.apply(property).created());
+        property = Property.create("default", "sw", "id2")
+                .addTag(TagAndValue.newStringTag("name", "foo"))
+                .build();
+        Assert.assertTrue(this.client.apply(property).created());
+
+        await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> {
+            List<Property> gotProperties = client.findProperties("default", "sw");
+            Assert.assertEquals(2, gotProperties.size());
+        });
+        await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> {
+            List<Property> gotProperties = client.findProperties("default", "sw", Arrays.asList("id1", "id2"), null);
+            Assert.assertEquals(2, gotProperties.size());
+        });
+        await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> {
+            List<Property> gotProperties = client.findProperties("default", "sw", Arrays.asList("id2"), null);
+            Assert.assertEquals(1, gotProperties.size());
+        });
+    }
+
 }
diff --git a/src/test/java/org/apache/skywalking/banyandb/v1/client/metadata/PropertyStoreTest.java b/src/test/java/org/apache/skywalking/banyandb/v1/client/metadata/PropertyStoreTest.java
index 8cceff0..ad31872 100644
--- a/src/test/java/org/apache/skywalking/banyandb/v1/client/metadata/PropertyStoreTest.java
+++ b/src/test/java/org/apache/skywalking/banyandb/v1/client/metadata/PropertyStoreTest.java
@@ -121,7 +121,7 @@ public class PropertyStoreTest extends AbstractBanyanDBClientTest {
                 .addTag(TagAndValue.newStringTag("name", "hello"))
                 .build();
         Assert.assertTrue(this.store.apply(property, PropertyStore.Strategy.REPLACE).created());
-        List<Property> listProperties = this.store.list("default", "sw");
+        List<Property> listProperties = this.store.list("default", "sw", null, null);
         Assert.assertNotNull(listProperties);
         Assert.assertEquals(1, listProperties.size());
         Assert.assertEquals(listProperties.get(0), property);