[GitHub] [servicecomb-java-chassis] huanghezhen opened a new issue #1976: rpc调用如何指定一个服务的访问地址

2020-09-27 Thread GitBox


huanghezhen opened a new issue #1976:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1976


   背景: 开发环境下 一个服务需要访问另外两个服务,这两个服务不想在本地启动,想直接连接测试环境
   
   请问如何实现?



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-java-chassis] wujimin opened a new pull request #1975: [SCB-2088] add OperationPostProcessor to swagger generator

2020-09-27 Thread GitBox


wujimin opened a new pull request #1975:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1975


   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 -Pit` 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 to 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




[GitHub] [servicecomb-service-center] popozy commented on a change in pull request #698: [Enhancement] Implement service/ms get service function

2020-09-27 Thread GitBox


popozy commented on a change in pull request #698:
URL: 
https://github.com/apache/servicecomb-service-center/pull/698#discussion_r495677215



##
File path: server/rest/controller/v4/microservice_controller.go
##
@@ -120,6 +120,7 @@ func (s *MicroServiceService) Unregister(w 
http.ResponseWriter, r *http.Request)
 func (s *MicroServiceService) GetServices(w http.ResponseWriter, r 
*http.Request) {
request := {}
resp, _ := core.ServiceAPI.GetServices(r.Context(), request)

Review comment:
   all err check missed has beed added in microservice_controller.go





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] popozy commented on a change in pull request #698: [Enhancement] Implement service/ms get service function

2020-09-27 Thread GitBox


popozy commented on a change in pull request #698:
URL: 
https://github.com/apache/servicecomb-service-center/pull/698#discussion_r495676851



##
File path: server/service/ms/etcd/etcd.go
##
@@ -57,78 +52,94 @@ func (ds *DataSource) initialize() error {
 }
 
 // RegisterService() implement:
-// 1. capsule request to etcd kv format
-// 2. invoke registry interface to store service information to etcd cluster
-// Attention: parameters validation && response check must be checked outside 
the method
+// 1. request validation
+// 2. capsule request to etcd kv format
+// 3. invoke etcd client to store data
+// 4. check etcd-client response && construct createServiceResponse
 func (ds *DataSource) RegisterService(ctx context.Context, request 
*pb.CreateServiceRequest) (
-   *registry.PluginResponse, error) {
+   *pb.CreateServiceResponse, error) {
+   if request == nil || request.Service == nil {
+   log.Errorf(nil, "create micro-service failed: request body is 
empty")
+   return {
+   Response: proto.CreateResponse(scerr.ErrInvalidParams, 
"Request body is empty"),
+   }, nil
+   }
+
+   // start to store service to etcd
remoteIP := util.GetIPFromContext(ctx)
serviceBody := request.Service
serviceFlag := util.StringJoin([]string{
serviceBody.Environment, serviceBody.AppId, 
serviceBody.ServiceName, serviceBody.Version}, "/")
 
-   serviceUtil.SetServiceDefaultValue(serviceBody)
-
-   domainProject := util.ParseDomainProject(ctx)
+   // request validation
+   err := service.Validate(request)

Review comment:
   I check it here based the conception that the input from invoker can 
nerver been trust.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] popozy commented on a change in pull request #698: [Enhancement] Implement service/ms get service function

2020-09-27 Thread GitBox


popozy commented on a change in pull request #698:
URL: 
https://github.com/apache/servicecomb-service-center/pull/698#discussion_r495676301



##
File path: server/service/ms/datasource.go
##
@@ -18,14 +18,14 @@ package ms
 import (
"context"
pb "github.com/apache/servicecomb-service-center/pkg/registry"
-   "github.com/apache/servicecomb-service-center/server/plugin/registry"
 )
 
 type DataSource interface {
-   RegisterService(ctx context.Context, service *pb.CreateServiceRequest) 
(*registry.PluginResponse, error)
-   GetService(ctx context.Context, service *pb.GetServiceRequest)
-   UpdateService(ctx context.Context, service 
*pb.UpdateServicePropsRequest)
-   UnregisterService(ctx context.Context, service *pb.DeleteServiceRequest)
+   RegisterService(ctx context.Context, request *pb.CreateServiceRequest) 
(*pb.CreateServiceResponse, error)
+   GetServices(ctx context.Context, request *pb.GetServicesRequest) 
(*pb.GetServicesResponse, error)
+   GetService(ctx context.Context, request *pb.GetServiceRequest) 
(*pb.GetServiceResponse, error)
+   UpdateService(ctx context.Context, request 
*pb.UpdateServicePropsRequest)

Review comment:
   done, has add response





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] popozy commented on a change in pull request #698: [Enhancement] Implement service/ms get service function

2020-09-27 Thread GitBox


popozy commented on a change in pull request #698:
URL: 
https://github.com/apache/servicecomb-service-center/pull/698#discussion_r495671871



##
File path: server/service/ms/etcd/etcd.go
##
@@ -57,78 +52,94 @@ func (ds *DataSource) initialize() error {
 }
 
 // RegisterService() implement:
-// 1. capsule request to etcd kv format
-// 2. invoke registry interface to store service information to etcd cluster
-// Attention: parameters validation && response check must be checked outside 
the method
+// 1. request validation
+// 2. capsule request to etcd kv format
+// 3. invoke etcd client to store data
+// 4. check etcd-client response && construct createServiceResponse
 func (ds *DataSource) RegisterService(ctx context.Context, request 
*pb.CreateServiceRequest) (
-   *registry.PluginResponse, error) {
+   *pb.CreateServiceResponse, error) {
+   if request == nil || request.Service == nil {
+   log.Errorf(nil, "create micro-service failed: request body is 
empty")
+   return {
+   Response: proto.CreateResponse(scerr.ErrInvalidParams, 
"Request body is empty"),
+   }, nil
+   }
+
+   // start to store service to etcd
remoteIP := util.GetIPFromContext(ctx)
serviceBody := request.Service
serviceFlag := util.StringJoin([]string{
serviceBody.Environment, serviceBody.AppId, 
serviceBody.ServiceName, serviceBody.Version}, "/")
 
-   serviceUtil.SetServiceDefaultValue(serviceBody)
-
-   domainProject := util.ParseDomainProject(ctx)
+   // request validation
+   err := service.Validate(request)

Review comment:
   Do you means that, this logic should be moved to api bussiness layer 
(invoker of datasource module), not storage module?





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] popozy commented on a change in pull request #698: [Enhancement] Implement service/ms get service function

2020-09-27 Thread GitBox


popozy commented on a change in pull request #698:
URL: 
https://github.com/apache/servicecomb-service-center/pull/698#discussion_r495669840



##
File path: server/service/ms/datasource.go
##
@@ -18,14 +18,14 @@ package ms
 import (
"context"
pb "github.com/apache/servicecomb-service-center/pkg/registry"
-   "github.com/apache/servicecomb-service-center/server/plugin/registry"
 )
 
 type DataSource interface {
-   RegisterService(ctx context.Context, service *pb.CreateServiceRequest) 
(*registry.PluginResponse, error)
-   GetService(ctx context.Context, service *pb.GetServiceRequest)
-   UpdateService(ctx context.Context, service 
*pb.UpdateServicePropsRequest)
-   UnregisterService(ctx context.Context, service *pb.DeleteServiceRequest)
+   RegisterService(ctx context.Context, request *pb.CreateServiceRequest) 
(*pb.CreateServiceResponse, error)
+   GetServices(ctx context.Context, request *pb.GetServicesRequest) 
(*pb.GetServicesResponse, error)
+   GetService(ctx context.Context, request *pb.GetServiceRequest) 
(*pb.GetServiceResponse, error)
+   UpdateService(ctx context.Context, request 
*pb.UpdateServicePropsRequest)

Review comment:
   This pr finish getservices/getservice interface with its ut.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] popozy commented on a change in pull request #698: [Enhancement] Implement service/ms get service function

2020-09-27 Thread GitBox


popozy commented on a change in pull request #698:
URL: 
https://github.com/apache/servicecomb-service-center/pull/698#discussion_r495669542



##
File path: server/service/ms/datasource.go
##
@@ -18,14 +18,14 @@ package ms
 import (
"context"
pb "github.com/apache/servicecomb-service-center/pkg/registry"
-   "github.com/apache/servicecomb-service-center/server/plugin/registry"
 )
 
 type DataSource interface {
-   RegisterService(ctx context.Context, service *pb.CreateServiceRequest) 
(*registry.PluginResponse, error)
-   GetService(ctx context.Context, service *pb.GetServiceRequest)
-   UpdateService(ctx context.Context, service 
*pb.UpdateServicePropsRequest)
-   UnregisterService(ctx context.Context, service *pb.DeleteServiceRequest)
+   RegisterService(ctx context.Context, request *pb.CreateServiceRequest) 
(*pb.CreateServiceResponse, error)
+   GetServices(ctx context.Context, request *pb.GetServicesRequest) 
(*pb.GetServicesResponse, error)
+   GetService(ctx context.Context, request *pb.GetServiceRequest) 
(*pb.GetServiceResponse, error)
+   UpdateService(ctx context.Context, request 
*pb.UpdateServicePropsRequest)

Review comment:
   In todo list, I'm now implementing them





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #698: [Enhancement] Implement service/ms get service function

2020-09-27 Thread GitBox


tianxiaoliang commented on a change in pull request #698:
URL: 
https://github.com/apache/servicecomb-service-center/pull/698#discussion_r495547579



##
File path: server/service/ms/datasource.go
##
@@ -18,14 +18,14 @@ package ms
 import (
"context"
pb "github.com/apache/servicecomb-service-center/pkg/registry"
-   "github.com/apache/servicecomb-service-center/server/plugin/registry"
 )
 
 type DataSource interface {
-   RegisterService(ctx context.Context, service *pb.CreateServiceRequest) 
(*registry.PluginResponse, error)
-   GetService(ctx context.Context, service *pb.GetServiceRequest)
-   UpdateService(ctx context.Context, service 
*pb.UpdateServicePropsRequest)
-   UnregisterService(ctx context.Context, service *pb.DeleteServiceRequest)
+   RegisterService(ctx context.Context, request *pb.CreateServiceRequest) 
(*pb.CreateServiceResponse, error)
+   GetServices(ctx context.Context, request *pb.GetServicesRequest) 
(*pb.GetServicesResponse, error)
+   GetService(ctx context.Context, request *pb.GetServiceRequest) 
(*pb.GetServiceResponse, error)
+   UpdateService(ctx context.Context, request 
*pb.UpdateServicePropsRequest)

Review comment:
   UpdateService,UnregisterService should return response

##
File path: server/rest/controller/v4/microservice_controller.go
##
@@ -120,6 +120,7 @@ func (s *MicroServiceService) Unregister(w 
http.ResponseWriter, r *http.Request)
 func (s *MicroServiceService) GetServices(w http.ResponseWriter, r 
*http.Request) {
request := {}
resp, _ := core.ServiceAPI.GetServices(r.Context(), request)

Review comment:
   check error

##
File path: server/service/ms/etcd/etcd.go
##
@@ -57,78 +52,94 @@ func (ds *DataSource) initialize() error {
 }
 
 // RegisterService() implement:
-// 1. capsule request to etcd kv format
-// 2. invoke registry interface to store service information to etcd cluster
-// Attention: parameters validation && response check must be checked outside 
the method
+// 1. request validation
+// 2. capsule request to etcd kv format
+// 3. invoke etcd client to store data
+// 4. check etcd-client response && construct createServiceResponse
 func (ds *DataSource) RegisterService(ctx context.Context, request 
*pb.CreateServiceRequest) (
-   *registry.PluginResponse, error) {
+   *pb.CreateServiceResponse, error) {
+   if request == nil || request.Service == nil {
+   log.Errorf(nil, "create micro-service failed: request body is 
empty")
+   return {
+   Response: proto.CreateResponse(scerr.ErrInvalidParams, 
"Request body is empty"),
+   }, nil
+   }
+
+   // start to store service to etcd
remoteIP := util.GetIPFromContext(ctx)
serviceBody := request.Service
serviceFlag := util.StringJoin([]string{
serviceBody.Environment, serviceBody.AppId, 
serviceBody.ServiceName, serviceBody.Version}, "/")
 
-   serviceUtil.SetServiceDefaultValue(serviceBody)
-
-   domainProject := util.ParseDomainProject(ctx)
+   // request validation
+   err := service.Validate(request)

Review comment:
   validation should be common logic for any storage





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1974: CSE跨域注册调用找不到新增接口,报404错误 (locate path failed, status:"NOT_FOUND")

2020-09-27 Thread GitBox


liubao68 commented on issue #1974:
URL: 
https://github.com/apache/servicecomb-java-chassis/issues/1974#issuecomment-699717848


   按照接口兼容规则, 1.2.x 在 1.1.x 基础上可以新增接口。 你的操作不太符合这个规则, 怎么会 1.1.x 在 1.2.x 上面新增接口了? 
是删除了接口? 



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-service-center] popozy opened a new pull request #698: [Enhancement] Implement service/ms get service function

2020-09-27 Thread GitBox


popozy opened a new pull request #698:
URL: https://github.com/apache/servicecomb-service-center/pull/698


   ### Commit message:
   1. optimize register function according to conversation in 
https://github.com/apache/servicecomb-service-center/pull/697#discussion_r494841829
   2. implement getservice && getservices function
   3. finish unit case
   
   ### history pr:
   #695 
   #697 



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [servicecomb-java-chassis] xiaoyuer11 opened a new issue #1974: CSE跨域注册调用找不到新增接口,报404错误

2020-09-27 Thread GitBox


xiaoyuer11 opened a new issue #1974:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1974


   Region R1服务S1版本1.1.X,Region R2服务S1版本1.2.X。R1 Region中S1的是新版本服务,有新增接口API1,当R1 
Region服务S2去调用R1 Region的S1新增接口API1,会报404。
   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[servicecomb-java-chassis] branch master updated: [scb-2086] fix problem about aggregated parameter

2020-09-27 Thread wujimin
This is an automated email from the ASF dual-hosted git repository.

wujimin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
 new 82cb202  [scb-2086] fix problem about aggregated parameter
82cb202 is described below

commit 82cb202e051cd1eef21af9a88ec7e7fa0e7a0a3a
Author: wujimin 
AuthorDate: Wed Sep 23 11:39:34 2020 +0800

[scb-2086] fix problem about aggregated parameter
---
 .../common/utils/LambdaMetafactoryUtils.java   | 56 ++
 .../common/utils/bean/SetterWrapper.java   | 50 ---
 .../common/utils/TestLambdaMetafactoryUtils.java   | 56 ++
 .../config/inject/ConfigObjectFactory.java | 10 ++--
 .../it/schema/objectparams/BeanParamRequest.java   | 56 ++
 .../objectparams/TestJAXRSObjectParamType.java | 43 -
 .../generator/jaxrs/model/AggregatedParam.java | 26 ++
 .../test/resources/schemas/aggregatedParam.yaml| 14 ++
 .../consumer/ConsumerArgumentsMapperCreator.java   | 10 +---
 .../producer/ProducerArgumentsMapperCreator.java   | 10 +---
 10 files changed, 215 insertions(+), 116 deletions(-)

diff --git 
a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/LambdaMetafactoryUtils.java
 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/LambdaMetafactoryUtils.java
index b392f6b..a63a9ab 100644
--- 
a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/LambdaMetafactoryUtils.java
+++ 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/LambdaMetafactoryUtils.java
@@ -47,6 +47,8 @@ import 
org.apache.servicecomb.foundation.common.utils.bean.Setter;
 import org.apache.servicecomb.foundation.common.utils.bean.ShortGetter;
 import org.apache.servicecomb.foundation.common.utils.bean.ShortSetter;
 
+import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition;
+
 public final class LambdaMetafactoryUtils {
   private static final Lookup LOOKUP = MethodHandles.lookup();
 
@@ -148,6 +150,19 @@ public final class LambdaMetafactoryUtils {
 return createLambda(getMethod, getterCls);
   }
 
+  @SuppressWarnings("unchecked")
+  public static Getter createObjectGetter(Method getMethod) {
+return createLambda(getMethod, Getter.class);
+  }
+
+  public static Getter 
createObjectGetter(BeanPropertyDefinition propertyDefinition) {
+if (propertyDefinition.hasGetter()) {
+  return createObjectGetter(propertyDefinition.getGetter().getAnnotated());
+}
+
+return createGetter(propertyDefinition.getField().getAnnotated());
+  }
+
   // slower than reflect directly
   @SuppressWarnings("unchecked")
   public static  Getter createGetter(Field field) {
@@ -177,6 +192,47 @@ public final class LambdaMetafactoryUtils {
 return createLambda(setMethod, setterCls);
   }
 
+  // just for avoid java 9~11 bug: 
https://bugs.openjdk.java.net/browse/JDK-8174983
+  // otherwise can be replaced by: createLambda(setMethod, Setter.class)
+  @SuppressWarnings("unchecked")
+  public static Setter createObjectSetter(Method setMethod) {
+Object setter = createSetter(setMethod);
+if (setter instanceof BoolSetter) {
+  return (Instance, value) -> ((BoolSetter) setter).set(Instance, 
(boolean) value);
+}
+if (setter instanceof ByteSetter) {
+  return (Instance, value) -> ((ByteSetter) setter).set(Instance, (byte) 
value);
+}
+if (setter instanceof CharSetter) {
+  return (Instance, value) -> ((CharSetter) setter).set(Instance, (char) 
value);
+}
+if (setter instanceof DoubleSetter) {
+  return (Instance, value) -> ((DoubleSetter) setter).set(Instance, 
(double) value);
+}
+if (setter instanceof FloatSetter) {
+  return (Instance, value) -> ((FloatSetter) setter).set(Instance, (float) 
value);
+}
+if (setter instanceof IntSetter) {
+  return (Instance, value) -> ((IntSetter) setter).set(Instance, (int) 
value);
+}
+if (setter instanceof LongSetter) {
+  return (Instance, value) -> ((LongSetter) setter).set(Instance, (long) 
value);
+}
+if (setter instanceof ShortSetter) {
+  return (Instance, value) -> ((ShortSetter) setter).set(Instance, (short) 
value);
+}
+
+return (Setter) setter;
+  }
+
+  public static Setter 
createObjectSetter(BeanPropertyDefinition propertyDefinition) {
+if (propertyDefinition.hasSetter()) {
+  return createObjectSetter(propertyDefinition.getSetter().getAnnotated());
+}
+
+return createSetter(propertyDefinition.getField().getAnnotated());
+  }
+
   // slower than reflect directly
   public static  Setter createSetter(Field field) {
 checkAccess(field);
diff --git 

[GitHub] [servicecomb-java-chassis] wujimin merged pull request #1969: [scb-2086] fix problem about aggregated parameter

2020-09-27 Thread GitBox


wujimin merged pull request #1969:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1969


   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org