Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d3e56bf
handler
xchoox Jul 7, 2025
2c885a7
handler
xchoox Jul 7, 2025
3100a43
commit
xchoox Jul 12, 2025
018e04b
client finish
xchoox Jul 12, 2025
4a26e8c
1
xchoox Jul 13, 2025
dd31c83
bootstrap finish
xchoox Jul 16, 2025
275a205
fix
xchoox Jul 17, 2025
b5014e4
Merge branch 'master' into feat_serviceManager
xchoox Jul 17, 2025
c85ddff
'fix'
xchoox Jul 19, 2025
aafe191
Merge branch 'master' into feat_serviceManager
xcsnx Jul 20, 2025
936f2d9
Merge branch 'master' into feat_serviceManager
Aias00 Jul 31, 2025
961bfc6
Merge branch 'master' into feat_serviceManager
Aias00 Aug 2, 2025
05fd690
Merge branch 'master' into feat_serviceManager
Aias00 Aug 2, 2025
665c2bf
Merge branch 'master' into feat_serviceManager
Aias00 Aug 5, 2025
c7afaae
Merge branch 'master' into feat_serviceManager
Aias00 Aug 14, 2025
4627afe
Merge branch 'master' into feat_serviceManager
Aias00 Aug 14, 2025
410340d
数据可视化
xchoox Aug 21, 2025
19a13b4
图标可视化
xchoox Aug 31, 2025
7765070
Merge branch 'master' into feat_serviceManager
xchoox Aug 31, 2025
3f5991c
Merge remote-tracking branch 'origin/feat_serviceManager' into feat_s…
xchoox Aug 31, 2025
e8235fa
可视化
xchoox Aug 31, 2025
24a144b
Merge branch 'master' into feat_serviceManager
xchoox Sep 4, 2025
6d795b5
fix cr
xchoox Sep 4, 2025
2da6bf0
fix cr
xchoox Sep 4, 2025
a2bcd4e
fix cr
xchoox Sep 4, 2025
4627d6a
Merge branch 'master' into feat_serviceManager
xcsnx Sep 8, 2025
d8ed52f
Merge branch 'master' into feat_serviceManager
xcsnx Sep 10, 2025
c023f45
Merge branch 'master' into feat_serviceManager
xchoox Sep 11, 2025
71ec29b
Merge branch 'master' into feat_serviceManager
xchoox Sep 13, 2025
ba45931
Merge branch 'master' into feat_serviceManager
xcsnx Sep 15, 2025
3a8fe31
Merge branch 'master' into feat_serviceManager
xchoox Sep 15, 2025
b823d33
Merge branch 'master' into feat_serviceManager
xcsnx Sep 17, 2025
9d3b264
Merge branch 'master' into feat_serviceManager
xchoox Sep 17, 2025
3b9c80c
fix cr
xchoox Sep 19, 2025
4262ec7
fix cr
xchoox Sep 19, 2025
ca97ffc
Merge remote-tracking branch 'origin/feat_serviceManager' into feat_s…
xchoox Sep 19, 2025
dff69ec
fix cr
xchoox Sep 19, 2025
a6114b2
Merge branch 'master' into feat_serviceManager
xcsnx Sep 21, 2025
78d8859
Merge branch 'master' into feat_serviceManager
xcsnx Sep 22, 2025
96f96a5
Merge branch 'master' into feat_serviceManager
xcsnx Sep 22, 2025
662c30c
Merge branch 'master' into feat_serviceManager
xcsnx Sep 22, 2025
0af6afe
Merge branch 'master' into feat_serviceManager
xcsnx Sep 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.shenyu.admin.mode.cluster.filter.ClusterForwardFilter;
import org.apache.shenyu.admin.mode.cluster.service.ClusterSelectMasterService;
import org.apache.shenyu.admin.mode.cluster.service.ShenyuClusterService;
import org.apache.shenyu.admin.service.impl.InstanceCheckService;
import org.apache.shenyu.admin.service.impl.UpstreamCheckService;
import org.apache.shenyu.admin.service.manager.LoadServiceDocEntry;
import org.slf4j.Logger;
Expand Down Expand Up @@ -50,6 +51,7 @@ public class ClusterConfiguration {
*
* @param shenyuClusterSelectMasterService shenyu cluster select master service
* @param upstreamCheckService upstream check service
* @param instanceCheckService instance check service
* @param loadServiceDocEntry load service doc entry
* @param clusterProperties cluster properties
* @return Shenyu cluster service
Expand All @@ -58,11 +60,13 @@ public class ClusterConfiguration {
@ConditionalOnMissingBean
public ShenyuRunningModeService shenyuRunningModeService(final ClusterSelectMasterService shenyuClusterSelectMasterService,
final UpstreamCheckService upstreamCheckService,
final InstanceCheckService instanceCheckService,
final LoadServiceDocEntry loadServiceDocEntry,
final ClusterProperties clusterProperties) {
LOGGER.info("starting in cluster mode ...");
return new ShenyuClusterService(shenyuClusterSelectMasterService,
upstreamCheckService,
instanceCheckService,
loadServiceDocEntry,
clusterProperties
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import org.apache.shenyu.admin.service.converter.SelectorHandleConverter;
import org.apache.shenyu.admin.service.converter.SelectorHandleConverterFactor;
import org.apache.shenyu.admin.service.publish.InstanceInfoReportEventPublisher;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
Expand Down Expand Up @@ -62,4 +64,9 @@ public LocaleResolver localeResolver() {
localeResolver.setSupportedLocales(Stream.of(Locale.US, Locale.SIMPLIFIED_CHINESE).collect(Collectors.toList()));
return localeResolver;
}

@Bean
public InstanceInfoReportEventPublisher instanceInfoReportEventPublisher(final ApplicationEventPublisher publisher) {
return new InstanceInfoReportEventPublisher(publisher);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.shenyu.admin.mode.ShenyuRunningModeService;
import org.apache.shenyu.admin.mode.standalone.ShenyuStandaloneService;
import org.apache.shenyu.admin.service.impl.InstanceCheckService;
import org.apache.shenyu.admin.service.impl.UpstreamCheckService;
import org.apache.shenyu.admin.service.manager.LoadServiceDocEntry;
import org.slf4j.Logger;
Expand All @@ -40,18 +41,21 @@ public class StandaloneConfiguration {
* Shenyu running mode standalone service.
*
* @param upstreamCheckService upstream check service
* @param instanceCheckService instance check service
* @param loadServiceDocEntry load service doc entry
* @return Shenyu standalone service
*/
@Bean(destroyMethod = "shutdown")
@ConditionalOnProperty(value = {"shenyu.cluster.enabled"}, havingValue = "false", matchIfMissing = true)
@ConditionalOnMissingBean
public ShenyuRunningModeService shenyuRunningModeService(final UpstreamCheckService upstreamCheckService,
final InstanceCheckService instanceCheckService,
final LoadServiceDocEntry loadServiceDocEntry) {
LOGGER.info("starting in standalone mode ...");
return new ShenyuStandaloneService(
upstreamCheckService,
loadServiceDocEntry
loadServiceDocEntry,
instanceCheckService
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@

package org.apache.shenyu.admin.controller;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.apache.shenyu.admin.aspect.annotation.RestApi;
import org.apache.shenyu.register.common.dto.InstanceBeatInfoDTO;
import org.apache.shenyu.admin.model.page.CommonPager;
import org.apache.shenyu.admin.model.page.PageParameter;
import org.apache.shenyu.admin.model.query.InstanceQuery;
Expand All @@ -27,10 +29,13 @@
import org.apache.shenyu.admin.model.vo.InstanceInfoVO;
import org.apache.shenyu.admin.service.InstanceInfoService;
import org.apache.shenyu.admin.service.PageService;
import org.apache.shenyu.admin.service.impl.InstanceCheckService;
import org.apache.shenyu.admin.utils.ShenyuResultMessage;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
Expand All @@ -41,8 +46,11 @@ public class InstanceController implements PagedController<InstanceQueryConditio

private final InstanceInfoService instanceInfoService;

public InstanceController(final InstanceInfoService instanceInfoService) {
private final InstanceCheckService instanceCheckService;

public InstanceController(final InstanceInfoService instanceInfoService, final InstanceCheckService instanceCheckService) {
this.instanceInfoService = instanceInfoService;
this.instanceCheckService = instanceCheckService;
}

/**
Expand Down Expand Up @@ -72,6 +80,13 @@ public ShenyuAdminResult queryPlugins(@RequestParam(name = "instanceType", requi
namespaceId
)
);
commonPager.getDataList().forEach(instanceInfoVO -> {
String instanceKey = instanceCheckService.getInstanceKey(instanceInfoVO);
InstanceInfoVO instanceHealthBeatInfo = instanceCheckService.getInstanceHealthBeatInfo(instanceKey);
instanceInfoVO.setLastHeartBeatTime(instanceHealthBeatInfo.getLastHeartBeatTime());
instanceInfoVO.setInstanceState(instanceHealthBeatInfo.getInstanceState());
instanceInfoVO.setDateUpdated(instanceHealthBeatInfo.getDateUpdated());
});
return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS, commonPager);
}

Expand All @@ -88,6 +103,33 @@ public ShenyuAdminResult detailInstanceInfo(@PathVariable("id") final String id)
return ShenyuAdminResult.success(ShenyuResultMessage.DETAIL_SUCCESS, instanceInfoVO);
}

/**
* receive beat.
*
* @param instanceBeatInfoDTO instanceBeatInfoDTO.
* @return {@linkplain ShenyuAdminResult}
*/
@PostMapping("/beat")
public String beat(@Valid @RequestBody final InstanceBeatInfoDTO instanceBeatInfoDTO) {
//todo:admin集群模式下,请求转发给master节点
instanceCheckService.handleBeatInfo(instanceBeatInfoDTO);
return ShenyuResultMessage.SUCCESS;
}

/**
* visual instance info.
*
* @param namespaceId namespace id.
* @return {@linkplain ShenyuAdminResult}
*/
@GetMapping("/analysis/{namespaceId}")
public ShenyuAdminResult getInstanceDataVisual(@PathVariable("namespaceId") final String namespaceId) {
return ShenyuAdminResult.success(ShenyuResultMessage.QUERY_SUCCESS, instanceCheckService.getInstanceDataVisual(namespaceId));
}





@Override
public PageService<InstanceQueryCondition, InstanceInfoVO> pageService() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void executor(final Collection<URIRegisterDTO> dataList) {
heartbeat.stream().map(URIRegisterDTO::getNamespaceId)
.filter(StringUtils::isNotBlank)
.findFirst()
.ifPresent(namespaceId -> service.heartbeat(selectorName, register, namespaceId));
.ifPresent(namespaceId -> service.heartbeat(selectorName, heartbeat, namespaceId));
}
if (CollectionUtils.isNotEmpty(offline)) {
offline.stream().map(URIRegisterDTO::getNamespaceId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.shenyu.admin.config.properties.ClusterProperties;
import org.apache.shenyu.admin.mode.ShenyuRunningModeService;
import org.apache.shenyu.admin.service.impl.InstanceCheckService;
import org.apache.shenyu.admin.service.impl.UpstreamCheckService;
import org.apache.shenyu.admin.service.manager.LoadServiceDocEntry;
import org.apache.shenyu.common.concurrent.ShenyuThreadFactory;
Expand All @@ -43,9 +44,12 @@ public class ShenyuClusterService implements ShenyuRunningModeService {
private final ScheduledExecutorService executorService;

private final ClusterProperties clusterProperties;

private final InstanceCheckService instanceCheckService;

public ShenyuClusterService(final ClusterSelectMasterService shenyuClusterSelectMasterService,
final UpstreamCheckService upstreamCheckService,
final InstanceCheckService instanceCheckService,
final LoadServiceDocEntry loadServiceDocEntry,
final ClusterProperties clusterProperties) {
this.shenyuClusterSelectMasterService = shenyuClusterSelectMasterService;
Expand All @@ -54,6 +58,7 @@ public ShenyuClusterService(final ClusterSelectMasterService shenyuClusterSelect
this.clusterProperties = clusterProperties;
this.executorService = new ScheduledThreadPoolExecutor(1,
ShenyuThreadFactory.create("master-selector", true));
this.instanceCheckService = instanceCheckService;
}

/**
Expand Down Expand Up @@ -85,7 +90,8 @@ private void doSelectMaster(final String host, final String port, final String c

// start upstream check task
upstreamCheckService.setup();


instanceCheckService.setup();
// load api
loadServiceDocEntry.loadApiDocument();

Expand All @@ -106,6 +112,7 @@ private void doSelectMaster(final String host, final String port, final String c
LOG.error("select master error", e);
// close the upstream check service
upstreamCheckService.close();
instanceCheckService.close();

String message = String.format("renew master fail, %s", e.getMessage());
throw new ShenyuException(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.shenyu.admin.mode.standalone;

import org.apache.shenyu.admin.mode.ShenyuRunningModeService;
import org.apache.shenyu.admin.service.impl.InstanceCheckService;
import org.apache.shenyu.admin.service.impl.UpstreamCheckService;
import org.apache.shenyu.admin.service.manager.LoadServiceDocEntry;

Expand All @@ -26,23 +27,31 @@ public class ShenyuStandaloneService implements ShenyuRunningModeService {
private final UpstreamCheckService upstreamCheckService;

private final LoadServiceDocEntry loadServiceDocEntry;

private final InstanceCheckService instanceCheckService;

public ShenyuStandaloneService(final UpstreamCheckService upstreamCheckService,
final LoadServiceDocEntry loadServiceDocEntry) {
final LoadServiceDocEntry loadServiceDocEntry,
final InstanceCheckService instanceCheckService) {
this.upstreamCheckService = upstreamCheckService;
this.loadServiceDocEntry = loadServiceDocEntry;
this.instanceCheckService = instanceCheckService;
}

@Override
public void start(final String host, final int port, final String contextPath) {
// start upstream check task
upstreamCheckService.setup();

instanceCheckService.setup();

// load api
loadServiceDocEntry.loadApiDocument();
}

@Override
public void shutdown() {
upstreamCheckService.close();
instanceCheckService.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.shenyu.admin.model.entity;

import org.apache.shenyu.admin.model.dto.InstanceInfoDTO;
import org.apache.shenyu.admin.model.vo.InstanceInfoVO;
import org.apache.shenyu.common.utils.UUIDUtils;

import java.sql.Timestamp;
Expand All @@ -39,6 +39,8 @@ public final class InstanceInfoDO extends BaseDO {
private Integer instanceState;

private String namespaceId;

private long lastHeartBeatTime;

public InstanceInfoDO() {

Expand Down Expand Up @@ -99,27 +101,7 @@ public InstanceInfoDO(final String id, final Timestamp dateCreated, final Timest
this.instanceInfo = instanceInfo;
this.namespaceId = namespaceId;
}

/**
* build InstanceInfoDO.
*
* @param instanceInfoDTO instanceInfoDTO
* @return InstanceInfoDO
*/
public static InstanceInfoDO buildInstanceInfoDO(final InstanceInfoDTO instanceInfoDTO) {
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
return InstanceInfoDO.builder()
.id(UUIDUtils.getInstance().generateShortUuid())
.instanceIp(instanceInfoDTO.getInstanceIp())
.instancePort(instanceInfoDTO.getInstancePort())
.instanceType(instanceInfoDTO.getInstanceType())
.instanceInfo(instanceInfoDTO.getInstanceInfo())
.instanceState(instanceInfoDTO.getInstanceState())
.namespaceId(instanceInfoDTO.getNamespaceId())
.dateCreated(currentTime)
.dateUpdated(currentTime)
.build();
}


/**
* get instanceIp.
Expand Down Expand Up @@ -228,7 +210,25 @@ public String getNamespaceId() {
public void setNamespaceId(final String namespaceId) {
this.namespaceId = namespaceId;
}


/**
* get lastHeartBeatTime.
*
* @return lastHeartBeatTime
*/
public long getLastHeartBeatTime() {
return lastHeartBeatTime;
}

/**
* set lastHeartBeatTime.
*
* @param lastHeartBeatTime lastHeartBeatTime
*/
public void setLastHeartBeatTime(final long lastHeartBeatTime) {
this.lastHeartBeatTime = lastHeartBeatTime;
}

/**
* builder.
*
Expand Down Expand Up @@ -262,6 +262,27 @@ public boolean equals(final Object o) {
public int hashCode() {
return Objects.hash(super.hashCode(), instanceIp, instancePort, instanceType, instanceInfo, instanceState, namespaceId);
}

/**
* build InstanceInfoDO.
*
* @param instanceInfoVO instanceInfoVO
* @return InstanceInfoDO
*/
public static InstanceInfoDO buildInstanceInfoDO(final InstanceInfoVO instanceInfoVO) {
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
return InstanceInfoDO.builder()
.id(UUIDUtils.getInstance().generateShortUuid())
.instanceIp(instanceInfoVO.getInstanceIp())
.instancePort(instanceInfoVO.getInstancePort())
.instanceType(instanceInfoVO.getInstanceType())
.instanceInfo(instanceInfoVO.getInstanceInfo())
.instanceState(instanceInfoVO.getInstanceState())
.namespaceId(instanceInfoVO.getNamespaceId())
.dateCreated(currentTime)
.dateUpdated(currentTime)
.build();
}

public static final class InstanceInfoDOBuilder {

Expand Down
Loading
Loading