|
|
@ -6,7 +6,8 @@ import com.gitee.easyopen.annotation.ApiService; |
|
|
|
import com.gitee.easyopen.doc.annotation.ApiDoc; |
|
|
|
import com.gitee.easyopen.doc.annotation.ApiDoc; |
|
|
|
import com.gitee.easyopen.doc.annotation.ApiDocMethod; |
|
|
|
import com.gitee.easyopen.doc.annotation.ApiDocMethod; |
|
|
|
import com.gitee.sop.adminserver.api.service.param.ServiceAddParam; |
|
|
|
import com.gitee.sop.adminserver.api.service.param.ServiceAddParam; |
|
|
|
import com.gitee.sop.adminserver.api.service.param.ServiceInstanceGrayParam; |
|
|
|
import com.gitee.sop.adminserver.api.service.param.ServiceGrayConfigParam; |
|
|
|
|
|
|
|
import com.gitee.sop.adminserver.api.service.param.ServiceIdParam; |
|
|
|
import com.gitee.sop.adminserver.api.service.param.ServiceInstanceParam; |
|
|
|
import com.gitee.sop.adminserver.api.service.param.ServiceInstanceParam; |
|
|
|
import com.gitee.sop.adminserver.api.service.param.ServiceSearchParam; |
|
|
|
import com.gitee.sop.adminserver.api.service.param.ServiceSearchParam; |
|
|
|
import com.gitee.sop.adminserver.api.service.result.RouteServiceInfo; |
|
|
|
import com.gitee.sop.adminserver.api.service.result.RouteServiceInfo; |
|
|
@ -22,7 +23,11 @@ import com.gitee.sop.adminserver.common.ChannelOperation; |
|
|
|
import com.gitee.sop.adminserver.common.StatusEnum; |
|
|
|
import com.gitee.sop.adminserver.common.StatusEnum; |
|
|
|
import com.gitee.sop.adminserver.common.ZookeeperPathExistException; |
|
|
|
import com.gitee.sop.adminserver.common.ZookeeperPathExistException; |
|
|
|
import com.gitee.sop.adminserver.common.ZookeeperPathNotExistException; |
|
|
|
import com.gitee.sop.adminserver.common.ZookeeperPathNotExistException; |
|
|
|
|
|
|
|
import com.gitee.sop.adminserver.entity.ConfigGray; |
|
|
|
|
|
|
|
import com.gitee.sop.adminserver.entity.ConfigGrayInstance; |
|
|
|
import com.gitee.sop.adminserver.entity.ConfigGrayUserkey; |
|
|
|
import com.gitee.sop.adminserver.entity.ConfigGrayUserkey; |
|
|
|
|
|
|
|
import com.gitee.sop.adminserver.mapper.ConfigGrayInstanceMapper; |
|
|
|
|
|
|
|
import com.gitee.sop.adminserver.mapper.ConfigGrayMapper; |
|
|
|
import com.gitee.sop.adminserver.mapper.ConfigGrayUserkeyMapper; |
|
|
|
import com.gitee.sop.adminserver.mapper.ConfigGrayUserkeyMapper; |
|
|
|
import com.gitee.sop.registryapi.bean.ServiceInfo; |
|
|
|
import com.gitee.sop.registryapi.bean.ServiceInfo; |
|
|
|
import com.gitee.sop.registryapi.bean.ServiceInstance; |
|
|
|
import com.gitee.sop.registryapi.bean.ServiceInstance; |
|
|
@ -57,6 +62,12 @@ public class ServiceApi { |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private ConfigGrayUserkeyMapper configGrayUserkeyMapper; |
|
|
|
private ConfigGrayUserkeyMapper configGrayUserkeyMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private ConfigGrayMapper configGrayMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private ConfigGrayInstanceMapper configGrayInstanceMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Api(name = "zookeeper.service.list") |
|
|
|
@Api(name = "zookeeper.service.list") |
|
|
|
@ApiDocMethod(description = "zk中的服务列表", elementClass = RouteServiceInfo.class) |
|
|
|
@ApiDocMethod(description = "zk中的服务列表", elementClass = RouteServiceInfo.class) |
|
|
|
List<RouteServiceInfo> listServiceInfo(ServiceSearchParam param) { |
|
|
|
List<RouteServiceInfo> listServiceInfo(ServiceSearchParam param) { |
|
|
@ -189,7 +200,7 @@ public class ServiceApi { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Api(name = "service.instance.env.pre") |
|
|
|
@Api(name = "service.instance.env.pre.open") |
|
|
|
@ApiDocMethod(description = "预发布") |
|
|
|
@ApiDocMethod(description = "预发布") |
|
|
|
void serviceEnvPre(ServiceInstanceParam param) throws IOException { |
|
|
|
void serviceEnvPre(ServiceInstanceParam param) throws IOException { |
|
|
|
try { |
|
|
|
try { |
|
|
@ -201,35 +212,51 @@ public class ServiceApi { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Api(name = "service.instance.env.gray") |
|
|
|
@Api(name = "service.gray.config.get") |
|
|
|
@ApiDocMethod(description = "灰度发布") |
|
|
|
@ApiDocMethod(description = "灰度配置--获取") |
|
|
|
void serviceEnvGray(ServiceInstanceGrayParam param) throws IOException { |
|
|
|
ConfigGray serviceEnvGrayConfigGet(ServiceIdParam param) throws IOException { |
|
|
|
|
|
|
|
String serviceId = param.getServiceId(); |
|
|
|
|
|
|
|
return configGrayMapper.getByColumn("service_id", serviceId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Api(name = "service.gray.config.save") |
|
|
|
|
|
|
|
@ApiDocMethod(description = "灰度配置--保存") |
|
|
|
|
|
|
|
void serviceEnvGrayConfigSave(ServiceGrayConfigParam param) throws IOException { |
|
|
|
|
|
|
|
String serviceId = param.getServiceId(); |
|
|
|
|
|
|
|
ConfigGray configGray = configGrayMapper.getByColumn("service_id", serviceId); |
|
|
|
|
|
|
|
if (configGray == null) { |
|
|
|
|
|
|
|
configGray = new ConfigGray(); |
|
|
|
|
|
|
|
configGray.setServiceId(serviceId); |
|
|
|
|
|
|
|
configGray.setNameVersionContent(param.getNameVersionContent()); |
|
|
|
|
|
|
|
configGray.setUserKeyContent(param.getUserKeyContent()); |
|
|
|
|
|
|
|
configGrayMapper.save(configGray); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
configGray.setNameVersionContent(param.getNameVersionContent()); |
|
|
|
|
|
|
|
configGray.setUserKeyContent(param.getUserKeyContent()); |
|
|
|
|
|
|
|
configGrayMapper.update(configGray); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Api(name = "service.instance.env.gray.open") |
|
|
|
|
|
|
|
@ApiDocMethod(description = "开启灰度发布") |
|
|
|
|
|
|
|
void serviceEnvGray(ServiceInstanceParam param) throws IOException { |
|
|
|
try { |
|
|
|
try { |
|
|
|
Boolean onlyUpdateGrayUserkey = param.getOnlyUpdateGrayUserkey(); |
|
|
|
|
|
|
|
if (onlyUpdateGrayUserkey == null || !onlyUpdateGrayUserkey) { |
|
|
|
|
|
|
|
MetadataEnum envPre = MetadataEnum.ENV_GRAY; |
|
|
|
MetadataEnum envPre = MetadataEnum.ENV_GRAY; |
|
|
|
registryService.setMetadata(param.buildServiceInstance(), envPre.getKey(), envPre.getValue()); |
|
|
|
registryService.setMetadata(param.buildServiceInstance(), envPre.getKey(), envPre.getValue()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String serviceId = param.getServiceId(); |
|
|
|
String serviceId = param.getServiceId(); |
|
|
|
String instanceId = param.getInstanceId(); |
|
|
|
String instanceId = param.getInstanceId(); |
|
|
|
String userKeyContent = param.getUserKeyContent(); |
|
|
|
|
|
|
|
String nameVersionContent = param.getNameVersionContent(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ConfigGrayUserkey configGrayUserkey = configGrayUserkeyMapper.getByColumn("instance_id", instanceId); |
|
|
|
ConfigGrayInstance configGrayInstance = configGrayInstanceMapper.getByColumn("instance_id", instanceId); |
|
|
|
if (configGrayUserkey == null) { |
|
|
|
if (configGrayInstance == null) { |
|
|
|
configGrayUserkey = new ConfigGrayUserkey(); |
|
|
|
configGrayInstance = new ConfigGrayInstance(); |
|
|
|
configGrayUserkey.setServiceId(serviceId); |
|
|
|
configGrayInstance.setServiceId(serviceId); |
|
|
|
configGrayUserkey.setInstanceId(instanceId); |
|
|
|
configGrayInstance.setInstanceId(instanceId); |
|
|
|
configGrayUserkey.setUserKeyContent(userKeyContent); |
|
|
|
configGrayInstance.setStatus(StatusEnum.STATUS_ENABLE.getStatus()); |
|
|
|
configGrayUserkey.setNameVersionContent(nameVersionContent); |
|
|
|
configGrayInstanceMapper.save(configGrayInstance); |
|
|
|
configGrayUserkey.setStatus(StatusEnum.STATUS_ENABLE.getStatus()); |
|
|
|
|
|
|
|
configGrayUserkeyMapper.save(configGrayUserkey); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
configGrayUserkey.setUserKeyContent(userKeyContent); |
|
|
|
configGrayInstance.setStatus(StatusEnum.STATUS_ENABLE.getStatus()); |
|
|
|
configGrayUserkey.setNameVersionContent(nameVersionContent); |
|
|
|
configGrayInstanceMapper.update(configGrayInstance); |
|
|
|
configGrayUserkey.setStatus(StatusEnum.STATUS_ENABLE.getStatus()); |
|
|
|
|
|
|
|
configGrayUserkeyMapper.update(configGrayUserkey); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
this.sendUserKeyMsg(instanceId, ChannelOperation.GRAY_USER_KEY_SET); |
|
|
|
this.sendUserKeyMsg(instanceId, ChannelOperation.GRAY_USER_KEY_SET); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
@ -245,10 +272,10 @@ public class ServiceApi { |
|
|
|
MetadataEnum envPre = MetadataEnum.ENV_ONLINE; |
|
|
|
MetadataEnum envPre = MetadataEnum.ENV_ONLINE; |
|
|
|
registryService.setMetadata(param, envPre.getKey(), envPre.getValue()); |
|
|
|
registryService.setMetadata(param, envPre.getKey(), envPre.getValue()); |
|
|
|
|
|
|
|
|
|
|
|
ConfigGrayUserkey configGrayUserkey = configGrayUserkeyMapper.getByColumn("instance_id", param.getInstanceId()); |
|
|
|
ConfigGrayInstance configGrayInstance = configGrayInstanceMapper.getByColumn("instance_id", param.getInstanceId()); |
|
|
|
if (configGrayUserkey != null && configGrayUserkey.getStatus() == StatusEnum.STATUS_ENABLE.getStatus()) { |
|
|
|
if (configGrayInstance != null) { |
|
|
|
configGrayUserkey.setStatus(StatusEnum.STATUS_DISABLE.getStatus()); |
|
|
|
configGrayInstance.setStatus(StatusEnum.STATUS_DISABLE.getStatus()); |
|
|
|
configGrayUserkeyMapper.update(configGrayUserkey); |
|
|
|
configGrayInstanceMapper.update(configGrayInstance); |
|
|
|
} |
|
|
|
} |
|
|
|
this.sendUserKeyMsg(param.getInstanceId(), ChannelOperation.GRAY_USER_KEY_CLEAR); |
|
|
|
this.sendUserKeyMsg(param.getInstanceId(), ChannelOperation.GRAY_USER_KEY_CLEAR); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|