Xuanwo commented on code in PR #3392: URL: https://github.com/apache/incubator-opendal/pull/3392#discussion_r1374042845
########## bindings/java/src/test/java/org/apache/opendal/test/NativeLayerTest.java: ########## @@ -0,0 +1,41 @@ +/* + * 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.opendal.test; + +import static org.assertj.core.api.Assertions.assertThat; +import java.util.HashMap; +import java.util.Map; +import lombok.Cleanup; +import org.apache.opendal.NativeLayer; +import org.apache.opendal.Operator; +import org.apache.opendal.layer.RetryNativeLayer; +import org.junit.jupiter.api.Test; + +public class NativeLayerTest { + @Test + void testOperatorWithRetryLayer() { + final Map<String, String> conf = new HashMap<>(); + conf.put("root", "/opendal/"); + final NativeLayer retryLayer = RetryNativeLayer.builder().build(); Review Comment: The `builder().build()` pattern looks like a bit verbose. ########## bindings/java/src/main/java/org/apache/opendal/layer/RetryNativeLayer.java: ########## @@ -0,0 +1,50 @@ +/* + * 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.opendal.layer; + +import java.time.Duration; +import lombok.Builder; +import org.apache.opendal.NativeLayer; + +@Builder +public class RetryNativeLayer extends NativeLayer { + + private final boolean jitter; Review Comment: Is it a good idea to store a `nativeHandle` (the `RetryLayer` in rust core) in `RetryNativeLayer` class and forward all functions to it? So the `doLayer` can be `doLayer(long nativeHandle, long layerHandle)`. Besides, I have two naming things: - How renaming `nativeHandle` to `nativeOperator`? - Do we need to keep `Native` in `RetryNativeLayer`? How about just `RetryLayer`? I feel like users don't need to know about this concept. ########## bindings/java/src/main/java/org/apache/opendal/NativeLayer.java: ########## @@ -0,0 +1,24 @@ +/* + * 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.opendal; + +public abstract class NativeLayer { Review Comment: Can we make `NativeLayer` private and only used inside opendal package? ########## bindings/java/src/test/java/org/apache/opendal/test/NativeLayerTest.java: ########## @@ -0,0 +1,41 @@ +/* + * 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.opendal.test; + +import static org.assertj.core.api.Assertions.assertThat; +import java.util.HashMap; +import java.util.Map; +import lombok.Cleanup; +import org.apache.opendal.NativeLayer; +import org.apache.opendal.Operator; +import org.apache.opendal.layer.RetryNativeLayer; +import org.junit.jupiter.api.Test; + +public class NativeLayerTest { + @Test + void testOperatorWithRetryLayer() { + final Map<String, String> conf = new HashMap<>(); + conf.put("root", "/opendal/"); + final NativeLayer retryLayer = RetryNativeLayer.builder().build(); + @Cleanup final Operator op = Operator.of("memory", conf); Review Comment: Can we have `Operator.of("memory", conf).layer(retryLayer)`? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
