parseGetStateResult(RuntimeProto.BulkStateItem bulkStateIt
/**
* Getter method for property stubManager.
- *
+ *
* Do not use it !
* This method is deprecated and might be refactored in the future.
* We want this client to expose grpc Channels instead of grpc stubs.
@@ -530,22 +530,24 @@ public void shutdown() {
@Override
public PutFileResponse putFile(PutFileRequest request, int timeoutMs) throws Exception {
-
checkParamOfPutFile(request);
PutFileFuture putFuture = new PutFileFuture(request.getFileName());
StreamObserver observer = createPutFileObserver(putFuture, timeoutMs);
- observer.onNext(buildPutFileMetaDataRequest(request.getStoreName(), request.getFileName(),
- request.getMetaData()));
+ RuntimeProto.PutFileRequest putFileRequest = buildPutFileMetaDataRequest(
+ request.getStoreName(),
+ request.getFileName(),
+ request.getMetaData());
+ observer.onNext(putFileRequest);
byte[] buf = new byte[4096];
for (int size = request.getIn().read(buf); size > 0; size = request.getIn().read(buf)) {
- observer.onNext(buildPutFileDataRequest(buf, size));
+ RuntimeProto.PutFileRequest fileRequest = buildPutFileDataRequest(buf, size);
+ observer.onNext(fileRequest);
}
observer.onCompleted();
-
putFuture.awaitDone(timeoutMs);
return new PutFileResponse();
@@ -553,72 +555,64 @@ public PutFileResponse putFile(PutFileRequest request, int timeoutMs) throws Exc
@Override
public GetFileResponse getFile(GetFileRequest request, int timeoutMs) throws Exception {
-
checkParamOfGetFile(request);
GetFilePipe pipe = new GetFilePipe(request.getFileName());
- stubManager.
- getAsyncStub().
- getFile(
- buildGetFileRequest(
- request.getStoreName(),
- request.getFileName(),
- request.getMetaData()),
- pipe);
+ RuntimeProto.GetFileRequest getFileRequest = buildGetFileRequest(
+ request.getStoreName(),
+ request.getFileName(),
+ request.getMetaData());
+ stubManager.getAsyncStub()
+ .getFile(getFileRequest, pipe);
return new GetFileResponse(pipe.getReader());
}
@Override
public ListFileResponse listFile(ListFileRequest request, int timeoutMs) throws Exception {
-
checkParamOfListFile(request);
- RuntimeProto.ListFileResp response = stubManager.
- getBlockingStub().
- withDeadlineAfter(timeoutMs, TimeUnit.MILLISECONDS).
- listFile(
- buildListFileRequest(
- request.getStoreName(),
- request.getName(),
- request.getMarker(),
- request.getPageSize(),
- request.getMetaData()));
+ RuntimeProto.ListFileRequest listFileRequest = buildListFileRequest(
+ request.getStoreName(),
+ request.getName(),
+ request.getMarker(),
+ request.getPageSize(),
+ request.getMetaData());
+ RuntimeProto.ListFileResp response = stubManager.getBlockingStub()
+ .withDeadlineAfter(timeoutMs, TimeUnit.MILLISECONDS)
+ .listFile(listFileRequest);
return buildListFileResponse(response);
}
@Override
public DelFileResponse delFile(DelFileRequest request, int timeoutMs) throws Exception {
-
checkParamOfDeleteFile(request);
- stubManager.
- getBlockingStub().
- withDeadlineAfter(timeoutMs, TimeUnit.MILLISECONDS).
- delFile(
- buildDelFileRequest(request.getStoreName(), request.getFileName(), request.getMetaData()));
+ RuntimeProto.DelFileRequest delFileRequest = buildDelFileRequest(request.getStoreName(), request.getFileName(),
+ request.getMetaData());
+ stubManager.getBlockingStub()
+ .withDeadlineAfter(timeoutMs, TimeUnit.MILLISECONDS)
+ .delFile(delFileRequest);
return new DelFileResponse();
}
@Override
public GetMeteResponse getFileMeta(GetMetaRequest request, int timeoutMs) throws Exception {
-
checkParamOfGetFileMeta(request);
- RuntimeProto.GetFileMetaResponse resp = stubManager.
- getBlockingStub().
- withDeadlineAfter(timeoutMs, TimeUnit.MILLISECONDS).
- getFileMeta(
- buildGetFileMetaRequest(request.getStoreName(), request.getFileName(), request.getMetaData()));
+ RuntimeProto.GetFileMetaRequest getFileMetaRequest = buildGetFileMetaRequest(request.getStoreName(),
+ request.getFileName(), request.getMetaData());
+ RuntimeProto.GetFileMetaResponse resp = stubManager.getBlockingStub()
+ .withDeadlineAfter(timeoutMs, TimeUnit.MILLISECONDS)
+ .getFileMeta(getFileMetaRequest);
return buildGetFileMetaResponse(resp);
}
private void checkParamOfGetFile(GetFileRequest request) {
-
// check request
if (request == null) {
throw new IllegalArgumentException("miss request");
@@ -636,7 +630,6 @@ private void checkParamOfGetFile(GetFileRequest request) {
}
private void checkParamOfPutFile(PutFileRequest request) {
-
// check request
if (request == null) {
throw new IllegalArgumentException("miss request");
@@ -659,7 +652,6 @@ private void checkParamOfPutFile(PutFileRequest request) {
}
private void checkParamOfListFile(ListFileRequest request) {
-
// check request
if (request == null) {
throw new IllegalArgumentException("miss request");
@@ -672,7 +664,6 @@ private void checkParamOfListFile(ListFileRequest request) {
}
private void checkParamOfDeleteFile(DelFileRequest request) {
-
// check request
if (request == null) {
throw new IllegalArgumentException("miss request");
@@ -690,7 +681,6 @@ private void checkParamOfDeleteFile(DelFileRequest request) {
}
private void checkParamOfGetFileMeta(GetMetaRequest request) {
-
// check request
if (request == null) {
throw new IllegalArgumentException("miss request");
@@ -738,7 +728,6 @@ public void onCompleted() {
}
public void awaitDone(int timeoutMs) throws Exception {
-
boolean finished = latch.await(timeoutMs, TimeUnit.MILLISECONDS);
if (!finished) {
String tip = String.format("put file timeout, file=%s", fileName);
@@ -767,7 +756,6 @@ private class PipeFileInputStream extends PipedInputStream {
@Override
public synchronized int read() throws IOException {
-
checkCause();
return super.read();
@@ -775,7 +763,6 @@ public synchronized int read() throws IOException {
@Override
public int read(byte[] b) throws IOException {
-
checkCause();
return super.read(b);
@@ -783,7 +770,6 @@ public int read(byte[] b) throws IOException {
@Override
public synchronized int read(byte[] b, int off, int len) throws IOException {
-
checkCause();
return super.read(b, off, len);
@@ -815,7 +801,6 @@ private class GetFilePipe implements StreamObserver createPutFileObserver(
StreamObserver callBackObserver,
int timeoutMs) {
- return stubManager.
- getAsyncStub().
- withDeadlineAfter(timeoutMs, TimeUnit.MILLISECONDS).
- putFile(callBackObserver);
+ return stubManager.getAsyncStub()
+ .withDeadlineAfter(timeoutMs, TimeUnit.MILLISECONDS)
+ .putFile(callBackObserver);
}
private RuntimeProto.PutFileRequest buildPutFileMetaDataRequest(String storeName,
String fileName,
Map meta) {
- return RuntimeProto.PutFileRequest.
- newBuilder().
- setStoreName(storeName).
- setName(fileName).
- putAllMetadata(meta).
- build();
+ return RuntimeProto.PutFileRequest
+ .newBuilder()
+ .setStoreName(storeName)
+ .setName(fileName)
+ .putAllMetadata(meta)
+ .build();
}
private RuntimeProto.PutFileRequest buildPutFileDataRequest(byte[] bytes, int size) {
-
- return RuntimeProto.PutFileRequest.
- newBuilder().
- setData(ByteString.copyFrom(bytes, 0, size)).
- build();
+ return RuntimeProto.PutFileRequest
+ .newBuilder()
+ .setData(ByteString.copyFrom(bytes, 0, size))
+ .build();
}
private RuntimeProto.GetFileRequest buildGetFileRequest(String storeName,
String fileName,
Map meta) {
-
- return RuntimeProto.GetFileRequest.
- newBuilder().
- setStoreName(storeName).
- setName(fileName).
- putAllMetadata(meta).
- build();
+ return RuntimeProto.GetFileRequest
+ .newBuilder()
+ .setStoreName(storeName)
+ .setName(fileName)
+ .putAllMetadata(meta)
+ .build();
}
private RuntimeProto.ListFileRequest buildListFileRequest(String storeName, String name, String marker,
int pageSize, Map meta) {
+ RuntimeProto.FileRequest fileRequest = RuntimeProto.FileRequest
+ .newBuilder()
+ .setStoreName(storeName)
+ .setName(name)
+ .putAllMetadata(meta)
+ .build();
- RuntimeProto.FileRequest fileRequest = RuntimeProto.FileRequest.
- newBuilder().
- setStoreName(storeName).
- setName(name).
- putAllMetadata(meta).
- build();
-
- return RuntimeProto.ListFileRequest.
- newBuilder().
- setRequest(fileRequest).
- setMarker(marker).
- setPageSize(pageSize).
- build();
+ return RuntimeProto.ListFileRequest
+ .newBuilder()
+ .setRequest(fileRequest)
+ .setMarker(marker)
+ .setPageSize(pageSize)
+ .build();
}
private RuntimeProto.DelFileRequest buildDelFileRequest(String storeName,
String fileName,
Map meta) {
+ RuntimeProto.FileRequest fileRequest = RuntimeProto.FileRequest
+ .newBuilder()
+ .setStoreName(storeName)
+ .setName(fileName)
+ .putAllMetadata(meta)
+ .build();
- RuntimeProto.FileRequest fileRequest = RuntimeProto.FileRequest.
- newBuilder().
- setStoreName(storeName).
- setName(fileName).
- putAllMetadata(meta).
- build();
-
- return RuntimeProto.DelFileRequest.
- newBuilder().
- setRequest(fileRequest).
- build();
+ return RuntimeProto.DelFileRequest
+ .newBuilder()
+ .setRequest(fileRequest)
+ .build();
}
private RuntimeProto.GetFileMetaRequest buildGetFileMetaRequest(String storeName,
String fileName,
Map meta) {
+ RuntimeProto.FileRequest fileRequest = RuntimeProto.FileRequest
+ .newBuilder()
+ .setStoreName(storeName)
+ .setName(fileName)
+ .putAllMetadata(meta)
+ .build();
- RuntimeProto.FileRequest fileRequest = RuntimeProto.FileRequest.
- newBuilder().
- setStoreName(storeName).
- setName(fileName).
- putAllMetadata(meta).
- build();
-
- return RuntimeProto.GetFileMetaRequest.
- newBuilder().
- setRequest(fileRequest).
- build();
+ return RuntimeProto.GetFileMetaRequest
+ .newBuilder()
+ .setRequest(fileRequest)
+ .build();
}
private GetMeteResponse buildGetFileMetaResponse(RuntimeProto.GetFileMetaResponse resp) {
-
Map metas = new HashMap<>();
- resp.getResponse().
- getMetadataMap().
- forEach(
- (s, fileMetaValue) ->
- metas.put(s, fileMetaValue.getValueList().toArray(new String[0])));
+ resp.getResponse()
+ .getMetadataMap()
+ .forEach((s, fileMetaValue) ->
+ metas.put(s, fileMetaValue.getValueList().toArray(new String[0])));
GetMeteResponse result = new GetMeteResponse();
result.setSize(resp.getSize());
@@ -971,16 +946,13 @@ private GetMeteResponse buildGetFileMetaResponse(RuntimeProto.GetFileMetaRespons
}
private ListFileResponse buildListFileResponse(RuntimeProto.ListFileResp resp) {
-
- FileInfo[] files = resp.getFilesList().
- stream().
- map(
- fileInfo ->
- new FileInfo(
- fileInfo.getFileName(),
- fileInfo.getSize(),
- fileInfo.getLastModified(),
- fileInfo.getMetadataMap())).
+ FileInfo[] files = resp.getFilesList()
+ .stream()
+ .map(fileInfo -> new FileInfo(
+ fileInfo.getFileName(),
+ fileInfo.getSize(),
+ fileInfo.getLastModified(),
+ fileInfo.getMetadataMap())).
toArray(FileInfo[]::new);
ListFileResponse result = new ListFileResponse();
diff --git a/sdk/src/main/java/spec/sdk/runtime/v1/client/RuntimeClient.java b/sdk/src/main/java/spec/sdk/runtime/v1/client/RuntimeClient.java
index f19f7d5..711a738 100644
--- a/sdk/src/main/java/spec/sdk/runtime/v1/client/RuntimeClient.java
+++ b/sdk/src/main/java/spec/sdk/runtime/v1/client/RuntimeClient.java
@@ -33,5 +33,12 @@ public interface RuntimeClient extends
SequencerRuntime,
FileRuntime {
+ /**
+ * Waits for the sidecar, giving up after timeout.
+ *
+ * @param timeoutInMilliseconds Timeout in milliseconds to wait for sidecar.
+ */
+ // void waitForSidecar(int timeoutInMilliseconds);
+
void shutdown();
}
\ No newline at end of file
diff --git a/spec/pom.xml b/spec/pom.xml
index 5eed022..6094343 100644
--- a/spec/pom.xml
+++ b/spec/pom.xml
@@ -1,101 +1,101 @@
- 4.0.0
+ 4.0.0
-
- io.mosn.layotto
- runtime-sdk-parent
- 1.1.0-SNAPSHOT
-
+
+ io.mosn.layotto
+ runtime-sdk-parent
+ 1.1.0-SNAPSHOT
+
- runtime-spec-pb
- runtime-spec-pb
- jar
+ runtime-spec-pb
+ runtime-spec-pb
+ jar
-
-
- io.grpc
- grpc-all
-
-
+
+
+ io.grpc
+ grpc-all
+
+
-
- src/main/java
-
-
- src/main/resources
- true
-
- **/**
-
-
-
- proto
- true
-
- **/*.proto
-
-
-
+
+ src/main/java
+
+
+ src/main/resources
+ true
+
+ **/**
+
+
+
+ proto
+ true
+
+ **/*.proto
+
+
+
- src/test/java
-
-
- src/test/resources
- true
-
- **/**
-
-
-
+ src/test/java
+
+
+ src/test/resources
+ true
+
+ **/**
+
+
+
-
-
- kr.motd.maven
- os-maven-plugin
- 1.4.1.Final
-
-
+
+
+ kr.motd.maven
+ os-maven-plugin
+ 1.4.1.Final
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
- 3.0.1
-
-
- attach-sources
-
- jar
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 3.0.1
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spec/src/main/java/spec/proto/runtime/v1/AppCallbackGrpc.java b/spec/src/main/java/spec/proto/runtime/v1/AppCallbackGrpc.java
index 33bc7b9..a5bbe30 100644
--- a/spec/src/main/java/spec/proto/runtime/v1/AppCallbackGrpc.java
+++ b/spec/src/main/java/spec/proto/runtime/v1/AppCallbackGrpc.java
@@ -1,3 +1,17 @@
+/*
+ * Copyright 2021 Layotto Authors
+ * Licensed 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 spec.proto.runtime.v1;
import static io.grpc.MethodDescriptor.generateFullMethodName;
diff --git a/spec/src/main/java/spec/proto/runtime/v1/AppCallbackProto.java b/spec/src/main/java/spec/proto/runtime/v1/AppCallbackProto.java
index 3477433..91a5fd5 100644
--- a/spec/src/main/java/spec/proto/runtime/v1/AppCallbackProto.java
+++ b/spec/src/main/java/spec/proto/runtime/v1/AppCallbackProto.java
@@ -1,3 +1,17 @@
+/*
+ * Copyright 2021 Layotto Authors
+ * Licensed 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.
+ */
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: proto/runtime/v1/appcallback.proto
diff --git a/spec/src/main/java/spec/proto/runtime/v1/RuntimeGrpc.java b/spec/src/main/java/spec/proto/runtime/v1/RuntimeGrpc.java
index 9e194c5..aff843d 100644
--- a/spec/src/main/java/spec/proto/runtime/v1/RuntimeGrpc.java
+++ b/spec/src/main/java/spec/proto/runtime/v1/RuntimeGrpc.java
@@ -1,3 +1,17 @@
+/*
+ * Copyright 2021 Layotto Authors
+ * Licensed 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 spec.proto.runtime.v1;
import static io.grpc.MethodDescriptor.generateFullMethodName;
diff --git a/spec/src/main/java/spec/proto/runtime/v1/RuntimeProto.java b/spec/src/main/java/spec/proto/runtime/v1/RuntimeProto.java
index 92b8cd8..415158a 100644
--- a/spec/src/main/java/spec/proto/runtime/v1/RuntimeProto.java
+++ b/spec/src/main/java/spec/proto/runtime/v1/RuntimeProto.java
@@ -1,3 +1,17 @@
+/*
+ * Copyright 2021 Layotto Authors
+ * Licensed 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.
+ */
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: proto/runtime/v1/runtime.proto