Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------------
Expand Down
30 changes: 11 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<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
* @param request query request
* @return query response
*/
public List<Property> findProperties(String group, String name, List<String> ids, List<String> 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);
}

/**
Expand All @@ -882,23 +845,12 @@ public List<Property> findProperties(String group, String name, List<String> 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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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));
}
}

This file was deleted.

5 changes: 3 additions & 2 deletions src/main/proto/banyandb/v1/banyandb-common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading