Skip to content

Commit 6da79d9

Browse files
committed
adopt the status field which is changed to the string type
Signed-off-by: Gao Hongtao <[email protected]>
1 parent f7cb84b commit 6da79d9

File tree

9 files changed

+72
-11
lines changed

9 files changed

+72
-11
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Release Notes.
88

99
* Bump up the API to support the index mode of Measure.
1010
* Bump up the API to support the new property.
11+
* Bump up the API to adopt the status field which is changed to the string type due to the compatibility issue.
1112

1213
0.7.0
1314
------------------

src/main/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClient.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.apache.skywalking.banyandb.database.v1.BanyandbDatabase.IndexRule;
4141
import org.apache.skywalking.banyandb.database.v1.BanyandbDatabase.IndexRuleBinding;
4242
import org.apache.skywalking.banyandb.database.v1.BanyandbDatabase.Subject;
43+
import org.apache.skywalking.banyandb.model.v1.BanyandbModel;
4344
import org.apache.skywalking.banyandb.property.v1.BanyandbProperty;
4445
import org.apache.skywalking.banyandb.property.v1.BanyandbProperty.Property;
4546
import org.apache.skywalking.banyandb.property.v1.BanyandbProperty.ApplyRequest.Strategy;
@@ -75,6 +76,8 @@
7576
import java.util.concurrent.TimeUnit;
7677
import java.util.concurrent.locks.ReentrantLock;
7778
import java.util.stream.Collectors;
79+
80+
import org.apache.skywalking.banyandb.v1.client.util.StatusUtil;
7881
import org.apache.skywalking.banyandb.v1.client.util.TimeUtils;
7982

