[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16631517#comment-16631517 ] ASF GitHub Bot commented on SCB-926: yhs0092 closed pull request #926: [SCB-926] 3rd party invoke URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/926 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java index 70c66f89b..5ed1759c1 100644 --- a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java +++ b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java @@ -19,6 +19,7 @@ import org.apache.servicecomb.core.definition.MicroserviceMeta; import org.apache.servicecomb.core.definition.loader.SchemaListenerManager; +import org.apache.servicecomb.core.definition.schema.StaticSchemaFactory; import org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager; import org.apache.servicecomb.core.provider.producer.ProducerProviderManager; import org.apache.servicecomb.core.transport.TransportManager; @@ -74,6 +75,7 @@ public void onApplicationEvent(ApplicationEvent event) { SCBEngine.getInstance().setTransportManager(applicationContext.getBean(TransportManager.class)); SCBEngine.getInstance().setSchemaListenerManager(applicationContext.getBean(SchemaListenerManager.class)); SCBEngine.getInstance().setBootListenerList(applicationContext.getBeansOfType(BootListener.class).values()); + SCBEngine.getInstance().setStaticSchemaFactory(applicationContext.getBean(StaticSchemaFactory.class)); } SCBEngine.getInstance().init(); diff --git a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java index 4be7e7c7b..f364d1c6f 100644 --- a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java +++ b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java @@ -31,6 +31,7 @@ import org.apache.servicecomb.core.BootListener.EventType; import org.apache.servicecomb.core.definition.MicroserviceMeta; import org.apache.servicecomb.core.definition.loader.SchemaListenerManager; +import org.apache.servicecomb.core.definition.schema.StaticSchemaFactory; import org.apache.servicecomb.core.endpoint.AbstractEndpointsCache; import org.apache.servicecomb.core.event.InvocationFinishEvent; import org.apache.servicecomb.core.event.InvocationStartEvent; @@ -82,6 +83,8 @@ private EventBus eventBus = EventManager.getEventBus(); + private StaticSchemaFactory staticSchemaFactory; + private static final SCBEngine INSTANCE = new SCBEngine(); public void setStatus(SCBStatus status) { @@ -374,4 +377,12 @@ public void waitStatusUp(long msWait) throws InterruptedException, TimeoutExcept } } } + + public StaticSchemaFactory getStaticSchemaFactory() { +return staticSchemaFactory; + } + + public void setStaticSchemaFactory(StaticSchemaFactory staticSchemaFactory) { +this.staticSchemaFactory = staticSchemaFactory; + } } diff --git a/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java b/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java index a5eff5853..e4e27632b 100644 --- a/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java +++ b/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java @@ -20,10 +20,15 @@ import org.apache.servicecomb.core.CseContext; import org.apache.servicecomb.core.definition.classloader.MicroserviceClassLoaderFactory; import org.apache.servicecomb.serviceregistry.api.Const; +import org.apache.servicecomb.serviceregistry.api.registry.Microservice; import org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersion; public class MicroserviceVersionMeta extends MicroserviceVersion { - private MicroserviceMeta microserviceMeta; + MicroserviceMeta microserviceMeta; + + MicroserviceVersionMeta(Microservice microservice) { +super(microservice); + } public MicroserviceVersionMeta(String microserviceName, String microserviceId, MicroserviceClassLoaderFactory classLoaderFactory) { diff --git a/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVersionMeta.java b/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVersionMeta.java new file mode 100644 index 0..0fd866bc0 --- /dev/null +++ b/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVe
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16631516#comment-16631516 ] ASF GitHub Bot commented on SCB-926: yhs0092 commented on issue #926: [SCB-926] 3rd party invoke URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/926#issuecomment-425359816 All commits have been merged in pull 915, just close this PR. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16631288#comment-16631288 ] ASF GitHub Bot commented on SCB-926: liubao68 closed pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java index 70c66f89b..5ed1759c1 100644 --- a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java +++ b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java @@ -19,6 +19,7 @@ import org.apache.servicecomb.core.definition.MicroserviceMeta; import org.apache.servicecomb.core.definition.loader.SchemaListenerManager; +import org.apache.servicecomb.core.definition.schema.StaticSchemaFactory; import org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager; import org.apache.servicecomb.core.provider.producer.ProducerProviderManager; import org.apache.servicecomb.core.transport.TransportManager; @@ -74,6 +75,7 @@ public void onApplicationEvent(ApplicationEvent event) { SCBEngine.getInstance().setTransportManager(applicationContext.getBean(TransportManager.class)); SCBEngine.getInstance().setSchemaListenerManager(applicationContext.getBean(SchemaListenerManager.class)); SCBEngine.getInstance().setBootListenerList(applicationContext.getBeansOfType(BootListener.class).values()); + SCBEngine.getInstance().setStaticSchemaFactory(applicationContext.getBean(StaticSchemaFactory.class)); } SCBEngine.getInstance().init(); diff --git a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java index 4be7e7c7b..f364d1c6f 100644 --- a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java +++ b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java @@ -31,6 +31,7 @@ import org.apache.servicecomb.core.BootListener.EventType; import org.apache.servicecomb.core.definition.MicroserviceMeta; import org.apache.servicecomb.core.definition.loader.SchemaListenerManager; +import org.apache.servicecomb.core.definition.schema.StaticSchemaFactory; import org.apache.servicecomb.core.endpoint.AbstractEndpointsCache; import org.apache.servicecomb.core.event.InvocationFinishEvent; import org.apache.servicecomb.core.event.InvocationStartEvent; @@ -82,6 +83,8 @@ private EventBus eventBus = EventManager.getEventBus(); + private StaticSchemaFactory staticSchemaFactory; + private static final SCBEngine INSTANCE = new SCBEngine(); public void setStatus(SCBStatus status) { @@ -374,4 +377,12 @@ public void waitStatusUp(long msWait) throws InterruptedException, TimeoutExcept } } } + + public StaticSchemaFactory getStaticSchemaFactory() { +return staticSchemaFactory; + } + + public void setStaticSchemaFactory(StaticSchemaFactory staticSchemaFactory) { +this.staticSchemaFactory = staticSchemaFactory; + } } diff --git a/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java b/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java index a5eff5853..e4e27632b 100644 --- a/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java +++ b/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java @@ -20,10 +20,15 @@ import org.apache.servicecomb.core.CseContext; import org.apache.servicecomb.core.definition.classloader.MicroserviceClassLoaderFactory; import org.apache.servicecomb.serviceregistry.api.Const; +import org.apache.servicecomb.serviceregistry.api.registry.Microservice; import org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersion; public class MicroserviceVersionMeta extends MicroserviceVersion { - private MicroserviceMeta microserviceMeta; + MicroserviceMeta microserviceMeta; + + MicroserviceVersionMeta(Microservice microservice) { +super(microservice); + } public MicroserviceVersionMeta(String microserviceName, String microserviceId, MicroserviceClassLoaderFactory classLoaderFactory) { diff --git a/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVersionMeta.java b/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVersionMeta.java new file mode 100644 index 0..0fd866bc0 --- /dev/null +++ b/core/src/main/java/org/apache/servicecomb/core/definition/St
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16629729#comment-16629729 ] ASF GitHub Bot commented on SCB-926: coveralls edited a comment on issue #926: [SCB-926] 3rd party invoke URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/926#issuecomment-424679119 [![Coverage Status](https://coveralls.io/builds/19216310/badge)](https://coveralls.io/builds/19216310) Coverage increased (+0.09%) to 86.31% when pulling **be9f265a3c4b68c9cee448f53b8fcf17bcab24fe on yhs0092:3rd_party_invoke** into **7588d90894c10a9f94d4f589e543ee14a7d0c272 on apache:master**. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16629669#comment-16629669 ] ASF GitHub Bot commented on SCB-926: yhs0092 closed pull request #926: [SCB-926] 3rd party invoke URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/926 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java index 70c66f89b..5ed1759c1 100644 --- a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java +++ b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java @@ -19,6 +19,7 @@ import org.apache.servicecomb.core.definition.MicroserviceMeta; import org.apache.servicecomb.core.definition.loader.SchemaListenerManager; +import org.apache.servicecomb.core.definition.schema.StaticSchemaFactory; import org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager; import org.apache.servicecomb.core.provider.producer.ProducerProviderManager; import org.apache.servicecomb.core.transport.TransportManager; @@ -74,6 +75,7 @@ public void onApplicationEvent(ApplicationEvent event) { SCBEngine.getInstance().setTransportManager(applicationContext.getBean(TransportManager.class)); SCBEngine.getInstance().setSchemaListenerManager(applicationContext.getBean(SchemaListenerManager.class)); SCBEngine.getInstance().setBootListenerList(applicationContext.getBeansOfType(BootListener.class).values()); + SCBEngine.getInstance().setStaticSchemaFactory(applicationContext.getBean(StaticSchemaFactory.class)); } SCBEngine.getInstance().init(); diff --git a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java index 4be7e7c7b..f364d1c6f 100644 --- a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java +++ b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java @@ -31,6 +31,7 @@ import org.apache.servicecomb.core.BootListener.EventType; import org.apache.servicecomb.core.definition.MicroserviceMeta; import org.apache.servicecomb.core.definition.loader.SchemaListenerManager; +import org.apache.servicecomb.core.definition.schema.StaticSchemaFactory; import org.apache.servicecomb.core.endpoint.AbstractEndpointsCache; import org.apache.servicecomb.core.event.InvocationFinishEvent; import org.apache.servicecomb.core.event.InvocationStartEvent; @@ -82,6 +83,8 @@ private EventBus eventBus = EventManager.getEventBus(); + private StaticSchemaFactory staticSchemaFactory; + private static final SCBEngine INSTANCE = new SCBEngine(); public void setStatus(SCBStatus status) { @@ -374,4 +377,12 @@ public void waitStatusUp(long msWait) throws InterruptedException, TimeoutExcept } } } + + public StaticSchemaFactory getStaticSchemaFactory() { +return staticSchemaFactory; + } + + public void setStaticSchemaFactory(StaticSchemaFactory staticSchemaFactory) { +this.staticSchemaFactory = staticSchemaFactory; + } } diff --git a/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java b/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java index a5eff5853..e4e27632b 100644 --- a/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java +++ b/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java @@ -20,10 +20,15 @@ import org.apache.servicecomb.core.CseContext; import org.apache.servicecomb.core.definition.classloader.MicroserviceClassLoaderFactory; import org.apache.servicecomb.serviceregistry.api.Const; +import org.apache.servicecomb.serviceregistry.api.registry.Microservice; import org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersion; public class MicroserviceVersionMeta extends MicroserviceVersion { - private MicroserviceMeta microserviceMeta; + MicroserviceMeta microserviceMeta; + + MicroserviceVersionMeta(Microservice microservice) { +super(microservice); + } public MicroserviceVersionMeta(String microserviceName, String microserviceId, MicroserviceClassLoaderFactory classLoaderFactory) { diff --git a/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVersionMeta.java b/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVersionMeta.java new file mode 100644 index 0..0fd866bc0 --- /dev/null +++ b/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVe
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16629670#comment-16629670 ] ASF GitHub Bot commented on SCB-926: yhs0092 opened a new pull request #926: [SCB-926] 3rd party invoke URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/926 Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [x] Each commit in the pull request should have a meaningful subject line and body. - [x] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Run `mvn clean install` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [x] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16629007#comment-16629007 ] ASF GitHub Bot commented on SCB-926: coveralls edited a comment on issue #926: [SCB-926] 3rd party invoke URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/926#issuecomment-424679119 [![Coverage Status](https://coveralls.io/builds/19203793/badge)](https://coveralls.io/builds/19203793) Coverage increased (+0.09%) to 86.276% when pulling **74f1fbed8d8f50fa1c71d17dbf1e6db2fb72a5f3 on yhs0092:3rd_party_invoke** into **55854d47ad2689070a098121ca0bea47acf3d707 on apache:master**. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628955#comment-16628955 ] ASF GitHub Bot commented on SCB-926: yhs0092 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r220615252 ## File path: service-registry/src/main/java/org/apache/servicecomb/serviceregistry/ServiceRegistry.java ## @@ -59,4 +59,38 @@ MicroserviceInstances findServiceInstances(String appId, String microserviceName Microservice getRemoteMicroservice(String microserviceId); Features getFeatures(); + + /** + * + * Register a third party service if not registered before, and set it's instances into + * {@linkplain org.apache.servicecomb.serviceregistry.consumer.StaticMicroserviceVersions StaticMicroserviceVersions}. + * + * + * The registered third party service has the same {@code appId} and {@code environment} as this microservice instance has, + * and there is only one schema represented by {@code schemaIntfCls}, whose name is the same as {@code microserviceName}. + * + * + * This method is for initializing 3rd party service endpoint config. + * i.e. If this service has not been registered before, this service will be registered and the instances will be set; + * otherwise, NOTHING will happen. + * + * + * @param microserviceName name of the 3rd party service, and this param also specifies the schemaId + * @param version version of this 3rd party service + * @param schemaIntfCls the producer interface of the service. This interface is used to generate swagger schema and + * can also be used for the proxy interface of RPC style invocation. + * @param instances the instances of this 3rd party service. Users only need to specify the endpoint information, other + * necessary information will be generate and set in the implementation of this method. + */ + void registerMicroserviceMapping(String microserviceName, String version, Class schemaIntfCls, Review comment: Fixed. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628894#comment-16628894 ] ASF GitHub Bot commented on SCB-926: yhs0092 closed pull request #926: [SCB-926] 3rd party invoke URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/926 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java index 70c66f89b..5ed1759c1 100644 --- a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java +++ b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java @@ -19,6 +19,7 @@ import org.apache.servicecomb.core.definition.MicroserviceMeta; import org.apache.servicecomb.core.definition.loader.SchemaListenerManager; +import org.apache.servicecomb.core.definition.schema.StaticSchemaFactory; import org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager; import org.apache.servicecomb.core.provider.producer.ProducerProviderManager; import org.apache.servicecomb.core.transport.TransportManager; @@ -74,6 +75,7 @@ public void onApplicationEvent(ApplicationEvent event) { SCBEngine.getInstance().setTransportManager(applicationContext.getBean(TransportManager.class)); SCBEngine.getInstance().setSchemaListenerManager(applicationContext.getBean(SchemaListenerManager.class)); SCBEngine.getInstance().setBootListenerList(applicationContext.getBeansOfType(BootListener.class).values()); + SCBEngine.getInstance().setStaticSchemaFactory(applicationContext.getBean(StaticSchemaFactory.class)); } SCBEngine.getInstance().init(); diff --git a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java index 4be7e7c7b..f364d1c6f 100644 --- a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java +++ b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java @@ -31,6 +31,7 @@ import org.apache.servicecomb.core.BootListener.EventType; import org.apache.servicecomb.core.definition.MicroserviceMeta; import org.apache.servicecomb.core.definition.loader.SchemaListenerManager; +import org.apache.servicecomb.core.definition.schema.StaticSchemaFactory; import org.apache.servicecomb.core.endpoint.AbstractEndpointsCache; import org.apache.servicecomb.core.event.InvocationFinishEvent; import org.apache.servicecomb.core.event.InvocationStartEvent; @@ -82,6 +83,8 @@ private EventBus eventBus = EventManager.getEventBus(); + private StaticSchemaFactory staticSchemaFactory; + private static final SCBEngine INSTANCE = new SCBEngine(); public void setStatus(SCBStatus status) { @@ -374,4 +377,12 @@ public void waitStatusUp(long msWait) throws InterruptedException, TimeoutExcept } } } + + public StaticSchemaFactory getStaticSchemaFactory() { +return staticSchemaFactory; + } + + public void setStaticSchemaFactory(StaticSchemaFactory staticSchemaFactory) { +this.staticSchemaFactory = staticSchemaFactory; + } } diff --git a/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java b/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java index a5eff5853..e4e27632b 100644 --- a/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java +++ b/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java @@ -20,10 +20,15 @@ import org.apache.servicecomb.core.CseContext; import org.apache.servicecomb.core.definition.classloader.MicroserviceClassLoaderFactory; import org.apache.servicecomb.serviceregistry.api.Const; +import org.apache.servicecomb.serviceregistry.api.registry.Microservice; import org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersion; public class MicroserviceVersionMeta extends MicroserviceVersion { - private MicroserviceMeta microserviceMeta; + MicroserviceMeta microserviceMeta; + + MicroserviceVersionMeta(Microservice microservice) { +super(microservice); + } public MicroserviceVersionMeta(String microserviceName, String microserviceId, MicroserviceClassLoaderFactory classLoaderFactory) { diff --git a/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVersionMeta.java b/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVersionMeta.java new file mode 100644 index 0..0fd866bc0 --- /dev/null +++ b/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVe
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628895#comment-16628895 ] ASF GitHub Bot commented on SCB-926: yhs0092 opened a new pull request #926: [SCB-926] 3rd party invoke URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/926 Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [x] Each commit in the pull request should have a meaningful subject line and body. - [x] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Run `mvn clean install` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [x] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628866#comment-16628866 ] ASF GitHub Bot commented on SCB-926: yhs0092 commented on issue #926: [SCB-926] 3rd party invoke URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/926#issuecomment-424738394 See [pull 915](https://github.com/apache/incubator-servicecomb-java-chassis/pull/915). This pull request is just for triggering Travis-CI This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628857#comment-16628857 ] ASF GitHub Bot commented on SCB-926: yhs0092 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r220585348 ## File path: service-registry/src/main/java/org/apache/servicecomb/serviceregistry/ServiceRegistry.java ## @@ -59,4 +59,38 @@ MicroserviceInstances findServiceInstances(String appId, String microserviceName Microservice getRemoteMicroservice(String microserviceId); Features getFeatures(); + + /** + * + * Register a third party service if not registered before, and set it's instances into + * {@linkplain org.apache.servicecomb.serviceregistry.consumer.StaticMicroserviceVersions StaticMicroserviceVersions}. + * + * + * The registered third party service has the same {@code appId} and {@code environment} as this microservice instance has, + * and there is only one schema represented by {@code schemaIntfCls}, whose name is the same as {@code microserviceName}. + * + * + * This method is for initializing 3rd party service endpoint config. + * i.e. If this service has not been registered before, this service will be registered and the instances will be set; + * otherwise, NOTHING will happen. + * + * + * @param microserviceName name of the 3rd party service, and this param also specifies the schemaId + * @param version version of this 3rd party service + * @param schemaIntfCls the producer interface of the service. This interface is used to generate swagger schema and + * can also be used for the proxy interface of RPC style invocation. + * @param instances the instances of this 3rd party service. Users only need to specify the endpoint information, other + * necessary information will be generate and set in the implementation of this method. + */ + void registerMicroserviceMapping(String microserviceName, String version, Class schemaIntfCls, Review comment: Yes, I think we should consider multiple schemas in the next step. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628837#comment-16628837 ] ASF GitHub Bot commented on SCB-926: coveralls edited a comment on issue #926: [SCB-926] 3rd party invoke URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/926#issuecomment-424679119 [![Coverage Status](https://coveralls.io/builds/19201690/badge)](https://coveralls.io/builds/19201690) Coverage increased (+0.08%) to 86.272% when pulling **49bd8bf939b0520af36cbbafebee9e9ea29abd80 on yhs0092:3rd_party_invoke** into **55854d47ad2689070a098121ca0bea47acf3d707 on apache:master**. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628818#comment-16628818 ] ASF GitHub Bot commented on SCB-926: yhs0092 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r220576778 ## File path: core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java ## @@ -20,10 +20,15 @@ import org.apache.servicecomb.core.CseContext; import org.apache.servicecomb.core.definition.classloader.MicroserviceClassLoaderFactory; import org.apache.servicecomb.serviceregistry.api.Const; +import org.apache.servicecomb.serviceregistry.api.registry.Microservice; import org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersion; public class MicroserviceVersionMeta extends MicroserviceVersion { - private MicroserviceMeta microserviceMeta; + MicroserviceMeta microserviceMeta; + + MicroserviceVersionMeta(Microservice microservice) { Review comment: `microserviceMeta` in `MicroserviceVersionMeta` is initialized in constructors and has package access modifier which ensures that the classes out of its package can only get access to it by getter method. So I think NPE can be avoid since users can only get `microserviceMeta` after it is initialized. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628809#comment-16628809 ] ASF GitHub Bot commented on SCB-926: yhs0092 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r220571800 ## File path: core/src/main/java/org/apache/servicecomb/core/definition/schema/AbstractSchemaFactory.java ## @@ -45,6 +48,8 @@ @Inject protected CompositeSwaggerGeneratorContext compositeSwaggerGeneratorContext; + private ObjectWriter writer = Yaml.pretty(); Review comment: Yes, has been fixed. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628781#comment-16628781 ] ASF GitHub Bot commented on SCB-926: yhs0092 opened a new pull request #926: [SCB-926] 3rd party invoke URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/926 Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [x] Each commit in the pull request should have a meaningful subject line and body. - [x] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Run `mvn clean install` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [x] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628779#comment-16628779 ] ASF GitHub Bot commented on SCB-926: yhs0092 closed pull request #926: [SCB-926] 3rd party invoke URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/926 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java index 70c66f89b..5ed1759c1 100644 --- a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java +++ b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java @@ -19,6 +19,7 @@ import org.apache.servicecomb.core.definition.MicroserviceMeta; import org.apache.servicecomb.core.definition.loader.SchemaListenerManager; +import org.apache.servicecomb.core.definition.schema.StaticSchemaFactory; import org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager; import org.apache.servicecomb.core.provider.producer.ProducerProviderManager; import org.apache.servicecomb.core.transport.TransportManager; @@ -74,6 +75,7 @@ public void onApplicationEvent(ApplicationEvent event) { SCBEngine.getInstance().setTransportManager(applicationContext.getBean(TransportManager.class)); SCBEngine.getInstance().setSchemaListenerManager(applicationContext.getBean(SchemaListenerManager.class)); SCBEngine.getInstance().setBootListenerList(applicationContext.getBeansOfType(BootListener.class).values()); + SCBEngine.getInstance().setStaticSchemaFactory(applicationContext.getBean(StaticSchemaFactory.class)); } SCBEngine.getInstance().init(); diff --git a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java index 4be7e7c7b..f364d1c6f 100644 --- a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java +++ b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java @@ -31,6 +31,7 @@ import org.apache.servicecomb.core.BootListener.EventType; import org.apache.servicecomb.core.definition.MicroserviceMeta; import org.apache.servicecomb.core.definition.loader.SchemaListenerManager; +import org.apache.servicecomb.core.definition.schema.StaticSchemaFactory; import org.apache.servicecomb.core.endpoint.AbstractEndpointsCache; import org.apache.servicecomb.core.event.InvocationFinishEvent; import org.apache.servicecomb.core.event.InvocationStartEvent; @@ -82,6 +83,8 @@ private EventBus eventBus = EventManager.getEventBus(); + private StaticSchemaFactory staticSchemaFactory; + private static final SCBEngine INSTANCE = new SCBEngine(); public void setStatus(SCBStatus status) { @@ -374,4 +377,12 @@ public void waitStatusUp(long msWait) throws InterruptedException, TimeoutExcept } } } + + public StaticSchemaFactory getStaticSchemaFactory() { +return staticSchemaFactory; + } + + public void setStaticSchemaFactory(StaticSchemaFactory staticSchemaFactory) { +this.staticSchemaFactory = staticSchemaFactory; + } } diff --git a/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java b/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java index a5eff5853..e4e27632b 100644 --- a/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java +++ b/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java @@ -20,10 +20,15 @@ import org.apache.servicecomb.core.CseContext; import org.apache.servicecomb.core.definition.classloader.MicroserviceClassLoaderFactory; import org.apache.servicecomb.serviceregistry.api.Const; +import org.apache.servicecomb.serviceregistry.api.registry.Microservice; import org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersion; public class MicroserviceVersionMeta extends MicroserviceVersion { - private MicroserviceMeta microserviceMeta; + MicroserviceMeta microserviceMeta; + + MicroserviceVersionMeta(Microservice microservice) { +super(microservice); + } public MicroserviceVersionMeta(String microserviceName, String microserviceId, MicroserviceClassLoaderFactory classLoaderFactory) { diff --git a/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVersionMeta.java b/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVersionMeta.java new file mode 100644 index 0..0fd866bc0 --- /dev/null +++ b/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVe
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628708#comment-16628708 ] ASF GitHub Bot commented on SCB-926: liubao68 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r220547270 ## File path: service-registry/src/main/java/org/apache/servicecomb/serviceregistry/ServiceRegistry.java ## @@ -59,4 +59,38 @@ MicroserviceInstances findServiceInstances(String appId, String microserviceName Microservice getRemoteMicroservice(String microserviceId); Features getFeatures(); + + /** + * + * Register a third party service if not registered before, and set it's instances into + * {@linkplain org.apache.servicecomb.serviceregistry.consumer.StaticMicroserviceVersions StaticMicroserviceVersions}. + * + * + * The registered third party service has the same {@code appId} and {@code environment} as this microservice instance has, + * and there is only one schema represented by {@code schemaIntfCls}, whose name is the same as {@code microserviceName}. + * + * + * This method is for initializing 3rd party service endpoint config. + * i.e. If this service has not been registered before, this service will be registered and the instances will be set; + * otherwise, NOTHING will happen. + * + * + * @param microserviceName name of the 3rd party service, and this param also specifies the schemaId + * @param version version of this 3rd party service + * @param schemaIntfCls the producer interface of the service. This interface is used to generate swagger schema and + * can also be used for the proxy interface of RPC style invocation. + * @param instances the instances of this 3rd party service. Users only need to specify the endpoint information, other + * necessary information will be generate and set in the implementation of this method. + */ + void registerMicroserviceMapping(String microserviceName, String version, Class schemaIntfCls, Review comment: It's better to put schemaIntfCls as last parameter, since we can extend it to schemaIntfCls... to support several schemas. I think this is quite normal in many scenarios like register a gateway service as a third party service. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628698#comment-16628698 ] ASF GitHub Bot commented on SCB-926: liubao68 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r220543507 ## File path: core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java ## @@ -20,10 +20,15 @@ import org.apache.servicecomb.core.CseContext; import org.apache.servicecomb.core.definition.classloader.MicroserviceClassLoaderFactory; import org.apache.servicecomb.serviceregistry.api.Const; +import org.apache.servicecomb.serviceregistry.api.registry.Microservice; import org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersion; public class MicroserviceVersionMeta extends MicroserviceVersion { - private MicroserviceMeta microserviceMeta; + MicroserviceMeta microserviceMeta; + + MicroserviceVersionMeta(Microservice microservice) { Review comment: microserviceMeta is not initialized, and getMicroserviceMeta may return null and cause NPE. From the following code, I think it's better to define the method protected that should be overrided by sub class. Or remove this constructor and define microserviceMeta to be protected. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628694#comment-16628694 ] ASF GitHub Bot commented on SCB-926: liubao68 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r220543507 ## File path: core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java ## @@ -20,10 +20,15 @@ import org.apache.servicecomb.core.CseContext; import org.apache.servicecomb.core.definition.classloader.MicroserviceClassLoaderFactory; import org.apache.servicecomb.serviceregistry.api.Const; +import org.apache.servicecomb.serviceregistry.api.registry.Microservice; import org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersion; public class MicroserviceVersionMeta extends MicroserviceVersion { - private MicroserviceMeta microserviceMeta; + MicroserviceMeta microserviceMeta; + + MicroserviceVersionMeta(Microservice microservice) { Review comment: microserviceMeta is not initialized, and getMicroserviceMeta may return null and cause NPE. From the following code, I think it's better to define the method protected that should be override by sub class. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628695#comment-16628695 ] ASF GitHub Bot commented on SCB-926: liubao68 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r220543507 ## File path: core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java ## @@ -20,10 +20,15 @@ import org.apache.servicecomb.core.CseContext; import org.apache.servicecomb.core.definition.classloader.MicroserviceClassLoaderFactory; import org.apache.servicecomb.serviceregistry.api.Const; +import org.apache.servicecomb.serviceregistry.api.registry.Microservice; import org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersion; public class MicroserviceVersionMeta extends MicroserviceVersion { - private MicroserviceMeta microserviceMeta; + MicroserviceMeta microserviceMeta; + + MicroserviceVersionMeta(Microservice microservice) { Review comment: microserviceMeta is not initialized, and getMicroserviceMeta may return null and cause NPE. From the following code, I think it's better to define the method protected that should be overrided by sub class. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628690#comment-16628690 ] ASF GitHub Bot commented on SCB-926: liubao68 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r220543507 ## File path: core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java ## @@ -20,10 +20,15 @@ import org.apache.servicecomb.core.CseContext; import org.apache.servicecomb.core.definition.classloader.MicroserviceClassLoaderFactory; import org.apache.servicecomb.serviceregistry.api.Const; +import org.apache.servicecomb.serviceregistry.api.registry.Microservice; import org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersion; public class MicroserviceVersionMeta extends MicroserviceVersion { - private MicroserviceMeta microserviceMeta; + MicroserviceMeta microserviceMeta; + + MicroserviceVersionMeta(Microservice microservice) { Review comment: microserviceMeta is not initialized, and getMicroserviceMeta may return null and cause NPE. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628671#comment-16628671 ] ASF GitHub Bot commented on SCB-926: liubao68 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r220534817 ## File path: core/src/main/java/org/apache/servicecomb/core/definition/schema/AbstractSchemaFactory.java ## @@ -45,6 +48,8 @@ @Inject protected CompositeSwaggerGeneratorContext compositeSwaggerGeneratorContext; + private ObjectWriter writer = Yaml.pretty(); Review comment: unused code? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628603#comment-16628603 ] ASF GitHub Bot commented on SCB-926: coveralls commented on issue #926: [SCB-926] 3rd party invoke URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/926#issuecomment-424679119 [![Coverage Status](https://coveralls.io/builds/19198871/badge)](https://coveralls.io/builds/19198871) Coverage increased (+0.07%) to 86.281% when pulling **9c233d6d2b418cf35c40bd8a3abef38be186318e on yhs0092:3rd_party_invoke** into **20627dd0af924dcdf51fe529afe49e51864dc18c on apache:master**. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628581#comment-16628581 ] ASF GitHub Bot commented on SCB-926: yhs0092 opened a new pull request #926: [SCB-926] 3rd party invoke URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/926 Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [x] Each commit in the pull request should have a meaningful subject line and body. - [x] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Run `mvn clean install` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [x] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628298#comment-16628298 ] ASF GitHub Bot commented on SCB-926: yhs0092 opened a new pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915 Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [x] Each commit in the pull request should have a meaningful subject line and body. - [x] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Run `mvn clean install` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- Support invoking 3rd party service just like invoking ServiceComb microservice registered in service-center. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628296#comment-16628296 ] ASF GitHub Bot commented on SCB-926: yhs0092 closed pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java index 70c66f89b..5ed1759c1 100644 --- a/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java +++ b/core/src/main/java/org/apache/servicecomb/core/CseApplicationListener.java @@ -19,6 +19,7 @@ import org.apache.servicecomb.core.definition.MicroserviceMeta; import org.apache.servicecomb.core.definition.loader.SchemaListenerManager; +import org.apache.servicecomb.core.definition.schema.StaticSchemaFactory; import org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager; import org.apache.servicecomb.core.provider.producer.ProducerProviderManager; import org.apache.servicecomb.core.transport.TransportManager; @@ -74,6 +75,7 @@ public void onApplicationEvent(ApplicationEvent event) { SCBEngine.getInstance().setTransportManager(applicationContext.getBean(TransportManager.class)); SCBEngine.getInstance().setSchemaListenerManager(applicationContext.getBean(SchemaListenerManager.class)); SCBEngine.getInstance().setBootListenerList(applicationContext.getBeansOfType(BootListener.class).values()); + SCBEngine.getInstance().setStaticSchemaFactory(applicationContext.getBean(StaticSchemaFactory.class)); } SCBEngine.getInstance().init(); diff --git a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java index 4be7e7c7b..f364d1c6f 100644 --- a/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java +++ b/core/src/main/java/org/apache/servicecomb/core/SCBEngine.java @@ -31,6 +31,7 @@ import org.apache.servicecomb.core.BootListener.EventType; import org.apache.servicecomb.core.definition.MicroserviceMeta; import org.apache.servicecomb.core.definition.loader.SchemaListenerManager; +import org.apache.servicecomb.core.definition.schema.StaticSchemaFactory; import org.apache.servicecomb.core.endpoint.AbstractEndpointsCache; import org.apache.servicecomb.core.event.InvocationFinishEvent; import org.apache.servicecomb.core.event.InvocationStartEvent; @@ -82,6 +83,8 @@ private EventBus eventBus = EventManager.getEventBus(); + private StaticSchemaFactory staticSchemaFactory; + private static final SCBEngine INSTANCE = new SCBEngine(); public void setStatus(SCBStatus status) { @@ -374,4 +377,12 @@ public void waitStatusUp(long msWait) throws InterruptedException, TimeoutExcept } } } + + public StaticSchemaFactory getStaticSchemaFactory() { +return staticSchemaFactory; + } + + public void setStaticSchemaFactory(StaticSchemaFactory staticSchemaFactory) { +this.staticSchemaFactory = staticSchemaFactory; + } } diff --git a/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java b/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java index a5eff5853..e4e27632b 100644 --- a/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java +++ b/core/src/main/java/org/apache/servicecomb/core/definition/MicroserviceVersionMeta.java @@ -20,10 +20,15 @@ import org.apache.servicecomb.core.CseContext; import org.apache.servicecomb.core.definition.classloader.MicroserviceClassLoaderFactory; import org.apache.servicecomb.serviceregistry.api.Const; +import org.apache.servicecomb.serviceregistry.api.registry.Microservice; import org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersion; public class MicroserviceVersionMeta extends MicroserviceVersion { - private MicroserviceMeta microserviceMeta; + MicroserviceMeta microserviceMeta; + + MicroserviceVersionMeta(Microservice microservice) { +super(microservice); + } public MicroserviceVersionMeta(String microserviceName, String microserviceId, MicroserviceClassLoaderFactory classLoaderFactory) { diff --git a/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVersionMeta.java b/core/src/main/java/org/apache/servicecomb/core/definition/StaticMicroserviceVersionMeta.java new file mode 100644 index 0..0fd866bc0 --- /dev/null +++ b/core/src/main/java/org/apache/servicecomb/core/definition/Sta
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16625698#comment-16625698 ] ASF GitHub Bot commented on SCB-926: yhs0092 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r219806264 ## File path: integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/thirdparty/Test3rdPartyInvocation.java ## @@ -0,0 +1,244 @@ +/* + * 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.servicecomb.it.testcase.thirdparty; + +import java.util.Collections; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +import javax.ws.rs.CookieParam; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; +import javax.xml.ws.Holder; + +import org.apache.servicecomb.it.extend.engine.GateRestTemplate; +import org.apache.servicecomb.provider.pojo.Invoker; +import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder; +import org.apache.servicecomb.provider.springmvc.reference.async.CseAsyncRestTemplate; +import org.apache.servicecomb.serviceregistry.RegistryUtils; +import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.util.concurrent.ListenableFuture; +import org.springframework.web.client.RestTemplate; + +public class Test3rdPartyInvocation { + + private static final String THIRD_PARTY_MICROSERVICE_NAME = "3rdPartyDataTypeJaxrs"; + + private static final String ASYNC_THIRD_PARTY_MICROSERVICE_NAME = THIRD_PARTY_MICROSERVICE_NAME + "Async"; + + // to get endpoint from urlPrefix + static GateRestTemplate rt = (GateRestTemplate) GateRestTemplate.createEdgeRestTemplate("dataTypeJaxrs"); + + private static DataTypeJaxrsSchemaIntf dataTypeJaxrsSchema; + + private static DataTypeJaxrsSchemaAsyncIntf dataTypeJaxrsSchemaAsync; + + @BeforeClass + public static void beforeClass() { +String urlPrefix = rt.getUrlPrefix(); +int beginIndex = urlPrefix.indexOf("//"); +int endIndex = urlPrefix.indexOf("/", beginIndex + 3); +String endpoint = "rest:" + urlPrefix.substring(beginIndex, endIndex); +RegistryUtils.getServiceRegistry() +.registryMicroserviceMappingByEndpoints( +THIRD_PARTY_MICROSERVICE_NAME, "1.2.1", DataTypeJaxrsSchemaIntf.class, +Collections.singletonList(endpoint)); + +MicroserviceInstance instance = new MicroserviceInstance(); +instance.setEndpoints(Collections.singletonList(endpoint)); +RegistryUtils.getServiceRegistry() Review comment: I've asked wujimin's opinion and maybe we can have a new discussion on the scenario that there are microservices registered in sc with only instance info but no schema. This issue is planned to provide the basic ability to invoke 3rd party service. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16625695#comment-16625695 ] ASF GitHub Bot commented on SCB-926: yhs0092 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r219805724 ## File path: core/src/main/java/org/apache/servicecomb/core/definition/schema/AbstractSchemaFactory.java ## @@ -103,4 +109,12 @@ protected SwaggerGenerator generateSwagger(CONTEXT context) { return generator; } + + protected String getSwaggerContent(Swagger swagger) { Review comment: Fixed. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16625694#comment-16625694 ] ASF GitHub Bot commented on SCB-926: yhs0092 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r219805614 ## File path: core/src/main/java/org/apache/servicecomb/core/CseContext.java ## @@ -40,6 +41,8 @@ public static CseContext getInstance() { private ConsumerSchemaFactory consumerSchemaFactory; + private StaticSchemaFactory staticSchemaFactory; Review comment: Fixed. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16625693#comment-16625693 ] ASF GitHub Bot commented on SCB-926: yhs0092 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r219805512 ## File path: integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/thirdparty/Test3rdPartyInvocation.java ## @@ -0,0 +1,244 @@ +/* + * 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.servicecomb.it.testcase.thirdparty; + +import java.util.Collections; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +import javax.ws.rs.CookieParam; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; +import javax.xml.ws.Holder; + +import org.apache.servicecomb.it.extend.engine.GateRestTemplate; +import org.apache.servicecomb.provider.pojo.Invoker; +import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder; +import org.apache.servicecomb.provider.springmvc.reference.async.CseAsyncRestTemplate; +import org.apache.servicecomb.serviceregistry.RegistryUtils; +import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.util.concurrent.ListenableFuture; +import org.springframework.web.client.RestTemplate; + +public class Test3rdPartyInvocation { + + private static final String THIRD_PARTY_MICROSERVICE_NAME = "3rdPartyDataTypeJaxrs"; + + private static final String ASYNC_THIRD_PARTY_MICROSERVICE_NAME = THIRD_PARTY_MICROSERVICE_NAME + "Async"; + + // to get endpoint from urlPrefix + static GateRestTemplate rt = (GateRestTemplate) GateRestTemplate.createEdgeRestTemplate("dataTypeJaxrs"); + + private static DataTypeJaxrsSchemaIntf dataTypeJaxrsSchema; + + private static DataTypeJaxrsSchemaAsyncIntf dataTypeJaxrsSchemaAsync; + + @BeforeClass + public static void beforeClass() { +String urlPrefix = rt.getUrlPrefix(); +int beginIndex = urlPrefix.indexOf("//"); +int endIndex = urlPrefix.indexOf("/", beginIndex + 3); +String endpoint = "rest:" + urlPrefix.substring(beginIndex, endIndex); +RegistryUtils.getServiceRegistry() +.registryMicroserviceMappingByEndpoints( +THIRD_PARTY_MICROSERVICE_NAME, "1.2.1", DataTypeJaxrsSchemaIntf.class, +Collections.singletonList(endpoint)); + +MicroserviceInstance instance = new MicroserviceInstance(); +instance.setEndpoints(Collections.singletonList(endpoint)); +RegistryUtils.getServiceRegistry() +.registryMicroserviceMapping( +ASYNC_THIRD_PARTY_MICROSERVICE_NAME, "1.1.1", DataTypeJaxrsSchemaAsyncIntf.class, +Collections.singletonList(instance) +); + +dataTypeJaxrsSchema = Invoker.createProxy( +THIRD_PARTY_MICROSERVICE_NAME, THIRD_PARTY_MICROSERVICE_NAME, DataTypeJaxrsSchemaIntf.class); +dataTypeJaxrsSchemaAsync = Invoker.createProxy( +ASYNC_THIRD_PARTY_MICROSERVICE_NAME, ASYNC_THIRD_PARTY_MICROSERVICE_NAME, DataTypeJaxrsSchemaAsyncIntf.class); + } + + @Test + public void testSyncInvoke_RPC() { +Assert.assertEquals(1, dataTypeJaxrsSchema.intPath(1)); +Assert.assertEquals(2, dataTypeJaxrsSchema.intQuery(2)); +Assert.assertEquals(3, dataTypeJaxrsSchema.intHeader(3)); +Assert.assertEquals(4, dataTypeJaxrsSchema.intCookie(4)); +Assert.assertEquals(5, dataTypeJaxrsSchema.intForm(5)); +Assert.assertEquals(6, dataTypeJaxrsSchema.intBody(6)); +Assert.assertEquals(7, dataTypeJaxrsSchema.add(3, 4)); +Assert.assertEquals("abc", dataTypeJaxrsSchema.stringPath("abc")); +Assert.assertEquals("def", dat
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16625691#comment-16625691 ] ASF GitHub Bot commented on SCB-926: yhs0092 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r219804658 ## File path: service-registry/src/main/java/org/apache/servicecomb/serviceregistry/registry/AbstractServiceRegistry.java ## @@ -303,4 +307,30 @@ public void destroy() { eventBus.post(new ShutdownEvent()); unregisterInstance(); } + + @Override + public void registryMicroserviceMapping(String microserviceName, String version, Class schemaIntfCls, + List instances) { +String app = RegistryUtils.getAppId(); +MicroserviceManager microserviceManager = appManager.getOrCreateMicroserviceManager(app); +StaticMicroserviceVersions microserviceVersions = +(StaticMicroserviceVersions) microserviceManager.getVersionsByName() +.computeIfAbsent(microserviceName, +svcName -> new StaticMicroserviceVersions(this.appManager, app, microserviceName, schemaIntfCls)); + +microserviceVersions.addInstances(version, instances); Review comment: `addInstances` is put inside `computeIfAbsent`. Currently only initial instance method is provided. Users cannot re-set instance info of a 3rd party service. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16625684#comment-16625684 ] ASF GitHub Bot commented on SCB-926: yhs0092 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r219804062 ## File path: service-registry/src/main/java/org/apache/servicecomb/serviceregistry/ServiceRegistry.java ## @@ -59,4 +59,31 @@ MicroserviceInstances findServiceInstances(String appId, String microserviceName Microservice getRemoteMicroservice(String microserviceId); Features getFeatures(); + + /** + * + * Register a third party service if not registered before, and add it's instances into + * {@linkplain org.apache.servicecomb.serviceregistry.consumer.StaticMicroserviceVersions StaticMicroserviceVersions}. + * + * + * The registered third party service has the same {@code appId} and {@code environment} as this microservice instance has, + * and there is only one schema represented by {@code schemaIntfCls}, whose name is the same as {@code microserviceName}. + * + * + * @param microserviceName name of the 3rd party service, and this param also specifies the schemaId + * @param version version of this 3rd party service + * @param schemaIntfCls the producer interface of the service. This interface is used to generate swagger schema and + * can also be used for the proxy interface of RPC style invocation. + * @param instances the instances of this 3rd party service. Users only need to specify the endpoint information, other + * necessary information will be generate and set in the implementation of this method. + */ + void registryMicroserviceMapping(String microserviceName, String version, Class schemaIntfCls, + List instances); + + /** + * @see #registryMicroserviceMapping(String, String, Class, List) + * @param endpoints the endpoints of 3rd party service. Each of endpoints will be treated as a separated instance. Review comment: Yes, the example is added in the comment of method `registerMicroserviceMappingByEndpoints` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16621467#comment-16621467 ] ASF GitHub Bot commented on SCB-926: liubao68 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r219026316 ## File path: integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/thirdparty/Test3rdPartyInvocation.java ## @@ -0,0 +1,244 @@ +/* + * 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.servicecomb.it.testcase.thirdparty; + +import java.util.Collections; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +import javax.ws.rs.CookieParam; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; +import javax.xml.ws.Holder; + +import org.apache.servicecomb.it.extend.engine.GateRestTemplate; +import org.apache.servicecomb.provider.pojo.Invoker; +import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder; +import org.apache.servicecomb.provider.springmvc.reference.async.CseAsyncRestTemplate; +import org.apache.servicecomb.serviceregistry.RegistryUtils; +import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.util.concurrent.ListenableFuture; +import org.springframework.web.client.RestTemplate; + +public class Test3rdPartyInvocation { + + private static final String THIRD_PARTY_MICROSERVICE_NAME = "3rdPartyDataTypeJaxrs"; + + private static final String ASYNC_THIRD_PARTY_MICROSERVICE_NAME = THIRD_PARTY_MICROSERVICE_NAME + "Async"; + + // to get endpoint from urlPrefix + static GateRestTemplate rt = (GateRestTemplate) GateRestTemplate.createEdgeRestTemplate("dataTypeJaxrs"); + + private static DataTypeJaxrsSchemaIntf dataTypeJaxrsSchema; + + private static DataTypeJaxrsSchemaAsyncIntf dataTypeJaxrsSchemaAsync; + + @BeforeClass + public static void beforeClass() { +String urlPrefix = rt.getUrlPrefix(); +int beginIndex = urlPrefix.indexOf("//"); +int endIndex = urlPrefix.indexOf("/", beginIndex + 3); +String endpoint = "rest:" + urlPrefix.substring(beginIndex, endIndex); +RegistryUtils.getServiceRegistry() +.registryMicroserviceMappingByEndpoints( +THIRD_PARTY_MICROSERVICE_NAME, "1.2.1", DataTypeJaxrsSchemaIntf.class, +Collections.singletonList(endpoint)); + +MicroserviceInstance instance = new MicroserviceInstance(); +instance.setEndpoints(Collections.singletonList(endpoint)); +RegistryUtils.getServiceRegistry() Review comment: There are two scenarios need to consider: 1. consumers register producers endpoints and schemas 2. consumers register only schemas, this is quite common in mesher mode which the service is already registered to service center but schemas are not, and used very widely Can we provide scenario 2 support? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16621465#comment-16621465 ] ASF GitHub Bot commented on SCB-926: liubao68 commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r219026316 ## File path: integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/thirdparty/Test3rdPartyInvocation.java ## @@ -0,0 +1,244 @@ +/* + * 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.servicecomb.it.testcase.thirdparty; + +import java.util.Collections; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +import javax.ws.rs.CookieParam; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; +import javax.xml.ws.Holder; + +import org.apache.servicecomb.it.extend.engine.GateRestTemplate; +import org.apache.servicecomb.provider.pojo.Invoker; +import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder; +import org.apache.servicecomb.provider.springmvc.reference.async.CseAsyncRestTemplate; +import org.apache.servicecomb.serviceregistry.RegistryUtils; +import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.util.concurrent.ListenableFuture; +import org.springframework.web.client.RestTemplate; + +public class Test3rdPartyInvocation { + + private static final String THIRD_PARTY_MICROSERVICE_NAME = "3rdPartyDataTypeJaxrs"; + + private static final String ASYNC_THIRD_PARTY_MICROSERVICE_NAME = THIRD_PARTY_MICROSERVICE_NAME + "Async"; + + // to get endpoint from urlPrefix + static GateRestTemplate rt = (GateRestTemplate) GateRestTemplate.createEdgeRestTemplate("dataTypeJaxrs"); + + private static DataTypeJaxrsSchemaIntf dataTypeJaxrsSchema; + + private static DataTypeJaxrsSchemaAsyncIntf dataTypeJaxrsSchemaAsync; + + @BeforeClass + public static void beforeClass() { +String urlPrefix = rt.getUrlPrefix(); +int beginIndex = urlPrefix.indexOf("//"); +int endIndex = urlPrefix.indexOf("/", beginIndex + 3); +String endpoint = "rest:" + urlPrefix.substring(beginIndex, endIndex); +RegistryUtils.getServiceRegistry() +.registryMicroserviceMappingByEndpoints( +THIRD_PARTY_MICROSERVICE_NAME, "1.2.1", DataTypeJaxrsSchemaIntf.class, +Collections.singletonList(endpoint)); + +MicroserviceInstance instance = new MicroserviceInstance(); +instance.setEndpoints(Collections.singletonList(endpoint)); +RegistryUtils.getServiceRegistry() Review comment: There are two scenarios need to consider: 1. consumers register producers endpoints and schemas 2. consumers register only schemas, this is quite common in mesher mode, and used very widely Can we provide scenario 2 support? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservic
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16620965#comment-16620965 ] ASF GitHub Bot commented on SCB-926: wujimin commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r218903985 ## File path: core/src/main/java/org/apache/servicecomb/core/definition/schema/AbstractSchemaFactory.java ## @@ -103,4 +109,12 @@ protected SwaggerGenerator generateSwagger(CONTEXT context) { return generator; } + + protected String getSwaggerContent(Swagger swagger) { Review comment: can we just use SwaggerUtils? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16620956#comment-16620956 ] ASF GitHub Bot commented on SCB-926: wujimin commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r218903137 ## File path: core/src/main/java/org/apache/servicecomb/core/CseContext.java ## @@ -40,6 +41,8 @@ public static CseContext getInstance() { private ConsumerSchemaFactory consumerSchemaFactory; + private StaticSchemaFactory staticSchemaFactory; Review comment: CseContext will de Deprecated, use ScbEngine This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16620952#comment-16620952 ] ASF GitHub Bot commented on SCB-926: wujimin commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r218902062 ## File path: integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/thirdparty/Test3rdPartyInvocation.java ## @@ -0,0 +1,244 @@ +/* + * 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.servicecomb.it.testcase.thirdparty; + +import java.util.Collections; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +import javax.ws.rs.CookieParam; +import javax.ws.rs.FormParam; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; +import javax.xml.ws.Holder; + +import org.apache.servicecomb.it.extend.engine.GateRestTemplate; +import org.apache.servicecomb.provider.pojo.Invoker; +import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder; +import org.apache.servicecomb.provider.springmvc.reference.async.CseAsyncRestTemplate; +import org.apache.servicecomb.serviceregistry.RegistryUtils; +import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.util.concurrent.ListenableFuture; +import org.springframework.web.client.RestTemplate; + +public class Test3rdPartyInvocation { + + private static final String THIRD_PARTY_MICROSERVICE_NAME = "3rdPartyDataTypeJaxrs"; + + private static final String ASYNC_THIRD_PARTY_MICROSERVICE_NAME = THIRD_PARTY_MICROSERVICE_NAME + "Async"; + + // to get endpoint from urlPrefix + static GateRestTemplate rt = (GateRestTemplate) GateRestTemplate.createEdgeRestTemplate("dataTypeJaxrs"); + + private static DataTypeJaxrsSchemaIntf dataTypeJaxrsSchema; + + private static DataTypeJaxrsSchemaAsyncIntf dataTypeJaxrsSchemaAsync; + + @BeforeClass + public static void beforeClass() { +String urlPrefix = rt.getUrlPrefix(); +int beginIndex = urlPrefix.indexOf("//"); +int endIndex = urlPrefix.indexOf("/", beginIndex + 3); +String endpoint = "rest:" + urlPrefix.substring(beginIndex, endIndex); +RegistryUtils.getServiceRegistry() +.registryMicroserviceMappingByEndpoints( +THIRD_PARTY_MICROSERVICE_NAME, "1.2.1", DataTypeJaxrsSchemaIntf.class, +Collections.singletonList(endpoint)); + +MicroserviceInstance instance = new MicroserviceInstance(); +instance.setEndpoints(Collections.singletonList(endpoint)); +RegistryUtils.getServiceRegistry() +.registryMicroserviceMapping( +ASYNC_THIRD_PARTY_MICROSERVICE_NAME, "1.1.1", DataTypeJaxrsSchemaAsyncIntf.class, +Collections.singletonList(instance) +); + +dataTypeJaxrsSchema = Invoker.createProxy( +THIRD_PARTY_MICROSERVICE_NAME, THIRD_PARTY_MICROSERVICE_NAME, DataTypeJaxrsSchemaIntf.class); +dataTypeJaxrsSchemaAsync = Invoker.createProxy( +ASYNC_THIRD_PARTY_MICROSERVICE_NAME, ASYNC_THIRD_PARTY_MICROSERVICE_NAME, DataTypeJaxrsSchemaAsyncIntf.class); + } + + @Test + public void testSyncInvoke_RPC() { +Assert.assertEquals(1, dataTypeJaxrsSchema.intPath(1)); +Assert.assertEquals(2, dataTypeJaxrsSchema.intQuery(2)); +Assert.assertEquals(3, dataTypeJaxrsSchema.intHeader(3)); +Assert.assertEquals(4, dataTypeJaxrsSchema.intCookie(4)); +Assert.assertEquals(5, dataTypeJaxrsSchema.intForm(5)); +Assert.assertEquals(6, dataTypeJaxrsSchema.intBody(6)); +Assert.assertEquals(7, dataTypeJaxrsSchema.add(3, 4)); +Assert.assertEquals("abc", dataTypeJaxrsSchema.stringPath("abc")); +Assert.assertEquals("def", dat
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16620670#comment-16620670 ] ASF GitHub Bot commented on SCB-926: wujimin commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r218826807 ## File path: service-registry/src/main/java/org/apache/servicecomb/serviceregistry/registry/AbstractServiceRegistry.java ## @@ -303,4 +307,30 @@ public void destroy() { eventBus.post(new ShutdownEvent()); unregisterInstance(); } + + @Override + public void registryMicroserviceMapping(String microserviceName, String version, Class schemaIntfCls, + List instances) { +String app = RegistryUtils.getAppId(); +MicroserviceManager microserviceManager = appManager.getOrCreateMicroserviceManager(app); +StaticMicroserviceVersions microserviceVersions = +(StaticMicroserviceVersions) microserviceManager.getVersionsByName() +.computeIfAbsent(microserviceName, +svcName -> new StaticMicroserviceVersions(this.appManager, app, microserviceName, schemaIntfCls)); + +microserviceVersions.addInstances(version, instances); Review comment: addInstances should put inside computeIfAbsent? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16620668#comment-16620668 ] ASF GitHub Bot commented on SCB-926: wujimin commented on a change in pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#discussion_r218826063 ## File path: service-registry/src/main/java/org/apache/servicecomb/serviceregistry/ServiceRegistry.java ## @@ -59,4 +59,31 @@ MicroserviceInstances findServiceInstances(String appId, String microserviceName Microservice getRemoteMicroservice(String microserviceId); Features getFeatures(); + + /** + * + * Register a third party service if not registered before, and add it's instances into + * {@linkplain org.apache.servicecomb.serviceregistry.consumer.StaticMicroserviceVersions StaticMicroserviceVersions}. + * + * + * The registered third party service has the same {@code appId} and {@code environment} as this microservice instance has, + * and there is only one schema represented by {@code schemaIntfCls}, whose name is the same as {@code microserviceName}. + * + * + * @param microserviceName name of the 3rd party service, and this param also specifies the schemaId + * @param version version of this 3rd party service + * @param schemaIntfCls the producer interface of the service. This interface is used to generate swagger schema and + * can also be used for the proxy interface of RPC style invocation. + * @param instances the instances of this 3rd party service. Users only need to specify the endpoint information, other + * necessary information will be generate and set in the implementation of this method. + */ + void registryMicroserviceMapping(String microserviceName, String version, Class schemaIntfCls, + List instances); + + /** + * @see #registryMicroserviceMapping(String, String, Class, List) + * @param endpoints the endpoints of 3rd party service. Each of endpoints will be treated as a separated instance. Review comment: add example for endpoint? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16620365#comment-16620365 ] ASF GitHub Bot commented on SCB-926: coveralls commented on issue #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915#issuecomment-422726102 [![Coverage Status](https://coveralls.io/builds/19076089/badge)](https://coveralls.io/builds/19076089) Coverage increased (+0.08%) to 86.194% when pulling **f210638ff6b67f95f71ab8db8c97e293ec5a7ce8 on yhs0092:3rd_party_invocation** into **c019638318ba2556e53e55c26d51b4bb607d9600 on apache:master**. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-926) Invoke 3rd party service
[ https://issues.apache.org/jira/browse/SCB-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16620339#comment-16620339 ] ASF GitHub Bot commented on SCB-926: yhs0092 opened a new pull request #915: [SCB-926] support invoking 3rd party service URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/915 Follow this checklist to help us incorporate your contribution quickly and easily: - [x] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [x] Each commit in the pull request should have a meaningful subject line and body. - [x] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Run `mvn clean install` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- Support invoking 3rd party service just like invoking ServiceComb microservice registered in service-center. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Invoke 3rd party service > > > Key: SCB-926 > URL: https://issues.apache.org/jira/browse/SCB-926 > Project: Apache ServiceComb > Issue Type: New Feature >Affects Versions: java-chassis-1.1.0 >Reporter: YaoHaishi >Assignee: YaoHaishi >Priority: Major > > Provide a interface to let users specify 3rd party services' endpoints and > let users can invoke 3rd party service like invoking the ServiceComb > microservice. -- This message was sent by Atlassian JIRA (v7.6.3#76005)