This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git


The following commit(s) were added to refs/heads/master by this push:
     new fe77e931 Revert Triple migration samples (#487)
fe77e931 is described below

commit fe77e931fc2f37d75c794d48784932e896a900bd
Author: Albumen Kevin <[email protected]>
AuthorDate: Sat Aug 6 20:32:46 2022 +0800

    Revert Triple migration samples (#487)
---
 .../tri/migration/ApiMigrationBothConsumer.java    | 71 +++++++++++++++++++++
 .../tri/migration/ApiMigrationDubboConsumer.java   | 56 ++++++++++++++++
 .../tri/migration/ApiMigrationDubboProvider.java   | 44 +++++++++++++
 .../tri/migration/ApiMigrationTriConsumer.java     | 56 ++++++++++++++++
 .../tri/migration/ApiMigrationTriProvider.java     | 45 +++++++++++++
 .../dubbo/sample/tri/migration/IGreeterImpl.java   | 74 ++++++++++++++++++++++
 .../sample/tri/migration/IWrapperGreeter.java      | 39 ++++++++++++
 7 files changed, 385 insertions(+)

diff --git 
a/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/ApiMigrationBothConsumer.java
 
b/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/ApiMigrationBothConsumer.java
new file mode 100644
index 00000000..24cf0e1e
--- /dev/null
+++ 
b/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/ApiMigrationBothConsumer.java
@@ -0,0 +1,71 @@
+/*
+ *  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.dubbo.sample.tri.migration;
+
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.sample.tri.util.TriSampleConstants;
+
+class ApiMigrationBothConsumer {
+    private final IWrapperGreeter dubboDelegate;
+    private final IWrapperGreeter triDelegate;
+
+    public ApiMigrationBothConsumer() {
+        ReferenceConfig<IWrapperGreeter> ref = new ReferenceConfig<>();
+        ref.setInterface(IWrapperGreeter.class);
+        ref.setCheck(false);
+        ref.setTimeout(3000);
+        ref.setProtocol(CommonConstants.DUBBO_PROTOCOL);
+        ref.setLazy(true);
+
+        ReferenceConfig<IWrapperGreeter> ref2 = new ReferenceConfig<>();
+        ref2.setInterface(IWrapperGreeter.class);
+        ref2.setCheck(false);
+        ref2.setTimeout(3000);
+        ref2.setProtocol(CommonConstants.TRIPLE);
+        ref2.setLazy(true);
+
+        DubboBootstrap bootstrap = DubboBootstrap.getInstance();
+        bootstrap.application(new 
ApplicationConfig("demo-migration-dubbo-consumer"))
+                .registry(new RegistryConfig(TriSampleConstants.ZK_ADDRESS))
+                .reference(ref)
+                .reference(ref2)
+                .start();
+        this.dubboDelegate = ref.get();
+        this.triDelegate = ref2.get();
+    }
+
+    public static void main(String[] args) {
+        final ApiMigrationBothConsumer consumer = new 
ApiMigrationBothConsumer();
+        System.out.println("demo-migration-both-consumer started");
+        consumer.sayHelloUnary(CommonConstants.DUBBO_PROTOCOL);
+        consumer.sayTriHelloUnary(CommonConstants.TRIPLE);
+    }
+
+    public void sayHelloUnary(String protocol) {
+        System.out.println(dubboDelegate.sayHello("unary" + "--" + protocol));
+    }
+
+    public void sayTriHelloUnary(String protocol) {
+        System.out.println(triDelegate.sayHello("unary" + "--" + protocol));
+    }
+
+}
diff --git 
a/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/ApiMigrationDubboConsumer.java
 
b/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/ApiMigrationDubboConsumer.java
new file mode 100644
index 00000000..6f130ae4
--- /dev/null
+++ 
b/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/ApiMigrationDubboConsumer.java
@@ -0,0 +1,56 @@
+/*
+ *  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.dubbo.sample.tri.migration;
+
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.sample.tri.util.TriSampleConstants;
+
+class ApiMigrationDubboConsumer {
+    private final IWrapperGreeter delegate;
+
+    public ApiMigrationDubboConsumer() {
+        ReferenceConfig<IWrapperGreeter> ref = new ReferenceConfig<>();
+        ref.setInterface(IWrapperGreeter.class);
+        ref.setCheck(false);
+        ref.setTimeout(3000);
+        ref.setProtocol(CommonConstants.DUBBO_PROTOCOL);
+        ref.setLazy(true);
+
+        DubboBootstrap bootstrap = DubboBootstrap.getInstance();
+        bootstrap.application(new 
ApplicationConfig("demo-migration-dubbo-consumer"))
+                .registry(new RegistryConfig(TriSampleConstants.ZK_ADDRESS))
+                .reference(ref)
+                .start();
+        this.delegate = ref.get();
+    }
+
+    public static void main(String[] args) {
+        final ApiMigrationDubboConsumer consumer = new 
ApiMigrationDubboConsumer();
+        System.out.println("demo-migration-dubbo-consumer dubbo started");
+        consumer.sayHelloUnary(CommonConstants.DUBBO_PROTOCOL);
+    }
+
+    public void sayHelloUnary(String protocol) {
+        System.out.println(delegate.sayHello("unary" + "--" + protocol));
+    }
+
+}
diff --git 
a/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/ApiMigrationDubboProvider.java
 
b/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/ApiMigrationDubboProvider.java
new file mode 100644
index 00000000..3b1609ee
--- /dev/null
+++ 
b/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/ApiMigrationDubboProvider.java
@@ -0,0 +1,44 @@
+/*
+ *  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.dubbo.sample.tri.migration;
+
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ProtocolConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.ServiceConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.sample.tri.util.TriSampleConstants;
+
+class ApiMigrationDubboProvider {
+
+    public static void main(String[] args) {
+        ServiceConfig<IWrapperGreeter> service2 = new ServiceConfig<>();
+        service2.setInterface(IWrapperGreeter.class);
+        service2.setRef(new IGreeterImpl());
+
+        DubboBootstrap bootstrap = DubboBootstrap.getInstance();
+        bootstrap.application(new 
ApplicationConfig("demo-migration-dubbo-provider"))
+                .registry(new RegistryConfig(TriSampleConstants.ZK_ADDRESS))
+                .protocol(new ProtocolConfig(CommonConstants.DUBBO, 
TriSampleConstants.DEFAULT_DUBBO_PORT))
+                .service(service2)
+                .start()
+                .await();
+
+    }
+}
diff --git 
a/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/ApiMigrationTriConsumer.java
 
b/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/ApiMigrationTriConsumer.java
new file mode 100644
index 00000000..82f75244
--- /dev/null
+++ 
b/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/ApiMigrationTriConsumer.java
@@ -0,0 +1,56 @@
+/*
+ *  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.dubbo.sample.tri.migration;
+
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.sample.tri.util.TriSampleConstants;
+
+class ApiMigrationTriConsumer {
+    private final IWrapperGreeter triDelegate;
+
+    public ApiMigrationTriConsumer() {
+        ReferenceConfig<IWrapperGreeter> ref2 = new ReferenceConfig<>();
+        ref2.setInterface(IWrapperGreeter.class);
+        ref2.setCheck(false);
+        ref2.setTimeout(3000);
+        ref2.setProtocol(CommonConstants.TRIPLE);
+        ref2.setLazy(true);
+
+        DubboBootstrap bootstrap = DubboBootstrap.getInstance();
+        bootstrap.application(new 
ApplicationConfig("demo-migration-tri-consumer"))
+                .registry(new RegistryConfig(TriSampleConstants.ZK_ADDRESS))
+                .reference(ref2)
+                .start();
+        this.triDelegate = ref2.get();
+    }
+
+    public static void main(String[] args) {
+        final ApiMigrationTriConsumer consumer = new ApiMigrationTriConsumer();
+        System.out.println("demo-migration-both-consumer started");
+        consumer.sayTriHelloUnary(CommonConstants.TRIPLE);
+    }
+
+    public void sayTriHelloUnary(String protocol) {
+        System.out.println(triDelegate.sayHello("unary" + "--" + protocol));
+    }
+
+}
diff --git 
a/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/ApiMigrationTriProvider.java
 
b/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/ApiMigrationTriProvider.java
new file mode 100644
index 00000000..11e45333
--- /dev/null
+++ 
b/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/ApiMigrationTriProvider.java
@@ -0,0 +1,45 @@
+/*
+ *  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.dubbo.sample.tri.migration;
+
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ProtocolConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.ServiceConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.sample.tri.util.TriSampleConstants;
+
+class ApiMigrationTriProvider {
+
+    public static void main(String[] args) {
+
+        ServiceConfig<IWrapperGreeter> service2 = new ServiceConfig<>();
+        service2.setInterface(IWrapperGreeter.class);
+        service2.setRef(new IGreeterImpl());
+
+        DubboBootstrap bootstrap = DubboBootstrap.getInstance();
+        bootstrap.application(new 
ApplicationConfig("demo-migration-tri-provider"))
+                .registry(new RegistryConfig(TriSampleConstants.ZK_ADDRESS))
+                .protocol(new ProtocolConfig(CommonConstants.TRIPLE, 
TriSampleConstants.SERVER_PORT))
+                .service(service2)
+                .start()
+                .await();
+
+    }
+}
diff --git 
a/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/IGreeterImpl.java
 
b/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/IGreeterImpl.java
new file mode 100644
index 00000000..f8de4bc8
--- /dev/null
+++ 
b/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/IGreeterImpl.java
@@ -0,0 +1,74 @@
+/*
+ *  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.dubbo.sample.tri.migration;
+
+import org.apache.dubbo.common.stream.StreamObserver;
+import org.apache.dubbo.rpc.RpcContext;
+import org.apache.dubbo.sample.tri.util.EchoStreamObserver;
+
+public class IGreeterImpl implements IWrapperGreeter {
+
+    @Override
+    public String sayHello(String request) {
+        return "hello," + request;
+    }
+
+    @Override
+    public void sayHelloResponseVoid(String request) {
+        System.out.println("call void response");
+    }
+
+    @Override
+    public String sayHelloRequestVoid() {
+        System.out.println("call void request");
+        return "hello!";
+    }
+
+    @Override
+    public String sayHelloException(String request) {
+        throw new RuntimeException("Biz exception");
+    }
+
+    @Override
+    public String sayHelloWithAttachment(String request) {
+        
System.out.println(RpcContext.getServerAttachment().getObjectAttachments());
+        RpcContext.getServerContext().setAttachment("str", "str")
+                .setAttachment("integer", 1)
+                .setAttachment("raw", new byte[]{1, 2, 3, 4});
+        return "hello," + request;
+    }
+
+    @Override
+    public StreamObserver<String> sayHelloStream(StreamObserver<String> 
response) {
+        return new EchoStreamObserver<>(str -> "hello," + str, response);
+    }
+
+    @Override
+    public StreamObserver<String> sayHelloStreamError(StreamObserver<String> 
response) {
+        response.onError(new Throwable("ServerStream error"));
+        return new EchoStreamObserver<>(str -> "hello," + str, response);
+    }
+
+    @Override
+    public void sayHelloServerStream(String request, StreamObserver<String> 
response) {
+        for (int i = 0; i < 10; i++) {
+            response.onNext("hello," + request);
+        }
+        response.onCompleted();
+    }
+}
diff --git 
a/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/IWrapperGreeter.java
 
b/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/IWrapperGreeter.java
new file mode 100644
index 00000000..6a815595
--- /dev/null
+++ 
b/dubbo-samples-triple/src/main/java/org/apache/dubbo/sample/tri/migration/IWrapperGreeter.java
@@ -0,0 +1,39 @@
+/*
+ *  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.dubbo.sample.tri.migration;
+
+import org.apache.dubbo.common.stream.StreamObserver;
+
+public interface IWrapperGreeter {
+
+    String sayHello(String request);
+
+    void sayHelloResponseVoid(String request);
+
+    String sayHelloRequestVoid();
+
+    String sayHelloException(String request);
+
+    String sayHelloWithAttachment(String request);
+
+    StreamObserver<String> sayHelloStream(StreamObserver<String> response);
+
+    StreamObserver<String> sayHelloStreamError(StreamObserver<String> 
response);
+
+    void sayHelloServerStream(String request, StreamObserver<String> response);
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to