8083
import static com.google.common.base.Preconditions.checkNotNull;
@@ -227,7 +230,10 @@ public CompletableFuture<Void> write(StreamWrite streamWrite) {
227230

228231
@Override
229232
public void onNext(BanyandbStream.WriteResponse writeResponse) {
230-
switch (writeResponse.getStatus()) {
233+
BanyandbModel.Status status = StatusUtil.convertStringToStatus(writeResponse.getStatus());
234+
switch (status) {
235+
case STATUS_SUCCEED:
236+
break;
231237
case STATUS_INVALID_TIMESTAMP:
232238
responseException = new InvalidArgumentException(
233239
"Invalid timestamp: " + streamWrite.getTimestamp(), null, Status.Code.INVALID_ARGUMENT, false);
@@ -250,11 +256,10 @@ public void onNext(BanyandbStream.WriteResponse writeResponse) {
250256
responseException = new InvalidArgumentException(
251257
"Expired revision: " + metadata.getModRevision(), null, Status.Code.INVALID_ARGUMENT, true);
252258
break;
253-
case STATUS_INTERNAL_ERROR:
259+
default:
254260
responseException = new InternalException(
255-
"Internal error occurs in server", null, Status.Code.INTERNAL, true);
261+
String.format("Internal error (%s) occurs in server", writeResponse.getStatus()), null, Status.Code.INTERNAL, true);
256262
break;
257-
default:
258263
}
259264
}
260265

src/main/java/org/apache/skywalking/banyandb/v1/client/MeasureBulkWriteProcessor.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import org.apache.skywalking.banyandb.common.v1.BanyandbCommon;
2525
import org.apache.skywalking.banyandb.measure.v1.BanyandbMeasure;
2626
import org.apache.skywalking.banyandb.measure.v1.MeasureServiceGrpc;
27+
import org.apache.skywalking.banyandb.model.v1.BanyandbModel;
2728
import org.apache.skywalking.banyandb.v1.client.grpc.exception.BanyanDBException;
29+
import org.apache.skywalking.banyandb.v1.client.util.StatusUtil;
2830

2931
import javax.annotation.concurrent.ThreadSafe;
3032

@@ -69,7 +71,10 @@ protected StreamObserver<BanyandbMeasure.WriteRequest> buildStreamObserver(Measu
6971

7072
@Override
7173
public void onNext(BanyandbMeasure.WriteResponse writeResponse) {
72-
switch (writeResponse.getStatus()) {
74+
BanyandbModel.Status status = StatusUtil.convertStringToStatus(writeResponse.getStatus());
75+
switch (status) {
76+
case STATUS_SUCCEED:
77+
break;
7378
case STATUS_EXPIRED_SCHEMA:
7479
BanyandbCommon.Metadata metadata = writeResponse.getMetadata();
7580
String schemaKey = metadata.getGroup() + "." + metadata.getName();
@@ -84,6 +89,7 @@ public void onNext(BanyandbMeasure.WriteResponse writeResponse) {
8489
}
8590
break;
8691
default:
92+
log.warn("Write measure failed with status: {}", status);
8793
}
8894
}
8995

src/main/java/org/apache/skywalking/banyandb/v1/client/StreamBulkWriteProcessor.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
import lombok.extern.slf4j.Slf4j;
2424

2525
import org.apache.skywalking.banyandb.common.v1.BanyandbCommon;
26+
import org.apache.skywalking.banyandb.model.v1.BanyandbModel;
2627
import org.apache.skywalking.banyandb.stream.v1.StreamServiceGrpc;
2728
import org.apache.skywalking.banyandb.stream.v1.BanyandbStream;
2829
import org.apache.skywalking.banyandb.v1.client.grpc.exception.BanyanDBException;
30+
import org.apache.skywalking.banyandb.v1.client.util.StatusUtil;
2931

3032
import javax.annotation.concurrent.ThreadSafe;
3133

@@ -70,7 +72,10 @@ protected StreamObserver<BanyandbStream.WriteRequest> buildStreamObserver(Stream
7072

7173
@Override
7274
public void onNext(BanyandbStream.WriteResponse writeResponse) {
73-
switch (writeResponse.getStatus()) {
75+
BanyandbModel.Status status = StatusUtil.convertStringToStatus(writeResponse.getStatus());
76+
switch (status) {
77+
case STATUS_SUCCEED:
78+
break;
7479
case STATUS_EXPIRED_SCHEMA:
7580
BanyandbCommon.Metadata metadata = writeResponse.getMetadata();
7681
String schemaKey = metadata.getGroup() + "." + metadata.getName();
@@ -85,6 +90,7 @@ public void onNext(BanyandbStream.WriteResponse writeResponse) {
8590
}
8691
break;
8792
default:
93+
log.warn("Write stream failed with status: {}", status);
8894
}
8995
}
9096

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.banyandb.v1.client.util;
20+
21+
import org.apache.skywalking.banyandb.model.v1.BanyandbModel;
22+
23+
/**
24+
* Status is a utility class for converting between strings and Status enums.
25+
*/
26+
public class StatusUtil {
27+
28+
/**
29+
* Convert a Status enum to a string.
30+
*
31+
* @param statusString the string to convert
32+
* @return the Status enum
33+
*/
34+
public static BanyandbModel.Status convertStringToStatus(String statusString) {
35+
try {
36+
return BanyandbModel.Status.valueOf(statusString);
37+
} catch (IllegalArgumentException e) {
38+
// Return a specific enum value for unknown strings
39+
return BanyandbModel.Status.STATUS_UNSPECIFIED;
40+
}
41+
}
42+
}

src/main/proto/banyandb/v1/banyandb-measure.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ message WriteResponse {
169169
// the message_id from request.
170170
uint64 message_id = 1 [(validate.rules).uint64.gt = 0];
171171
// status indicates the request processing result
172-
model.v1.Status status = 2 [(validate.rules).enum.defined_only = true];
172+
string status = 2;
173173
// the metadata from request when request fails
174174
common.v1.Metadata metadata = 3;
175175
}

src/main/proto/banyandb/v1/banyandb-model.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,5 @@ enum Status {
216216
STATUS_NOT_FOUND = 3;
217217
STATUS_EXPIRED_SCHEMA = 4;
218218
STATUS_INTERNAL_ERROR = 5;
219+
STATUS_DISK_FULL = 6;
219220
}

src/main/proto/banyandb/v1/banyandb-stream.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ message WriteResponse {
102102
// the message_id from request.
103103
uint64 message_id = 1 [(validate.rules).uint64.gt = 0];
104104
// status indicates the request processing result
105-
model.v1.Status status = 2 [(validate.rules).enum.defined_only = true];
105+
string status = 2;
106106
// the metadata from request when request fails
107107
common.v1.Metadata metadata = 3;
108108
}

src/test/java/org/apache/skywalking/banyandb/v1/client/BanyanDBClientTestCI.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929

3030
@Slf4j
3131
public class BanyanDBClientTestCI {
32-
private static final String REGISTRY = "ghcr.io";
33-
private static final String IMAGE_NAME = "apache/skywalking-banyandb";
34-
private static final String TAG = "1d4ddc3d42103dc3364ad729403c4154690be195";
32+
private static final String REGISTRY = "docker.io";
33+
private static final String IMAGE_NAME = "hanahmily/skywalking-banyandb";
34+
private static final String TAG = "v0.7.0-42-ga96ffb3-max-disk";
3535

3636
private static final String IMAGE = REGISTRY + "/" + IMAGE_NAME + ":" + TAG;
3737

0 commit comments

Comments
 (0)