diff --git a/CHANGES.md b/CHANGES.md index fc5f912e..eb27d36a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ Release Notes. ### Features * Bump up the API to support the index mode of Measure. +* Bump up the API to support the new property. 0.7.0 ------------------ diff --git a/README.md b/README.md index 0e3aa851..402e1878 100644 --- a/README.md +++ b/README.md @@ -496,35 +496,27 @@ Property property = Property.create("default", "sw", "ui_template") this.client.apply(property); //created:false tagsNum:1 ``` -The property supports setting TTL. - -```java -Property property = Property.create("default", "sw", "temp_date") - .addTag(TagAndValue.newStringTag("state", "failed")) - .ttl("30m") - .build(); -this.client.apply(property); //created:false tagsNum:1 lease_id:1 -``` -The property's TTL can be extended by calling `Client.keepAliveProperty`, - -```java -this.client.keepAliveProperty(1); //lease_id:1 -``` - -The property's live time is reset to 30 minutes. - ### Query Property can be queried via `Client.findProperty`, ```java -Property gotProperty = this.client.findProperty("default", "sw", "ui_template"); + BanyandbProperty.QueryResponse resp = client.query(BanyandbProperty.QueryRequest.newBuilder() + .addGroups("default") + .setContainer("sw") + .addIds("ui_template") + .build()); ``` The query operation could filter tags, ```java -Property gotProperty = this.client.findProperty("default", "sw", "ui_template", "state"); +BanyandbProperty.QueryResponse resp = client.query(BanyandbProperty.QueryRequest.newBuilder() + .addGroups("default") + .setContainer("sw") + .addIds("ui_template") + .addTagProjection("state") + .build()); ``` ### Delete 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 38fd65ba..bf52a736 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 @@ -60,7 +60,6 @@ import org.apache.skywalking.banyandb.v1.client.metadata.IndexRuleMetadataRegistry; import org.apache.skywalking.banyandb.v1.client.metadata.MeasureMetadataRegistry; import org.apache.skywalking.banyandb.v1.client.metadata.MetadataCache; -import org.apache.skywalking.banyandb.v1.client.metadata.PropertyStore; import org.apache.skywalking.banyandb.v1.client.metadata.ResourceExist; import org.apache.skywalking.banyandb.v1.client.metadata.StreamMetadataRegistry; import org.apache.skywalking.banyandb.v1.client.metadata.TopNAggregationMetadataRegistry; @@ -830,50 +829,14 @@ public ApplyResponse apply(Property property, Strategy strategy) throws } /** - * Find property + * Query properties * - * @param group group of the metadata - * @param name name of the metadata - * @param id identity of the property - * @param tags tags to be returned - * @return property if it can be found - */ - public Property findProperty(String group, String name, String id, String... tags) throws BanyanDBException { - PropertyStore store = new PropertyStore(checkNotNull(this.channel)); - try { - return store.get(group, name, id, tags); - } catch (BanyanDBException ex) { - if (ex.getStatus().equals(Status.Code.NOT_FOUND)) { - return null; - } - throw ex; - } - } - - /** - * List Properties - * - * @param group group of the metadata - * @param name name of the metadata - * @return all properties belonging to the group and the name - */ - public List 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 + * @param request query request + * @return query response */ - public List findProperties(String group, String name, List ids, List tags) throws BanyanDBException { + public BanyandbProperty.QueryResponse query(BanyandbProperty.QueryRequest request) throws BanyanDBException { PropertyStore store = new PropertyStore(checkNotNull(this.channel)); - return store.list(group, name, ids, tags); + return store.query(request); } /** @@ -882,23 +845,12 @@ public List findProperties(String group, String name, List ids * @param group group of the metadata * @param name name of the metadata * @param id identity of the property - * @param tags tags to be deleted. If null, the property is deleted * @return if this property has been deleted */ - public DeleteResponse deleteProperty(String group, String name, String id, String... tags) throws + public DeleteResponse deleteProperty(String group, String name, String id) throws BanyanDBException { PropertyStore store = new PropertyStore(checkNotNull(this.channel)); - return store.delete(group, name, id, tags); - } - - /** - * Keep alive the property - * - * @param leaseId lease id of the property - */ - public void keepAliveProperty(long leaseId) throws BanyanDBException { - PropertyStore store = new PropertyStore(checkNotNull(this.channel)); - store.keepAlive(leaseId); + return store.delete(group, name, id); } /** diff --git a/src/main/java/org/apache/skywalking/banyandb/v1/client/PropertyStore.java b/src/main/java/org/apache/skywalking/banyandb/v1/client/PropertyStore.java new file mode 100644 index 00000000..8e2fbe38 --- /dev/null +++ b/src/main/java/org/apache/skywalking/banyandb/v1/client/PropertyStore.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.banyandb.v1.client; + +import io.grpc.Channel; +import org.apache.skywalking.banyandb.property.v1.BanyandbProperty; +import org.apache.skywalking.banyandb.property.v1.BanyandbProperty.ApplyRequest; +import org.apache.skywalking.banyandb.property.v1.BanyandbProperty.ApplyRequest.Strategy; +import org.apache.skywalking.banyandb.property.v1.BanyandbProperty.ApplyResponse; +import org.apache.skywalking.banyandb.property.v1.BanyandbProperty.DeleteResponse; +import org.apache.skywalking.banyandb.property.v1.BanyandbProperty.Property; +import org.apache.skywalking.banyandb.property.v1.PropertyServiceGrpc; +import org.apache.skywalking.banyandb.v1.client.grpc.HandleExceptionsWith; +import org.apache.skywalking.banyandb.v1.client.grpc.exception.BanyanDBException; + +public class PropertyStore { + private final PropertyServiceGrpc.PropertyServiceBlockingStub stub; + + public PropertyStore(Channel channel) { + this.stub = PropertyServiceGrpc.newBlockingStub(channel); + } + + public ApplyResponse apply(Property payload) throws BanyanDBException { + return apply(payload, Strategy.STRATEGY_MERGE); + } + + public ApplyResponse apply(Property payload, Strategy strategy) throws BanyanDBException { + BanyandbProperty.ApplyRequest.Strategy s = BanyandbProperty.ApplyRequest.Strategy.STRATEGY_MERGE; + ApplyRequest r = BanyandbProperty.ApplyRequest.newBuilder() + .setProperty(payload) + .setStrategy(strategy) + .build(); + return HandleExceptionsWith.callAndTranslateApiException(() -> + this.stub.apply(r)); + } + + public DeleteResponse delete(String group, String name, String id) throws BanyanDBException { + return HandleExceptionsWith.callAndTranslateApiException(() -> + this.stub.delete(BanyandbProperty.DeleteRequest.newBuilder() + .setGroup(group) + .setContainer(name) + .setId(id) + .build())); + } + + public BanyandbProperty.QueryResponse query(BanyandbProperty.QueryRequest req) throws BanyanDBException { + return HandleExceptionsWith.callAndTranslateApiException(() -> + this.stub.query(req)); + } +} 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 deleted file mode 100644 index a5ea6e64..00000000 --- a/src/main/java/org/apache/skywalking/banyandb/v1/client/metadata/PropertyStore.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.skywalking.banyandb.v1.client.metadata; - -import io.grpc.Channel; -import org.apache.skywalking.banyandb.common.v1.BanyandbCommon; -import org.apache.skywalking.banyandb.property.v1.BanyandbProperty; -import org.apache.skywalking.banyandb.property.v1.BanyandbProperty.Property; -import org.apache.skywalking.banyandb.property.v1.BanyandbProperty.ApplyRequest; -import org.apache.skywalking.banyandb.property.v1.BanyandbProperty.ApplyRequest.Strategy; -import org.apache.skywalking.banyandb.property.v1.BanyandbProperty.ApplyResponse; -import org.apache.skywalking.banyandb.property.v1.BanyandbProperty.DeleteRequest; -import org.apache.skywalking.banyandb.property.v1.BanyandbProperty.DeleteResponse; -import org.apache.skywalking.banyandb.property.v1.PropertyServiceGrpc; -import org.apache.skywalking.banyandb.v1.client.grpc.HandleExceptionsWith; -import org.apache.skywalking.banyandb.v1.client.grpc.exception.BanyanDBException; - -import java.util.Arrays; -import java.util.List; - -public class PropertyStore { - private final PropertyServiceGrpc.PropertyServiceBlockingStub stub; - - public PropertyStore(Channel channel) { - this.stub = PropertyServiceGrpc.newBlockingStub(channel); - } - - public ApplyResponse apply(Property payload) throws BanyanDBException { - return apply(payload, Strategy.STRATEGY_MERGE); - } - - public ApplyResponse apply(Property payload, Strategy strategy) throws BanyanDBException { - BanyandbProperty.ApplyRequest.Strategy s = BanyandbProperty.ApplyRequest.Strategy.STRATEGY_MERGE; - ApplyRequest r = BanyandbProperty.ApplyRequest.newBuilder() - .setProperty(payload) - .setStrategy(strategy) - .build(); - return HandleExceptionsWith.callAndTranslateApiException(() -> - this.stub.apply(r)); - } - - public DeleteResponse delete(String group, String name, String id, String... tags) throws BanyanDBException { - DeleteRequest.Builder b = DeleteRequest.newBuilder(); - if (tags != null && tags.length > 0) { - b.addAllTags(Arrays.asList(tags)); - } - return HandleExceptionsWith.callAndTranslateApiException(() -> - this.stub.delete(b.setMetadata(BanyandbProperty.Metadata - .newBuilder() - .setContainer(BanyandbCommon.Metadata.newBuilder() - .setGroup(group) - .setName(name) - .build()) - .setId(id) - .build()) - .build())); - } - - public Property get(String group, String name, String id, String... tags) throws BanyanDBException { - BanyandbProperty.GetRequest.Builder b = BanyandbProperty.GetRequest.newBuilder(); - if (tags != null && tags.length > 0) { - b.addAllTags(Arrays.asList(tags)); - } - BanyandbProperty.GetResponse resp = HandleExceptionsWith.callAndTranslateApiException(() -> - this.stub.get(b.setMetadata(BanyandbProperty.Metadata - .newBuilder() - .setContainer(BanyandbCommon.Metadata.newBuilder() - .setGroup(group) - .setName(name) - .build()) - .setId(id) - .build()) - .build())); - - return resp.getProperty(); - } - - public List list(String group, String name, List ids, List 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(builder.build())); - - return resp.getPropertyList(); - } - - public void keepAlive(long leaseId) throws BanyanDBException { - BanyandbProperty.KeepAliveRequest req = BanyandbProperty.KeepAliveRequest.newBuilder() - .setLeaseId(leaseId) - .build(); - HandleExceptionsWith.callAndTranslateApiException(() -> - this.stub.keepAlive(req)); - } - -// public enum Strategy { -// MERGE, REPLACE -// } -// -// @AutoValue -// public abstract static class ApplyResult { -// public abstract boolean created(); -// -// public abstract int tagsNum(); -// -// public abstract long leaseId(); -// } -// -// @AutoValue -// public abstract static class DeleteResult { -// public abstract boolean deleted(); -// -// public abstract int tagsNum(); -// } -} diff --git a/src/main/proto/banyandb/v1/banyandb-common.proto b/src/main/proto/banyandb/v1/banyandb-common.proto index 3e0ac35e..67e64ba8 100644 --- a/src/main/proto/banyandb/v1/banyandb-common.proto +++ b/src/main/proto/banyandb/v1/banyandb-common.proto @@ -28,6 +28,7 @@ enum Catalog { CATALOG_UNSPECIFIED = 0; CATALOG_STREAM = 1; CATALOG_MEASURE = 2; + CATALOG_PROPERTY = 3; } // Metadata is for multi-tenant, multi-model use @@ -61,9 +62,9 @@ message ResourceOpts { // shard_num is the number of shards uint32 shard_num = 1 [(validate.rules).uint32.gt = 0]; // segment_interval indicates the length of a segment - IntervalRule segment_interval = 2 [(validate.rules).message.required = true]; + IntervalRule segment_interval = 2; // ttl indicates time to live, how long the data will be cached - IntervalRule ttl = 3 [(validate.rules).message.required = true]; + IntervalRule ttl = 3; } // Group is an internal object for Group management diff --git a/src/main/proto/banyandb/v1/banyandb-property.proto b/src/main/proto/banyandb/v1/banyandb-property.proto index 73299a04..357a82cb 100644 --- a/src/main/proto/banyandb/v1/banyandb-property.proto +++ b/src/main/proto/banyandb/v1/banyandb-property.proto @@ -29,35 +29,27 @@ import "banyandb/v1/banyandb-model.proto"; // Metadata is for multi-tenant use message Metadata { // container is created when it receives the first property - common.v1.Metadata container = 1; + common.v1.Metadata container = 1 [(validate.rules).message.required = true]; // id identifies a property - string id = 2; + string id = 2 [(validate.rules).string.min_len = 1]; } - // Property stores the user defined data message Property { // metadata is the identity of a property - Metadata metadata = 1; + Metadata metadata = 1 [(validate.rules).message.required = true]; // tag stores the content of a property - repeated model.v1.Tag tags = 2; + repeated model.v1.Tag tags = 2 [(validate.rules).repeated.min_items = 1]; // updated_at indicates when the property is updated google.protobuf.Timestamp updated_at = 3; - // readonly. lease_id is the ID of the lease that attached to key. - int64 lease_id = 4; - // ttl indicates the time to live of the property. - // It's a string in the format of "1h", "2m", "3s", "1500ms". - // It defaults to 0s, which means the property never expires. - // The minimum allowed ttl is 1s. - string ttl = 5; } message ApplyRequest { banyandb.property.v1.Property property = 1 [(validate.rules).message.required = true]; enum Strategy { - STRATEGY_UNSPECIFIED=0; - STRATEGY_MERGE=1; - STRATEGY_REPLACE=2; + STRATEGY_UNSPECIFIED = 0; + STRATEGY_MERGE = 1; + STRATEGY_REPLACE = 2; } // strategy indicates how to update a property. It defaults to STRATEGY_MERGE Strategy strategy = 2; @@ -68,49 +60,51 @@ message ApplyResponse { // True: the property is absent. False: the property existed. bool created = 1; uint32 tags_num = 2; - int64 lease_id = 3; } message DeleteRequest { - banyandb.property.v1.Metadata metadata = 1 [(validate.rules).message.required = true]; - repeated string tags = 2; + // groups indicate where the data points are stored. + string group = 1 [(validate.rules).string.min_len = 1]; + // container is created when it receives the first property + string container = 2 [(validate.rules).string.min_len = 1]; + // id is the identity of properties + string id = 3; } message DeleteResponse { bool deleted = 1; - uint32 tags_num = 2; -} - -message GetRequest { - banyandb.property.v1.Metadata metadata = 1 [(validate.rules).message.required = true]; - repeated string tags = 2; -} - -message GetResponse { - banyandb.property.v1.Property property = 1; } -message ListRequest { - banyandb.common.v1.Metadata container = 1 [(validate.rules).message.required = true]; - repeated string ids = 2; - repeated string tags = 3; -} - -message ListResponse { - repeated banyandb.property.v1.Property property = 1; +// QueryRequest is the request contract for query. +message QueryRequest { + // groups indicate where the data points are stored. + repeated string groups = 1 [(validate.rules).repeated.min_items = 1]; + // container is created when it receives the first property + string container = 2; + // ids is the identities of properties + repeated string ids = 3; + // criteria is used to filter properties based on tags + model.v1.Criteria criteria = 4; + // tag_projection can be used to select tags of the data points in the response + repeated string tag_projection = 5; + uint32 limit = 6; + // trace is used to enable trace for the query + bool trace = 7; } -message KeepAliveRequest { - int64 lease_id = 1; +// QueryResponse is the response for a query to the Query module. +message QueryResponse { + // properties are the actual data returned + repeated banyandb.property.v1.Property properties = 1; + // trace contains the trace information of the query when trace is enabled + common.v1.Trace trace = 2; } -message KeepAliveResponse {} - service PropertyService { // Apply creates a property if it's absent, or update a existed one based on a strategy. rpc Apply(ApplyRequest) returns (ApplyResponse); + rpc Delete(DeleteRequest) returns (DeleteResponse); - rpc Get(GetRequest) returns (GetResponse); - rpc List(ListRequest) returns (ListResponse); - rpc KeepAlive(KeepAliveRequest) returns (KeepAliveResponse); + + rpc Query(QueryRequest) returns (QueryResponse); } diff --git a/src/test/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClientTestCI.java b/src/test/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClientTestCI.java index 6c2d23b3..5ccaacc4 100644 --- a/src/test/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClientTestCI.java +++ b/src/test/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClientTestCI.java @@ -31,7 +31,7 @@ public class BanyanDBClientTestCI { private static final String REGISTRY = "ghcr.io"; private static final String IMAGE_NAME = "apache/skywalking-banyandb"; - private static final String TAG = "079483262016e8b2ac58c3f115f974d8ad7e9d2e"; + private static final String TAG = "1d4ddc3d42103dc3364ad729403c4154690be195"; private static final String IMAGE = REGISTRY + "/" + IMAGE_NAME + ":" + TAG; 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 44e4d157..828284a9 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,8 +28,6 @@ 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 org.apache.skywalking.banyandb.common.v1.BanyandbCommon; import org.apache.skywalking.banyandb.common.v1.BanyandbCommon.Group; @@ -43,7 +41,12 @@ public class ITBanyanDBPropertyTests extends BanyanDBClientTestCI { public void setUp() throws IOException, BanyanDBException, InterruptedException { super.setUpConnection(); Group expectedGroup = - Group.newBuilder().setMetadata(Metadata.newBuilder().setName("default")).setCatalog(BanyandbCommon.Catalog.CATALOG_UNSPECIFIED).build(); + Group.newBuilder().setMetadata(Metadata.newBuilder() + .setName("default")) + .setCatalog(BanyandbCommon.Catalog.CATALOG_PROPERTY) + .setResourceOpts(BanyandbCommon.ResourceOpts.newBuilder() + .setShardNum(2)) + .build(); client.define(expectedGroup); Assert.assertNotNull(expectedGroup); } @@ -61,7 +64,13 @@ public void test_PropertyCreateAndGet() throws BanyanDBException { Assert.assertTrue(this.client.apply(property).getCreated()); await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> { - Property gotProperty = client.findProperty("default", "sw", "ui_template"); + BanyandbProperty.QueryResponse resp = client.query(BanyandbProperty.QueryRequest.newBuilder() + .addGroups("default") + .setContainer("sw") + .addIds("ui_template") + .build()); + Assert.assertEquals(1, resp.getPropertiesCount()); + Property gotProperty = resp.getProperties(0); Assert.assertNotNull(gotProperty); Assert.assertEquals(property.getTagsList(), gotProperty.getTagsList()); }); @@ -75,13 +84,24 @@ public void test_PropertyCreateDeleteAndGet() throws BanyanDBException { Assert.assertTrue(this.client.apply(property).getCreated()); await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> { - Property gotProperty = client.findProperty("default", "sw", "ui_template"); + BanyandbProperty.QueryResponse resp = client.query(BanyandbProperty.QueryRequest.newBuilder() + .addGroups("default") + .setContainer("sw") + .addIds("ui_template") + .build()); + Assert.assertEquals(1, resp.getPropertiesCount()); + Property gotProperty = resp.getProperties(0); Assert.assertNotNull(gotProperty); Assert.assertEquals(property.getTagsList(), gotProperty.getTagsList()); }); Assert.assertTrue(this.client.deleteProperty("default", "sw", "ui_template").getDeleted()); - Assert.assertNull(client.findProperty("default", "sw", "ui_template")); + BanyandbProperty.QueryResponse resp = client.query(BanyandbProperty.QueryRequest.newBuilder() + .addGroups("default") + .setContainer("sw") + .addIds("ui_template") + .build()); + Assert.assertEquals(0, resp.getPropertiesCount()); } @Test @@ -97,7 +117,13 @@ public void test_PropertyCreateUpdateAndGet() throws BanyanDBException { Assert.assertFalse(this.client.apply(property2).getCreated()); await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> { - Property gotProperty = client.findProperty("default", "sw", "ui_template"); + BanyandbProperty.QueryResponse resp = client.query(BanyandbProperty.QueryRequest.newBuilder() + .addGroups("default") + .setContainer("sw") + .addIds("ui_template") + .build()); + Assert.assertEquals(1, resp.getPropertiesCount()); + Property gotProperty = resp.getProperties(0); Assert.assertNotNull(gotProperty); Assert.assertEquals(property2.getTagsList(), gotProperty.getTagsList()); }); @@ -115,31 +141,31 @@ public void test_PropertyList() throws BanyanDBException { Assert.assertTrue(this.client.apply(property).getCreated()); await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> { - List gotProperties = client.findProperties("default", "sw"); - Assert.assertEquals(2, gotProperties.size()); + BanyandbProperty.QueryResponse resp = client.query(BanyandbProperty.QueryRequest.newBuilder() + .addGroups("default") + .setContainer("sw") + .build()); + Assert.assertEquals(2, resp.getPropertiesCount()); }); await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> { - List gotProperties = client.findProperties("default", "sw", Arrays.asList("id1", "id2"), null); - Assert.assertEquals(2, gotProperties.size()); + BanyandbProperty.QueryResponse resp = client.query(BanyandbProperty.QueryRequest.newBuilder() + .addGroups("default") + .setContainer("sw") + .addIds("id1") + .addIds("id2") + .build()); + Assert.assertEquals(2, resp.getPropertiesCount()); }); await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> { - List gotProperties = client.findProperties("default", "sw", Arrays.asList("id2"), null); - Assert.assertEquals(1, gotProperties.size()); + BanyandbProperty.QueryResponse resp = client.query(BanyandbProperty.QueryRequest.newBuilder() + .addGroups("default") + .setContainer("sw") + .addIds("id2") + .build()); + Assert.assertEquals(1, resp.getPropertiesCount()); }); } - @Test - public void test_PropertyKeepAlive() throws BanyanDBException { - Property property = buildProperty("default", "sw", "id1") - .toBuilder().addTags( - Tag.newBuilder().setKey("name").setValue( - TagValue.newBuilder().setStr(Str.newBuilder().setValue("bar")))).setTtl("30m").build(); - BanyandbProperty.ApplyResponse resp = this.client.apply(property); - Assert.assertTrue(resp.getCreated()); - Assert.assertTrue(resp.getLeaseId() > 0); - this.client.keepAliveProperty(resp.getLeaseId()); - } - private BanyandbProperty.Property buildProperty(String group, String name, String id) { BanyandbProperty.Property.Builder builder = BanyandbProperty.Property.newBuilder() .setMetadata( diff --git a/src/test/java/org/apache/skywalking/banyandb/v1/client/ITMeasureMetadataRegistryTest.java b/src/test/java/org/apache/skywalking/banyandb/v1/client/ITMeasureMetadataRegistryTest.java index 84e72f48..ebe75ed3 100644 --- a/src/test/java/org/apache/skywalking/banyandb/v1/client/ITMeasureMetadataRegistryTest.java +++ b/src/test/java/org/apache/skywalking/banyandb/v1/client/ITMeasureMetadataRegistryTest.java @@ -63,25 +63,6 @@ public void testMeasureRegistry_createAndGet() throws BanyanDBException { Assert.assertEquals(expectedMeasure, actualMeasure); } - @Test - public void testMeasureRegistry_createAndUpdate() throws BanyanDBException { - this.client.define(buildMeasure()); - Measure beforeMeasure = client.findMeasure("sw_metric", "service_cpm_minute"); - Assert.assertNotNull(beforeMeasure); - Assert.assertNotNull(beforeMeasure.getUpdatedAt()); - - Measure updatedMeasure = beforeMeasure.toBuilder() - .setInterval(Duration.ofMinutes(2).format()) - .build(); - this.client.update(updatedMeasure); - Measure afterMeasure = client.findMeasure("sw_metric", "service_cpm_minute"); - Assert.assertNotNull(afterMeasure); - Assert.assertNotNull(afterMeasure.getUpdatedAt()); - updatedMeasure = updatedMeasure.toBuilder().clearUpdatedAt().setMetadata(updatedMeasure.getMetadata().toBuilder().clearModRevision().clearCreateRevision()).build(); - afterMeasure = afterMeasure.toBuilder().clearUpdatedAt().setMetadata(afterMeasure.getMetadata().toBuilder().clearModRevision().clearCreateRevision()).build(); - Assert.assertEquals(updatedMeasure, afterMeasure); - } - @Test public void testMeasureRegistry_createAndList() throws BanyanDBException { Measure expectedMeasure = buildMeasure(); diff --git a/src/test/java/org/apache/skywalking/banyandb/v1/client/ITStreamMetadataRegistryTest.java b/src/test/java/org/apache/skywalking/banyandb/v1/client/ITStreamMetadataRegistryTest.java index 26153bc1..74a9fe00 100644 --- a/src/test/java/org/apache/skywalking/banyandb/v1/client/ITStreamMetadataRegistryTest.java +++ b/src/test/java/org/apache/skywalking/banyandb/v1/client/ITStreamMetadataRegistryTest.java @@ -66,8 +66,11 @@ public void testStreamRegistry_createAndUpdate() throws BanyanDBException { Stream beforeStream = client.findStream("sw_record", "trace"); Assert.assertNotNull(beforeStream); Assert.assertNotNull(beforeStream.getUpdatedAt()); - Stream updatedStream = beforeStream.toBuilder().setEntity(Entity.newBuilder().addAllTagNames( - Arrays.asList("service_id", "is_error"))).build(); + Stream updatedStream = beforeStream.toBuilder().addTagFamilies(TagFamilySpec.newBuilder() + .setName("ex") + .addTags(TagSpec.newBuilder() + .setName("ex") + .setType(TagType.TAG_TYPE_INT))).build(); this.client.update(updatedStream); Stream afterStream = client.findStream("sw_record", "trace"); Assert.assertNotNull(afterStream);