Change-Id: I6734d0e2264c79faf1c02b5d3c4500140dc14f80
Issue-ID: MSB-197
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
13 files changed:
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* 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
/**
* @ClassName: MicroServiceInfo Bean
/**
* @ClassName: MicroServiceInfo Bean
- * @Description:微服务信息实体类
* @author 10188044
* @date 2016-1-19
*/
* @author 10188044
* @date 2016-1-19
*/
/*******************************************************************************
* Copyright 2017-2018 ZTE, Inc. and others.
/*******************************************************************************
* Copyright 2017-2018 ZTE, Inc. and others.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* 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
// health check type, allowableValues = "HTTP,TCP, TTL", example = "HTTP")
private String checkType = "";
// health check url, example for http "http://192.168.0.2:80/heallth", example for tcp
// health check type, allowableValues = "HTTP,TCP, TTL", example = "HTTP")
private String checkType = "";
// health check url, example for http "http://192.168.0.2:80/heallth", example for tcp
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* 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
- private String status; // 实例健康检查状态
@JsonSerialize(using = CustomDateSerializer.class)
private Date expiration;
@JsonSerialize(using = CustomDateSerializer.class)
private Date expiration;
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* 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
/**
* @ClassName: ApiRouteResult
/**
* @ClassName: ApiRouteResult
- * @Description: TODO(ApiRoute操作返回类)
* @author tanghua10186366
* @author tanghua10186366
- * @date 2015年9月25日 上午11:24:42
- *
*/
public class RouteResult {
private String result;
*/
public class RouteResult {
private String result;
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* 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
private static ObjectMapper mapper;
/**
private static ObjectMapper mapper;
/**
- * 获取ObjectMapper实例
- *
- * @param createNew 方式:true,新实例;false,存在的mapper实例
+ *
+ * @param createNew create a new instanse if truer, otherwise return the existing instance
* @return
*/
public static synchronized ObjectMapper getMapperInstance() {
* @return
*/
public static synchronized ObjectMapper getMapperInstance() {
- * 将java对象转换成json字符串
- *
- * @param obj 准备转换的对象
- * @return json字符串
+ * conver java object to json
+ *
+ * @param obj
+ * @return
* @throws Exception
*/
public static String beanToJson(Object obj) throws RouteException {
* @throws Exception
*/
public static String beanToJson(Object obj) throws RouteException {
- * 将json字符串转换成java对象
- *
- * @param json 准备转换的json字符串
- * @param cls 准备转换的类
+ * convert json string to java object
+ *
+ * @param json
+ * @param cls
* @return
* @throws Exception
*/
* @return
* @throws Exception
*/
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* 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
/**
* @ClassName: MsbUtil
/**
* @ClassName: MsbUtil
- * @Description: TODO(msb功能工具方法类)
+ * @Description: Utils for MSB
* @author tanghua10186366
* @author tanghua10186366
*/
public class MsbUtil {
/**
* @Title getConsulServiceName
*/
public class MsbUtil {
/**
* @Title getConsulServiceName
- * @Description TODO(通过服务名和命名空间组装conusl存储名,用于服务变化监听)
* @param serviceName
* @param namespace
* @return String
* @param serviceName
* @param namespace
* @return String
}
public static String checkVersion(String version) throws RouteException{
}
public static String checkVersion(String version) throws RouteException{
if (StringUtils.isNotBlank(version)) {
if (!RegExpTestUtil.versionRegExpTest(version)) {
throw new RouteException("version is not a valid format", "DATA_FORMAT_ERROR");
if (StringUtils.isNotBlank(version)) {
if (!RegExpTestUtil.versionRegExpTest(version)) {
throw new RouteException("version is not a valid format", "DATA_FORMAT_ERROR");
}
public static void checkHost(String ip,String port) throws RouteException{
}
public static void checkHost(String ip,String port) throws RouteException{
if (StringUtils.isBlank(ip)) {
throw new RouteException("ip can't be empty", "DATA_FORMAT_ERROR");
if (StringUtils.isBlank(ip)) {
throw new RouteException("ip can't be empty", "DATA_FORMAT_ERROR");
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* 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
logger.warn("first invoke httpclient error,endPoint:{},method:{},msg:{}", endPoint, method,
e.getMessage());
logger.warn("first invoke httpclient error,endPoint:{},method:{},msg:{}", endPoint, method,
e.getMessage());
handler.clean();
try {
return ((Call) handler.reInvoke(proxy, method, args, endPoint)).execute();
handler.clean();
try {
return ((Call) handler.reInvoke(proxy, method, args, endPoint)).execute();
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* 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
public class ServiceHttpEndPointBeanObject {
public class ServiceHttpEndPointBeanObject {
private String serviceName;
private String serviceName;
private String serviceVersion;
private String serviceVersion;
private String msbProtocl = "https";
private String msbProtocl = "https";
private String clientProtocl = "http";
private String clientProtocl = "http";
private String nameSpace = "";
private String nameSpace = "";
- // 服务的可见范围,系统间:“0”,系统内:“1”(默认),可配置多个,以 | 分隔
+ // The visibility of service: '0' if the service can be accessed outside, '1' if it can only be accessed within the system, default '1'
private String visualRange = "0";
private String visualRange = "0";
private String serverType = "api";
private String serverType = "api";
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* 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
import java.lang.annotation.Target;
/**
import java.lang.annotation.Target;
/**
- * 服务名和版本号不同,接口名就需要不同
- *
@Retention(RetentionPolicy.RUNTIME)
public @interface ServiceHttpEndPoint {
@Retention(RetentionPolicy.RUNTIME)
public @interface ServiceHttpEndPoint {
String msbProtocl() default "https";
String msbProtocl() default "https";
String clientProtocl() default "http";
String clientProtocl() default "http";
String nameSpace() default "";
String nameSpace() default "";
- // 服务的可见范围,系统间:“0”,系统内:“1”(默认),可配置多个,以 | 分隔
+ // The visibility of service: '0' if the service can be accessed outside, '1' if it can only be accessed within the system, default '1'
String visualRange() default "1";
String visualRange() default "1";
String serverType() default "api";
}
String serverType() default "api";
}
/*******************************************************************************
* Copyright 2017-2018 ZTE, Inc. and others.
/*******************************************************************************
* Copyright 2017-2018 ZTE, Inc. and others.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
******************************************************************************/
/**
* 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.onap.msb.sdk.httpclient.builder.impl;
*/
package org.onap.msb.sdk.httpclient.builder.impl;
* @see
* com.zte.ums.zenap.httpclient.retrofit.builder.IRetrofitObjectBuilder#buildRetrofitObject(
* java. util.concurrent.atomic.AtomicReference)
* @see
* com.zte.ums.zenap.httpclient.retrofit.builder.IRetrofitObjectBuilder#buildRetrofitObject(
* java. util.concurrent.atomic.AtomicReference)
srvhttpEndPointBeanObject.getServiceName(),
srvhttpEndPointBeanObject.getServiceVersion(), nodeInfo, cloneFullInfo);
srvhttpEndPointBeanObject.getServiceName(),
srvhttpEndPointBeanObject.getServiceVersion(), nodeInfo, cloneFullInfo);
String baseUrl = null;
if (fullInfo.getUrl() == null || fullInfo.getUrl().trim().length() == 0
|| fullInfo.getUrl().equals("/")) {
String baseUrl = null;
if (fullInfo.getUrl() == null || fullInfo.getUrl().trim().length() == 0
|| fullInfo.getUrl().equals("/")) {
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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.
******************************************************************************/
/**
* 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.onap.msb.sdk.httpclient.handler.impl;
*/
package org.onap.msb.sdk.httpclient.handler.impl;
* @see
* com.zte.ums.zenap.versey.rpc.retrofit2.service.impl.handler.HandlerContextBuilder#build(com.zte
* .ums.zenap.versey.rpc.retrofit2.service.impl.handler.RetrofitServiceHandlerContext)
* @see
* com.zte.ums.zenap.versey.rpc.retrofit2.service.impl.handler.HandlerContextBuilder#build(com.zte
* .ums.zenap.versey.rpc.retrofit2.service.impl.handler.RetrofitServiceHandlerContext)
public void build(RetrofitServiceHandlerContext ctx) throws RetrofitServiceRuntimeException {
if (ctx.getServiceHttpEndPointBeanObject() == null) {
public void build(RetrofitServiceHandlerContext ctx) throws RetrofitServiceRuntimeException {
if (ctx.getServiceHttpEndPointBeanObject() == null) {
ServiceHttpEndPointBeanObject beanObject =
buildBeanObjectFromClassAnnotion(ctx.getRetrofitSrvInterfaceClazz());
ctx.setServiceHttpEndPointBeanObject(beanObject);
ServiceHttpEndPointBeanObject beanObject =
buildBeanObjectFromClassAnnotion(ctx.getRetrofitSrvInterfaceClazz());
ctx.setServiceHttpEndPointBeanObject(beanObject);
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* 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
import org.onap.msb.sdk.httpclient.ServiceHttpEndPointObject;
/**
import org.onap.msb.sdk.httpclient.ServiceHttpEndPointObject;
/**
- * 每个实际的策略对象在运行中会保持单例
- *
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
/*******************************************************************************
* Copyright 2017 ZTE, Inc. and others.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* 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
*/
public class LoadBalanceContext {
*/
public class LoadBalanceContext {
- // 从msb上查询到的全部endPoint信息
private List<ServiceHttpEndPointObject> endPoints;
private Object[] args;
private List<ServiceHttpEndPointObject> endPoints;
private Object[] args;