/*******************************************************************************
* 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
- *
+ *
* 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
/**
* @ClassName: MicroServiceInfo Bean
- * @Description:微服务信息实体类
+ * @Description
* @author 10188044
* @date 2016-1-19
*/
/*******************************************************************************
* 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
- *
+ *
* 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
private String ttl = "";
- // 健康检查参数
// 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.
- *
+ *
* 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
- *
+ *
* 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 nodeId;
- private String status; // 实例健康检查状态
+ private String status;
@JsonSerialize(using = CustomDateSerializer.class)
private Date expiration;
/*******************************************************************************
* 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
- *
+ *
* 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
/**
* @ClassName: ApiRouteResult
- * @Description: TODO(ApiRoute操作返回类)
+ * @Description
* @author tanghua10186366
- * @date 2015年9月25日 上午11:24:42
- *
+ * @date 2015/9/25
+ *
*/
public class RouteResult {
private String result;
/*******************************************************************************
* 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
- *
+ *
* 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
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() {
}
/**
- * 将java对象转换成json字符串
- *
- * @param obj 准备转换的对象
- * @return json字符串
+ * conver java object to json
+ *
+ * @param obj
+ * @return
* @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
*/
/*******************************************************************************
* 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
- *
+ *
* 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
/**
* @ClassName: MsbUtil
- * @Description: TODO(msb功能工具方法类)
+ * @Description: Utils for MSB
* @author tanghua10186366
- * @date 2017年6月26日
- *
+ * @date 2017/6/26
+ *
*/
public class MsbUtil {
/**
* @Title getConsulServiceName
- * @Description TODO(通过服务名和命名空间组装conusl存储名,用于服务变化监听)
+ * @Description
* @param serviceName
* @param namespace
* @return String
}
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");
}
public static void checkHost(String ip,String port) throws RouteException{
- // HOST空值和格式检查
if (StringUtils.isBlank(ip)) {
throw new RouteException("ip can't be empty", "DATA_FORMAT_ERROR");
/*******************************************************************************
* 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
- *
+ *
* 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
logger.warn("first invoke httpclient error,endPoint:{},method:{},msg:{}", endPoint, method,
e.getMessage());
- // 清理残留的endpoint记录
handler.clean();
try {
return ((Call) handler.reInvoke(proxy, method, args, endPoint)).execute();
/*******************************************************************************
* 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
- *
+ *
* 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
public class ServiceHttpEndPointBeanObject {
- // 在MSB上注册的服务名
private String serviceName;
- // 在MSB注册的版本号
private String serviceVersion;
- // 在通过msb转发时,所用的协议
private String msbProtocl = "https";
- // 服务间点对点访问时,所用的协议
private String clientProtocl = "http";
- // 服务所在的租户名
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";
- // 在MSB上注册的服务类型
private String serverType = "api";
/*******************************************************************************
* 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
- *
+ *
* 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
import java.lang.annotation.Target;
/**
- * 服务名和版本号不同,接口名就需要不同
- *
+ *
* @author hu.rui
*
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface ServiceHttpEndPoint {
- // 在MSB上注册的服务名
String serviceName();
- // 在MSB注册的版本号
String serviceVersion();
- // 在通过msb转发时,所用的协议
String msbProtocl() default "https";
- // 服务间点对点访问时,所用的协议
String clientProtocl() default "http";
- // 服务所在的租户名
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";
- // 在MSB上注册的服务类型
String serverType() default "api";
}
/*******************************************************************************
* 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
- *
+ *
* 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.onap.msb.sdk.httpclient.builder.impl;
/*
* (non-Javadoc)
- *
+ *
* @see
* com.zte.ums.zenap.httpclient.retrofit.builder.IRetrofitObjectBuilder#buildRetrofitObject(
* java. util.concurrent.atomic.AtomicReference)
srvhttpEndPointBeanObject.getServiceName(),
srvhttpEndPointBeanObject.getServiceVersion(), nodeInfo, cloneFullInfo);
- // 目前支持http
String baseUrl = null;
if (fullInfo.getUrl() == null || fullInfo.getUrl().trim().length() == 0
|| fullInfo.getUrl().equals("/")) {
/*******************************************************************************
* 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
- *
+ *
* 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.onap.msb.sdk.httpclient.handler.impl;
/*
* (non-Javadoc)
- *
+ *
* @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) {
- // 从注解上构建
ServiceHttpEndPointBeanObject beanObject =
buildBeanObjectFromClassAnnotion(ctx.getRetrofitSrvInterfaceClazz());
ctx.setServiceHttpEndPointBeanObject(beanObject);
/*******************************************************************************
* 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
- *
+ *
* 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
import org.onap.msb.sdk.httpclient.ServiceHttpEndPointObject;
/**
- * 每个实际的策略对象在运行中会保持单例
- *
+ *
* @author hu.rui
*
*/
/*******************************************************************************
* 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
- *
+ *
* 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
*/
public class LoadBalanceContext {
- // 从msb上查询到的全部endPoint信息
private List<ServiceHttpEndPointObject> endPoints;
private Object[] args;