├── .gitignore ├── LICENSE ├── README.md ├── pom.xml └── src ├── main ├── filters │ ├── ucar-development.properties │ └── ucar-test.properties ├── java │ └── com │ │ └── ucar │ │ └── zkdoctor │ │ ├── PersistenceJPAConfig.java │ │ ├── ZkDoctorMain.java │ │ ├── business │ │ └── clusterMonitorAlarmTask │ │ │ ├── base │ │ │ ├── dao │ │ │ │ └── BaseDao.java │ │ │ └── service │ │ │ │ ├── BaseService.java │ │ │ │ └── impl │ │ │ │ └── BaseServiceImpl.java │ │ │ ├── controller │ │ │ ├── ZkAlarmInfoController.java │ │ │ └── ZkMonitorTaskController.java │ │ │ ├── dao │ │ │ ├── ZkAlarmInfoMapper.java │ │ │ └── ZkMonitorTaskMapper.java │ │ │ ├── pojo │ │ │ ├── ZkAlarmInfo.java │ │ │ └── ZkMonitorTask.java │ │ │ ├── service │ │ │ ├── ZkAlarmInfoService.java │ │ │ ├── ZkMonitorTaskService.java │ │ │ └── impl │ │ │ │ ├── ZkAlarmInfoServiceImpl.java │ │ │ │ └── ZkMonitorTaskServiceImpl.java │ │ │ └── valueobject │ │ │ ├── IndexCollectInfo.java │ │ │ └── IndexCollectInfos.java │ │ ├── dao │ │ └── mysql │ │ │ ├── ClientInfoDao.java │ │ │ ├── ClusterAlarmUserDao.java │ │ │ ├── ClusterInfoDao.java │ │ │ ├── ClusterStateDao.java │ │ │ ├── InstanceInfoDao.java │ │ │ ├── InstanceStateDao.java │ │ │ ├── InstanceStateLogDao.java │ │ │ ├── MachineInfoDao.java │ │ │ ├── MachineStateDao.java │ │ │ ├── MachineStateLogDao.java │ │ │ ├── MonitorIndicatorDao.java │ │ │ ├── MonitorTaskDao.java │ │ │ ├── QuartzDao.java │ │ │ ├── ServiceLineDao.java │ │ │ ├── SysConfigDao.java │ │ │ └── UserDao.java │ │ ├── pojo │ │ ├── BaseTimeLineObject.java │ │ ├── bo │ │ │ ├── AddNewConfigFileBO.java │ │ │ ├── CacheObject.java │ │ │ ├── ClientConnectionSearchBO.java │ │ │ ├── ClusterInfoSearchBO.java │ │ │ ├── HostAndPort.java │ │ │ ├── InstanceInfoSearchBO.java │ │ │ ├── InstanceStateLogSearchBO.java │ │ │ ├── MachineSearchBO.java │ │ │ ├── MonitorIndicatorSearchBO.java │ │ │ ├── MonitorTaskSearchBO.java │ │ │ ├── StatSearchBO.java │ │ │ └── UserSearchBO.java │ │ ├── dto │ │ │ ├── ConnectionInfoDTO.java │ │ │ ├── ServerStateInfoDTO.java │ │ │ └── ZKServerConfigDTO.java │ │ ├── po │ │ │ ├── ClientInfo.java │ │ │ ├── ClusterAlarmUser.java │ │ │ ├── ClusterInfo.java │ │ │ ├── ClusterState.java │ │ │ ├── InstanceInfo.java │ │ │ ├── InstanceState.java │ │ │ ├── InstanceStateLog.java │ │ │ ├── MachineInfo.java │ │ │ ├── MachineState.java │ │ │ ├── MachineStateLog.java │ │ │ ├── MonitorIndicator.java │ │ │ ├── MonitorTask.java │ │ │ ├── ServiceLine.java │ │ │ ├── SysConfig.java │ │ │ ├── TriggerInfo.java │ │ │ └── User.java │ │ └── vo │ │ │ ├── AllTrendChartVO.java │ │ │ ├── ClusterDeployVO.java │ │ │ ├── ClusterDetailVO.java │ │ │ ├── ClusterListVO.java │ │ │ ├── CreateNewZnodeVO.java │ │ │ ├── InstanceDetailVO.java │ │ │ ├── MachineDetailVO.java │ │ │ ├── PageVO.java │ │ │ ├── TreeNodeVO.java │ │ │ ├── TrendChartVO.java │ │ │ ├── UpdateZnodeDataVO.java │ │ │ ├── UploadedJarFileVO.java │ │ │ ├── ZKConfigInfoVO.java │ │ │ ├── ZKServerInfoVO.java │ │ │ ├── ZnodeDetailInfoVO.java │ │ │ └── ZnodeTreeNodeVO.java │ │ ├── service │ │ ├── cluster │ │ │ ├── ClusterService.java │ │ │ ├── ClusterStateService.java │ │ │ └── impl │ │ │ │ ├── ClusterServiceImpl.java │ │ │ │ └── ClusterStateServiceImpl.java │ │ ├── collection │ │ │ ├── CollectService.java │ │ │ └── impl │ │ │ │ └── CollectServiceImpl.java │ │ ├── instance │ │ │ ├── InstanceService.java │ │ │ ├── InstanceStateService.java │ │ │ └── impl │ │ │ │ ├── InstanceServiceImpl.java │ │ │ │ └── InstanceStateServiceImpl.java │ │ ├── machine │ │ │ ├── MachineOperationService.java │ │ │ ├── MachineService.java │ │ │ ├── MachineStateService.java │ │ │ └── impl │ │ │ │ ├── MachineOperationServiceImpl.java │ │ │ │ ├── MachineServiceImpl.java │ │ │ │ └── MachineStateServiceImpl.java │ │ ├── monitor │ │ │ ├── AlertService.java │ │ │ ├── MonitorBase.java │ │ │ ├── MonitorService.java │ │ │ ├── detail │ │ │ │ ├── AvgLatencyMonitor.java │ │ │ │ ├── InstanceAvgLatencyMonitor.java │ │ │ │ ├── InstanceConnectionsMonitor.java │ │ │ │ ├── InstanceOpenFilesDescCountMonitor.java │ │ │ │ ├── InstanceRunOkMonitor.java │ │ │ │ ├── InstanceStateChangeMonitor.java │ │ │ │ ├── InstanceWatcherMonitor.java │ │ │ │ ├── MachineCpuMonitor.java │ │ │ │ ├── MachineDiskMonitor.java │ │ │ │ ├── MachineLoadMonitor.java │ │ │ │ ├── MachineMemoryMonitor.java │ │ │ │ ├── MachineNetTrafficMonitor.java │ │ │ │ ├── MaxLatencyMonitor.java │ │ │ │ ├── OutstandingsMonitor.java │ │ │ │ ├── ReceivedMonitor.java │ │ │ │ └── SendMonitor.java │ │ │ └── impl │ │ │ │ ├── AlertServiceImpl.java │ │ │ │ └── MonitorServiceImpl.java │ │ ├── schedule │ │ │ ├── AutowiringSpringBeanJobFactory.java │ │ │ ├── SchedulerConfig.java │ │ │ ├── SchedulerService.java │ │ │ ├── impl │ │ │ │ └── SchedulerServiceImpl.java │ │ │ └── jobs │ │ │ │ ├── BaseJob.java │ │ │ │ ├── CleanCollectDataJob.java │ │ │ │ ├── InstanceConnectionCollectJob.java │ │ │ │ ├── MachineJob.java │ │ │ │ ├── MonitorJob.java │ │ │ │ └── ZKJob.java │ │ ├── system │ │ │ ├── ConfigService.java │ │ │ ├── Init.java │ │ │ ├── ServiceLineService.java │ │ │ └── impl │ │ │ │ ├── ConfigServiceImpl.java │ │ │ │ └── ServiceLineServiceImpl.java │ │ ├── user │ │ │ ├── LoginService.java │ │ │ ├── UserService.java │ │ │ └── impl │ │ │ │ ├── LoginServiceImpl.java │ │ │ │ └── UserServiceImpl.java │ │ ├── view │ │ │ ├── MenuService.java │ │ │ └── impl │ │ │ │ └── MenuServiceImpl.java │ │ └── zk │ │ │ ├── CustomZKManager.java │ │ │ ├── ZKService.java │ │ │ └── impl │ │ │ └── ZKServiceImpl.java │ │ ├── util │ │ ├── config │ │ │ ├── ConfigUtil.java │ │ │ └── ModifiableConfig.java │ │ ├── constant │ │ │ ├── ClusterEnumClass.java │ │ │ ├── CommonEnumClass.java │ │ │ ├── FourLetterCommand.java │ │ │ ├── InstanceEnumClass.java │ │ │ ├── SchedulerConstant.java │ │ │ ├── SymbolConstant.java │ │ │ ├── UserEnumClass.java │ │ │ ├── ZKServerEnumClass.java │ │ │ └── protocol │ │ │ │ ├── MachineProtocol.java │ │ │ │ └── ZKProtocol.java │ │ ├── exception │ │ │ ├── ParseException.java │ │ │ └── SSHException.java │ │ ├── parser │ │ │ ├── ConnectionInfoParser.java │ │ │ ├── ConnectionReaderParser.java │ │ │ ├── KVPairParamParser.java │ │ │ ├── LineParser.java │ │ │ ├── MapReaderParser.java │ │ │ ├── PropertiesReader.java │ │ │ ├── ReaderParser.java │ │ │ ├── ServerStateReaderParser.java │ │ │ ├── StringReaderParser.java │ │ │ └── ZKServerConfigReaderParser.java │ │ ├── ssh │ │ │ ├── SSHExecutor.java │ │ │ └── SSHUtil.java │ │ ├── thread │ │ │ └── NamedThreadFactory.java │ │ └── tool │ │ │ ├── ChartConvertUtil.java │ │ │ ├── CommandHelper.java │ │ │ ├── DateUtil.java │ │ │ ├── HessianSerializerUtils.java │ │ │ ├── IdempotentConfirmer.java │ │ │ ├── LoginUtil.java │ │ │ ├── MessageUtil.java │ │ │ ├── ReflectUtils.java │ │ │ └── SHACryptor.java │ │ └── web │ │ ├── ConResult.java │ │ ├── UserCheckFilter.java │ │ └── controller │ │ ├── BaseController.java │ │ ├── LoginController.java │ │ ├── common │ │ ├── MenuController.java │ │ └── UserController.java │ │ ├── manager │ │ ├── ClusterManageController.java │ │ ├── InstanceManageController.java │ │ ├── MachineManageController.java │ │ ├── MonitorManageController.java │ │ ├── QuartzManageController.java │ │ └── SystemConfigManageController.java │ │ └── ordinary │ │ ├── ClusterController.java │ │ ├── InstanceController.java │ │ ├── MachineController.java │ │ └── MonitorController.java ├── resources │ ├── application.properties │ ├── logback.xml │ ├── machine_init.sh │ ├── mapper │ │ ├── ClientInfoDao.xml │ │ ├── ClusterAlarmUserDao.xml │ │ ├── ClusterInfoDao.xml │ │ ├── ClusterStateDao.xml │ │ ├── InstanceInfoDao.xml │ │ ├── InstanceStateDao.xml │ │ ├── InstanceStateLogDao.xml │ │ ├── MachineInfoDao.xml │ │ ├── MachineStateDao.xml │ │ ├── MachineStateLogDao.xml │ │ ├── MonitorIndicatorDao.xml │ │ ├── MonitorTaskDao.xml │ │ ├── QuartzDao.xml │ │ ├── ServiceLineDao.xml │ │ ├── SysConfigDao.xml │ │ ├── UserDao.xml │ │ ├── ZkAlarmInfoMapper.xml │ │ └── ZkMonitorTaskMapper.xml │ ├── mybatis │ │ └── mybatis-config.xml │ ├── quartz.properties │ └── zkdoctorConfig.properties ├── script │ ├── machine_init.sh │ ├── start.sh │ ├── stop.sh │ └── zkdoctor.sql └── webapp │ ├── .gitignore │ ├── .roadhogrc │ ├── .roadhogrc.mock.js │ ├── WEB-INF │ └── web.xml │ ├── index.html │ ├── mock │ ├── app.js │ ├── cluster.js │ ├── clusterOps.js │ ├── clusterStats.js │ ├── collect.js │ ├── instance.js │ ├── instanceOps.js │ ├── instanceStats.js │ ├── mClusterMonitorAlarmTask.js │ ├── machine.js │ ├── monitor.js │ ├── quartz.js │ ├── systemOps.js │ └── user.js │ ├── package.json │ ├── public │ ├── background │ │ └── background.gif │ ├── favicon.ico │ ├── index.html │ ├── logo │ │ └── logo.png │ └── polyfill.min.js │ ├── src │ ├── cluster │ │ ├── model │ │ │ ├── ClusterModel.ts │ │ │ └── ClusterStatsTrendModel.ts │ │ ├── service │ │ │ ├── cluster.ts │ │ │ └── clusterStat.ts │ │ └── view │ │ │ ├── ClusterDetail.tsx │ │ │ ├── ClusterList.tsx │ │ │ ├── clusterDetail │ │ │ ├── ClusterAlarmUser.tsx │ │ │ ├── ClusterAlarmUserModal.tsx │ │ │ ├── ClusterInfo.tsx │ │ │ └── HeadInfo.tsx │ │ │ ├── clusterList │ │ │ ├── List.tsx │ │ │ └── Search.tsx │ │ │ ├── clusterState │ │ │ ├── Stats.tsx │ │ │ └── StatsDetail.tsx │ │ │ ├── clusterZnode │ │ │ ├── ClusterZnode.tsx │ │ │ ├── ClusterZnodeList.tsx │ │ │ ├── CreateNewNodeModal.tsx │ │ │ └── UpdateZnodeModal.tsx │ │ │ └── newCluster │ │ │ ├── NewCluster.tsx │ │ │ └── NewClusterForm.tsx │ ├── collect │ │ ├── model │ │ │ └── ClusterMonitorAlarmInfoModel.ts │ │ ├── service │ │ │ └── ClusterMonitorAlarmInfoService.ts │ │ └── view │ │ │ ├── AlarmInfoList.tsx │ │ │ ├── ClusterCollectInfo.tsx │ │ │ └── IndexCollectList.tsx │ ├── common.js │ ├── common │ │ ├── config.js │ │ ├── model │ │ │ └── Pagination.ts │ │ └── utils │ │ │ ├── IOC.ts │ │ │ ├── preference.ts │ │ │ ├── request.ts │ │ │ └── safeLocalStorage.ts │ ├── declaration.d.ts │ ├── index.ejs │ ├── index.tsx │ ├── instance │ │ ├── model │ │ │ └── InstanceModel.ts │ │ ├── service │ │ │ └── instance.ts │ │ └── view │ │ │ ├── BaseInfo.tsx │ │ │ ├── ClusterInstanceExecptionList.tsx │ │ │ ├── ClusterInstanceList.tsx │ │ │ ├── ConnectionSearch.tsx │ │ │ ├── InstanceDetail.tsx │ │ │ ├── InstanceExceptionList.tsx │ │ │ ├── InstanceHeadInfo.tsx │ │ │ ├── InstanceList.tsx │ │ │ └── TrafficModal.tsx │ ├── machine │ │ ├── model │ │ │ ├── MachineModel.ts │ │ │ └── SSHModel.ts │ │ ├── service │ │ │ └── machine.ts │ │ └── view │ │ │ ├── List.tsx │ │ │ ├── MachineInstanceList.tsx │ │ │ ├── MachineInstanceTable.tsx │ │ │ ├── MachineList.tsx │ │ │ ├── ModifyMachineModal.tsx │ │ │ ├── SSHInit.tsx │ │ │ └── Search.tsx │ ├── monitor │ │ ├── model │ │ │ ├── ClusterMonitorAlarmTaskModel.ts │ │ │ ├── MonitorIndicatorModel.ts │ │ │ └── MonitorTaskModel.ts │ │ ├── service │ │ │ ├── MonitorAlarmTaskService.ts │ │ │ └── monitor.ts │ │ └── view │ │ │ ├── AlarmHistory.tsx │ │ │ ├── ClusterMonitorAlarmTaskList.tsx │ │ │ ├── IndicatorList.tsx │ │ │ ├── IndicatorModal.tsx │ │ │ ├── MonitorAlarmTaskList.tsx │ │ │ ├── MonitorAlarmTaskModal.tsx │ │ │ ├── MonitorIndicatorList.tsx │ │ │ ├── TaskList.tsx │ │ │ └── TaskModal.tsx │ ├── ops │ │ ├── model │ │ │ ├── ClusterOpsModel.ts │ │ │ ├── InstanceOpsModel.ts │ │ │ ├── ServiceLineOpsModel.ts │ │ │ └── SystemOpsModel.ts │ │ ├── service │ │ │ ├── ClusterOpsService.ts │ │ │ ├── InstanceOpsService.ts │ │ │ ├── ServiceLineOpsService.ts │ │ │ └── SystemOpsService.ts │ │ └── view │ │ │ ├── ClusterDeploy.tsx │ │ │ ├── ClusterDeployForm.tsx │ │ │ ├── ClusterDynamicExpansionModal.tsx │ │ │ ├── ClusterDynamicExpansionResultModal.tsx │ │ │ ├── ClusterOps.tsx │ │ │ ├── ClusterOpsList.tsx │ │ │ ├── ClusterRestartModal.tsx │ │ │ ├── ClusterRestartResultModal.tsx │ │ │ ├── InstanceConfigOps.tsx │ │ │ ├── InstanceOps.tsx │ │ │ ├── InstanceOpsList.tsx │ │ │ ├── InstanceUpdateServerModal.tsx │ │ │ ├── ModifyClusterModal.tsx │ │ │ ├── NewConfigFileModal.tsx │ │ │ ├── NewInstanceForClusterModal.tsx │ │ │ ├── ServiceLine.tsx │ │ │ ├── ServiceLineList.tsx │ │ │ ├── ServiceLineUpdateModal.tsx │ │ │ ├── SystemConfig.tsx │ │ │ ├── SystemConfigList.tsx │ │ │ └── SystemConfigUpdateModal.tsx │ ├── quartz │ │ ├── model │ │ │ └── QuartzModel.ts │ │ ├── service │ │ │ └── quartz.ts │ │ └── view │ │ │ ├── List.tsx │ │ │ ├── QuartzList.tsx │ │ │ └── Search.tsx │ ├── router.js │ ├── sys │ │ ├── model │ │ │ ├── BaseInfoModel.ts │ │ │ ├── SysInfoModel.ts │ │ │ └── SysUserModel.ts │ │ ├── service │ │ │ └── app.ts │ │ └── view │ │ │ ├── App.tsx │ │ │ ├── Dashboard.less │ │ │ ├── Dashboard.tsx │ │ │ ├── Login.tsx │ │ │ ├── LoginRegister.tsx │ │ │ ├── error.js │ │ │ ├── error.less │ │ │ ├── layout │ │ │ ├── bread.js │ │ │ ├── common.less │ │ │ ├── footer.js │ │ │ ├── header.js │ │ │ ├── main.less │ │ │ ├── menu.js │ │ │ └── sider.js │ │ │ ├── login │ │ │ ├── LoginForm.tsx │ │ │ ├── LoginRegisterForm.tsx │ │ │ └── login.less │ │ │ ├── skin.less │ │ │ └── vars.less │ ├── theme.js │ ├── themes │ │ ├── Search.less │ │ ├── console.less │ │ ├── default.less │ │ ├── index.less │ │ ├── mixin.less │ │ └── vars.less │ └── user │ │ ├── model │ │ └── UserModel.ts │ │ ├── service │ │ └── user.ts │ │ └── view │ │ ├── User.tsx │ │ ├── UserList.tsx │ │ ├── UserModal.tsx │ │ ├── UserRegister.tsx │ │ ├── UserRegisterForm.tsx │ │ └── UserSearch.tsx │ └── tsconfig.json ├── test └── java │ └── com │ └── ucar │ └── zkdoctor │ ├── BaseTest.java │ ├── dao │ └── mysql │ │ └── UserDaoTest.java │ ├── pojo │ └── bo │ │ └── HostAndPortTest.java │ ├── service │ ├── cluster │ │ └── impl │ │ │ ├── ClusterServiceImplTest.java │ │ │ └── ClusterStateServiceImplTest.java │ ├── collection │ │ └── impl │ │ │ └── CollectServiceImplTest.java │ ├── instance │ │ └── impl │ │ │ ├── InstanceServiceImplTest.java │ │ │ └── InstanceStateServiceImplTest.java │ ├── machine │ │ └── impl │ │ │ ├── MachineServiceImplTest.java │ │ │ └── MachineStateServiceImplTest.java │ ├── monitor │ │ └── impl │ │ │ └── MonitorServiceImplTest.java │ ├── schedule │ │ └── impl │ │ │ └── SchedulerServiceImplTest.java │ ├── system │ │ └── impl │ │ │ ├── ConfigServiceImplTest.java │ │ │ └── ServiceLineServiceImplTest.java │ ├── user │ │ └── impl │ │ │ └── UserServiceImplTest.java │ └── zk │ │ ├── CustomZKManagerTest.java │ │ └── ZKServiceTest.java │ └── util │ ├── ssh │ └── SSHUtilTest.java │ └── tool │ └── HessianSerializerUtilsTest.java └── wikiimages ├── 业务线配置.jpg ├── 动态扩容.jpg ├── 实例运维.jpg ├── 新增报警用户.jpg ├── 服务升级.jpg ├── 服务部署.jpg ├── 机器信息收集开关.jpg ├── 注册登录页面.png ├── 注册页面.png ├── 添加集群.jpg ├── 登录页面.png ├── 监控报警.jpg ├── 系统架构图.png ├── 系统配置.jpg ├── 连接信息收集开关.jpg ├── 集群统计.jpg └── 集群运维.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.nar 16 | *.ear 17 | *.zip 18 | *.tar.gz 19 | *.rar 20 | 21 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 22 | hs_err_pid* 23 | -------------------------------------------------------------------------------- /src/main/filters/ucar-development.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/main/filters/ucar-development.properties -------------------------------------------------------------------------------- /src/main/filters/ucar-test.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/main/filters/ucar-test.properties -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/PersistenceJPAConfig.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor; 2 | 3 | import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.context.annotation.PropertySource; 9 | 10 | import javax.sql.DataSource; 11 | 12 | /** 13 | * Description: 支持外部数据源配置 14 | * Created on 2018/5/11 10:02 15 | * 16 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 17 | */ 18 | @Configuration 19 | @ComponentScan 20 | @PropertySource(value = {"classpath:/application.properties", 21 | "${spring.datasource.location}"}, ignoreResourceNotFound = true) 22 | public class PersistenceJPAConfig { 23 | 24 | @Bean 25 | @ConfigurationProperties(prefix = "spring.datasource") 26 | public DataSource dataSource() { 27 | return DataSourceBuilder.create().build(); 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/ZkDoctorMain.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.builder.SpringApplicationBuilder; 7 | import org.springframework.boot.web.support.SpringBootServletInitializer; 8 | 9 | /** 10 | * Description: 启动类 11 | * Created on 2017/12/18 17:09 12 | * 13 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 14 | */ 15 | @SpringBootApplication 16 | @MapperScan({"com.ucar.zkdoctor.dao.mysql", "com.ucar.zkdoctor.business.clusterMonitorAlarmTask.dao"}) 17 | public class ZkDoctorMain extends SpringBootServletInitializer { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(ZkDoctorMain.class, args); 21 | } 22 | 23 | /** 24 | * 使用外部tomcat容器时,需继承SpringBootServletInitializer,重写configure方法 25 | * 26 | * @param builder SpringApplicationBuilder 27 | * @return 28 | */ 29 | @Override 30 | protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { 31 | builder.sources(this.getClass()); 32 | return super.configure(builder); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/business/clusterMonitorAlarmTask/base/dao/BaseDao.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.business.clusterMonitorAlarmTask.base.dao; 2 | 3 | import java.io.Serializable; 4 | 5 | public interface BaseDao { 6 | T getById(Serializable id); 7 | 8 | void insert(T entity); 9 | 10 | void update(T entity); 11 | 12 | void delete(Serializable id); 13 | } -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/business/clusterMonitorAlarmTask/base/service/BaseService.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.business.clusterMonitorAlarmTask.base.service; 2 | 3 | import java.io.Serializable; 4 | 5 | public interface BaseService { 6 | T getById(Serializable id); 7 | 8 | void save(T entity); 9 | 10 | void delete(Serializable id); 11 | } -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/business/clusterMonitorAlarmTask/base/service/impl/BaseServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.business.clusterMonitorAlarmTask.base.service.impl; 2 | 3 | import com.ucar.zkdoctor.business.clusterMonitorAlarmTask.base.service.BaseService; 4 | import org.springframework.transaction.annotation.Propagation; 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) 8 | public abstract class BaseServiceImpl implements BaseService { 9 | 10 | } -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/business/clusterMonitorAlarmTask/controller/ZkAlarmInfoController.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.business.clusterMonitorAlarmTask.controller; 2 | 3 | import com.ucar.zkdoctor.business.clusterMonitorAlarmTask.pojo.ZkAlarmInfo; 4 | import com.ucar.zkdoctor.business.clusterMonitorAlarmTask.service.ZkAlarmInfoService; 5 | import com.ucar.zkdoctor.web.ConResult; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestMethod; 10 | import org.springframework.web.bind.annotation.ResponseBody; 11 | 12 | @Controller 13 | @RequestMapping(value = "/alarmInfo") 14 | public class ZkAlarmInfoController { 15 | 16 | @Autowired 17 | private ZkAlarmInfoService zkAlarmInfoService; 18 | 19 | @RequestMapping(value = "/getAllZkAlarmInfo", method = RequestMethod.GET, produces = "application/json") 20 | @ResponseBody 21 | public ConResult getAllZkAlarmInfo() { 22 | return zkAlarmInfoService.getAllZkAlarmInfo(); 23 | } 24 | 25 | /** 26 | * 插入报警相关信息 27 | * 28 | * @param zkAlarmInfo 报警信息对象 29 | * @return 30 | */ 31 | @RequestMapping(value = "/insertZkAlarmInfo") 32 | @ResponseBody 33 | public ConResult insertZkAlarmInfo(ZkAlarmInfo zkAlarmInfo) { 34 | return zkAlarmInfoService.insertZkAlarmInfo(zkAlarmInfo); 35 | } 36 | 37 | /** 38 | * 获得集群监控相关指标汇总信息 39 | * 40 | * @return 41 | */ 42 | @RequestMapping(value = "/getCollectInfo") 43 | @ResponseBody 44 | public ConResult getCollectInfo() { 45 | return zkAlarmInfoService.getClusterInstanceCollectInfo(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/business/clusterMonitorAlarmTask/dao/ZkAlarmInfoMapper.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.business.clusterMonitorAlarmTask.dao; 2 | 3 | import com.ucar.zkdoctor.business.clusterMonitorAlarmTask.pojo.ZkAlarmInfo; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.HashMap; 8 | import java.util.List; 9 | 10 | @Repository 11 | public interface ZkAlarmInfoMapper { 12 | int deleteByPrimaryKey(Integer id); 13 | 14 | int insert(ZkAlarmInfo record); 15 | 16 | int insertZkAlarmInfo(ZkAlarmInfo record); 17 | 18 | ZkAlarmInfo selectByPrimaryKey(Integer id); 19 | 20 | List selectAll(); 21 | 22 | int updateByPrimaryKey(ZkAlarmInfo record); 23 | 24 | List> selectAllContainName(String alarmTime); 25 | 26 | int selectClusterTotal(@Param("status") Integer status); 27 | 28 | int selectInstanceTotal(@Param("status") Integer status); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/business/clusterMonitorAlarmTask/dao/ZkMonitorTaskMapper.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.business.clusterMonitorAlarmTask.dao; 2 | 3 | import com.ucar.zkdoctor.business.clusterMonitorAlarmTask.pojo.ZkMonitorTask; 4 | import org.springframework.stereotype.Repository; 5 | 6 | import java.util.HashMap; 7 | import java.util.List; 8 | 9 | @Repository 10 | public interface ZkMonitorTaskMapper { 11 | int deleteByPrimaryKey(Integer id); 12 | 13 | int insert(ZkMonitorTask record); 14 | 15 | ZkMonitorTask selectByPrimaryKey(Integer id); 16 | 17 | List selectAll(); 18 | 19 | int updateByPrimaryKey(ZkMonitorTask record); 20 | 21 | int updateMonitorTaskSwitchOn(ZkMonitorTask record); 22 | 23 | List> selectAllContainName(); 24 | 25 | List> selectByClusterId(Integer clusterId); 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/business/clusterMonitorAlarmTask/service/ZkAlarmInfoService.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.business.clusterMonitorAlarmTask.service; 2 | 3 | import com.ucar.zkdoctor.business.clusterMonitorAlarmTask.base.service.BaseService; 4 | import com.ucar.zkdoctor.business.clusterMonitorAlarmTask.pojo.ZkAlarmInfo; 5 | import com.ucar.zkdoctor.web.ConResult; 6 | 7 | import java.util.List; 8 | 9 | public interface ZkAlarmInfoService extends BaseService { 10 | int deleteByPrimaryKey(Integer id); 11 | 12 | ConResult insert(ZkAlarmInfo record); 13 | 14 | ConResult insertZkAlarmInfo(ZkAlarmInfo record); 15 | 16 | ZkAlarmInfo selectByPrimaryKey(Integer id); 17 | 18 | List selectAll(); 19 | 20 | ConResult updateByPrimaryKey(ZkAlarmInfo record); 21 | 22 | ConResult getAllZkAlarmInfo(); 23 | 24 | ConResult getClusterInstanceCollectInfo(); 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/business/clusterMonitorAlarmTask/service/ZkMonitorTaskService.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.business.clusterMonitorAlarmTask.service; 2 | 3 | import com.ucar.zkdoctor.business.clusterMonitorAlarmTask.base.service.BaseService; 4 | import com.ucar.zkdoctor.business.clusterMonitorAlarmTask.pojo.ZkMonitorTask; 5 | import com.ucar.zkdoctor.web.ConResult; 6 | 7 | import java.util.List; 8 | 9 | public interface ZkMonitorTaskService extends BaseService { 10 | int deleteByPrimaryKey(Integer id); 11 | 12 | int insert(ZkMonitorTask record); 13 | 14 | ZkMonitorTask selectByPrimaryKey(Integer id); 15 | 16 | List selectAll(); 17 | 18 | ConResult updateByPrimaryKey(ZkMonitorTask record); 19 | 20 | ConResult updateMonitorTaskSwitchOn(ZkMonitorTask record); 21 | 22 | ConResult getZkMonitorTaskList(); 23 | 24 | ConResult selectByClusterId(Integer clusterId); 25 | 26 | ConResult getAllZkMonitorTask(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/business/clusterMonitorAlarmTask/valueobject/IndexCollectInfos.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.business.clusterMonitorAlarmTask.valueobject; 2 | 3 | import java.io.Serializable; 4 | 5 | public class IndexCollectInfos implements Serializable { 6 | private IndexCollectInfo clusterCollectInfo; 7 | private IndexCollectInfo instanceCollectInfo; 8 | 9 | public IndexCollectInfo getClusterCollectInfo() { 10 | return clusterCollectInfo; 11 | } 12 | 13 | public void setClusterCollectInfo(IndexCollectInfo clusterCollectInfo) { 14 | this.clusterCollectInfo = clusterCollectInfo; 15 | } 16 | 17 | public IndexCollectInfo getInstanceCollectInfo() { 18 | return instanceCollectInfo; 19 | } 20 | 21 | public void setInstanceCollectInfo(IndexCollectInfo instanceCollectInfo) { 22 | this.instanceCollectInfo = instanceCollectInfo; 23 | } 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/dao/mysql/ClientInfoDao.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.dao.mysql; 2 | 3 | import com.ucar.zkdoctor.pojo.bo.ClientConnectionSearchBO; 4 | import com.ucar.zkdoctor.pojo.po.ClientInfo; 5 | 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | /** 10 | * Description: 客户端连接信息操作Dao 11 | * Created on 2018/2/23 15:21 12 | * 13 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 14 | */ 15 | public interface ClientInfoDao { 16 | 17 | /** 18 | * 批量保存客户端连接信息 19 | * 20 | * @param clientInfoList 客户端连接信息 21 | * @return 22 | */ 23 | boolean batchInsertClientConnections(List clientInfoList); 24 | 25 | /** 26 | * 根据查询条件,获取符合条件的客户端连接信息 27 | * 28 | * @param clientConnectionSearchBO 查询条件 29 | * @return 30 | */ 31 | List getClientConnectionsByParams(ClientConnectionSearchBO clientConnectionSearchBO); 32 | 33 | /** 34 | * 需要删除的实例连接信息状态历史数据记录的数量 35 | * 36 | * @param endDate 时间 37 | * @return 38 | */ 39 | Long cleanClientConnectionsCount(Date endDate); 40 | 41 | /** 42 | * 删除此时间之前的所有实例连接信息状态历史数据 43 | * 44 | * @param endDate 时间 45 | * @return 46 | */ 47 | boolean cleanClientConnectionsData(Date endDate); 48 | 49 | /** 50 | * 获取最近一次收集的客户端信息 51 | * 52 | * @param instanceId 实例id 53 | * @return 54 | */ 55 | ClientInfo getLatestClientInfo(int instanceId); 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/dao/mysql/ClusterAlarmUserDao.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.dao.mysql; 2 | 3 | import com.ucar.zkdoctor.pojo.po.ClusterAlarmUser; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Description: 集群下配置的用户信息 10 | * Created on 2018/1/11 20:41 11 | * 12 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 13 | */ 14 | public interface ClusterAlarmUserDao { 15 | 16 | /** 17 | * 插入新的集群用户信息 18 | * 19 | * @param clusterAlarmUser 集群与用户对应信息 20 | * @return 21 | */ 22 | boolean insertClusterAlarmUser(ClusterAlarmUser clusterAlarmUser); 23 | 24 | /** 25 | * 获取集群下的所有报警用户信息 26 | * 27 | * @param clusterId 集群id 28 | * @return 29 | */ 30 | List getUserIdsByClusterId(int clusterId); 31 | 32 | /** 33 | * 获取用户对应的集群信息 34 | * 35 | * @param userId 用户id 36 | * @return 37 | */ 38 | List getClusterIdsByUserId(int userId); 39 | 40 | /** 41 | * 删除集群与用户对应关系 42 | * 43 | * @param clusterId 集群id 44 | * @param userId 用户id 45 | * @return 46 | */ 47 | boolean deleteAlarmUser(@Param("clusterId") int clusterId, @Param("userId") int userId); 48 | 49 | /** 50 | * 删除某个用户的所有报警设置 51 | * 52 | * @param userId 用户id 53 | * @return 54 | */ 55 | boolean deleteAllAlarmUser(int userId); 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/dao/mysql/ClusterStateDao.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.dao.mysql; 2 | 3 | import com.ucar.zkdoctor.pojo.po.ClusterState; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | /** 10 | * Description: 集群状态Dao 11 | * Created on 2018/1/9 11:03 12 | * 13 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 14 | */ 15 | public interface ClusterStateDao { 16 | 17 | /** 18 | * 插入新的集群状态信息 19 | * 20 | * @param clusterState 集群状态 21 | * @return 22 | */ 23 | boolean insertClusterState(ClusterState clusterState); 24 | 25 | /** 26 | * 通过集群id获取最新集群状态信息 27 | * 28 | * @param clusterId 集群id 29 | * @return 30 | */ 31 | ClusterState getClusterStateByClusterId(int clusterId); 32 | 33 | /** 34 | * 删除某集群状态信息 35 | * 36 | * @param clusterId 集群id 37 | * @return 38 | */ 39 | boolean deleteClusterStateByClusterId(int clusterId); 40 | 41 | /** 42 | * 批量写入集群运行状态历史记录 43 | * 44 | * @param clusterStateList 集群状态信息 45 | * @return 46 | */ 47 | boolean batchInsertClusterStateLogs(List clusterStateList); 48 | 49 | /** 50 | * 插入某条集群运行状态记录 51 | * 52 | * @param clusterState 集群状态信息 53 | * @return 54 | */ 55 | boolean insertClusterStateLogs(ClusterState clusterState); 56 | 57 | /** 58 | * 获取某集群的历史状态信息 59 | * 60 | * @param clusterId 集群id 61 | * @param startDate 开始时间 62 | * @param endDate 结束时间 63 | * @return 64 | */ 65 | List getClusterStateLogByClusterId(@Param("clusterId") int clusterId, @Param("startDate") Date startDate, @Param("endDate") Date endDate); 66 | 67 | /** 68 | * 删除此时间之前的所有集群状态历史数据 69 | * 70 | * @param endDate 此时间之前的数据将删除 71 | * @return 72 | */ 73 | boolean cleanClusterStateLogData(Date endDate); 74 | 75 | /** 76 | * 需要删除的集群状态历史数据记录的数量 77 | * 78 | * @param endDate 获取此时间之前的所有数据条数 79 | * @return 80 | */ 81 | Long cleanClusterStateLogCount(Date endDate); 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/dao/mysql/InstanceStateDao.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.dao.mysql; 2 | 3 | import com.ucar.zkdoctor.pojo.po.InstanceState; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Description: 实例状态Dao 9 | * Created on 2018/1/9 11:04 10 | * 11 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 12 | */ 13 | public interface InstanceStateDao { 14 | 15 | /** 16 | * 插入新的实例状态信息 17 | * 18 | * @param instanceState 实例状态 19 | * @return 20 | */ 21 | boolean insertInstanceState(InstanceState instanceState); 22 | 23 | /** 24 | * 通过实例id获取最新实例状态信息 25 | * 26 | * @param instanceId 实例id 27 | * @return 28 | */ 29 | InstanceState getInstanceStateByInstanceId(int instanceId); 30 | 31 | /** 32 | * 获取某集群下所有实例最近状态信息 33 | * 34 | * @param clusterId 集群id 35 | * @return 36 | */ 37 | List getInstanceStateByClusterId(int clusterId); 38 | 39 | /** 40 | * 删除某实例状态信息 41 | * 42 | * @param instanceId 实例id 43 | * @return 44 | */ 45 | boolean deleteInstanceStateByInstanceId(int instanceId); 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/dao/mysql/MachineStateDao.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.dao.mysql; 2 | 3 | import com.ucar.zkdoctor.pojo.po.MachineState; 4 | 5 | /** 6 | * Description: 机器状态Dao 7 | * Created on 2018/1/9 11:07 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public interface MachineStateDao { 12 | 13 | /** 14 | * 插入新的机器状态信息 15 | * 16 | * @param machineState 机器状态 17 | * @return 18 | */ 19 | boolean insertMachineState(MachineState machineState); 20 | 21 | /** 22 | * 通过机器id获取最新机器状态信息 23 | * 24 | * @param machineId 机器id 25 | * @return 26 | */ 27 | MachineState getMachineStateByMachineId(int machineId); 28 | 29 | /** 30 | * 删除某机器状态信息 31 | * 32 | * @param machineId 机器id 33 | * @return 34 | */ 35 | boolean deleteMachineStateByMachineId(int machineId); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/dao/mysql/MachineStateLogDao.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.dao.mysql; 2 | 3 | import com.ucar.zkdoctor.pojo.po.MachineStateLog; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | /** 10 | * Description: 机器状态历史信息Dao 11 | * Created on 2018/1/9 17:05 12 | * 13 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 14 | */ 15 | public interface MachineStateLogDao { 16 | 17 | /** 18 | * 批量写入机器运行状态记录 19 | * 20 | * @param machineStateLogList 机器状态信息 21 | * @return 22 | */ 23 | boolean batchInsertMachineStateLogs(List machineStateLogList); 24 | 25 | /** 26 | * 插入某条机器运行状态记录 27 | * 28 | * @param machineStateLog 机器状态信息 29 | * @return 30 | */ 31 | boolean insertMachineStateLogs(MachineStateLog machineStateLog); 32 | 33 | /** 34 | * 获取某机器的历史状态信息 35 | * 36 | * @param machineId 机器id 37 | * @param startDate 开始时间 38 | * @param endDate 结束时间 39 | * @return 40 | */ 41 | List getMachineStateLogByMachine(@Param("machineId") int machineId, @Param("startDate") Date startDate, @Param("endDate") Date endDate); 42 | 43 | /** 44 | * 删除此时间之前的所有机器状态历史数据 45 | * 46 | * @param endDate 此时间之前的数据将删除 47 | * @return 48 | */ 49 | boolean cleanMachineStateLogData(Date endDate); 50 | 51 | /** 52 | * 需要删除的机器状态历史数据记录的数量 53 | * 54 | * @param endDate 获取此时间之前的所有数据条数 55 | * @return 56 | */ 57 | Long cleanMachineStateLogCount(Date endDate); 58 | 59 | /** 60 | * 获取某一时间点机器状态信息 61 | * 62 | * @param host 机器ip 63 | * @param dateTime 时间点 64 | * @return 65 | */ 66 | MachineStateLog getMachineStateLogByTime(@Param("host") String host, @Param("dateTime") Date dateTime); 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/dao/mysql/MonitorIndicatorDao.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.dao.mysql; 2 | 3 | import com.ucar.zkdoctor.pojo.bo.MonitorIndicatorSearchBO; 4 | import com.ucar.zkdoctor.pojo.po.MonitorIndicator; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Description: 监控指标Dao 11 | * Created on 2018/2/6 11:30 12 | * 13 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 14 | */ 15 | public interface MonitorIndicatorDao { 16 | 17 | /** 18 | * 保存监控指标 19 | * 20 | * @param monitorIndicator 监控指标 21 | * @return 22 | */ 23 | boolean insertIndicator(MonitorIndicator monitorIndicator); 24 | 25 | /** 26 | * 更新监控指标 27 | * 28 | * @param monitorIndicator 监控指标 29 | * @return 30 | */ 31 | boolean updateIndicator(MonitorIndicator monitorIndicator); 32 | 33 | /** 34 | * 修改监控指标开关 35 | * 36 | * @param id 监控指标id 37 | * @param switchOn 开关状态 38 | * @return 39 | */ 40 | boolean updateIndicatorSwitchOn(@Param("id") int id, @Param("switchOn") boolean switchOn); 41 | 42 | /** 43 | * 根据监控指标id查询监控指标信息 44 | * 45 | * @param id 监控指标id 46 | * @return 47 | */ 48 | MonitorIndicator getIndicatorByIndicatorId(int id); 49 | 50 | /** 51 | * 根据监控指标类名查询监控指标信息 52 | * 53 | * @param className 监控类名 54 | * @return 55 | */ 56 | MonitorIndicator getIndicatorByClassName(String className); 57 | 58 | /** 59 | * 根据查询条件查询监控指标列表 60 | * 61 | * @param monitorIndicatorSearchBO 监控指标查询条件 62 | * @return 63 | */ 64 | List getIndicatorsByParams(MonitorIndicatorSearchBO monitorIndicatorSearchBO); 65 | 66 | /** 67 | * 删除某一监控指标 68 | * 69 | * @param id 监控指标id 70 | * @return 71 | */ 72 | boolean deleteIndicatorByIndicatorId(int id); 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/dao/mysql/MonitorTaskDao.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.dao.mysql; 2 | 3 | import com.ucar.zkdoctor.pojo.bo.MonitorTaskSearchBO; 4 | import com.ucar.zkdoctor.pojo.po.MonitorTask; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Description: 监控任务Dao 11 | * Created on 2018/2/6 11:31 12 | * 13 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 14 | */ 15 | public interface MonitorTaskDao { 16 | 17 | /** 18 | * 创建监控任务 19 | * 20 | * @param monitorTask 监控任务 21 | * @return 22 | */ 23 | boolean insertTask(MonitorTask monitorTask); 24 | 25 | /** 26 | * 更新某一监控任务 27 | * 28 | * @param monitorTask 监控任务 29 | * @return 30 | */ 31 | boolean updateTask(MonitorTask monitorTask); 32 | 33 | /** 34 | * 修改监控任务开关 35 | * 36 | * @param id 监控任务id 37 | * @param switchOn 开关状态 38 | * @return 39 | */ 40 | boolean updateTaskSwitchOn(@Param("id") int id, @Param("switchOn") boolean switchOn); 41 | 42 | /** 43 | * 获取某一监控任务 44 | * 45 | * @param id 监控任务id 46 | * @return 47 | */ 48 | MonitorTask getTaskByTaskId(int id); 49 | 50 | /** 51 | * 根据查询条件,获取相关的监控任务列表 52 | * 53 | * @param monitorTaskSearchBO 监控任务查询条件 54 | * @return 55 | */ 56 | List getTasksByParams(MonitorTaskSearchBO monitorTaskSearchBO); 57 | 58 | /** 59 | * 删除某一监控任务 60 | * 61 | * @param id 监控任务id 62 | * @return 63 | */ 64 | boolean deleteTaskByTaskId(int id); 65 | 66 | /** 67 | * 删除某一监控指标下的所有监控任务 68 | * 69 | * @param indicatorId 监控指标id 70 | * @return 71 | */ 72 | boolean deleteByIndicatorId(int indicatorId); 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/dao/mysql/QuartzDao.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.dao.mysql; 2 | 3 | import com.ucar.zkdoctor.pojo.po.TriggerInfo; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Description: 定时任务Dao 9 | * Created on 2018/2/5 16:58 10 | * 11 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 12 | */ 13 | public interface QuartzDao { 14 | 15 | /** 16 | * 获取所有定时任务详细信息 17 | * 18 | * @return 19 | */ 20 | List getAllTriggers(); 21 | 22 | /** 23 | * 通过名称或组查询定时任务信息 24 | * 25 | * @param queryString 查询信息字符串 26 | * @return 27 | */ 28 | List searchTriggerByNameOrGroup(String queryString); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/dao/mysql/ServiceLineDao.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.dao.mysql; 2 | 3 | import com.ucar.zkdoctor.pojo.po.ServiceLine; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Description: 业务线Dao 9 | * Created on 2018/4/10 10:28 10 | * 11 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 12 | */ 13 | public interface ServiceLineDao { 14 | 15 | /** 16 | * 保存新业务线信息 17 | * 18 | * @param serviceLine 业务线信息 19 | * @return 20 | */ 21 | boolean insertServiceLine(ServiceLine serviceLine); 22 | 23 | /** 24 | * 根据业务线名称获取业务线相关信息 25 | * 26 | * @param serviceLineName 业务线名称 27 | * @return 28 | */ 29 | ServiceLine getServiceLineByName(String serviceLineName); 30 | 31 | /** 32 | * 获取所有业务线信息 33 | * 34 | * @return 35 | */ 36 | List getAllServiceLine(); 37 | 38 | /** 39 | * 更新某业务线信息 40 | * 41 | * @param serviceLine 业务线 42 | * @return 43 | */ 44 | boolean updateServiceLine(ServiceLine serviceLine); 45 | 46 | /** 47 | * 删除某业务线信息 48 | * 49 | * @param serviceLineName 业务线名称 50 | * @return 51 | */ 52 | boolean deleteServiceLineByName(String serviceLineName); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/dao/mysql/SysConfigDao.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.dao.mysql; 2 | 3 | import com.ucar.zkdoctor.pojo.po.SysConfig; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Description: 配置信息Dao 9 | * Created on 2018/1/23 14:02 10 | * 11 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 12 | */ 13 | public interface SysConfigDao { 14 | /** 15 | * 保存新配置信息 16 | * 17 | * @param sysConfig 配置信息 18 | * @return 19 | */ 20 | boolean insertSysConfig(SysConfig sysConfig); 21 | 22 | /** 23 | * 获取指定配置信息 24 | * 25 | * @param configName 配置名称 26 | * @return 27 | */ 28 | SysConfig getSysConfigByName(String configName); 29 | 30 | /** 31 | * 获取所有配置信息 32 | * 33 | * @return 34 | */ 35 | List getAllSysConfig(); 36 | 37 | /** 38 | * 删除某项配置信息 39 | * 40 | * @param configName 配置名称 41 | * @return 42 | */ 43 | boolean deleteSysConfigByName(String configName); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/dao/mysql/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.dao.mysql; 2 | 3 | import com.ucar.zkdoctor.pojo.bo.UserSearchBO; 4 | import com.ucar.zkdoctor.pojo.po.User; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Description: 用户信息Dao 10 | * Created on 2017/12/18 10:17 11 | * 12 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 13 | */ 14 | public interface UserDao { 15 | 16 | /** 17 | * 根据id获取用户信息 18 | * 19 | * @param id 用户id 20 | * @return 21 | */ 22 | User getUserById(int id); 23 | 24 | /** 25 | * 根据用户名获取用户信息 26 | * 27 | * @param userName 用户名 28 | * @return 29 | */ 30 | User getUserByName(String userName); 31 | 32 | /** 33 | * 插入新的用户信息 34 | * 35 | * @param user 用户信息 36 | * @return 37 | */ 38 | boolean insertNewUser(User user); 39 | 40 | /** 41 | * 更新用户信息 42 | * 43 | * @param user 用户信息 44 | * @return 45 | */ 46 | boolean updateUser(User user); 47 | 48 | /** 49 | * 通过用户id删除用户 50 | * 51 | * @param userId 用户id 52 | * @return 53 | */ 54 | boolean deleteUserById(int userId); 55 | 56 | /** 57 | * 通过用户名删除用户 58 | * 59 | * @param userName 用户名 60 | * @return 61 | */ 62 | boolean deleteUserByName(String userName); 63 | 64 | /** 65 | * 获取所有用户信息 66 | * 67 | * @return 68 | */ 69 | List getAllUsersByParams(UserSearchBO userSearchBO); 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/BaseTimeLineObject.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo; 2 | 3 | import com.ucar.zkdoctor.util.tool.DateUtil; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | /** 9 | * Description: 所有拥有创建时间与修改时间的对象基类 10 | * Created on 2018/1/5 16:21 11 | * 12 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 13 | */ 14 | public class BaseTimeLineObject implements Serializable { 15 | 16 | private static final long serialVersionUID = 1846619688484980693L; 17 | 18 | /** 19 | * 创建时间 20 | */ 21 | private Date createTime; 22 | 23 | /** 24 | * 创建时间字符串表示,yyyy-mm-dd hh:mm:ss 25 | */ 26 | private String createTimeStr; 27 | 28 | /** 29 | * 修改时间 30 | */ 31 | private Date modifyTime; 32 | 33 | /** 34 | * 修改时间字符串表示,yyyy-mm-dd hh:mm:ss 35 | */ 36 | private String modifyTimeStr; 37 | 38 | @Override 39 | public String toString() { 40 | return "BaseTimeLineObject{" + 41 | "createTime=" + createTime + 42 | ", modifyTime=" + modifyTime + 43 | '}'; 44 | } 45 | 46 | public Date getCreateTime() { 47 | return createTime; 48 | } 49 | 50 | public void setCreateTime(Date createTime) { 51 | this.createTime = createTime; 52 | } 53 | 54 | public String getCreateTimeStr() { 55 | if (createTime != null) { 56 | return DateUtil.formatYYYYMMddHHMMss(createTime); 57 | } else { 58 | return ""; 59 | } 60 | } 61 | 62 | public void setCreateTimeStr(String createTimeStr) { 63 | this.createTimeStr = createTimeStr; 64 | } 65 | 66 | public String getModifyTimeStr() { 67 | if (modifyTime != null) { 68 | return DateUtil.formatYYYYMMddHHMMss(modifyTime); 69 | } else { 70 | return ""; 71 | } 72 | } 73 | 74 | public void setModifyTimeStr(String modifyTimeStr) { 75 | this.modifyTimeStr = modifyTimeStr; 76 | } 77 | 78 | public Date getModifyTime() { 79 | return modifyTime; 80 | } 81 | 82 | public void setModifyTime(Date modifyTime) { 83 | this.modifyTime = modifyTime; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/bo/AddNewConfigFileBO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.bo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Description: 像目标服务器新增某个配置文件BO 7 | * Created on 2018/3/1 15:32 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class AddNewConfigFileBO implements Serializable { 12 | 13 | private static final long serialVersionUID = 7856548311176266786L; 14 | 15 | /** 16 | * 目标服务器ip 17 | */ 18 | private String host; 19 | 20 | /** 21 | * 新增配置目录 22 | */ 23 | private String confDir; 24 | 25 | /** 26 | * 新增配置名称 27 | */ 28 | private String confFileName; 29 | 30 | /** 31 | * 配置内容 32 | */ 33 | private String confFileContent; 34 | 35 | public String getHost() { 36 | return host; 37 | } 38 | 39 | public void setHost(String host) { 40 | this.host = host; 41 | } 42 | 43 | public String getConfDir() { 44 | return confDir; 45 | } 46 | 47 | public void setConfDir(String confDir) { 48 | this.confDir = confDir; 49 | } 50 | 51 | public String getConfFileName() { 52 | return confFileName; 53 | } 54 | 55 | public void setConfFileName(String confFileName) { 56 | this.confFileName = confFileName; 57 | } 58 | 59 | public String getConfFileContent() { 60 | return confFileContent; 61 | } 62 | 63 | public void setConfFileContent(String confFileContent) { 64 | this.confFileContent = confFileContent; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/bo/CacheObject.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.bo; 2 | 3 | import java.util.Date; 4 | 5 | /** 6 | * Description: 本地缓存对象类 7 | * Created on 2018/1/31 11:19 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class CacheObject { 12 | 13 | /** 14 | * 需要缓存的对象 15 | */ 16 | private T object; 17 | 18 | /** 19 | * 缓存时长,超过该时长,需要重新再获取数据进行覆盖 20 | */ 21 | private long time; 22 | 23 | public CacheObject(T object, long time) { 24 | this.object = object; 25 | this.time = time; 26 | } 27 | 28 | public T getObject() { 29 | return object; 30 | } 31 | 32 | /** 33 | * 是否过期 34 | * 35 | * @param second 过期时长 36 | * @return 37 | */ 38 | public boolean expired(int second) { 39 | if (second <= 0) { 40 | return false; 41 | } else { 42 | return (new Date().getTime() - time) > second * 1000; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/bo/ClientConnectionSearchBO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.bo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Description: 客户端连接信息查询BO 7 | * Created on 2018/2/23 16:59 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class ClientConnectionSearchBO implements Serializable { 12 | 13 | private static final long serialVersionUID = 5679522468625763190L; 14 | 15 | /** 16 | * 集群id 17 | */ 18 | private Integer clusterId; 19 | 20 | /** 21 | * 实例id 22 | */ 23 | private Integer instanceId; 24 | 25 | /** 26 | * 查询开始时间 27 | */ 28 | private String startDate; 29 | 30 | /** 31 | * 查询结束时间 32 | */ 33 | private String endDate; 34 | 35 | /** 36 | * 排序字段 37 | */ 38 | private String orderBy; 39 | 40 | public Integer getClusterId() { 41 | return clusterId; 42 | } 43 | 44 | public void setClusterId(Integer clusterId) { 45 | this.clusterId = clusterId; 46 | } 47 | 48 | public Integer getInstanceId() { 49 | return instanceId; 50 | } 51 | 52 | public void setInstanceId(Integer instanceId) { 53 | this.instanceId = instanceId; 54 | } 55 | 56 | public String getStartDate() { 57 | return startDate; 58 | } 59 | 60 | public void setStartDate(String startDate) { 61 | this.startDate = startDate; 62 | } 63 | 64 | public String getEndDate() { 65 | return endDate; 66 | } 67 | 68 | public void setEndDate(String endDate) { 69 | this.endDate = endDate; 70 | } 71 | 72 | public String getOrderBy() { 73 | return orderBy; 74 | } 75 | 76 | public void setOrderBy(String orderBy) { 77 | this.orderBy = orderBy; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/bo/ClusterInfoSearchBO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.bo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Description: 集群查询信息 7 | * Created on 2018/1/10 10:31 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class ClusterInfoSearchBO implements Serializable { 12 | 13 | private static final long serialVersionUID = 7235621084735424474L; 14 | 15 | /** 16 | * 集群名称 17 | */ 18 | private String clusterName; 19 | 20 | /** 21 | * 负责人用户名 22 | */ 23 | private String officer; 24 | 25 | /** 26 | * 集群状态 27 | */ 28 | private Integer status; 29 | 30 | /** 31 | * 部署类型 32 | */ 33 | private Integer deployType; 34 | 35 | /** 36 | * 集群所属业务线 37 | */ 38 | private Integer serviceLine; 39 | 40 | /** 41 | * zk版本号 42 | */ 43 | private String version; 44 | 45 | public String getClusterName() { 46 | return clusterName; 47 | } 48 | 49 | public void setClusterName(String clusterName) { 50 | this.clusterName = clusterName; 51 | } 52 | 53 | public String getOfficer() { 54 | return officer; 55 | } 56 | 57 | public void setOfficer(String officer) { 58 | this.officer = officer; 59 | } 60 | 61 | public Integer getStatus() { 62 | return status; 63 | } 64 | 65 | public void setStatus(Integer status) { 66 | this.status = status; 67 | } 68 | 69 | public Integer getDeployType() { 70 | return deployType; 71 | } 72 | 73 | public void setDeployType(Integer deployType) { 74 | this.deployType = deployType; 75 | } 76 | 77 | public Integer getServiceLine() { 78 | return serviceLine; 79 | } 80 | 81 | public void setServiceLine(Integer serviceLine) { 82 | this.serviceLine = serviceLine; 83 | } 84 | 85 | public String getVersion() { 86 | return version; 87 | } 88 | 89 | public void setVersion(String version) { 90 | this.version = version; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/bo/InstanceInfoSearchBO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.bo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Description: 实例查询信息 7 | * Created on 2018/1/9 17:21 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class InstanceInfoSearchBO implements Serializable { 12 | 13 | private static final long serialVersionUID = -7448713796459220199L; 14 | 15 | /** 16 | * 集群id 17 | */ 18 | private Integer clusterId; 19 | 20 | /** 21 | * 机器id 22 | */ 23 | private Integer machineId; 24 | 25 | /** 26 | * 实例ip 27 | */ 28 | private String host; 29 | 30 | /** 31 | * 部署类型 32 | */ 33 | private Integer deployType; 34 | 35 | /** 36 | * 实例状态 37 | */ 38 | private Integer status; 39 | 40 | public Integer getClusterId() { 41 | return clusterId; 42 | } 43 | 44 | public void setClusterId(Integer clusterId) { 45 | this.clusterId = clusterId; 46 | } 47 | 48 | public Integer getMachineId() { 49 | return machineId; 50 | } 51 | 52 | public void setMachineId(Integer machineId) { 53 | this.machineId = machineId; 54 | } 55 | 56 | public String getHost() { 57 | return host; 58 | } 59 | 60 | public void setHost(String host) { 61 | this.host = host; 62 | } 63 | 64 | public Integer getDeployType() { 65 | return deployType; 66 | } 67 | 68 | public void setDeployType(Integer deployType) { 69 | this.deployType = deployType; 70 | } 71 | 72 | public Integer getStatus() { 73 | return status; 74 | } 75 | 76 | public void setStatus(Integer status) { 77 | this.status = status; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/bo/InstanceStateLogSearchBO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.bo; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | 6 | /** 7 | * Description: 实例状态历史记录查询条件 8 | * Created on 2018/1/10 16:02 9 | * 10 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 11 | */ 12 | public class InstanceStateLogSearchBO implements Serializable { 13 | 14 | private static final long serialVersionUID = -7181815544517795324L; 15 | 16 | /** 17 | * 集群id 18 | */ 19 | private Integer clusterId; 20 | 21 | /** 22 | * 查询开始时间 23 | */ 24 | private Date startDate; 25 | 26 | /** 27 | * 查询结束时间 28 | */ 29 | private Date endDate; 30 | 31 | /** 32 | * 所查询数据是否只选择leader的数据 33 | */ 34 | private Boolean onlyLeader; 35 | 36 | public Integer getClusterId() { 37 | return clusterId; 38 | } 39 | 40 | public void setClusterId(Integer clusterId) { 41 | this.clusterId = clusterId; 42 | } 43 | 44 | public Date getStartDate() { 45 | return startDate; 46 | } 47 | 48 | public void setStartDate(Date startDate) { 49 | this.startDate = startDate; 50 | } 51 | 52 | public Date getEndDate() { 53 | return endDate; 54 | } 55 | 56 | public void setEndDate(Date endDate) { 57 | this.endDate = endDate; 58 | } 59 | 60 | public Boolean getOnlyLeader() { 61 | return onlyLeader; 62 | } 63 | 64 | public void setOnlyLeader(Boolean onlyLeader) { 65 | this.onlyLeader = onlyLeader; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/bo/MachineSearchBO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.bo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Description: 机器查询信息 7 | * Created on 2018/1/10 14:36 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class MachineSearchBO implements Serializable { 12 | 13 | private static final long serialVersionUID = -7390578957623112712L; 14 | 15 | /** 16 | * 机器ip 17 | */ 18 | private String host; 19 | 20 | /** 21 | * 是否为虚机 22 | */ 23 | private Boolean virtual; 24 | 25 | /** 26 | * 机器所在机房名称 27 | */ 28 | private String room; 29 | 30 | /** 31 | * 机器是否可用 32 | */ 33 | private Boolean available; 34 | 35 | /** 36 | * 机器所属业务线 37 | */ 38 | private Integer serviceLine; 39 | 40 | /** 41 | * 域名 42 | */ 43 | private String hostDomain; 44 | 45 | public String getHost() { 46 | return host; 47 | } 48 | 49 | public void setHost(String host) { 50 | this.host = host; 51 | } 52 | 53 | public Boolean getVirtual() { 54 | return virtual; 55 | } 56 | 57 | public void setVirtual(Boolean virtual) { 58 | this.virtual = virtual; 59 | } 60 | 61 | public String getRoom() { 62 | return room; 63 | } 64 | 65 | public void setRoom(String room) { 66 | this.room = room; 67 | } 68 | 69 | public Boolean getAvailable() { 70 | return available; 71 | } 72 | 73 | public void setAvailable(Boolean available) { 74 | this.available = available; 75 | } 76 | 77 | public Integer getServiceLine() { 78 | return serviceLine; 79 | } 80 | 81 | public void setServiceLine(Integer serviceLine) { 82 | this.serviceLine = serviceLine; 83 | } 84 | 85 | public String getHostDomain() { 86 | return hostDomain; 87 | } 88 | 89 | public void setHostDomain(String hostDomain) { 90 | this.hostDomain = hostDomain; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/bo/MonitorIndicatorSearchBO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.bo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Description: 监控指标搜索BO 7 | * Created on 2018/2/6 14:19 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class MonitorIndicatorSearchBO implements Serializable { 12 | 13 | private static final long serialVersionUID = -2476686051289665955L; 14 | 15 | /** 16 | * 监控指标名称 17 | */ 18 | private String indicatorName; 19 | 20 | /** 21 | * 实现该监控指标的类名称 22 | */ 23 | private String className; 24 | 25 | /** 26 | * 监控指标是否开启,0:关闭,1:开启 27 | */ 28 | private Boolean switchOn; 29 | 30 | /** 31 | * 修改用户id 32 | */ 33 | private Integer modifyUserId; 34 | 35 | @Override 36 | public String toString() { 37 | return "MonitorIndicatorSearchBO{" + 38 | "indicatorName='" + indicatorName + '\'' + 39 | ", className='" + className + '\'' + 40 | ", switchOn=" + switchOn + 41 | ", modifyUserId=" + modifyUserId + 42 | '}'; 43 | } 44 | 45 | public String getIndicatorName() { 46 | return indicatorName; 47 | } 48 | 49 | public void setIndicatorName(String indicatorName) { 50 | this.indicatorName = indicatorName; 51 | } 52 | 53 | public String getClassName() { 54 | return className; 55 | } 56 | 57 | public void setClassName(String className) { 58 | this.className = className; 59 | } 60 | 61 | public Boolean getSwitchOn() { 62 | return switchOn; 63 | } 64 | 65 | public void setSwitchOn(Boolean switchOn) { 66 | this.switchOn = switchOn; 67 | } 68 | 69 | public Integer getModifyUserId() { 70 | return modifyUserId; 71 | } 72 | 73 | public void setModifyUserId(Integer modifyUserId) { 74 | this.modifyUserId = modifyUserId; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/bo/MonitorTaskSearchBO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.bo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Description: 监控任务搜索BO 7 | * Created on 2018/2/6 14:24 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class MonitorTaskSearchBO implements Serializable { 12 | 13 | private static final long serialVersionUID = 1209876326729280870L; 14 | 15 | /** 16 | * 监控指标id 17 | */ 18 | private Integer indicatorId; 19 | 20 | /** 21 | * 集群id 22 | */ 23 | private Integer clusterId; 24 | 25 | /** 26 | * 监控任务是否开启 27 | */ 28 | private Boolean switchOn; 29 | 30 | public Integer getIndicatorId() { 31 | return indicatorId; 32 | } 33 | 34 | public void setIndicatorId(Integer indicatorId) { 35 | this.indicatorId = indicatorId; 36 | } 37 | 38 | public Integer getClusterId() { 39 | return clusterId; 40 | } 41 | 42 | public void setClusterId(Integer clusterId) { 43 | this.clusterId = clusterId; 44 | } 45 | 46 | public Boolean getSwitchOn() { 47 | return switchOn; 48 | } 49 | 50 | public void setSwitchOn(Boolean switchOn) { 51 | this.switchOn = switchOn; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/bo/StatSearchBO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.bo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Description: 统计数据查询BO 7 | * Created on 2018/1/26 10:42 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class StatSearchBO implements Serializable { 12 | 13 | private static final long serialVersionUID = -736420775948348233L; 14 | 15 | /** 16 | * id 17 | */ 18 | private Integer id; 19 | 20 | /** 21 | * 开始时间 22 | */ 23 | private String start; 24 | 25 | /** 26 | * 结束时间 27 | */ 28 | private String end; 29 | 30 | public Integer getId() { 31 | return id; 32 | } 33 | 34 | public void setId(Integer id) { 35 | this.id = id; 36 | } 37 | 38 | public String getStart() { 39 | return start; 40 | } 41 | 42 | public void setStart(String start) { 43 | this.start = start; 44 | } 45 | 46 | public String getEnd() { 47 | return end; 48 | } 49 | 50 | public void setEnd(String end) { 51 | this.end = end; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/bo/UserSearchBO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.bo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Description: 用户查询信息 7 | * Created on 2018/1/8 15:21 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class UserSearchBO implements Serializable { 12 | 13 | private static final long serialVersionUID = 4767886499383494098L; 14 | 15 | /** 16 | * 用户名(英文,唯一识别用户。默认邮箱前缀) 17 | */ 18 | private String userName; 19 | 20 | /** 21 | * 中文名 22 | */ 23 | private String chName; 24 | 25 | /** 26 | * 用户域账户邮箱 27 | */ 28 | private String email; 29 | 30 | /** 31 | * 用户手机 32 | */ 33 | private String mobile; 34 | 35 | /** 36 | * 用户类型(UserEnumClass.UserRoleEnum) 37 | */ 38 | private Integer userRole; 39 | 40 | public String getUserName() { 41 | return userName; 42 | } 43 | 44 | public void setUserName(String userName) { 45 | this.userName = userName; 46 | } 47 | 48 | public String getChName() { 49 | return chName; 50 | } 51 | 52 | public void setChName(String chName) { 53 | this.chName = chName; 54 | } 55 | 56 | public String getEmail() { 57 | return email; 58 | } 59 | 60 | public void setEmail(String email) { 61 | this.email = email; 62 | } 63 | 64 | public String getMobile() { 65 | return mobile; 66 | } 67 | 68 | public void setMobile(String mobile) { 69 | this.mobile = mobile; 70 | } 71 | 72 | public Integer getUserRole() { 73 | return userRole; 74 | } 75 | 76 | public void setUserRole(Integer userRole) { 77 | this.userRole = userRole; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/po/ClusterAlarmUser.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.po; 2 | 3 | /** 4 | * Description: 集群下配置的用户信息,用于报警使用 5 | * Created on 2018/1/11 20:41 6 | * 7 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 8 | */ 9 | public class ClusterAlarmUser { 10 | 11 | /** 12 | * id 13 | */ 14 | private Long id; 15 | 16 | /** 17 | * 集群id 18 | */ 19 | private Integer clusterId; 20 | 21 | /** 22 | * 用户id 23 | */ 24 | private Integer userId; 25 | 26 | @Override 27 | public String toString() { 28 | return "ClusterAlarmUser{" + 29 | "id=" + id + 30 | ", clusterId=" + clusterId + 31 | ", userId=" + userId + 32 | '}'; 33 | } 34 | 35 | public Long getId() { 36 | return id; 37 | } 38 | 39 | public void setId(Long id) { 40 | this.id = id; 41 | } 42 | 43 | public Integer getClusterId() { 44 | return clusterId; 45 | } 46 | 47 | public void setClusterId(Integer clusterId) { 48 | this.clusterId = clusterId; 49 | } 50 | 51 | public Integer getUserId() { 52 | return userId; 53 | } 54 | 55 | public void setUserId(Integer userId) { 56 | this.userId = userId; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/po/ServiceLine.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.po; 2 | 3 | import com.ucar.zkdoctor.pojo.BaseTimeLineObject; 4 | 5 | /** 6 | * Description: 业务线 7 | * Created on 2018/4/10 10:28 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class ServiceLine extends BaseTimeLineObject { 12 | 13 | private static final long serialVersionUID = -3718012297900500354L; 14 | 15 | /** 16 | * id 17 | */ 18 | private Integer id; 19 | 20 | /** 21 | * 业务线名称 22 | */ 23 | private String serviceLineName; 24 | 25 | /** 26 | * 业务线描述 27 | */ 28 | private String serviceLineDesc; 29 | 30 | @Override 31 | public String toString() { 32 | return "ServiceLine{" + 33 | "id=" + id + 34 | ", serviceLineName='" + serviceLineName + '\'' + 35 | ", serviceLineDesc='" + serviceLineDesc + '\'' + 36 | "} " + super.toString(); 37 | } 38 | 39 | public Integer getId() { 40 | return id; 41 | } 42 | 43 | public void setId(Integer id) { 44 | this.id = id; 45 | } 46 | 47 | public String getServiceLineName() { 48 | return serviceLineName; 49 | } 50 | 51 | public void setServiceLineName(String serviceLineName) { 52 | this.serviceLineName = serviceLineName; 53 | } 54 | 55 | public String getServiceLineDesc() { 56 | return serviceLineDesc; 57 | } 58 | 59 | public void setServiceLineDesc(String serviceLineDesc) { 60 | this.serviceLineDesc = serviceLineDesc; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/vo/AllTrendChartVO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.vo; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | /** 8 | * Description: 所有实例运行状态历史折线图表数据点 9 | * Created on 2018/1/26 20:52 10 | * 11 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 12 | */ 13 | public class AllTrendChartVO implements Serializable { 14 | 15 | private static final long serialVersionUID = 5872311797482426796L; 16 | 17 | /** 18 | * 时间点列表 19 | */ 20 | private List time; 21 | 22 | /** 23 | * 实例值列表 24 | */ 25 | private Map> value; 26 | 27 | public List getTime() { 28 | return time; 29 | } 30 | 31 | public void setTime(List time) { 32 | this.time = time; 33 | } 34 | 35 | public Map> getValue() { 36 | return value; 37 | } 38 | 39 | public void setValue(Map> value) { 40 | this.value = value; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/vo/ClusterDeployVO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.vo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Description: 集群部署参数VO 7 | * Created on 2018/1/22 21:24 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class ClusterDeployVO implements Serializable { 12 | 13 | private static final long serialVersionUID = 7657015818597330835L; 14 | 15 | /** 16 | * 集群名称 17 | */ 18 | private String clusterName; 19 | 20 | /** 21 | * 负责人 22 | */ 23 | private String officer; 24 | 25 | /** 26 | * 安装文件名称 27 | */ 28 | private String installFileName; 29 | 30 | /** 31 | * 安装文件存放在的服务器目录 32 | */ 33 | private String installFileDir; 34 | 35 | /** 36 | * 安装包网址 37 | */ 38 | private String downloadSite; 39 | 40 | /** 41 | * 业务线 42 | */ 43 | private Integer serviceLine; 44 | 45 | public String getClusterName() { 46 | return clusterName; 47 | } 48 | 49 | public void setClusterName(String clusterName) { 50 | this.clusterName = clusterName; 51 | } 52 | 53 | public String getOfficer() { 54 | return officer; 55 | } 56 | 57 | public void setOfficer(String officer) { 58 | this.officer = officer; 59 | } 60 | 61 | public String getInstallFileName() { 62 | return installFileName; 63 | } 64 | 65 | public void setInstallFileName(String installFileName) { 66 | this.installFileName = installFileName; 67 | } 68 | 69 | public String getInstallFileDir() { 70 | return installFileDir; 71 | } 72 | 73 | public void setInstallFileDir(String installFileDir) { 74 | this.installFileDir = installFileDir; 75 | } 76 | 77 | public String getDownloadSite() { 78 | return downloadSite; 79 | } 80 | 81 | public void setDownloadSite(String downloadSite) { 82 | this.downloadSite = downloadSite; 83 | } 84 | 85 | public Integer getServiceLine() { 86 | return serviceLine; 87 | } 88 | 89 | public void setServiceLine(Integer serviceLine) { 90 | this.serviceLine = serviceLine; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/vo/ClusterDetailVO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.vo; 2 | 3 | import com.ucar.zkdoctor.pojo.po.ClusterInfo; 4 | import com.ucar.zkdoctor.pojo.po.ClusterState; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Description: 集群详情VO 10 | * Created on 2018/1/11 9:51 11 | * 12 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 13 | */ 14 | public class ClusterDetailVO implements Serializable { 15 | 16 | private static final long serialVersionUID = 7589258238846331400L; 17 | 18 | /** 19 | * 集群基本信息 20 | */ 21 | private ClusterInfo clusterInfo; 22 | 23 | /** 24 | * 集群状态信息 25 | */ 26 | private ClusterState clusterState; 27 | 28 | public ClusterInfo getClusterInfo() { 29 | return clusterInfo; 30 | } 31 | 32 | public void setClusterInfo(ClusterInfo clusterInfo) { 33 | this.clusterInfo = clusterInfo; 34 | } 35 | 36 | public ClusterState getClusterState() { 37 | return clusterState; 38 | } 39 | 40 | public void setClusterState(ClusterState clusterState) { 41 | this.clusterState = clusterState; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/vo/InstanceDetailVO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.vo; 2 | 3 | import com.ucar.zkdoctor.pojo.po.InstanceInfo; 4 | import com.ucar.zkdoctor.pojo.po.InstanceState; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Description: 实例详情VO 10 | * Created on 2018/1/18 17:26 11 | * 12 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 13 | */ 14 | public class InstanceDetailVO implements Serializable { 15 | 16 | private static final long serialVersionUID = 6685428792542140166L; 17 | 18 | /** 19 | * 实例基本信息 20 | */ 21 | private InstanceInfo instanceInfo; 22 | 23 | /** 24 | * 实例状态信息 25 | */ 26 | private InstanceState instanceState; 27 | 28 | public InstanceInfo getInstanceInfo() { 29 | return instanceInfo; 30 | } 31 | 32 | public void setInstanceInfo(InstanceInfo instanceInfo) { 33 | this.instanceInfo = instanceInfo; 34 | } 35 | 36 | public InstanceState getInstanceState() { 37 | return instanceState; 38 | } 39 | 40 | public void setInstanceState(InstanceState instanceState) { 41 | this.instanceState = instanceState; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/vo/MachineDetailVO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.vo; 2 | 3 | import com.ucar.zkdoctor.pojo.po.MachineInfo; 4 | import com.ucar.zkdoctor.pojo.po.MachineState; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Description: 机器详情VO 10 | * Created on 2018/1/19 16:55 11 | * 12 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 13 | */ 14 | public class MachineDetailVO implements Serializable { 15 | 16 | private static final long serialVersionUID = 1502401795667199341L; 17 | 18 | /** 19 | * 机器基本信息 20 | */ 21 | private MachineInfo machineInfo; 22 | 23 | /** 24 | * 机器状态信息 25 | */ 26 | private MachineState machineState; 27 | 28 | public MachineInfo getMachineInfo() { 29 | return machineInfo; 30 | } 31 | 32 | public void setMachineInfo(MachineInfo machineInfo) { 33 | this.machineInfo = machineInfo; 34 | } 35 | 36 | public MachineState getMachineState() { 37 | return machineState; 38 | } 39 | 40 | public void setMachineState(MachineState machineState) { 41 | this.machineState = machineState; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/vo/PageVO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.vo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Description: 分页控制 7 | * Created on 2017/12/26 16:08 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class PageVO implements Serializable { 12 | 13 | private static final long serialVersionUID = 6930724533908437030L; 14 | 15 | private Integer pageSize = 1; 16 | private Integer pageNum = 20; 17 | private Integer total = 1; 18 | 19 | public Integer getPageSize() { 20 | return pageSize; 21 | } 22 | 23 | public void setPageSize(Integer pageSize) { 24 | this.pageSize = pageSize; 25 | } 26 | 27 | public Integer getPageNum() { 28 | return pageNum; 29 | } 30 | 31 | public void setPageNum(Integer pageNum) { 32 | this.pageNum = pageNum; 33 | } 34 | 35 | public Integer getTotal() { 36 | return total; 37 | } 38 | 39 | public void setTotal(Integer total) { 40 | this.total = total; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/vo/TrendChartVO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.vo; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | /** 7 | * Description: 运行状态历史折线图表数据点 8 | * Created on 2018/1/26 11:08 9 | * 10 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 11 | */ 12 | public class TrendChartVO implements Serializable { 13 | 14 | private static final long serialVersionUID = 2147637421895156004L; 15 | 16 | /** 17 | * 时间点列表 18 | */ 19 | private List time; 20 | 21 | /** 22 | * 值列表 23 | */ 24 | private List value; 25 | 26 | public List getTime() { 27 | return time; 28 | } 29 | 30 | public void setTime(List time) { 31 | this.time = time; 32 | } 33 | 34 | public List getValue() { 35 | return value; 36 | } 37 | 38 | public void setValue(List value) { 39 | this.value = value; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/vo/UpdateZnodeDataVO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.vo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Description: 更新节点数据VO 7 | * Created on 2018/2/5 10:19 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class UpdateZnodeDataVO implements Serializable { 12 | 13 | private static final long serialVersionUID = 3983724855440812081L; 14 | 15 | /** 16 | * 修改数据的节点路径 17 | */ 18 | private String path; 19 | 20 | /** 21 | * 新数据内容,目前只支持string类型 22 | */ 23 | private String data; 24 | 25 | /** 26 | * 指定节点的版本号 27 | */ 28 | private Integer version; 29 | 30 | @Override 31 | public String toString() { 32 | return "UpdateZnodeDataVO{" + 33 | ", path='" + path + '\'' + 34 | ", data='" + data + '\'' + 35 | ", version=" + version + 36 | '}'; 37 | } 38 | 39 | public String getPath() { 40 | return path; 41 | } 42 | 43 | public void setPath(String path) { 44 | this.path = path; 45 | } 46 | 47 | public String getData() { 48 | return data; 49 | } 50 | 51 | public void setData(String data) { 52 | this.data = data; 53 | } 54 | 55 | public Integer getVersion() { 56 | return version; 57 | } 58 | 59 | public void setVersion(Integer version) { 60 | this.version = version; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/vo/UploadedJarFileVO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.vo; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Description: 已上传文件列表前端展示VO 7 | * Created on 2018/3/13 20:56 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class UploadedJarFileVO implements Serializable { 12 | 13 | private static final long serialVersionUID = 6351805454642352351L; 14 | 15 | /** 16 | * 表示文件id 17 | */ 18 | private Integer uid; 19 | 20 | /** 21 | * 显示的文件名称 22 | */ 23 | private String name; 24 | 25 | /** 26 | * 文件上传状态,done:已上传,error:上传失败 27 | */ 28 | private String status; 29 | 30 | /** 31 | * 服务器响应信息 32 | */ 33 | private String response; 34 | 35 | /** 36 | * 文件URL 37 | */ 38 | private String url; 39 | 40 | public Integer getUid() { 41 | return uid; 42 | } 43 | 44 | public void setUid(Integer uid) { 45 | this.uid = uid; 46 | } 47 | 48 | public String getName() { 49 | return name; 50 | } 51 | 52 | public void setName(String name) { 53 | this.name = name; 54 | } 55 | 56 | public String getStatus() { 57 | return status; 58 | } 59 | 60 | public void setStatus(String status) { 61 | this.status = status; 62 | } 63 | 64 | public String getResponse() { 65 | return response; 66 | } 67 | 68 | public void setResponse(String response) { 69 | this.response = response; 70 | } 71 | 72 | public String getUrl() { 73 | return url; 74 | } 75 | 76 | public void setUrl(String url) { 77 | this.url = url; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/pojo/vo/ZnodeTreeNodeVO.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.vo; 2 | 3 | /** 4 | * Description: znode节点数据VO 5 | * Created on 2018/2/1 16:08 6 | * 7 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 8 | */ 9 | public class ZnodeTreeNodeVO { 10 | 11 | /** 12 | * 节点结构示例: 13 | * + /zookeeper1 14 | * + /node1 15 | * + /zode11 16 | * + /node2 17 | * + /zookeeper2 18 | * + /node1 19 | * + /node2 20 | */ 21 | 22 | /** 23 | * znode节点名称,用于展示节点名字。如示例中:/zookeeper1、/node1等 24 | */ 25 | private String title; 26 | 27 | /** 28 | * 唯一识别该节点的key,此处用该节点path来表示。如示例中:/zookeeper1,/zookeeper1/node1等 29 | */ 30 | private String key; 31 | 32 | /** 33 | * 该节点是否为叶子节点,默认为非叶子节点,能够展开 34 | */ 35 | private Boolean isLeaf = false; 36 | 37 | @Override 38 | public String toString() { 39 | return "ZnodeTreeNodeVO{" + 40 | "title='" + title + '\'' + 41 | ", key='" + key + '\'' + 42 | ", isLeaf=" + isLeaf + 43 | '}'; 44 | } 45 | 46 | public String getTitle() { 47 | return title; 48 | } 49 | 50 | public void setTitle(String title) { 51 | this.title = title; 52 | } 53 | 54 | public String getKey() { 55 | return key; 56 | } 57 | 58 | public void setKey(String key) { 59 | this.key = key; 60 | } 61 | 62 | public Boolean getLeaf() { 63 | return isLeaf; 64 | } 65 | 66 | public void setLeaf(Boolean leaf) { 67 | isLeaf = leaf; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/cluster/ClusterStateService.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.cluster; 2 | 3 | import com.ucar.zkdoctor.pojo.po.ClusterState; 4 | 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | /** 9 | * Description: 集群状态服务接口 10 | * Created on 2018/1/11 15:14 11 | * 12 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 13 | */ 14 | public interface ClusterStateService { 15 | /** 16 | * 通过集群id获取最新集群状态信息 17 | * 18 | * @param clusterId 集群id 19 | * @return 20 | */ 21 | ClusterState getClusterStateByClusterId(int clusterId); 22 | 23 | /** 24 | * 插入新的集群状态信息 25 | * 26 | * @param clusterState 集群状态 27 | * @return 28 | */ 29 | boolean mergeClusterState(ClusterState clusterState); 30 | 31 | /** 32 | * 删除某集群状态信息 33 | * 34 | * @param clusterId 集群id 35 | * @return 36 | */ 37 | boolean deleteClusterStateByClusterId(int clusterId); 38 | 39 | /** 40 | * 批量写入集群运行状态历史记录 41 | * 42 | * @param clusterStateList 集群状态信息 43 | * @return 44 | */ 45 | boolean batchInsertClusterStateLogs(List clusterStateList); 46 | 47 | /** 48 | * 插入某条集群运行状态记录 49 | * 50 | * @param clusterState 集群状态信息 51 | * @return 52 | */ 53 | boolean insertClusterStateLogs(ClusterState clusterState); 54 | 55 | /** 56 | * 获取某集群的历史状态信息 57 | * 58 | * @param clusterId 集群id 59 | * @param startDate 开始时间 60 | * @param endDate 结束时间 61 | * @return 62 | */ 63 | List getClusterStateLogByClusterId(int clusterId, Date startDate, Date endDate); 64 | 65 | /** 66 | * 删除此时间之前的所有集群状态历史数据 67 | * 68 | * @param endDate 此时间之前的数据将删除 69 | * @return 70 | */ 71 | boolean cleanClusterStateLogData(Date endDate); 72 | 73 | /** 74 | * 需要删除的集群状态历史数据记录的数量 75 | * 76 | * @param endDate 获取此时间之前的所有数据条数 77 | * @return 78 | */ 79 | Long cleanClusterStateLogCount(Date endDate); 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/machine/MachineOperationService.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.machine; 2 | 3 | /** 4 | * Description: 远程ssh机器相关操作接口 5 | * Created on 2018/1/23 12:28 6 | * 7 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 8 | */ 9 | public interface MachineOperationService { 10 | /** 11 | * 在机器上执行shell命令 12 | * 13 | * @param host 目标服务器ip 14 | * @param shell shell命令 15 | * @return 16 | */ 17 | String executeShell(String host, String shell); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/machine/impl/MachineOperationServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.machine.impl; 2 | 3 | import com.ucar.zkdoctor.service.machine.MachineOperationService; 4 | import com.ucar.zkdoctor.util.exception.SSHException; 5 | import com.ucar.zkdoctor.util.ssh.SSHUtil; 6 | import org.apache.commons.lang.StringUtils; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.stereotype.Service; 10 | 11 | /** 12 | * Description: 远程ssh机器相关操作接口实现类 TODO 13 | * Created on 2018/1/23 12:29 14 | * 15 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 16 | */ 17 | @Service 18 | public class MachineOperationServiceImpl implements MachineOperationService { 19 | 20 | private static final Logger LOGGER = LoggerFactory.getLogger(MachineOperationServiceImpl.class); 21 | 22 | @Override 23 | public String executeShell(String host, String shell) { 24 | if (StringUtils.isBlank(host) || StringUtils.isBlank(shell)) { 25 | return null; 26 | } 27 | try { 28 | return SSHUtil.execute(host, shell); 29 | } catch (SSHException e) { 30 | LOGGER.error("execute cmd {} in {} error :" + e.getMessage(), shell, host, e); 31 | } 32 | return null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/monitor/AlertService.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.monitor; 2 | 3 | /** 4 | * Description: 报警服务接口 5 | * Created on 2018/2/5 16:15 6 | * 7 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 8 | */ 9 | public interface AlertService { 10 | 11 | /** 12 | * 集群与实例相关报警 13 | * 14 | * @param clusterId 集群id 15 | * @param instanceId 实例id(null表示该报警为集群级报警) 16 | * @param currentValue 当前值 17 | * @param alertValue 报警阈值 18 | * @param alertForm 报警形式 19 | * @param alertInfo 报警信息 20 | * @param alertUnit 报警值单位 21 | * @param time 发生报警时间 22 | * @param isValueThreshold 此次报警是否为超过阈值类型的报警 23 | */ 24 | void alert(int clusterId, Integer instanceId, String currentValue, String alertValue, int alertForm, 25 | String alertInfo, String alertUnit, String time, Boolean isValueThreshold); 26 | 27 | /** 28 | * 机器相关报警 29 | * 30 | * @param clusterId 集群id 31 | * @param machineId 机器id 32 | * @param currentValue 当前值 33 | * @param alertValue 报警阈值 34 | * @param alertForm 报警形式 35 | * @param alertInfo 报警信息 36 | * @param alertUnit 报警值单位 37 | * @param time 发生报警时间 38 | */ 39 | void alert(int clusterId, Integer machineId, String currentValue, String alertValue, int alertForm, 40 | String alertInfo, String alertUnit, String time); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/schedule/AutowiringSpringBeanJobFactory.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.schedule; 2 | 3 | import org.quartz.spi.TriggerFiredBundle; 4 | import org.springframework.beans.factory.config.AutowireCapableBeanFactory; 5 | import org.springframework.context.ApplicationContext; 6 | import org.springframework.context.ApplicationContextAware; 7 | import org.springframework.scheduling.quartz.SpringBeanJobFactory; 8 | 9 | /** 10 | * Description: 定时任务bean初始化 11 | * Created on 2018/1/29 10:59 12 | * 13 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 14 | */ 15 | public final class AutowiringSpringBeanJobFactory extends SpringBeanJobFactory implements 16 | ApplicationContextAware { 17 | 18 | private transient AutowireCapableBeanFactory beanFactory; 19 | 20 | @Override 21 | public void setApplicationContext(final ApplicationContext context) { 22 | beanFactory = context.getAutowireCapableBeanFactory(); 23 | } 24 | 25 | @Override 26 | protected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception { 27 | final Object job = super.createJobInstance(bundle); 28 | beanFactory.autowireBean(job); 29 | return job; 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/schedule/SchedulerService.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.schedule; 2 | 3 | import com.ucar.zkdoctor.pojo.po.TriggerInfo; 4 | import org.quartz.JobKey; 5 | import org.quartz.TriggerKey; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | /** 11 | * Description: 定时任务 12 | * Created on 2018/1/16 10:55 13 | * 14 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 15 | */ 16 | public interface SchedulerService { 17 | 18 | /** 19 | * 移除定时任务 20 | * 21 | * @param triggerKey 22 | * @return 23 | */ 24 | boolean unscheduleJob(TriggerKey triggerKey); 25 | 26 | /** 27 | * 根据cron部署Job 28 | * 29 | * @param jobKey 30 | * @param triggerKey 31 | * @param dataMap 32 | * @param cron 33 | * @param replace 34 | * @return 35 | */ 36 | boolean deployJobByCron(JobKey jobKey, TriggerKey triggerKey, Map dataMap, String cron, boolean replace); 37 | 38 | /** 39 | * 获取所有trigger 40 | * 41 | * @return 42 | */ 43 | List getAllTriggers(); 44 | 45 | /** 46 | * 模糊查询trigger 47 | * 48 | * @return 49 | */ 50 | List getTriggersByNameOrGroup(String query); 51 | 52 | /** 53 | * 暂停trigger 54 | * 55 | * @param triggerKey triggerKey 56 | * @return 57 | */ 58 | boolean pauseTrigger(TriggerKey triggerKey); 59 | 60 | /** 61 | * 恢复trigger 62 | * 63 | * @param triggerKey triggerKey 64 | * @return 65 | */ 66 | boolean resumeTrigger(TriggerKey triggerKey); 67 | 68 | /** 69 | * 删除定时任务 70 | * 71 | * @param triggerKey triggerKey 72 | * @return 73 | */ 74 | boolean removeTrigger(TriggerKey triggerKey); 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/schedule/jobs/BaseJob.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.schedule.jobs; 2 | 3 | import org.quartz.Job; 4 | import org.quartz.JobExecutionContext; 5 | import org.quartz.JobExecutionException; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | * Description: 定时任务基类,记录job执行时间 13 | * Created on 2018/1/28 22:07 14 | * 15 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 16 | */ 17 | public abstract class BaseJob implements Job, Serializable { 18 | 19 | private static final long serialVersionUID = 3796069056795105260L; 20 | 21 | protected static final Logger LOGGER = LoggerFactory.getLogger(BaseJob.class); 22 | 23 | // 定时任务逻辑 24 | public abstract void action(JobExecutionContext context); 25 | 26 | /** 27 | * 统计时间 28 | * 29 | * @param context 30 | * @throws org.quartz.JobExecutionException 31 | */ 32 | @Override 33 | public void execute(JobExecutionContext context) throws JobExecutionException { 34 | long start = System.currentTimeMillis(); 35 | this.action(context); 36 | long end = System.currentTimeMillis(); 37 | LOGGER.info("Job: {}, trigger: {}, cost: {} ms", context.getJobDetail().getKey(), 38 | context.getTrigger().getKey(), (end - start)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/schedule/jobs/CleanCollectDataJob.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.schedule.jobs; 2 | 3 | import com.ucar.zkdoctor.service.collection.CollectService; 4 | import org.quartz.JobExecutionContext; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import javax.annotation.Resource; 9 | 10 | /** 11 | * Description: 每天晚上1点,根据配置的保存天数信息,清除历史统计数据 12 | * Created on 2018/1/30 9:03 13 | * 14 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 15 | */ 16 | public class CleanCollectDataJob extends BaseJob { 17 | 18 | private static final long serialVersionUID = 357426219319968381L; 19 | 20 | private static final Logger LOGGER = LoggerFactory.getLogger(CleanCollectDataJob.class); 21 | 22 | @Resource 23 | private CollectService collectService; 24 | 25 | @Override 26 | public void action(JobExecutionContext context) { 27 | try { 28 | collectService.cleanCollectData(); 29 | } catch (Exception e) { 30 | LOGGER.error("CleanCollectDataJob execute failed.", e); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/schedule/jobs/InstanceConnectionCollectJob.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.schedule.jobs; 2 | 3 | import com.ucar.zkdoctor.service.collection.CollectService; 4 | import org.quartz.JobExecutionContext; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import javax.annotation.Resource; 9 | 10 | /** 11 | * Description: 实例信息收集定时任务,每一分钟执行一次 12 | * Created on 2018/2/23 11:21 13 | * 14 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 15 | */ 16 | public class InstanceConnectionCollectJob extends BaseJob { 17 | 18 | private static final long serialVersionUID = -1210837346182355771L; 19 | 20 | private static final Logger LOGGER = LoggerFactory.getLogger(InstanceConnectionCollectJob.class); 21 | 22 | @Resource 23 | private CollectService collectService; 24 | 25 | @Override 26 | public void action(JobExecutionContext context) { 27 | try { 28 | collectService.collectAllInstanceConnections(); 29 | } catch (Exception e) { 30 | LOGGER.error("InstanceConnectionCollectJob execute failed.", e); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/schedule/jobs/MachineJob.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.schedule.jobs; 2 | 3 | import com.ucar.zkdoctor.service.collection.CollectService; 4 | import org.quartz.JobExecutionContext; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import javax.annotation.Resource; 9 | 10 | /** 11 | * Description: 机器监控定时任务,每一分钟执行一次 12 | * Created on 2018/2/22 9:24 13 | * 14 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 15 | */ 16 | public class MachineJob extends BaseJob { 17 | 18 | private static final long serialVersionUID = 9107115062681338556L; 19 | 20 | private static final Logger LOGGER = LoggerFactory.getLogger(MachineJob.class); 21 | 22 | @Resource 23 | private CollectService collectService; 24 | 25 | @Override 26 | public void action(JobExecutionContext context) { 27 | try { 28 | collectService.collectAllMachineState(); 29 | } catch (Exception e) { 30 | LOGGER.error("MachineJob execute failed.", e); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/schedule/jobs/MonitorJob.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.schedule.jobs; 2 | 3 | import com.ucar.zkdoctor.service.monitor.MonitorBase; 4 | import org.quartz.JobExecutionContext; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import javax.annotation.Resource; 9 | 10 | /** 11 | * Description: 监控定时任务 12 | * Created on 2018/2/6 16:24 13 | * 14 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 15 | */ 16 | public class MonitorJob extends BaseJob { 17 | 18 | private static final long serialVersionUID = -7416220048861930099L; 19 | 20 | private static final Logger LOGGER = LoggerFactory.getLogger(MonitorJob.class); 21 | 22 | @Resource 23 | private MonitorBase monitorBase; 24 | 25 | @Override 26 | public void action(JobExecutionContext context) { 27 | try { 28 | monitorBase.execute(); 29 | } catch (Exception e) { 30 | LOGGER.error("MonitorJob execute failed.", e); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/schedule/jobs/ZKJob.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.schedule.jobs; 2 | 3 | import com.ucar.zkdoctor.service.collection.CollectService; 4 | import com.ucar.zkdoctor.util.constant.SchedulerConstant; 5 | import org.quartz.JobDataMap; 6 | import org.quartz.JobExecutionContext; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import javax.annotation.Resource; 11 | 12 | /** 13 | * Description: 实例以及集群zk服务端信息收集定时任务,一分钟执行一次 14 | * Created on 2018/1/28 22:03 15 | * 16 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 17 | */ 18 | public class ZKJob extends BaseJob { 19 | 20 | private static final long serialVersionUID = -5377061873474758885L; 21 | 22 | private static final Logger LOGGER = LoggerFactory.getLogger(ZKJob.class); 23 | 24 | @Resource 25 | private CollectService collectService; 26 | 27 | @Override 28 | public void action(JobExecutionContext context) { 29 | try { 30 | JobDataMap dataMap = context.getMergedJobDataMap(); 31 | int clusterId = dataMap.getInt(SchedulerConstant.CLUSTER_KEY); 32 | collectService.collectZKInfo(clusterId); 33 | } catch (Exception e) { 34 | LOGGER.error("ZKJob execute failed.", e); 35 | } 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/system/ConfigService.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.system; 2 | 3 | import com.ucar.zkdoctor.pojo.po.SysConfig; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Description: 系统相关配置服务接口 9 | * Created on 2018/1/23 13:56 10 | * 11 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 12 | */ 13 | public interface ConfigService { 14 | 15 | /** 16 | * 系统初始化的时候,加载指定系统配置项 17 | */ 18 | void initConfig(); 19 | 20 | /** 21 | * 保存新配置信息 22 | * 23 | * @param sysConfig 配置信息 24 | * @return 25 | */ 26 | boolean insertSysConfig(SysConfig sysConfig); 27 | 28 | /** 29 | * 获取指定配置信息 30 | * 31 | * @param configName 配置名称 32 | * @return 33 | */ 34 | SysConfig getSysConfigByName(String configName); 35 | 36 | /** 37 | * 获取所有配置信息 38 | * 39 | * @return 40 | */ 41 | List getAllSysConfig(); 42 | 43 | /** 44 | * 删除某项配置信息 45 | * 46 | * @param configName 配置名称 47 | * @return 48 | */ 49 | boolean deleteSystemByName(String configName); 50 | 51 | /** 52 | * 获取所有配置信息,包含默认配置信息 53 | * 54 | * @return 55 | */ 56 | List getAllSysConfigIncludeDefault(); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/system/Init.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.system; 2 | 3 | import com.ucar.zkdoctor.service.monitor.MonitorService; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.boot.context.event.ApplicationReadyEvent; 7 | import org.springframework.context.ApplicationListener; 8 | import org.springframework.context.ConfigurableApplicationContext; 9 | import org.springframework.stereotype.Component; 10 | 11 | /** 12 | * Description: 初始化工作 13 | * Created on 2018/1/29 15:43 14 | * 15 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 16 | */ 17 | @Component 18 | public class Init implements ApplicationListener { 19 | 20 | private static final Logger LOGGER = LoggerFactory.getLogger(Init.class); 21 | 22 | @Override 23 | public void onApplicationEvent(final ApplicationReadyEvent event) { 24 | LOGGER.info("Init..."); 25 | ConfigurableApplicationContext context = event.getApplicationContext(); 26 | // 初始化监控报警信息 27 | try { 28 | MonitorService monitorService = context.getBean("monitorService", MonitorService.class); 29 | monitorService.initMonitor(); 30 | } catch (Exception e) { 31 | LOGGER.error("Init all monitor info failed.", e); 32 | } 33 | // 初始化系统配置信息 34 | try { 35 | ConfigService configService = context.getBean("configService", ConfigService.class); 36 | configService.initConfig(); 37 | } catch (Exception e) { 38 | LOGGER.error("Init all configuration info failed.", e); 39 | } 40 | // 初始化业务线默认配置信息 41 | try { 42 | ServiceLineService serviceLineService = context.getBean("serviceLineService", ServiceLineService.class); 43 | serviceLineService.initDefaultServiceLine(); 44 | } catch (Exception e) { 45 | LOGGER.error("Init all service lines info failed.", e); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/system/ServiceLineService.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.system; 2 | 3 | import com.ucar.zkdoctor.pojo.po.ServiceLine; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Description: 业务线相关操作服务接口 9 | * Created on 2018/4/10 10:29 10 | * 11 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 12 | */ 13 | public interface ServiceLineService { 14 | 15 | /** 16 | * 系统初始化的时候,初始化默认业务线配置 17 | */ 18 | void initDefaultServiceLine(); 19 | 20 | /** 21 | * 保存新业务线信息 22 | * 23 | * @param serviceLine 业务线信息 24 | * @return 25 | */ 26 | boolean insertServiceLine(ServiceLine serviceLine); 27 | 28 | /** 29 | * 根据业务线名称获取业务线相关信息 30 | * 31 | * @param serviceLineName 业务线名称 32 | * @return 33 | */ 34 | ServiceLine getServiceLineByName(String serviceLineName); 35 | 36 | /** 37 | * 获取所有业务线信息 38 | * 39 | * @return 40 | */ 41 | List getAllServiceLine(); 42 | 43 | /** 44 | * 更新某业务线信息 45 | * 46 | * @param serviceLine 业务线 47 | * @return 48 | */ 49 | boolean updateServiceLine(ServiceLine serviceLine); 50 | 51 | /** 52 | * 删除某业务线信息 53 | * 54 | * @param serviceLineName 业务线名称 55 | * @return 56 | */ 57 | boolean deleteServiceLineByName(String serviceLineName); 58 | 59 | /** 60 | * 获取默认业务线 61 | * 62 | * @return 63 | */ 64 | ServiceLine getDefaultServiceLine(); 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/user/LoginService.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.user; 2 | 3 | /** 4 | * Description: 登录服务 5 | * Created on 2017/12/15 11:06 6 | * 7 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 8 | */ 9 | public interface LoginService { 10 | 11 | /** 12 | * 用户登录校验 13 | * 14 | * @param userName 用户名 15 | * @param password 用户密码 16 | * @return 17 | */ 18 | boolean login(String userName, String password); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/user/UserService.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.user; 2 | 3 | import com.ucar.zkdoctor.pojo.bo.UserSearchBO; 4 | import com.ucar.zkdoctor.pojo.po.User; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Description: 用户服务接口 10 | * Created on 2018/1/5 15:06 11 | * 12 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 13 | */ 14 | public interface UserService { 15 | 16 | /** 17 | * 根据id获取用户信息 18 | * 19 | * @param userId 用户id 20 | * @return 21 | */ 22 | User getUserById(int userId); 23 | 24 | /** 25 | * 根据用户名获取用户信息 26 | * 27 | * @param userName 用户名 28 | * @return 29 | */ 30 | User getUserByName(String userName); 31 | 32 | /** 33 | * 插入新的用户信息 34 | * 35 | * @param userName 用户名称 36 | * @return 37 | */ 38 | boolean saveNewUser(String userName); 39 | 40 | /** 41 | * 插入新的用户信息 42 | * 43 | * @param userName 用户名称 44 | * @param chName 用户中文名 45 | * @param email 邮箱 46 | * @param mobile 手机号 47 | * @param userRole 用户角色 48 | * @return 49 | */ 50 | boolean saveNewUser(String userName, String chName, String email, String mobile, int userRole); 51 | 52 | /** 53 | * 插入新的用户信息 54 | * 55 | * @param user 新用户信息 56 | * @return 57 | */ 58 | boolean saveNewUser(User user); 59 | 60 | /** 61 | * 更新用户信息 62 | * 63 | * @param user 用户新信息 64 | * @return 65 | */ 66 | boolean updateUser(User user); 67 | 68 | /** 69 | * 通过用户id删除用户 70 | * 71 | * @param userId 用户id 72 | * @return 73 | */ 74 | boolean deleteUserById(int userId); 75 | 76 | /** 77 | * 通过用户名删除用户 78 | * 79 | * @param userName 用户名 80 | * @return 81 | */ 82 | boolean deleteUserByName(String userName); 83 | 84 | /** 85 | * 获取所有用户信息 86 | * 87 | * @return 88 | */ 89 | List getAllUsersByParams(UserSearchBO userSearchBO); 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/user/impl/LoginServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.user.impl; 2 | 3 | import com.ucar.zkdoctor.pojo.po.User; 4 | import com.ucar.zkdoctor.service.user.LoginService; 5 | import com.ucar.zkdoctor.service.user.UserService; 6 | import com.ucar.zkdoctor.util.config.ConfigUtil; 7 | import com.ucar.zkdoctor.util.constant.UserEnumClass.LoginCheckType; 8 | import com.ucar.zkdoctor.util.tool.LoginUtil; 9 | import org.springframework.stereotype.Service; 10 | 11 | import javax.annotation.Resource; 12 | 13 | /** 14 | * Description: 登录服务 15 | * Created on 2017/12/15 11:05 16 | * 17 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 18 | */ 19 | @Service 20 | public class LoginServiceImpl implements LoginService { 21 | 22 | @Resource 23 | private UserService userService; 24 | 25 | @Override 26 | public boolean login(String userName, String password) { 27 | LoginCheckType loginCheckType = ConfigUtil.getLoginCheckType(); 28 | switch (loginCheckType) { 29 | case REGISTER: 30 | User user = userService.getUserByName(userName); 31 | if (user != null) { // 进行用户名密码校验 32 | return LoginUtil.registerLogin(password, user.getPassword()); 33 | } 34 | break; 35 | case LDAP: 36 | boolean login = LoginUtil.ldapLogin(userName, password); 37 | if (login) { // 如果使用ldap登录,用户之前未登录,则保存用户信息 38 | User loginUser = userService.getUserByName(userName); 39 | if (loginUser == null) { 40 | userService.saveNewUser(userName); 41 | } 42 | } 43 | return login; 44 | } 45 | return false; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/service/view/MenuService.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.view; 2 | 3 | import com.ucar.zkdoctor.pojo.po.User; 4 | import com.ucar.zkdoctor.pojo.vo.TreeNodeVO; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Description: 菜单 10 | * Created on 2017/12/26 14:58 11 | * 12 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 13 | */ 14 | public interface MenuService { 15 | /** 16 | * 根据用户角色信息,返回显示的菜单 17 | * 18 | * @param user 用户信息 19 | * @return 20 | */ 21 | List getTreeList(User user); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/constant/ClusterEnumClass.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.constant; 2 | 3 | /** 4 | * Description: 集群相关枚举类 5 | * Created on 2018/1/9 11:36 6 | * 7 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 8 | */ 9 | public class ClusterEnumClass { 10 | 11 | /** 12 | * 集群状态枚举类 13 | */ 14 | public enum ClusterStatusEnum { 15 | 16 | /** 17 | * 集群未监控状态 18 | */ 19 | NOT_MONITORED(1, "未监控"), 20 | 21 | /** 22 | * 集群监控状态,且正常运行 23 | */ 24 | RUNNING(2, "运行中"), 25 | 26 | /** 27 | * 集群已下线 28 | */ 29 | OFFLINE(3, "已下线"), 30 | 31 | /** 32 | * 集群监控状态,但异常 33 | */ 34 | EXCEPTION(4, "异常"); 35 | 36 | private Integer status; 37 | private String desc; 38 | 39 | ClusterStatusEnum(Integer status, String desc) { 40 | this.status = status; 41 | this.desc = desc; 42 | } 43 | 44 | public Integer getStatus() { 45 | return status; 46 | } 47 | 48 | public String getDesc() { 49 | return desc; 50 | } 51 | 52 | public static String getDescByStatus(int status) { 53 | for (ClusterStatusEnum statusEnum : ClusterStatusEnum.values()) { 54 | if (statusEnum.getStatus() == status) { 55 | return statusEnum.getDesc(); 56 | } 57 | } 58 | return "null"; 59 | } 60 | 61 | public static ClusterStatusEnum getClusterStatusEnumByStatus(int status) { 62 | for (ClusterStatusEnum statusEnum : ClusterStatusEnum.values()) { 63 | if (statusEnum.getStatus() == status) { 64 | return statusEnum; 65 | } 66 | } 67 | return null; 68 | } 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/constant/CommonEnumClass.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.constant; 2 | 3 | /** 4 | * Description: 通用的一些枚举类 5 | * Created on 2018/1/9 11:45 6 | * 7 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 8 | */ 9 | public class CommonEnumClass { 10 | 11 | /** 12 | * 报警形式枚举类 13 | */ 14 | public enum AlertForm { 15 | /** 16 | * 邮件 17 | */ 18 | MAIL(0, "邮件"), 19 | 20 | /** 21 | * 短信 22 | */ 23 | MESSAGE(1, "短信"), 24 | 25 | /** 26 | * 邮件+短信 27 | */ 28 | MAILADNMESSAGE(2, "邮件+短信"); 29 | 30 | private int alert; 31 | private String desc; 32 | 33 | AlertForm(int alert, String desc) { 34 | this.alert = alert; 35 | this.desc = desc; 36 | } 37 | 38 | public int getAlert() { 39 | return alert; 40 | } 41 | 42 | public String getDesc() { 43 | return desc; 44 | } 45 | 46 | public static String getDescByAlert(int alert) { 47 | for (AlertForm status : AlertForm.values()) { 48 | if (status.getAlert() == alert) { 49 | return status.getDesc(); 50 | } 51 | } 52 | return ""; 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/constant/FourLetterCommand.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.constant; 2 | 3 | /** 4 | * Description: 四字监控命令 5 | * Created on 2018/1/23 11:24 6 | * 7 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 8 | */ 9 | public enum FourLetterCommand { 10 | /** 11 | * conf (New in 3.3.0)输出相关服务配置的详细信息。比如端口、zk数据及日志配置路径、最大连接数,session超时时间、serverId等 12 | * cons (New in 3.3.0)列出所有连接到这台服务器的客户端连接/会话的详细信息。包括“接受/发送”的包数量、session id 、操作延迟、最后的操作执行等信息 13 | * crst New in 3.3.0)重置当前这台服务器所有连接/会话的统计信息 14 | * dump 列出未经处理的会话和临时节点(只在leader上有效) 15 | * envi 输出关于服务器的环境详细信息(不同于conf命令),比如host.name、java.version、java.home、user.dir=/data/zookeeper-3.4.6/bin之类信息 16 | * ruok 测试服务是否处于正确运行状态。如果正常返回"imok",否则返回空 17 | * srst 重置服务器的统计信息 18 | * srvr (New in 3.3.0)输出服务器的详细信息。zk版本、接收/发送包数量、连接数、模式(leader/follower)、节点总数 19 | * stat 输出服务器的详细信息:接收/发送包数量、连接数、模式(leader/follower)、节点总数、延迟。 所有客户端的列表 20 | * wchs (New in 3.3.0)列出服务器watches的简洁信息:连接总数、watching节点总数和watches总数 21 | * wchc (New in 3.3.0)通过session分组,列出watch的所有节点,它的输出是一个与 watch 相关的会话的节点列表。如果watches数量很大的话,将会产生很大的开销,会影响性能,小心使用 22 | * wchp (New in 3.3.0)通过路径分组,列出所有的 watch 的session id信息。它输出一个与 session 相关的路径。如果watches数量很大的话,将会产生很大的开销,会影响性能,小心使用 23 | * mntr (New in 3.4.0)列出集群的健康状态。包括“接受/发送”的包数量、操作延迟、当前服务模式(leader/follower)、节点总数、watch总数、临时节点总数 24 | */ 25 | conf, 26 | cons, 27 | crst, 28 | dump, 29 | envi, 30 | ruok, 31 | srst, 32 | srvr, 33 | stat, 34 | wchs, 35 | wchc, 36 | wchp, 37 | mntr, 38 | } -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/constant/InstanceEnumClass.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.constant; 2 | 3 | /** 4 | * Description: 5 | * Created on 2018/1/9 11:38 6 | * 7 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 8 | */ 9 | public class InstanceEnumClass { 10 | 11 | /** 12 | * 实例状态枚举类 13 | */ 14 | public enum InstanceStatusEnum { 15 | 16 | /** 17 | * 异常 18 | */ 19 | EXCEPTION(0, "异常"), 20 | 21 | /** 22 | * 正在运行 23 | */ 24 | RUNNING(1, "正在运行"), 25 | 26 | /** 27 | * 已下线 28 | */ 29 | OFFLINE(3, "已下线"), 30 | 31 | /** 32 | * 未运行 33 | */ 34 | NOT_RUNNING(4, "未运行"); 35 | 36 | private int status; 37 | private String desc; 38 | 39 | InstanceStatusEnum(int status, String desc) { 40 | this.status = status; 41 | this.desc = desc; 42 | } 43 | 44 | public int getStatus() { 45 | return status; 46 | } 47 | 48 | public String getDesc() { 49 | return desc; 50 | } 51 | 52 | public static String getDescByStatus(int status) { 53 | for (InstanceStatusEnum instanceStatusEnum : InstanceStatusEnum.values()) { 54 | if (instanceStatusEnum.getStatus() == status) { 55 | return instanceStatusEnum.getDesc(); 56 | } 57 | } 58 | return "null"; 59 | } 60 | 61 | public static InstanceStatusEnum getInstanceStatusEnumByStatus(int status) { 62 | for (InstanceStatusEnum statusEnum : InstanceStatusEnum.values()) { 63 | if (statusEnum.getStatus() == status) { 64 | return statusEnum; 65 | } 66 | } 67 | return null; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/constant/SymbolConstant.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.constant; 2 | 3 | /** 4 | * Description: 一些常用符号常量 5 | * Created on 2018/2/22 11:09 6 | * 7 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 8 | */ 9 | public class SymbolConstant { 10 | /** 11 | * 基本单位 12 | */ 13 | public static final int BASE_UNIT = 1024; 14 | 15 | /** 16 | * 换行 17 | */ 18 | public static final String NEXT_LINE = "\n"; 19 | 20 | /** 21 | * 任意空格 22 | */ 23 | public static final String ANY_BLANK = "\\s+"; 24 | 25 | /** 26 | * 空格 27 | */ 28 | public static final String BLANK = " "; 29 | 30 | /** 31 | * - 32 | */ 33 | public static final String DASH = "-"; 34 | 35 | /** 36 | * % 37 | */ 38 | public static final String PERCENT = "%"; 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/exception/ParseException.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.exception; 2 | 3 | /** 4 | * Description: 数据转化异常 5 | * Created on 2018/1/23 11:29 6 | * 7 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 8 | */ 9 | public class ParseException extends Exception { 10 | 11 | private static final long serialVersionUID = -2149749726436911783L; 12 | 13 | public ParseException() { 14 | } 15 | 16 | public ParseException(String message) { 17 | super(message); 18 | } 19 | 20 | public ParseException(String message, Throwable cause) { 21 | super(message, cause); 22 | } 23 | 24 | public ParseException(Throwable cause) { 25 | super(cause); 26 | } 27 | 28 | public ParseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 29 | super(message, cause, enableSuppression, writableStackTrace); 30 | } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/exception/SSHException.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.exception; 2 | 3 | /** 4 | * Description: SSH异常 5 | * Created on 2018/1/23 12:42 6 | * 7 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 8 | */ 9 | public class SSHException extends Exception { 10 | 11 | private static final long serialVersionUID = -3690754092850349309L; 12 | 13 | public SSHException() { 14 | super(); 15 | } 16 | 17 | public SSHException(String message) { 18 | super(message); 19 | } 20 | 21 | public SSHException(String message, Throwable cause) { 22 | super(message, cause); 23 | } 24 | 25 | public SSHException(Throwable cause) { 26 | super(cause); 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/parser/ConnectionReaderParser.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.parser; 2 | 3 | import com.ucar.zkdoctor.pojo.dto.ConnectionInfoDTO; 4 | import com.ucar.zkdoctor.util.exception.ParseException; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import java.io.BufferedReader; 9 | import java.io.IOException; 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | /** 14 | * Description: cons四字命令结果转化器 15 | * Created on 2018/1/31 14:03 16 | * 17 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 18 | */ 19 | public class ConnectionReaderParser implements ReaderParser> { 20 | 21 | private static final Logger LOGGER = LoggerFactory.getLogger(ConnectionReaderParser.class); 22 | 23 | private LineParser lineParser = new ConnectionInfoParser(); 24 | 25 | @Override 26 | public List parseReader(BufferedReader reader) throws ParseException { 27 | try { 28 | List result = new ArrayList(); 29 | String line; 30 | while ((line = reader.readLine()) != null) { 31 | try { 32 | ConnectionInfoDTO info = lineParser.parse(line); 33 | if (info != null) { 34 | result.add(info); 35 | } 36 | } catch (ParseException e) { 37 | LOGGER.warn("ConnectionInfo parse failed.", e); 38 | } 39 | } 40 | return result; 41 | } catch (IOException e) { 42 | throw new RuntimeException("流读取异常", e); 43 | } 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/parser/KVPairParamParser.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.parser; 2 | 3 | import com.ucar.zkdoctor.util.exception.ParseException; 4 | import org.apache.commons.lang.StringUtils; 5 | 6 | /** 7 | * Description: k-v数据格式转化 8 | * Created on 2018/1/29 19:52 9 | * 10 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 11 | */ 12 | public class KVPairParamParser implements LineParser { 13 | 14 | private static final String DEFAULT_SEPARATOR = "="; 15 | 16 | private String separator = DEFAULT_SEPARATOR; 17 | 18 | public KVPairParamParser() { 19 | 20 | } 21 | 22 | public KVPairParamParser(String separator) { 23 | if (separator == null || separator.length() == 0) { 24 | throw new IllegalArgumentException("argument separator can't be empty"); 25 | } 26 | this.separator = separator; 27 | } 28 | 29 | @Override 30 | public String[] parse(String line) throws ParseException { 31 | if (StringUtils.isBlank(line)) { 32 | return null; 33 | } 34 | String[] splits = line.split(separator); 35 | if (splits.length != 2) { 36 | throw new ParseException("参数解析失败,串格式错误:" + line); 37 | } 38 | return splits; 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/parser/LineParser.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.parser; 2 | 3 | import com.ucar.zkdoctor.util.exception.ParseException; 4 | 5 | /** 6 | * Description: 行转化器 7 | * Created on 2018/1/29 19:52 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public interface LineParser { 12 | T parse(String line) throws ParseException; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/parser/MapReaderParser.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.parser; 2 | 3 | import com.ucar.zkdoctor.util.exception.ParseException; 4 | 5 | import java.io.BufferedReader; 6 | import java.io.IOException; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * Description: map数据格式转化 12 | * Created on 2018/1/29 19:51 13 | * 14 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 15 | */ 16 | public class MapReaderParser implements ReaderParser> { 17 | 18 | private LineParser paramParser; 19 | 20 | public MapReaderParser() { 21 | this.paramParser = new KVPairParamParser(); 22 | } 23 | 24 | public MapReaderParser(String separator) { 25 | this.paramParser = new KVPairParamParser(separator); 26 | } 27 | 28 | public MapReaderParser(LineParser paramParser) { 29 | this.paramParser = paramParser; 30 | } 31 | 32 | @Override 33 | public Map parseReader(BufferedReader reader) throws ParseException { 34 | try { 35 | Map result = new HashMap(); 36 | String line = null; 37 | while ((line = reader.readLine()) != null) { 38 | String[] splits = paramParser.parse(line); 39 | if (splits == null) { 40 | continue; 41 | } 42 | if (splits.length == 2) { 43 | result.put(splits[0], splits[1]); 44 | } else { 45 | throw new RuntimeException("解析器返回结果数组长度错误"); 46 | } 47 | } 48 | return result; 49 | } catch (IOException e) { 50 | throw new RuntimeException("流读取异常", e); 51 | } 52 | } 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/parser/ReaderParser.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.parser; 2 | 3 | import com.ucar.zkdoctor.util.exception.ParseException; 4 | 5 | import java.io.BufferedReader; 6 | 7 | /** 8 | * Description: 数据流读转化器 9 | * Created on 2018/1/23 11:28 10 | * 11 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 12 | */ 13 | public interface ReaderParser { 14 | 15 | T parseReader(BufferedReader reader) throws ParseException; 16 | 17 | } -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/parser/ServerStateReaderParser.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.parser; 2 | 3 | import com.ucar.zkdoctor.pojo.dto.ServerStateInfoDTO; 4 | import com.ucar.zkdoctor.util.exception.ParseException; 5 | import com.ucar.zkdoctor.util.tool.ReflectUtils; 6 | 7 | import java.io.BufferedReader; 8 | import java.util.Map; 9 | 10 | /** 11 | * Description: mntr四字命令结果转化器 12 | * Created on 2018/1/29 19:49 13 | * 14 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 15 | */ 16 | public class ServerStateReaderParser implements ReaderParser { 17 | 18 | private ReaderParser> mapReaderParser = new MapReaderParser("\t"); 19 | 20 | @Override 21 | public ServerStateInfoDTO parseReader(BufferedReader reader) throws ParseException { 22 | Map attrMap = mapReaderParser.parseReader(reader); 23 | ServerStateInfoDTO info = new ServerStateInfoDTO(); 24 | ReflectUtils.assignAttrs(info, attrMap); 25 | return info; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/parser/StringReaderParser.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.parser; 2 | 3 | import com.ucar.zkdoctor.util.exception.ParseException; 4 | 5 | import java.io.BufferedReader; 6 | import java.io.IOException; 7 | 8 | /** 9 | * Description: 字符串解析器 10 | * Created on 2018/1/23 11:40 11 | * 12 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 13 | */ 14 | public class StringReaderParser implements ReaderParser { 15 | 16 | @Override 17 | public String parseReader(BufferedReader reader) throws ParseException { 18 | try { 19 | return reader.readLine(); 20 | } catch (IOException e) { 21 | throw new RuntimeException("流读取异常", e); 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/parser/ZKServerConfigReaderParser.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.parser; 2 | 3 | import com.ucar.zkdoctor.pojo.dto.ZKServerConfigDTO; 4 | import com.ucar.zkdoctor.util.exception.ParseException; 5 | import com.ucar.zkdoctor.util.tool.ReflectUtils; 6 | 7 | import java.io.BufferedReader; 8 | import java.util.Map; 9 | 10 | /** 11 | * Description: conf四字命令结果转化器 12 | * Created on 2018/1/30 21:51 13 | * 14 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 15 | */ 16 | public class ZKServerConfigReaderParser implements ReaderParser { 17 | 18 | private ReaderParser> mapReaderParser = new MapReaderParser(); 19 | 20 | @Override 21 | public ZKServerConfigDTO parseReader(BufferedReader reader) throws ParseException { 22 | Map attrMap = mapReaderParser.parseReader(reader); 23 | ZKServerConfigDTO zkServerConfigDTO = new ZKServerConfigDTO(); 24 | ReflectUtils.assignAttrs(zkServerConfigDTO, attrMap); 25 | return zkServerConfigDTO; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/thread/NamedThreadFactory.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.thread; 2 | 3 | import java.util.concurrent.ThreadFactory; 4 | import java.util.concurrent.atomic.AtomicInteger; 5 | 6 | /** 7 | * Description: 命名线程池工厂类 8 | * Created on 2018/1/23 12:40 9 | * 10 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 11 | */ 12 | public class NamedThreadFactory implements ThreadFactory { 13 | 14 | private static final AtomicInteger POOL_SEQ = new AtomicInteger(1); 15 | 16 | private final AtomicInteger mThreadNum = new AtomicInteger(1); 17 | 18 | private final String mPrefix; 19 | 20 | private final boolean mDaemo; 21 | 22 | private final ThreadGroup mGroup; 23 | 24 | public NamedThreadFactory() { 25 | this("pool-" + POOL_SEQ.getAndIncrement(), false); 26 | } 27 | 28 | public NamedThreadFactory(String prefix) { 29 | this(prefix, false); 30 | } 31 | 32 | public NamedThreadFactory(String prefix, boolean daemo) { 33 | mPrefix = prefix + "-thread-"; 34 | mDaemo = daemo; 35 | SecurityManager s = System.getSecurityManager(); 36 | mGroup = (s == null) ? Thread.currentThread().getThreadGroup() : s.getThreadGroup(); 37 | } 38 | 39 | public Thread newThread(Runnable runnable) { 40 | String name = mPrefix + mThreadNum.getAndIncrement(); 41 | Thread ret = new Thread(mGroup, runnable, name, 0); 42 | ret.setDaemon(mDaemo); 43 | return ret; 44 | } 45 | 46 | public ThreadGroup getThreadGroup() { 47 | return mGroup; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/tool/HessianSerializerUtils.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.tool; 2 | 3 | import com.caucho.hessian.io.AbstractHessianInput; 4 | import com.caucho.hessian.io.AbstractHessianOutput; 5 | import com.caucho.hessian.io.Hessian2Input; 6 | import com.caucho.hessian.io.Hessian2Output; 7 | import com.caucho.hessian.io.SerializerFactory; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | import java.io.ByteArrayInputStream; 12 | import java.io.ByteArrayOutputStream; 13 | import java.io.IOException; 14 | 15 | /** 16 | * Description: hessian序列化工具 17 | * Created on 2018/2/5 9:31 18 | * 19 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 20 | */ 21 | public class HessianSerializerUtils { 22 | 23 | private static final Logger LOGGER = LoggerFactory.getLogger(HessianSerializerUtils.class); 24 | 25 | /** 26 | * 将对象序列化为字节数组 27 | * 28 | * @param obj 待序列化对象 29 | * @return 30 | */ 31 | public static byte[] serialize(Object obj) { 32 | ByteArrayOutputStream ops = new ByteArrayOutputStream(); 33 | AbstractHessianOutput out = new Hessian2Output(ops); 34 | out.setSerializerFactory(new SerializerFactory()); 35 | try { 36 | out.writeObject(obj); 37 | out.close(); 38 | } catch (IOException e) { 39 | LOGGER.error("Hessian serialize failed.", e); 40 | throw new RuntimeException("Hessian serialize failed"); 41 | } 42 | return ops.toByteArray(); 43 | } 44 | 45 | /** 46 | * 反序列化 47 | * 48 | * @param bytes 待反序列化字节数组 49 | * @return 50 | */ 51 | public static Object deserialize(byte[] bytes) { 52 | ByteArrayInputStream ips = new ByteArrayInputStream(bytes); 53 | AbstractHessianInput in = new Hessian2Input(ips); 54 | in.setSerializerFactory(new SerializerFactory()); 55 | Object value; 56 | try { 57 | value = in.readObject(); 58 | in.close(); 59 | } catch (IOException e) { 60 | LOGGER.error("Hessian deserialize failed", e); 61 | throw new RuntimeException("Hessian deserialize failed"); 62 | } 63 | return value; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/tool/IdempotentConfirmer.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.tool; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | /** 7 | * Description: 幂等操作器 8 | * Created on 2018/1/16 10:31 9 | * 10 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 11 | */ 12 | public abstract class IdempotentConfirmer { 13 | 14 | private static final Logger LOGGER = LoggerFactory.getLogger(IdempotentConfirmer.class); 15 | 16 | private int retry = 3; 17 | 18 | protected IdempotentConfirmer(int retry) { 19 | this.retry = retry; 20 | } 21 | 22 | public IdempotentConfirmer() { 23 | } 24 | 25 | public abstract boolean execute(); 26 | 27 | public boolean run() { 28 | while (retry-- > 0) { 29 | try { 30 | boolean isOk = execute(); 31 | if (isOk) { 32 | return true; 33 | } 34 | } catch (Exception e) { 35 | LOGGER.error(e.getMessage(), e); 36 | continue; 37 | } 38 | } 39 | return false; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/tool/LoginUtil.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.tool; 2 | 3 | import org.apache.commons.lang.StringUtils; 4 | 5 | /** 6 | * Description: ldap 登录工具 7 | * Created on 2017/12/18 10:24 8 | * 9 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 10 | */ 11 | public class LoginUtil { 12 | 13 | /** 14 | * LDAP登录校验 15 | * 16 | * @param username 用户名 17 | * @param password 密码 18 | * @return 19 | */ 20 | public static boolean ldapLogin(String username, String password) { 21 | // TODO 自行增加ldap校验过程 22 | return true; 23 | } 24 | 25 | /** 26 | * 用户密码校验 27 | * 28 | * @param loginPassword 登录密码 29 | * @param userPassword 用户密码 30 | * @return 31 | */ 32 | public static boolean registerLogin(String loginPassword, String userPassword) { 33 | String shaPassword = SHACryptor.encode(loginPassword); 34 | return StringUtils.isNotBlank(shaPassword) && shaPassword.equals(userPassword); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/util/tool/SHACryptor.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.tool; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.math.BigInteger; 7 | import java.security.MessageDigest; 8 | 9 | /** 10 | * Description: SHA密码器,用于密码加密 11 | * Created on 2018/4/25 20:14 12 | * 13 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 14 | */ 15 | public class SHACryptor { 16 | 17 | private static final Logger LOGGER = LoggerFactory.getLogger(SHACryptor.class); 18 | 19 | /** 20 | * 加密算法 21 | */ 22 | public static final String KEY_SHA = "SHA"; 23 | 24 | /** 25 | * 对给定字符串进行加密 26 | * 27 | * @param src 待加密字符串 28 | * @return 29 | */ 30 | public static String encode(String src) { 31 | try { 32 | MessageDigest messageDigest = MessageDigest.getInstance(KEY_SHA); 33 | messageDigest.update(src.getBytes("utf-8")); 34 | BigInteger sha = new BigInteger(messageDigest.digest()); 35 | return sha.toString(); 36 | } catch (Exception e) { 37 | LOGGER.error("Encode src {} failed.", src, e); 38 | throw new RuntimeException("加密错误!"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/web/ConResult.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.web; 2 | 3 | import org.apache.commons.lang.StringUtils; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Description: 后台处理结果 9 | * Created on 2017/12/26 10:17 10 | * 11 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 12 | */ 13 | public class ConResult implements Serializable { 14 | 15 | private static final long serialVersionUID = -5957141240155159041L; 16 | 17 | /** 18 | * 请求是否成功 19 | */ 20 | private boolean success; 21 | 22 | /** 23 | * 信息 24 | */ 25 | private String message = "Successfully"; 26 | 27 | /** 28 | * 结果数据 29 | */ 30 | private Object data; 31 | 32 | public static ConResult success() { 33 | return success((Object) null); 34 | } 35 | 36 | public static ConResult success(Object data) { 37 | return new ConResult(true, (String) "Successfully", data); 38 | } 39 | 40 | public static ConResult success(Object data, String message) { 41 | return new ConResult(true, (String) message, data); 42 | } 43 | 44 | public static ConResult fail() { 45 | return fail("操作失败请重试!"); 46 | } 47 | 48 | public static ConResult fail(String message) { 49 | if (StringUtils.isEmpty(message) || message.indexOf("Exception") > 0) { 50 | message = "系统操作过程中出现错误,请重试"; 51 | } 52 | return new ConResult(false, message, (Object) null); 53 | } 54 | 55 | public ConResult(boolean success, String message, Object data) { 56 | this.success = success; 57 | this.message = message; 58 | this.data = data; 59 | } 60 | 61 | public ConResult() { 62 | } 63 | 64 | public boolean isSuccess() { 65 | return this.success; 66 | } 67 | 68 | public void setMessage(String message) { 69 | this.message = message; 70 | } 71 | 72 | public String getMessage() { 73 | return this.message; 74 | } 75 | 76 | public Object getData() { 77 | return this.data; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/web/controller/BaseController.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.web.controller; 2 | 3 | import com.ucar.zkdoctor.pojo.po.User; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | 7 | /** 8 | * Description: 控制器基类 9 | * Created on 2017/12/18 9:50 10 | * 11 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 12 | */ 13 | public class BaseController { 14 | 15 | /** 16 | * 记录用户session信息 17 | * 18 | * @param request 19 | * @param userBean 20 | */ 21 | protected void bindUserToSession(HttpServletRequest request, User userBean) { 22 | request.getSession().setAttribute("user", userBean); 23 | } 24 | 25 | /** 26 | * 查询用户session信息 27 | * 28 | * @param request 29 | * @return 30 | */ 31 | protected User retrieveUser(HttpServletRequest request) { 32 | return (User) request.getSession().getAttribute("user"); 33 | } 34 | 35 | /** 36 | * 清空用户session信息 37 | * 38 | * @param request 39 | */ 40 | protected void clearUserSession(HttpServletRequest request) { 41 | request.getSession().invalidate(); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/ucar/zkdoctor/web/controller/common/MenuController.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.web.controller.common; 2 | 3 | import com.ucar.zkdoctor.pojo.po.User; 4 | import com.ucar.zkdoctor.pojo.vo.TreeNodeVO; 5 | import com.ucar.zkdoctor.service.view.MenuService; 6 | import com.ucar.zkdoctor.web.ConResult; 7 | import com.ucar.zkdoctor.web.controller.BaseController; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | 14 | import javax.annotation.Resource; 15 | import javax.servlet.http.HttpServletRequest; 16 | import java.util.List; 17 | 18 | /** 19 | * Description: 菜单权限控制 20 | * Created on 2017/12/26 14:57 21 | * 22 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 23 | */ 24 | @Controller 25 | @RequestMapping("/menu") 26 | public class MenuController extends BaseController { 27 | 28 | private static final Logger LOGGER = LoggerFactory.getLogger(MenuController.class); 29 | 30 | @Resource 31 | private MenuService menuService; 32 | 33 | /** 34 | * 返回菜单栏 35 | * 36 | * @param request 37 | * @return 38 | */ 39 | @RequestMapping("/treeList") 40 | @ResponseBody 41 | public ConResult treeList(HttpServletRequest request) { 42 | try { 43 | User user = retrieveUser(request); 44 | List treeList = menuService.getTreeList(user); 45 | return ConResult.success(treeList); 46 | } catch (Exception e) { 47 | LOGGER.error(e.getMessage(), e); 48 | return ConResult.fail(e.getMessage()); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | ####### MySQL配置 ############################################# 2 | ${datasource.url} 3 | ${datasource.username} 4 | ${datasource.password} 5 | 6 | spring.datasource.type=com.zaxxer.hikari.HikariDataSource 7 | spring.datasource.hikari.minimum-idle=5 8 | spring.datasource.hikari.maximum-pool-size=15 9 | spring.datasource.hikari.auto-commit=true 10 | spring.datasource.hikari.idle-timeout=30000 11 | spring.datasource.hikari.pool-name=DatebookHikariCP 12 | spring.datasource.hikari.max-lifetime=1800000 13 | spring.datasource.hikari.connection-timeout=30000 14 | spring.datasource.hikari.connection-test-query=SELECT 1 15 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver 16 | spring.datasource.test-on-borrow=false 17 | spring.datasource.test-while-idle=true 18 | spring.datasource.time-between-eviction-runs-millis= 3600000 19 | spring.datasource.location = ${spring.datasource-location} 20 | 21 | ####### mybatis配置 ########################################### 22 | mybatis.mapper-locations=classpath:mapper/*.xml 23 | mybatis.config-locations=classpath:mybatis/mybatis-config.xml 24 | 25 | ####### context路径配置 ######################################## 26 | server.context-path=${context-path} 27 | 28 | ####### quartz配置 ############################################ 29 | quartz.enabled=true 30 | 31 | ####### 文件上传配置 ########################################### 32 | spring.http.multipart.max-file-size=20MB 33 | spring.http.multipart.max-request-size=20MB 34 | 35 | ####### tomcat配置 ############################################ 36 | server.tomcat.max-threads = 800 37 | server.tomcat.uri-encoding = UTF-8 38 | server.port=${server.port} 39 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ClusterAlarmUserDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | id,cluster_id clusterId,user_id userId 9 | 10 | 11 | 12 | id,cluster_id,user_id 13 | 14 | 15 | 17 | INSERT INTO zk_cluster_alarm_user 18 | () 19 | VALUES 20 | (#{id},#{clusterId},#{userId}); 21 | 22 | 23 | 29 | 30 | 36 | 37 | 38 | DELETE FROM zk_cluster_alarm_user 39 | WHERE cluster_id = #{clusterId} AND user_id = #{userId}; 40 | 41 | 42 | 43 | DELETE FROM zk_cluster_alarm_user 44 | WHERE user_id = #{userId}; 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/main/resources/mapper/QuartzDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | t.SCHED_NAME schedName,t.TRIGGER_NAME triggerName,t.TRIGGER_GROUP triggerGroup,t.JOB_NAME jobName,t.JOB_GROUP jobGroup, 9 | t.DESCRIPTION description,t.NEXT_FIRE_TIME nextFireTime,t.PREV_FIRE_TIME prevFireTime,t.PRIORITY priority, 10 | t.TRIGGER_STATE triggerState,t.TRIGGER_TYPE triggerType,t.START_TIME startTime,t.END_TIME endTime,t.CALENDAR_NAME calendarName, 11 | t.MISFIRE_INSTR misfireInstr 12 | 13 | 14 | 20 | 21 | 29 | -------------------------------------------------------------------------------- /src/main/resources/mapper/ServiceLineDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | id,service_line_name serviceLineName,service_line_desc serviceLineDesc,create_time createTime,modify_time modifyTime 9 | 10 | 11 | 12 | id,service_line_name,service_line_desc,create_time,modify_time 13 | 14 | 15 | 17 | INSERT INTO zk_service_line 18 | () 19 | VALUES 20 | (#{id},#{serviceLineName},#{serviceLineDesc},now(),#{modifyTime}); 21 | 22 | 23 | 29 | 30 | 35 | 36 | 37 | UPDATE zk_service_line 38 | SET 39 | service_line_name = #{serviceLineName}, 40 | service_line_desc = #{serviceLineDesc}, 41 | modify_time = now() 42 | WHERE id = #{id}; 43 | 44 | 45 | 46 | DELETE FROM zk_service_line WHERE service_line_name = #{serviceLineName}; 47 | 48 | -------------------------------------------------------------------------------- /src/main/resources/mapper/SysConfigDao.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | id,config_name configName,config_value configValue,config_desc configDesc 9 | 10 | 11 | 12 | id,config_name,config_value,config_desc 13 | 14 | 15 | 17 | INSERT INTO zk_sys_config 18 | () 19 | VALUES 20 | (#{id},#{configName},#{configValue},#{configDesc}) 21 | ON DUPLICATE KEY UPDATE 22 | config_value = #{configValue}; 23 | 24 | 25 | 31 | 32 | 37 | 38 | 39 | DELETE FROM zk_sys_config WHERE config_name = #{configName}; 40 | 41 | -------------------------------------------------------------------------------- /src/main/resources/mybatis/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 1 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/resources/quartz.properties: -------------------------------------------------------------------------------- 1 | org.quartz.scheduler.instanceName=ZKDoctorScheduler 2 | org.quartz.scheduler.instanceId=AUTO 3 | org.quartz.threadPool.threadCount=5 4 | org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX 5 | org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate 6 | org.quartz.jobStore.misfireThreshold=60000 7 | org.quartz.jobStore.tablePrefix=zk_qrtz_ 8 | 9 | org.quartz.jobStore.isClustered=true 10 | org.quartz.jobStore.clusterCheckinInterval=20000 11 | -------------------------------------------------------------------------------- /src/main/resources/zkdoctorConfig.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/main/resources/zkdoctorConfig.properties -------------------------------------------------------------------------------- /src/main/script/machine_init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # description: Init script for machine. Usage: sh machine_init.sh [username] [zooDir] 4 | # [username]: user who can ssh the zookeeper server machine. Default: zkdoctor 5 | # [zooDir]: the dir that zookeeper installed. Default: /user/local/zookeeper 6 | # 7 | 8 | # 1. create user [username] 9 | # 2. chown [username] permissions to [zooDir] 10 | # 3. install iftop command (to collect machine net traffic info. If not needed, just delete it.) 11 | execute() { 12 | if [ $# -ne 2 ]; then 13 | echo "Usage: sh machine_init.sh [username] [zooDir]" 14 | exit 1; 15 | fi 16 | 17 | local username="$1" 18 | local zooDir="$2" 19 | local userExists=`id $1 | wc -l` 20 | if [ ${userExists} == 1 ];then 21 | echo "User $1 exists, overwrite user info: [y/n]?" 22 | read overwrite 23 | if [ ${overwrite} == "y" ]; then 24 | echo "overwrite existed user: $1." 25 | userdel -r "$1" 26 | createUser "$1" 27 | fi 28 | else 29 | createUser "$1" 30 | fi 31 | 32 | if [ -d ${zooDir} ] 33 | then 34 | chown -R ${username}:${username} ${zooDir} 35 | echo "Chown ${username} permissions to ${zooDir}" 36 | fi 37 | 38 | # install iftop command, to collect machine net traffic info. 39 | installIftop ${username} 40 | } 41 | 42 | # create new user 43 | createUser() { 44 | echo "Creating user $1" 45 | useradd -m -d /home/$1 -s /bin/bash $1 46 | passwd $1 47 | echo "Create user: $1 successfully." 48 | } 49 | 50 | # install iftop 51 | installIftop() { 52 | if [ -n "$(iftopLocation)" ];then 53 | echo "iftop already installed" 54 | setIftop $1 "$(iftopLocation)" 55 | echo "Setcap for iftop" 56 | else 57 | echo "Installing iftop..." 58 | yum install -y iftop 59 | echo "iftop is installed" 60 | setIftop $1 "$(iftopLocation)" 61 | echo "Setcap for iftop" 62 | fi 63 | } 64 | 65 | # set iftop permission to [username] 66 | setIftop() { 67 | chgrp $1 $2 68 | chmod 750 $2 69 | setcap cap_net_raw,cap_net_admin=ep $2 70 | } 71 | 72 | # whether the iftop is present 73 | iftopLocation() { 74 | echo `which iftop` 75 | } 76 | 77 | execute $1 $2; -------------------------------------------------------------------------------- /src/main/script/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # description: Startup script for zkdoctor 4 | # 5 | 6 | ZKDOCTORDIR=/usr/local/zkdoctor 7 | ZKDOCTORLOGDIR=${ZKDOCTORDIR}/logs 8 | ZKDOCTORWAR=${ZKDOCTORDIR}/zkdoctor.war 9 | 10 | # get zkdoctor pid 11 | zkdoctor_pid() { 12 | echo `ps aux | grep ${ZKDOCTORWAR} | grep -v grep | awk '{ print $2 }'` 13 | } 14 | 15 | echo -n "Starting zkdoctor: " 16 | if [ -n "$(zkdoctor_pid)" ];then 17 | echo "Start ERROR: The zkdoctor already started! Please check pid: $(zkdoctor_pid)" 18 | exit 1 19 | fi 20 | 21 | JAVA_OPTS="-server -Xms2048m -Xmx2048m -Xmn512m -Xss256k -XX:PermSize=256m -XX:MaxPermSize=256m -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+UseCMSCompactAtFullCollection -XX:+CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=70 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${ZKDOCTORLOGDIR}/zkdoctor.hprof" 22 | nohup java $JAVA_OPTS -jar ${ZKDOCTORWAR} > ${ZKDOCTORLOGDIR}/stdout.log 2>&1 & 23 | 24 | if [ -n "$(zkdoctor_pid)" ];then 25 | echo "Start SUCCESS! PID: $(zkdoctor_pid)" 26 | else 27 | echo "Start FAILED! Please check logs!" 28 | fi -------------------------------------------------------------------------------- /src/main/script/stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # description: Stop script for zkdoctor 4 | # 5 | 6 | ZKDOCTORDIR=/usr/local/zkdoctor 7 | ZKDOcTORWAR=${ZKDOCTORDIR}/zkdoctor.war 8 | 9 | # get zkdoctor pid 10 | zkdoctor_pids() { 11 | echo `ps aux | grep ${ZKDOcTORWAR} | grep -v grep | awk '{ print $2 }'` 12 | } 13 | 14 | if [ -z "$(zkdoctor_pids)" ]; then 15 | echo "The zkdoctor is not running!" 16 | exit 1 17 | fi 18 | 19 | echo -n "Stopping zkdoctor: " 20 | for pid in $(zkdoctor_pids) ; do 21 | kill -9 ${pid} > /dev/null 2>&1 22 | done 23 | 24 | if [ -n "$(zkdoctor_pids)" ];then 25 | echo "Stop FAILED!" 26 | else 27 | echo "Stop SUCCESS!" 28 | fi -------------------------------------------------------------------------------- /src/main/webapp/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | /node_modules 3 | 4 | # testing 5 | /coverage 6 | 7 | # production 8 | /build 9 | /target 10 | 11 | # misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /src/main/webapp/.roadhogrc: -------------------------------------------------------------------------------- 1 | { 2 | "entry": "src/index.tsx", 3 | "disableCSSModules": false, 4 | "publicPath": "/zkdoctor/dist/", 5 | "theme": "./src/theme.js", 6 | "autoprefixer": null, 7 | "multipage": false, 8 | "hash": true, 9 | "extraBabelPlugins": [ 10 | "transform-runtime", 11 | ["import", { "libraryName": "antd", "style": true }] 12 | ] 13 | // 代理配置 14 | ,"proxy": { 15 | "/zkdoctor": { 16 | "target": "http://localhost:8080/zkdoctor", 17 | "changeOrigin": true, 18 | "pathRewrite": { "^/zkdoctor" : "" } 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/main/webapp/.roadhogrc.mock.js: -------------------------------------------------------------------------------- 1 | const mock = {} 2 | 3 | require('fs').readdirSync(require('path').join(`${__dirname}/mock`)).forEach((file) => { 4 | Object.assign(mock, require('./mock/' + file)) 5 | }) 6 | 7 | module.exports = mock -------------------------------------------------------------------------------- /src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | zkdoctor 8 | 9 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/main/webapp/mock/collect.js: -------------------------------------------------------------------------------- 1 | var Mock = require('mockjs'); 2 | var qs = require('qs'); 3 | 4 | let collectsData = Mock.mock({ 5 | 'collects|3': [ 6 | { 7 | 'id|+1': 1, 8 | clusterName: "@cname", 9 | infoContent: "@FIRST", 10 | alarmTime: '2018 06-01 00:00:00', 11 | } 12 | ], 13 | all: { 14 | clusterCollectInfo: { 15 | sumTotal: '@integer(1,5000)', 16 | runningTotal: '@integer(1,5000)', 17 | notRunningTotal: '@integer(1,5000)', 18 | exceptionsTotal: '@integer(1,5000)', 19 | referralTotal: '@integer(1,5000)', 20 | unmonitoredTotal: '@integer(1,5000)', 21 | }, 22 | instanceCollectInfo: { 23 | sumTotal: '@integer(1,5000)', 24 | runningTotal: '@integer(1,5000)', 25 | notRunningTotal: '@integer(1,5000)', 26 | exceptionsTotal: '@integer(1,5000)', 27 | referralTotal: '@integer(1,5000)', 28 | unmonitoredTotal: '@integer(1,5000)', 29 | }, 30 | }, 31 | }); 32 | 33 | module.exports = { 34 | 'GET /zkdoctor/alarmInfo/getAllZkAlarmInfo': function (req, res) { 35 | const page = qs.parse(req.query); 36 | 37 | let pageSize = page.pageSize; 38 | let pageNum = page.pageNum; 39 | if (!pageSize) { 40 | pageSize = 10; 41 | } 42 | if (!pageNum) { 43 | pageNum = 1; 44 | } 45 | let data = collectsData.collects; 46 | let result = data.length > pageSize ? data.slice((pageNum - 1) * pageSize, pageNum * pageSize) : data.slice(); 47 | res.json({ 48 | success: true, 49 | data: { 50 | data: result, 51 | page: { 52 | pageSize: parseInt(pageSize), 53 | pageNum: parseInt(pageNum), 54 | total: data.length 55 | } 56 | } 57 | }) 58 | }, 59 | 'GET /zkdoctor/alarmInfo/getCollectInfo': { 60 | success: true, 61 | data: { 62 | data: collectsData.all 63 | }, 64 | message: '' 65 | }, 66 | }; 67 | -------------------------------------------------------------------------------- /src/main/webapp/mock/instanceOps.js: -------------------------------------------------------------------------------- 1 | var Mock = require('mockjs'); 2 | var qs = require('qs'); 3 | 4 | let instanceOpsData = Mock.mock({ 5 | 'data': [{ 6 | uid: 1, 7 | name: 'zookeeper-3.4.10.jar', 8 | status: 'done', 9 | reponse: 'success', 10 | url: '/usr/local/zookeeper-3.4.10.jar', 11 | }] 12 | }); 13 | 14 | module.exports = { 15 | 'POST /zkdoctor/manage/instance/removeInstance': { 16 | success: true, 17 | message: '移除实例成功!' 18 | }, 19 | 'POST /zkdoctor/manage/instance/offLineInstance': { 20 | success: true, 21 | message: '下线实例成功!' 22 | }, 23 | 'POST /zkdoctor/manage/instance/restartInstance': { 24 | success: true, 25 | message: '重启实例成功!' 26 | }, 27 | 'POST /zkdoctor/manage/instance/queryInstanceConfig': { 28 | success: true, 29 | data: 'server.1=127.0.0.1:5008:6008', 30 | message: '' 31 | }, 32 | 'POST /zkdoctor/manage/instance/instanceConfOps': { 33 | success: true, 34 | message: '修改配置成功!' 35 | }, 36 | 'POST /zkdoctor/manage/instance/addNewInstance': { 37 | success: true, 38 | message: '新增实例成功!' 39 | }, 40 | 'POST /zkdoctor/manage/instance/addNewConfigFile': { 41 | success: true, 42 | message: '新增配置文件成功!' 43 | }, 44 | 'POST /zkdoctor/manage/instance/uploadNewJarFile': { 45 | success: true, 46 | message: '', 47 | data: {status: 'done'} 48 | }, 49 | 'GET /zkdoctor/manage/instance/queryUploadedJarFile': { 50 | success: true, 51 | data: instanceOpsData.data, 52 | message: '' 53 | }, 54 | 'POST /zkdoctor/manage/instance/instanceUpdateServer': { 55 | success: true, 56 | message: '升级成功!' 57 | }, 58 | 59 | }; -------------------------------------------------------------------------------- /src/main/webapp/mock/mClusterMonitorAlarmTask.js: -------------------------------------------------------------------------------- 1 | var Mock = require('mockjs'); 2 | var qs = require('qs'); 3 | 4 | let clusterMonitorAlarmTaskData = Mock.mock({ 5 | 'data|8': [ 6 | { 7 | 'clusterId|+1': 1, 8 | 'id|1-1000': 200, 9 | clusterName: '@cname', 10 | 'indicatorName|2': '@last', 11 | 'alertValue|1-100': 100, 12 | 'alertInterval|1-200': 100, 13 | 'alertFrequency|1-200': 100, 14 | 'alertForm|0-1': 0, 15 | param1: '@cname' 16 | } 17 | ] 18 | }); 19 | 20 | module.exports = { 21 | 'GET /zkdoctor/monitor/getZkMonitorTaskDataByClusterId': function (req, res) { 22 | const page = qs.parse(req.query); 23 | 24 | let pageSize = page.pageSize; 25 | let pageNum = page.pageNum; 26 | if (!pageSize) { 27 | pageSize = 10; 28 | } 29 | if (!pageNum) { 30 | pageNum = 1; 31 | } 32 | let data = clusterMonitorAlarmTaskData.data; 33 | let result = data.length > pageSize ? data.slice((pageNum - 1) * pageSize, pageNum * pageSize) : data.slice(); 34 | res.json({ 35 | success: true, 36 | data: { 37 | data: result, 38 | page: { 39 | pageSize: parseInt(pageSize), 40 | pageNum: parseInt(pageNum), 41 | total: data.length 42 | } 43 | } 44 | }) 45 | } 46 | 47 | }; 48 | -------------------------------------------------------------------------------- /src/main/webapp/mock/quartz.js: -------------------------------------------------------------------------------- 1 | var Mock = require('mockjs'); 2 | var qs = require('qs'); 3 | 4 | let triggerData = Mock.mock({ 5 | 'triggers|100': [ 6 | { 7 | id: '@last', 8 | triggerName: '@last', 9 | triggerGroup: '@last', 10 | cron: '0 0 1 ? * *', 11 | nextFireTimeStr: '2018-02-05 18:39:20', 12 | prevFireTimeStr: '2018-02-05 18:39:20', 13 | startTimeStr: '2018-02-05 18:39:20', 14 | triggerState: 'WAITING', 15 | description: '定时任务' 16 | }] 17 | }); 18 | 19 | module.exports = { 20 | 'GET /zkdoctor/manage/quartz/query': function (req, res) { 21 | const page = qs.parse(req.query); 22 | 23 | let pageSize = page.pageSize; 24 | let pageNum = page.pageNum; 25 | if (!pageSize) { 26 | pageSize = 10; 27 | } 28 | if (!pageNum) { 29 | pageNum = 1; 30 | } 31 | let data = triggerData.triggers; 32 | let result = data.length > pageSize ? data.slice((pageNum - 1) * pageSize, pageNum * pageSize) : data.slice(); 33 | res.json({ 34 | success: true, 35 | data: { 36 | data: result, 37 | page: { 38 | pageSize: parseInt(pageSize), 39 | pageNum: parseInt(pageNum), 40 | total: data.length 41 | } 42 | } 43 | }) 44 | }, 45 | 'GET /zkdoctor/manage/quartz/pauseTrigger': { 46 | success: true, 47 | message: '暂停定时任务成功' 48 | }, 49 | 'GET /zkdoctor/manage/quartz/resumeTrigger': { 50 | success: true, 51 | message: '恢复定时任务成功' 52 | }, 53 | 'GET /zkdoctor/manage/quartz/removeTrigger': { 54 | success: true, 55 | message: '删除定时任务成功' 56 | }, 57 | 58 | }; 59 | -------------------------------------------------------------------------------- /src/main/webapp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "start": "roadhog server", 5 | "build": "roadhog build" 6 | }, 7 | "dependencies": { 8 | "@types/react": "^16.0.10", 9 | "@types/react-dom": "^16.0.1", 10 | "ajv": "^6.0.0", 11 | "antd": "^3.4.0", 12 | "babel-runtime": "^6.9.2", 13 | "classnames": "^2.2.5", 14 | "echarts": "^3.7.2", 15 | "echarts-for-react": "^2.0.0", 16 | "inversify": "^2.0.0-rc.10", 17 | "inversify-binding-decorators": "^1.0.0-rc.2", 18 | "inversify-inject-decorators": "^1.0.0-beta.1", 19 | "isomorphic-fetch": "^2.2.1", 20 | "less-vars-to-js": "^1.2.0", 21 | "lodash": "^4.17.4", 22 | "mobx": "^3.2.2", 23 | "mobx-react": "^4.2.2", 24 | "mobx-utils": "^3.0.0", 25 | "qs": "^6.5.0", 26 | "react": "^16.0.0", 27 | "react-console-component": "^0.6.1", 28 | "react-dom": "^16.0.0", 29 | "react-flex-proto": "^1.0.0", 30 | "react-router": "^3.2.0", 31 | "reflect-metadata": "^0.1.10", 32 | "typescript": "2.6.2" 33 | }, 34 | "devDependencies": { 35 | "babel-plugin-import": "1.6.1", 36 | "babel-plugin-transform-runtime": "^6.9.0", 37 | "expect": "^1.20.2", 38 | "husky": "^0.12.0", 39 | "mockjs": "^1.0.1-beta3", 40 | "redbox-react": "^1.3.2", 41 | "roadhog": "^1.3.1" 42 | }, 43 | "peerDependencies": { 44 | "react": "^16.0.0", 45 | "react-dom": "^16.0.0" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/webapp/public/background/background.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/main/webapp/public/background/background.gif -------------------------------------------------------------------------------- /src/main/webapp/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/main/webapp/public/favicon.ico -------------------------------------------------------------------------------- /src/main/webapp/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | zkdoctor 8 | 9 | 10 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/main/webapp/public/logo/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/main/webapp/public/logo/logo.png -------------------------------------------------------------------------------- /src/main/webapp/src/cluster/view/clusterDetail/ClusterAlarmUser.tsx: -------------------------------------------------------------------------------- 1 | import React, {Component} from "react"; 2 | import {Button, Card, Popconfirm, Table} from "antd"; 3 | import {Link} from "react-router"; 4 | import {ClusterAlarmUserVo} from "../../model/ClusterModel"; 5 | 6 | export interface ClusterAlarmUserProps { 7 | alarmUsers: Array; 8 | onAdd: any, 9 | onDelete: any; 10 | } 11 | 12 | export class ClusterAlarmUser extends Component { 13 | columns = [ 14 | { 15 | title: '用户id', 16 | dataIndex: 'id', 17 | key: 'id', 18 | }, { 19 | title: '用户名', 20 | dataIndex: 'userName', 21 | key: 'userName', 22 | }, { 23 | title: '中文名', 24 | dataIndex: 'chName', 25 | key: 'chName' 26 | }, { 27 | title: '邮箱', 28 | dataIndex: 'email', 29 | key: 'email', 30 | }, { 31 | title: '手机', 32 | dataIndex: 'mobile', 33 | key: 'mobile', 34 | }, { 35 | title: '操作', 36 | dataIndex: 'operator', 37 | key: 'operator', 38 | render: (text, bean) => { 39 | return 40 | this.props.onDelete(bean)}> 42 | 43 | ; 44 | } 45 | }]; 46 | 47 | render() { 48 | return (
49 | 新增报警用户}> 51 | 53 | 54 | ) 55 | }; 56 | } 57 | ; 58 | -------------------------------------------------------------------------------- /src/main/webapp/src/cluster/view/clusterDetail/HeadInfo.tsx: -------------------------------------------------------------------------------- 1 | import React, {Component} from "react"; 2 | import {Link} from "react-router"; 3 | 4 | export interface HeadInfoProps { 5 | clusterName: string; 6 | } 7 | 8 | export default class HeadInfo extends Component { 9 | 10 | constructor(props) { 11 | super(props) 12 | } 13 | 14 | render() { 15 | return( 16 |
17 | 集群【{this.props.clusterName}】 18 |
19 | ) 20 | } 21 | } -------------------------------------------------------------------------------- /src/main/webapp/src/collect/service/ClusterMonitorAlarmInfoService.ts: -------------------------------------------------------------------------------- 1 | import {request} from "../../common/utils/request"; 2 | // import qs from "qs"; 3 | export async function getAllZkAlarmInfo() { 4 | return request('/alarmInfo/getAllZkAlarmInfo',{}) 5 | } 6 | export function getCollectInfo() { 7 | return request('/alarmInfo/getCollectInfo',{}) 8 | } -------------------------------------------------------------------------------- /src/main/webapp/src/collect/view/AlarmInfoList.tsx: -------------------------------------------------------------------------------- 1 | import React, {Component} from "react"; 2 | import {Table} from "antd"; 3 | import {Link} from "react-router"; 4 | import {ClusterMonitorAlarmInfoVo} from "../model/ClusterMonitorAlarmInfoModel"; 5 | 6 | export interface ListProps { 7 | dataSource: Array; 8 | loading: boolean; 9 | pageConfig: any; 10 | } 11 | 12 | export class AlarmInfoList extends Component { 13 | columns = [ 14 | { 15 | title: '报警信息id', 16 | dataIndex: 'id', 17 | key: 'id' 18 | }, 19 | { 20 | title: '集群名称', 21 | dataIndex: 'clusterName', 22 | key: 'clusterName' 23 | } 24 | /* , 25 | { 26 | title: '机器ID', 27 | dataIndex: 'machineId', 28 | key: 'machineId' 29 | }*/ 30 | /* , 31 | { 32 | title: '机器IP', 33 | dataIndex: 'machineIp', 34 | key: 'machineIp' 35 | }*/ 36 | , 37 | /*{ 38 | title: '实例ID', 39 | dataIndex: 'instanceId', 40 | key: 'instanceId' 41 | }, 42 | { 43 | title: '实例IP', 44 | dataIndex: 'instanceIp', 45 | key: 'instanceIp' 46 | }, { 47 | title: '端口号', 48 | dataIndex: 'port', 49 | key: 'port' 50 | },*/ 51 | { 52 | title: '报警信息内容', 53 | dataIndex: 'infoContent', 54 | key: 'infoContent' 55 | } 56 | , { 57 | title: '报警时间', 58 | dataIndex: 'alarmTime', 59 | key: 'alarmTime' 60 | } 61 | /* , { 62 | title: '备注', 63 | dataIndex: 'remark', 64 | key: 'remark' 65 | }*/ 66 | ]; 67 | 68 | render() { 69 | return (
70 |
73 | ) 74 | } 75 | 76 | } -------------------------------------------------------------------------------- /src/main/webapp/src/collect/view/ClusterCollectInfo.tsx: -------------------------------------------------------------------------------- 1 | import React, {Component} from "react"; 2 | import {observer} from "mobx-react"; 3 | import {inject} from "../../common/utils/IOC"; 4 | import {withRouter} from "react-router"; 5 | import {ClusterMonitorAlarmInfoModel} from "../model/ClusterMonitorAlarmInfoModel"; 6 | import {IndexCollectList} from "./IndexCollectList"; 7 | 8 | @observer 9 | export default class ClusterMonitorAlarmInfoList extends Component<{}, {}> { 10 | 11 | @inject(ClusterMonitorAlarmInfoModel) 12 | private clusterMonitorAlarmInfoModel: ClusterMonitorAlarmInfoModel; 13 | 14 | constructor(props) { 15 | super(props); 16 | } 17 | 18 | componentDidMount(): void { 19 | this.clusterMonitorAlarmInfoModel.query(null); 20 | this.clusterMonitorAlarmInfoModel.queryAllCollectInfo(); 21 | this.setState({}) 22 | } 23 | 24 | getIndexCollectInfoListProps() { 25 | let thisV = this; 26 | return { 27 | dataSource: thisV.clusterMonitorAlarmInfoModel.indexCollects, 28 | }; 29 | }; 30 | 31 | getAlarmInfoListProps() { 32 | let thisV = this; 33 | return { 34 | dataSource: thisV.clusterMonitorAlarmInfoModel.clusterMonitorAlarmInfos, 35 | loading: thisV.clusterMonitorAlarmInfoModel.loading, 36 | pageConfig: thisV.clusterMonitorAlarmInfoModel.pageConfig 37 | }; 38 | }; 39 | 40 | render() { 41 | return ( 42 |
43 | 44 |
45 | ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/webapp/src/common.js: -------------------------------------------------------------------------------- 1 | import ReactEcharts from "echarts-for-react"; 2 | import moment from "moment/moment"; 3 | import {DatePicker, Select, Table} from "antd"; 4 | 5 | module.exports = { 6 | ReactEcharts, 7 | moment, 8 | DatePicker, 9 | Select, 10 | Table 11 | } 12 | -------------------------------------------------------------------------------- /src/main/webapp/src/common/config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'zkdoctor系统', 3 | prefix: 'zkdoctor', 4 | assertPrefix: 'dist/', 5 | footerText: '版权所有 © 2017 ', 6 | logoSrc: 'logo/logo.png', 7 | logoText: 'zkdoctor', 8 | needLogin: true 9 | } 10 | -------------------------------------------------------------------------------- /src/main/webapp/src/common/utils/IOC.ts: -------------------------------------------------------------------------------- 1 | import {Kernel} from "inversify"; 2 | import {makeFluentProvideDecorator} from "inversify-binding-decorators"; 3 | import getDecorators from "inversify-inject-decorators"; 4 | 5 | export const kernel = new Kernel(); 6 | 7 | const provide = makeFluentProvideDecorator(kernel); 8 | 9 | export function provideInstance (identifier: string|Symbol|interfaces.Newable) { 10 | return provide(identifier).done(); 11 | } 12 | 13 | export function provideSingleton (identifier: string|Symbol|interfaces.Newable) { 14 | return provide(identifier).inSingletonScope().done(); 15 | } 16 | 17 | export const inject = getDecorators(kernel).lazyInject; 18 | -------------------------------------------------------------------------------- /src/main/webapp/src/common/utils/preference.ts: -------------------------------------------------------------------------------- 1 | import safeLocalStorage from "./safeLocalStorage"; 2 | import _ from "lodash"; 3 | 4 | function keyValueMirror(arr) { 5 | const obj = {}; 6 | arr.forEach(item => { 7 | obj[item] = item; 8 | }); 9 | return obj; 10 | } 11 | 12 | const PreferenceDefaultConfigs = { 13 | 'navFolded': false, //左侧导航栏,默认不收起 14 | }; 15 | 16 | const PreferenceKeys = keyValueMirror(_.keys(PreferenceDefaultConfigs)); 17 | 18 | const Preference = { 19 | set(key, value) { 20 | safeLocalStorage.setItem(key, value); 21 | }, 22 | get(key) { 23 | return safeLocalStorage.getItem(key) || PreferenceDefaultConfigs[key]; 24 | } 25 | }; 26 | 27 | export default Preference; 28 | 29 | export {PreferenceKeys} 30 | 31 | -------------------------------------------------------------------------------- /src/main/webapp/src/common/utils/request.ts: -------------------------------------------------------------------------------- 1 | import fetch from "isomorphic-fetch"; 2 | import config from "../config"; 3 | 4 | function checkStatus(response) { 5 | if (response.status >= 200 && response.status < 300) { 6 | return response; 7 | } 8 | const error = new Error(response.statusText); 9 | throw error; 10 | } 11 | 12 | var app; 13 | 14 | export function appContainer(appParam) { 15 | app = appParam; 16 | } 17 | 18 | function sendMessage(message) { 19 | if (app) { 20 | app.sendMessage(message); 21 | } 22 | } 23 | 24 | export function generateUrl(url) { 25 | return url.startsWith("http") ? url : '/' + config.prefix + url; 26 | } 27 | 28 | export async function request(url, options?: any) { 29 | let newUrl = generateUrl(url); 30 | const response = await fetch(newUrl, Object.assign({credentials: 'same-origin'}, options)); 31 | let result = {success: false}; 32 | try { 33 | checkStatus(response); 34 | const data = await response.json(); 35 | if (data) { 36 | if (data.success == false) { 37 | if (data.message == 'NO_USER') { 38 | sendMessage({type: 'error', title: 'NO_USER', msg: 'NO_USER'}); 39 | } else { 40 | sendMessage({type: 'error', title: '操作失败', msg: `${data.message}`}) 41 | } 42 | } else if (data.message == 'Timeout') { // 用户登录超时 43 | sendMessage({type: 'error', title: '登录超时', msg: '登录超时,请重新登录'}); 44 | } else if (data.message == 'Permission denied') { // 用户操作权限不足 45 | sendMessage({type: 'error', title: '操作失败', msg: `权限不足,不能进行操作`}) 46 | } else { 47 | result = data; 48 | } 49 | } else { 50 | const error = new Error("json解析错误"); 51 | throw error; 52 | } 53 | 54 | } catch (error) { 55 | sendMessage({type: 'error', title: '操作失败', msg: `后台操作出现错误,错误信息:${error ? error : ''}`}); 56 | } 57 | return result; 58 | } 59 | -------------------------------------------------------------------------------- /src/main/webapp/src/common/utils/safeLocalStorage.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 如果localStorage 可用,用之 3 | * 如果不可用(node环境或浏览器禁用),用对象模拟 4 | * 5 | * 6 | * 因为仅仅是简单使用localStorage,直接使用对象形式 7 | */ 8 | 9 | function isLocalStorageNameSupported() { 10 | if (window && window.localStorage) { 11 | let testKey = '__test', storage = window.localStorage; 12 | try { 13 | storage.setItem(testKey, '1'); 14 | storage.removeItem(testKey); 15 | return true; 16 | } catch (error) { 17 | return false; 18 | } 19 | } 20 | return false; 21 | } 22 | 23 | let pool = {}; 24 | if (isLocalStorageNameSupported()) { 25 | pool = window.localStorage; 26 | } 27 | const Storage = { 28 | 29 | getItem(key) { 30 | return pool[key] 31 | }, 32 | 33 | setItem(key, value) { 34 | pool[key] = value 35 | }, 36 | 37 | removeItem(key) { 38 | delete pool[key] 39 | } 40 | }; 41 | 42 | export default Storage -------------------------------------------------------------------------------- /src/main/webapp/src/declaration.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.less' { 2 | const content: any; 3 | export default content; 4 | } -------------------------------------------------------------------------------- /src/main/webapp/src/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | zkdoctor 8 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/main/webapp/src/index.tsx: -------------------------------------------------------------------------------- 1 | import "reflect-metadata"; 2 | import React, {Component} from "react"; 3 | import ReactDOM from "react-dom"; 4 | import {useStrict} from "mobx"; 5 | import zhCN from "antd/lib/locale-provider/zh_CN"; 6 | import {createHashHistory} from "history"; 7 | import Routes from "./router"; 8 | import {Router, useRouterHistory} from "react-router"; 9 | import {SysUserModel} from "./sys/model/SysUserModel"; 10 | import {inject} from "./common/utils/IOC"; 11 | import {appContainer} from "./common/utils/request"; 12 | import {SysInfoModel} from "./sys/model/SysInfoModel"; 13 | import {LocaleProvider} from "antd"; 14 | 15 | useStrict(true); 16 | 17 | const history = useRouterHistory(createHashHistory)({queryKey: false}); 18 | 19 | class AppContainer extends Component<{}, {}> { 20 | @inject(SysUserModel) 21 | private sysUserModel: SysUserModel; 22 | 23 | @inject(SysInfoModel) 24 | private sysInfoModel: SysInfoModel; 25 | 26 | render() { 27 | appContainer(this.sysInfoModel); 28 | return
29 | } 30 | } 31 | 32 | ReactDOM.render(( 33 | 34 | 35 | 36 | ), document.getElementById("root")); 37 | -------------------------------------------------------------------------------- /src/main/webapp/src/instance/view/InstanceHeadInfo.tsx: -------------------------------------------------------------------------------- 1 | import React, {Component} from "react"; 2 | import {Link} from "react-router"; 3 | 4 | export interface InstanceHeadInfoProps { 5 | clusterName: string; 6 | hostInfo: string; 7 | } 8 | 9 | export default class InstanceHeadInfo extends Component { 10 | 11 | constructor(props) { 12 | super(props) 13 | } 14 | 15 | render() { 16 | return( 17 |
18 | 实例【{this.props.hostInfo}{this.props.clusterName == '' ? '' : '-' + this.props.clusterName}】 19 |
20 | ) 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/webapp/src/machine/service/machine.ts: -------------------------------------------------------------------------------- 1 | import {generateUrl, request} from "../../common/utils/request"; 2 | import qs from "qs"; 3 | 4 | export function editMachineInfo(params) { 5 | let formData = new FormData(); 6 | for (let name in params) { 7 | formData.append(name, params[name]); 8 | } 9 | return request('/manage/machine/modifyMachine', { 10 | method: 'POST', 11 | body: formData 12 | }); 13 | } 14 | export function deleteMachine(machineId) { 15 | let params = {machineId: machineId}; 16 | return request(`/manage/machine/deleteMachine?${qs.stringify(params)}`, {}); 17 | } 18 | 19 | export function addMachine(params) { 20 | let formData = new FormData(); 21 | for (let name in params) { 22 | formData.append(name, params[name]); 23 | } 24 | return request('/manage/machine/addMachine', { 25 | method: 'POST', 26 | body: formData 27 | }); 28 | } 29 | 30 | export function updateMonitorStatus(params) { 31 | return request(`/manage/machine/updateMonitorStatus?${qs.stringify(params)}`, {}); 32 | } 33 | 34 | export function downloadMachineInitScript(args) { 35 | let {url, params, filename} = args; 36 | filename = filename ? filename : 'log.log'; 37 | let fullUrl = generateUrl(url); 38 | let urlParms = qs.stringify(params); 39 | if (urlParms) { 40 | fullUrl = fullUrl.indexOf("?") > 0 ? fullUrl + "&" + urlParms : fullUrl + "?" + urlParms; 41 | } 42 | let link = document.createElement('a'); 43 | link.setAttribute('href', fullUrl); 44 | link.setAttribute('download', filename); 45 | link.click(); 46 | } 47 | 48 | export function queryMachineInstances(params) { 49 | return request(`/machine/queryMachineInstances?${qs.stringify(params)}`, {}); 50 | } 51 | 52 | export function sshCommandExecute(params) { 53 | return request(`/manage/machine/supermanage/sshCommandExecute?${qs.stringify(params)}`,{}); 54 | } 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/main/webapp/src/machine/view/MachineInstanceTable.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import {Table, Tag} from "antd"; 3 | import {Link} from "react-router"; 4 | import {BaseInfoModel} from "../../../sys/model/BaseInfoModel"; 5 | import {InstanceInfoVo} from "../../instance/model/InstanceModel"; 6 | 7 | export interface ListProps { 8 | dataSource: Array; 9 | loading: boolean; 10 | pageConfig: any; 11 | baseInfoModel: BaseInfoModel; 12 | } 13 | 14 | export const MachineInstanceTable = (props: ListProps) => { 15 | const columns = [ 16 | { 17 | title: '实例id', 18 | dataIndex: 'id', 19 | key: 'id' 20 | }, { 21 | title: '集群id', 22 | dataIndex: 'clusterId', 23 | key: 'clusterId', 24 | render: (text, bean) => { 25 | return {text}; 26 | } 27 | }, { 28 | title: '实例ip', 29 | dataIndex: 'host', 30 | key: 'host' 31 | }, { 32 | title: '实例端口号', 33 | dataIndex: 'port', 34 | key: 'port' 35 | }, { 36 | title: '实例角色', 37 | dataIndex: 'serverStateLag', 38 | key: 'serverStateLag', 39 | render: (text) => { 40 | return {props.baseInfoModel.getServerStatesName(text)}; 41 | } 42 | }, { 43 | title: '状态', 44 | dataIndex: 'status', 45 | key: 'status', 46 | render: (text) => { 47 | return 48 | {props.baseInfoModel.getInstanceStatusName(text)}; 49 | } 50 | }]; 51 | 52 | return
55 | }; 56 | 57 | -------------------------------------------------------------------------------- /src/main/webapp/src/monitor/service/MonitorAlarmTaskService.ts: -------------------------------------------------------------------------------- 1 | import {request} from "../../common/utils/request"; 2 | import qs from "qs"; 3 | 4 | export async function updateIndicatorSwitchOn(params) { 5 | return request(`/manage/monitor/indicator/updateSwitchOn?${qs.stringify(params)}`,{}); 6 | } 7 | 8 | export async function updateMonitorTaskSwitchOn(params) { 9 | 10 | //return request(`/manage/monitor/updateSwitchOn?${qs.stringify(params)}`,{}); 11 | return request(`/monitor/task/updateSwitchOn?${qs.stringify(params)}`,{}); 12 | } 13 | export function updateMonitorTask(params) { 14 | let formData = new FormData(); 15 | for (let name in params) { 16 | formData.append(name, params[name]); 17 | } 18 | // return request(`/monitorAlarm/updateMonitorTask`, { 19 | return request(`/manage/monitor/updateMonitorTask`, { 20 | method: 'POST', 21 | body: formData 22 | 23 | }); 24 | } 25 | export function getMonitorTaskByClusterId(clusterId) { 26 | let params = {clusterId: clusterId}; 27 | return request(`/monitor/getZkMonitorTaskDataByClusterId?${qs.stringify(params)}`, {}); 28 | } 29 | 30 | export function updateIndicator(params) { 31 | let formData = new FormData(); 32 | for (let name in params) { 33 | formData.append(name, params[name]); 34 | } 35 | return request('/manage/monitor/indicator/updateIndicator', { 36 | method: 'POST', 37 | body: formData 38 | }); 39 | } 40 | 41 | export function updateTask(params) { 42 | let formData = new FormData(); 43 | for (let name in params) { 44 | formData.append(name, params[name]); 45 | } 46 | return request('/monitor/task/updateTask', { 47 | method: 'POST', 48 | body: formData 49 | }); 50 | } 51 | -------------------------------------------------------------------------------- /src/main/webapp/src/monitor/service/monitor.ts: -------------------------------------------------------------------------------- 1 | import {request} from "../../common/utils/request"; 2 | import qs from "qs"; 3 | 4 | export async function updateIndicatorSwitchOn(params) { 5 | return request(`/manage/monitor/indicator/updateSwitchOn?${qs.stringify(params)}`,{}); 6 | } 7 | 8 | export async function updateTaskSwitchOn(params) { 9 | return request(`/monitor/task/updateSwitchOn?${qs.stringify(params)}`,{}); 10 | } 11 | 12 | export function updateIndicator(params) { 13 | let formData = new FormData(); 14 | for (let name in params) { 15 | formData.append(name, params[name]); 16 | } 17 | return request('/manage/monitor/indicator/updateIndicator', { 18 | method: 'POST', 19 | body: formData 20 | }); 21 | } 22 | 23 | export function updateTask(params) { 24 | let formData = new FormData(); 25 | for (let name in params) { 26 | formData.append(name, params[name]); 27 | } 28 | return request('/monitor/task/updateTask', { 29 | method: 'POST', 30 | body: formData 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/webapp/src/monitor/view/AlarmHistory.tsx: -------------------------------------------------------------------------------- 1 | import React, {Component} from "react"; 2 | import {observer} from "mobx-react"; 3 | import {inject} from "../../common/utils/IOC"; 4 | import {withRouter} from "react-router"; 5 | import {Tabs} from "antd"; 6 | import {IndexCollectList} from "./IndexCollectList"; 7 | import {AlarmInfoList} from "../../collect/view/AlarmInfoList"; 8 | import {ClusterMonitorAlarmInfoModel} from "../../collect/model/ClusterMonitorAlarmInfoModel"; 9 | 10 | @observer 11 | export default class ClusterMonitorAlarmInfoList extends Component<{}, {}> { 12 | 13 | @inject(ClusterMonitorAlarmInfoModel) 14 | private clusterMonitorAlarmInfoModel: ClusterMonitorAlarmInfoModel; 15 | 16 | constructor(props) { 17 | super(props); 18 | } 19 | 20 | componentDidMount(): void { 21 | this.clusterMonitorAlarmInfoModel.query(null); 22 | this.setState({}) 23 | } 24 | 25 | 26 | getAlarmInfoListProps() { 27 | let thisV = this; 28 | return { 29 | dataSource: thisV.clusterMonitorAlarmInfoModel.clusterMonitorAlarmInfos, 30 | loading: thisV.clusterMonitorAlarmInfoModel.loading, 31 | pageConfig: thisV.clusterMonitorAlarmInfoModel.pageConfig 32 | }; 33 | }; 34 | 35 | render() { 36 | return ( 37 |
38 | 39 | 40 | 41 | 42 | 43 |
44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/webapp/src/ops/service/ServiceLineOpsService.ts: -------------------------------------------------------------------------------- 1 | import {request} from "../../common/utils/request"; 2 | 3 | export function insertServiceLine(params) { 4 | let formData = new FormData(); 5 | for (let name in params) { 6 | formData.append(name, params[name]); 7 | } 8 | return request('/manage/system/serviceLine/insert', { 9 | method: 'POST', 10 | body: formData 11 | }); 12 | } 13 | 14 | export function updateServiceLine(params) { 15 | let formData = new FormData(); 16 | for (let name in params) { 17 | formData.append(name, params[name]); 18 | } 19 | return request('/manage/system/serviceLine/update', { 20 | method: 'POST', 21 | body: formData 22 | }); 23 | } 24 | 25 | export function deleteServiceLine(params) { 26 | let formData = new FormData(); 27 | for (let name in params) { 28 | formData.append(name, params[name]); 29 | } 30 | return request('/manage/system/serviceLine/delete', { 31 | method: 'POST', 32 | body: formData 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/webapp/src/ops/service/SystemOpsService.ts: -------------------------------------------------------------------------------- 1 | import {request} from "../../common/utils/request"; 2 | 3 | export function updateConfig(params) { 4 | let formData = new FormData(); 5 | for (let name in params) { 6 | formData.append(name, params[name]); 7 | } 8 | return request('/manage/system/config/update', { 9 | method: 'POST', 10 | body: formData 11 | }); 12 | } 13 | 14 | export function deleteConfig(params) { 15 | let formData = new FormData(); 16 | for (let name in params) { 17 | formData.append(name, params[name]); 18 | } 19 | return request('/manage/system/config/delete', { 20 | method: 'POST', 21 | body: formData 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/webapp/src/ops/view/ClusterDynamicExpansionResultModal.tsx: -------------------------------------------------------------------------------- 1 | import React, {Component} from "react"; 2 | import {Form, Modal, Timeline} from "antd"; 3 | import {FormComponentProps} from "antd/lib/form/Form"; 4 | 5 | export interface ModalProps extends FormComponentProps { 6 | isExpansionOver: boolean, 7 | resultList: Array; 8 | onOk: any; 9 | onCancel: any; 10 | } 11 | 12 | class ClusterDynamicExpansionResultModal extends Component { 13 | 14 | render() { 15 | let handleOk = (e) => { 16 | e.preventDefault(); 17 | this.props.onOk(); 18 | }; 19 | 20 | const modalOpts = { 21 | title: '动态扩容中', 22 | visible: true, 23 | onOk: handleOk, 24 | onCancel: this.props.onCancel, 25 | wrapClassName: 'vertical-center-modal' 26 | }; 27 | 28 | let getResult = () => { 29 | const results = []; 30 | for (let i = 0; i < this.props.resultList.length; i++) { 31 | let line = this.props.resultList[i]; 32 | let color = line.indexOf("失败") == -1 ? "green" : "red"; 33 | results.push( 34 | {line} 35 | ); 36 | } 37 | return results; 38 | }; 39 | 40 | return ( 41 |
42 | 43 | 44 | {getResult()} 45 | 46 | 47 |
); 48 | } 49 | } 50 | 51 | export default Form.create()(ClusterDynamicExpansionResultModal); -------------------------------------------------------------------------------- /src/main/webapp/src/ops/view/ClusterRestartResultModal.tsx: -------------------------------------------------------------------------------- 1 | import React, {Component} from "react"; 2 | import {Form, Modal, Timeline} from "antd"; 3 | import {FormComponentProps} from "antd/lib/form/Form"; 4 | 5 | export interface ModalProps extends FormComponentProps { 6 | title: string; 7 | resultList: Array; 8 | onOk: any; 9 | onCancel: any; 10 | } 11 | 12 | interface ModalState { 13 | isOver: boolean, 14 | } 15 | 16 | class ClusterRestartResultModal extends Component { 17 | 18 | render() { 19 | let handleOk = (e) => { 20 | e.preventDefault(); 21 | this.props.onOk(); 22 | }; 23 | 24 | const modalOpts = { 25 | title: this.props.title, 26 | visible: true, 27 | onOk: handleOk, 28 | onCancel: this.props.onCancel, 29 | wrapClassName: 'vertical-center-modal' 30 | }; 31 | let getResult = () => { 32 | const results = []; 33 | for (let i = 0; i < this.props.resultList.length; i++) { 34 | let line = this.props.resultList[i]; 35 | let color = line.indexOf("失败") == -1 ? "green" : "red"; 36 | results.push( 37 | {line} 38 | ); 39 | } 40 | return results; 41 | }; 42 | 43 | return ( 44 |
45 | 46 | 47 | {getResult()} 48 | 49 | 50 |
); 51 | } 52 | } 53 | 54 | export default Form.create()(ClusterRestartResultModal); -------------------------------------------------------------------------------- /src/main/webapp/src/ops/view/ServiceLineList.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import {Button, Popconfirm, Table} from "antd"; 3 | import {Link} from "react-router"; 4 | import {ServiceLineVo} from "../model/ServiceLineOpsModel"; 5 | 6 | export interface ListProps { 7 | dataSource: Array; 8 | loading: boolean; 9 | pageConfig: any; 10 | onUpdateServiceLine: any; 11 | onDeleteServiceLine: any; 12 | } 13 | 14 | export const ServiceLineList = (props: ListProps) => { 15 | 16 | const columns = [ 17 | { 18 | title: '业务线id', 19 | dataIndex: 'id', 20 | key: 'id' 21 | }, { 22 | title: '业务线名称', 23 | dataIndex: 'serviceLineName', 24 | key: 'serviceLineName' 25 | }, { 26 | title: '描述', 27 | dataIndex: 'serviceLineDesc', 28 | key: 'serviceLineDesc' 29 | }, { 30 | title: '创建时间', 31 | dataIndex: 'createTimeStr', 32 | key: 'createTimeStr' 33 | }, { 34 | title: '最后修改时间', 35 | dataIndex: 'modifyTimeStr', 36 | key: 'modifyTimeStr' 37 | }]; 38 | 39 | let operationCol = { 40 | title: '操作', 41 | dataIndex: 'operator', 42 | key: 'operator', 43 | 44 | render: (text, bean) => { 45 | return ( 46 | 48 | { 50 | props.onDeleteServiceLine(bean.serviceLineName) 51 | }}> 52 | 53 | 54 | ); 55 | } 56 | }; 57 | 58 | let finalColumns = columns.concat(operationCol); 59 | 60 | return
63 | }; 64 | -------------------------------------------------------------------------------- /src/main/webapp/src/ops/view/SystemConfigList.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import {Button, Popconfirm, Table} from "antd"; 3 | import {Link} from "react-router"; 4 | import {SystemConfigVo} from "../model/SystemOpsModel"; 5 | 6 | export interface ListProps { 7 | dataSource: Array; 8 | loading: boolean; 9 | pageConfig: any; 10 | onUpdateConfig: any; 11 | onDeleteConfigValue: any; 12 | } 13 | 14 | export const SystemConfigList = (props: ListProps) => { 15 | 16 | const columns = [ 17 | { 18 | title: '配置名称', 19 | dataIndex: 'configName', 20 | key: 'configName' 21 | }, { 22 | title: '功能', 23 | dataIndex: 'configDesc', 24 | key: 'configDesc', 25 | width: 300 26 | }, { 27 | title: '默认值', 28 | dataIndex: 'defaultConfigValue', 29 | key: 'defaultConfigValue', 30 | width: 300 31 | }, { 32 | title: '当前配置值', 33 | dataIndex: 'configValue', 34 | key: 'configValue' 35 | }]; 36 | 37 | let operationCol = { 38 | title: '操作', 39 | dataIndex: 'operator', 40 | key: 'operator', 41 | 42 | render: (text, bean) => { 43 | return ( 44 | 46 | { 48 | props.onDeleteConfigValue(bean.configName) 49 | }}> 50 | 51 | 52 | ); 53 | } 54 | }; 55 | 56 | let finalColumns = columns.concat(operationCol); 57 | 58 | return
61 | }; 62 | -------------------------------------------------------------------------------- /src/main/webapp/src/quartz/service/quartz.ts: -------------------------------------------------------------------------------- 1 | import {request} from "../../common/utils/request"; 2 | import qs from "qs"; 3 | 4 | export function pauseTrigger(triggerName, triggerGroup) { 5 | let params = {triggerName: triggerName, triggerGroup: triggerGroup}; 6 | return request(`/manage/quartz/pauseTrigger?${qs.stringify(params)}`, {}); 7 | } 8 | 9 | export function resumeTrigger(triggerName, triggerGroup) { 10 | let params = {triggerName: triggerName, triggerGroup: triggerGroup}; 11 | return request(`/manage/quartz/resumeTrigger?${qs.stringify(params)}`, {}); 12 | } 13 | 14 | export function removeTrigger(triggerName, triggerGroup) { 15 | let params = {triggerName: triggerName, triggerGroup: triggerGroup}; 16 | return request(`/manage/quartz/removeTrigger?${qs.stringify(params)}`, {}); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/main/webapp/src/quartz/view/QuartzList.tsx: -------------------------------------------------------------------------------- 1 | import React, {Component} from "react"; 2 | import {observer} from "mobx-react"; 3 | import {inject} from "../../common/utils/IOC"; 4 | import {SysUserModel} from "../../sys/model/SysUserModel"; 5 | import {QuartzModel} from "../model/QuartzModel"; 6 | import {List} from "./List"; 7 | import Search from "./Search"; 8 | 9 | interface DetailPropsI { 10 | location: any; 11 | } 12 | 13 | @observer 14 | export default class QuartzList extends Component { 15 | 16 | @inject(QuartzModel) 17 | private quartzModel: QuartzModel; 18 | 19 | @inject(SysUserModel) 20 | private sysUserModel: SysUserModel; 21 | 22 | constructor(props) { 23 | super(props); 24 | } 25 | 26 | componentDidMount(): void { 27 | this.quartzModel.query({}); 28 | this.setState({ 29 | }) 30 | } 31 | 32 | getSearchProps() { 33 | let thisV = this; 34 | return { 35 | onSearch(query) { 36 | thisV.quartzModel.query(query); 37 | } 38 | }; 39 | }; 40 | 41 | getListProps() { 42 | let thisV = this; 43 | return { 44 | dataSource: this.quartzModel.triggers, 45 | loading: this.quartzModel.loading, 46 | pageConfig: this.quartzModel.pageConfig, 47 | sysUser: this.sysUserModel.sysUser, 48 | onDelete(triggerName, triggerGroup, callback) { 49 | thisV.quartzModel.removeTrigger(triggerName, triggerGroup, callback); 50 | }, 51 | onResume(triggerName, triggerGroup, callback) { 52 | thisV.quartzModel.resumeTrigger(triggerName, triggerGroup, callback); 53 | }, 54 | onPause(triggerName, triggerGroup, callback) { 55 | thisV.quartzModel.pauseTrigger(triggerName, triggerGroup, callback); 56 | }, 57 | }; 58 | }; 59 | 60 | render() { 61 | return ( 62 |
63 |
64 | 65 |
66 | 67 |
68 | ) 69 | } 70 | } -------------------------------------------------------------------------------- /src/main/webapp/src/sys/service/app.ts: -------------------------------------------------------------------------------- 1 | import {request} from "../../common/utils/request"; 2 | import qs from "qs"; 3 | 4 | export function menuTreeList () { 5 | return request(`/menu/treeList`) 6 | } 7 | 8 | export function userInfo (params) { 9 | return request('/user/info') 10 | } 11 | 12 | export function loginSubmit (params) { 13 | var formData = new FormData(); 14 | for(var name in params) { 15 | formData.append(name, params[name]); 16 | } 17 | return request('/user/login', { 18 | method: 'POST', 19 | body: formData, 20 | }); 21 | } 22 | 23 | export function logoutSubmit () { 24 | return request('/user/logout'); 25 | } 26 | 27 | export function register(params) { 28 | var formData = new FormData(); 29 | for(var name in params) { 30 | formData.append(name, params[name]); 31 | } 32 | return request('/user/register', { 33 | method: 'POST', 34 | body: formData, 35 | }); 36 | } 37 | 38 | export function checkUserExists(userName) { 39 | let params = {userName: userName}; 40 | return request(`/user/checkUserExists?${qs.stringify(params)}`, {}); 41 | } 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/main/webapp/src/sys/view/Dashboard.less: -------------------------------------------------------------------------------- 1 | @import "../../themes/vars.less"; 2 | 3 | .welcome { 4 | color: #fff; 5 | height: 100%; 6 | width: 100%; 7 | justify-content: space-between; 8 | font-size: 14px; 9 | 10 | .logo { 11 | padding-top: 8%; 12 | display: flex; 13 | flex-direction: column; 14 | 15 | .icon { 16 | margin-left: 40%; 17 | width: 209px; 18 | height: 145px; 19 | background-position: center; 20 | background-size: cover; 21 | } 22 | 23 | } 24 | 25 | .text { 26 | display: flex; 27 | flex-direction: column; 28 | width: 70%; 29 | margin-top: 5%; 30 | .temperature { 31 | color:#428F71; 32 | font-size: 36px; 33 | text-align: right; 34 | height: 64px; 35 | } 36 | 37 | .description { 38 | overflow: hidden; 39 | text-overflow: ellipsis; 40 | white-space: nowrap; 41 | text-align: right; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/webapp/src/sys/view/Dashboard.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import styles from "./Dashboard.less"; 3 | 4 | const Dashboard = (props: any) => { 5 | return
6 |
7 |

欢迎登陆zkdoctor系统

8 |
9 |
10 | }; 11 | 12 | 13 | export default Dashboard; 14 | -------------------------------------------------------------------------------- /src/main/webapp/src/sys/view/Login.tsx: -------------------------------------------------------------------------------- 1 | import React, {Component} from "react"; 2 | import LoginForm from "./login/LoginForm"; 3 | import "./layout/common.less"; 4 | import {withRouter} from "react-router"; 5 | import {SysUserModel} from "../model/SysUserModel"; 6 | import {inject} from "../../common/utils/IOC"; 7 | import config from "../../common/config.js"; 8 | 9 | 10 | const divStyle = { 11 | width: '100%', 12 | height: '1000px', 13 | backgroundImage: `url(${config.assertPrefix}background/background.gif)`, 14 | backgroundSize: '100%', 15 | backgroundRepeat: 'no-repeat', 16 | backgroundWidth: '100%' 17 | }; 18 | 19 | interface RouterI { 20 | router: any 21 | } 22 | 23 | class Login extends Component { 24 | @inject(SysUserModel) 25 | private sysUserModel: SysUserModel; 26 | 27 | render() { 28 | 29 | let thisV = this; 30 | let loginProps = { 31 | loading: this.sysUserModel.loading, 32 | onOk (userName: string, password: string) { 33 | thisV.sysUserModel.login(userName, password, thisV.props.router); 34 | } 35 | }; 36 | 37 | return (
38 | 39 |
); 40 | } 41 | } 42 | 43 | export default withRouter(Login); -------------------------------------------------------------------------------- /src/main/webapp/src/sys/view/LoginRegister.tsx: -------------------------------------------------------------------------------- 1 | import React, {Component} from "react"; 2 | import LoginRegisterForm from "./login/LoginRegisterForm"; 3 | import "./layout/common.less"; 4 | import {withRouter} from "react-router"; 5 | import {SysUserModel} from "../model/SysUserModel"; 6 | import {inject} from "../../common/utils/IOC"; 7 | import config from "../../common/config.js"; 8 | 9 | const divStyle = { 10 | width: '100%', 11 | height: '1000px', 12 | backgroundImage: `url(${config.assertPrefix}background/background.gif)`, 13 | backgroundSize: '100%', 14 | backgroundRepeat: 'no-repeat', 15 | backgroundWidth: '100%' 16 | }; 17 | 18 | interface RouterI { 19 | router: any 20 | } 21 | 22 | class LoginRegister extends Component { 23 | @inject(SysUserModel) 24 | private sysUserModel: SysUserModel; 25 | 26 | render() { 27 | 28 | let thisV = this; 29 | let loginProps = { 30 | loading: this.sysUserModel.loading, 31 | onOk (userName: string, password: string) { 32 | thisV.sysUserModel.login(userName, password, thisV.props.router); 33 | } 34 | }; 35 | 36 | return (
37 | 38 |
); 39 | } 40 | } 41 | 42 | export default withRouter(LoginRegister); -------------------------------------------------------------------------------- /src/main/webapp/src/sys/view/error.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import {Icon} from "antd"; 3 | import styles from "./error.less"; 4 | 5 | const Error = () =>
6 |
7 | 8 |

404 Not Found

9 |
10 |
11 | 12 | export default Error 13 | -------------------------------------------------------------------------------- /src/main/webapp/src/sys/view/error.less: -------------------------------------------------------------------------------- 1 | .error { 2 | color: black; 3 | text-align: center; 4 | position: absolute; 5 | top: 30%; 6 | margin-top: -50px; 7 | left: 50%; 8 | margin-left: -100px; 9 | width: 200px; 10 | 11 | :global .anticon { 12 | font-size: 48px; 13 | margin-bottom: 16px; 14 | } 15 | 16 | h1 { 17 | font-family: cursive; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/webapp/src/sys/view/layout/footer.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import styles from "./main.less"; 3 | import config from "../../../common/config"; 4 | 5 | const Footer = () =>
6 | {config.footerText} 7 |
; 8 | 9 | export default Footer 10 | -------------------------------------------------------------------------------- /src/main/webapp/src/sys/view/layout/header.js: -------------------------------------------------------------------------------- 1 | import {Icon, Menu} from "antd"; 2 | import styles from "./main.less"; 3 | 4 | function Header({baseInfoModel, user, logout, switchSider, siderFold,changeMessage,massageNewCount}) { 5 | let handleClickMenu = e => e.key === 'logout' && logout(); 6 | return (
7 |
8 | 9 |
10 | 11 | {baseInfoModel.getUserRoleName(user.userRole)}:{user? user.chName:'请登录'} }> 12 | 13 | 注销 14 | 15 | 16 | 17 |
) 18 | } 19 | 20 | export default Header; 21 | -------------------------------------------------------------------------------- /src/main/webapp/src/sys/view/layout/sider.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import styles from "./main.less"; 3 | import Menus from "./menu"; 4 | import config from "../../../common/config.js"; 5 | 6 | function Sider({user, menu, siderFold, darkTheme, handleClickNavMenu, location}) { 7 | const menusProps = { 8 | user, 9 | menu, 10 | siderFold, 11 | darkTheme, 12 | location, 13 | handleClickNavMenu 14 | }; 15 | return ( 16 |
17 |
18 | 19 |
20 | 21 |
22 | ) 23 | } 24 | 25 | export default Sider 26 | -------------------------------------------------------------------------------- /src/main/webapp/src/sys/view/skin.less: -------------------------------------------------------------------------------- 1 | @import "vars.less"; 2 | 3 | :global { 4 | .ant-modal-mask { 5 | background-color: rgba(55, 55, 55, 0.2); 6 | } 7 | 8 | .ant-modal-content { 9 | box-shadow: none; 10 | } 11 | 12 | .ant-card { 13 | &:hover { 14 | overflow: auto; 15 | } 16 | &-head { 17 | background-color: #428F71; 18 | border-radius: 5px 5px 0 0; 19 | 20 | &-title{ 21 | color: #666!important; 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/webapp/src/theme.js: -------------------------------------------------------------------------------- 1 | module.exports = () => { 2 | return { 3 | '@border-radius-base': '3px', 4 | '@border-radius-sm': '2px', 5 | '@shadow-color': 'rgba(0,0,0,0.05)', 6 | '@shadow-1-down': '4px 4px 40px @shadow-color', 7 | '@border-color-split': '#f4f4f4', 8 | '@border-color-base': '#e5e5e5', 9 | '@menu-dark-bg': '#3a3f51', 10 | '@text-color': '#666', 11 | '@primary-color': '#609be8', 12 | //'@card-head-background' : '#428F71', 13 | '@tooltip-max-width': '600px', 14 | '@font-family': 'Microsoft YaHei', 15 | '@font-size-base':'12px' 16 | //'@font-family': 'monospace,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", SimSun, sans-serif' 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/webapp/src/themes/Search.less: -------------------------------------------------------------------------------- 1 | .antAdvancedSearchForm { 2 | padding: 10px 0 0 0; 3 | display: flex; 4 | justify-content: flex-start; 5 | border: 1px solid #d9d9d9; 6 | border-radius: 6px; 7 | margin-bottom: 10px; 8 | margin-left: 0; 9 | } 10 | 11 | .detailCols { 12 | padding-bottom: 10px; 13 | } 14 | 15 | .detailColsContent { 16 | width: 80%; 17 | :global { 18 | .ant-progress-line { 19 | width: 50%; 20 | } 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /src/main/webapp/src/themes/default.less: -------------------------------------------------------------------------------- 1 | // 本文件是对 ant-design: 2 | // https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less 3 | // 相应变量值的覆盖 4 | // 注意:只需写出要覆盖的变量即可(不需要覆盖的变量不要写) 5 | // http://www.iconfont.cn/collections/detail?cid=790 6 | @import "../../node_modules/antd/lib/style/themes/default.less"; 7 | @border-radius-base: 3px; 8 | @border-radius-sm: 2px; 9 | @shadow-color: rgba(0,0,0,0.05); 10 | @shadow-1-down: 4px 4px 40px @shadow-color; 11 | @border-color-split: #f4f4f4; 12 | @border-color-base: #e5e5e5; 13 | @menu-dark-bg: #3e3e3e; 14 | @text-color: #666; 15 | @font-family: "AvenirNext-Regular", "Helvetica Neue", "lucida grande", "PingFangHK-Light", "STHeiti", "Heiti SC", "Hiragino Sans GB", "Microsoft JhengHei", "Microsoft Yahei", SimHei, "WenQuanYi Micro Hei", "Droid Sans", "Roboto", Helvetica, Tahoma, Arial, "sans-serif"; 16 | @icon-url: "/antd/iconfont"; 17 | -------------------------------------------------------------------------------- /src/main/webapp/src/themes/mixin.less: -------------------------------------------------------------------------------- 1 | @import "default"; // antd-admin 2 | @dark-half: #494949; 3 | @purple: #d897eb; 4 | @shadow-1: 4px 4px 20px 0 rgba(0,0,0,0.01); 5 | @shadow-2: 4px 4px 40px 0 rgba(0,0,0,0.05); 6 | @transition-ease-in: all 0.3s ease-out; 7 | @transition-ease-out: all 0.3s ease-out; 8 | @ease-in: ease-in; 9 | 10 | .text-overflow { 11 | white-space: nowrap; 12 | text-overflow: ellipsis; 13 | overflow: hidden; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/webapp/src/themes/vars.less: -------------------------------------------------------------------------------- 1 | @import "default"; 2 | @import "mixin"; 3 | -------------------------------------------------------------------------------- /src/main/webapp/src/user/service/user.ts: -------------------------------------------------------------------------------- 1 | import {request} from "../../common/utils/request"; 2 | 3 | export function listAll() { 4 | return request('/users/listAll'); 5 | } 6 | 7 | export function create(params) { 8 | let formData = new FormData(); 9 | for (let name in params) { 10 | formData.append(name, params[name]); 11 | } 12 | return request('/users/create', { 13 | method: 'POST', 14 | body: formData 15 | }); 16 | } 17 | 18 | export function update(params) { 19 | let formData = new FormData(); 20 | for (let name in params) { 21 | formData.append(name, params[name]); 22 | } 23 | return request('/users/update', { 24 | method: 'POST', 25 | body: formData 26 | }); 27 | } 28 | 29 | export function remove(params) { 30 | let formData = new FormData(); 31 | for (let name in params) { 32 | formData.append(name, params[name]); 33 | } 34 | return request('/users/delete', { 35 | method: 'POST', 36 | body: formData, 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/webapp/src/user/view/UserList.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import {Button, Popconfirm, Table} from "antd"; 3 | import {UserVo} from "../model/UserModel"; 4 | 5 | const columns = [ 6 | { 7 | title: '用户id', 8 | dataIndex: 'id', 9 | key: 'id' 10 | }, { 11 | title: '用户名', 12 | dataIndex: 'userName', 13 | key: 'userName' 14 | }, { 15 | title: '中文名', 16 | dataIndex: 'chName', 17 | key: 'chName' 18 | }, { 19 | title: '邮箱', 20 | dataIndex: 'email', 21 | key: 'email' 22 | }, { 23 | title: '手机号', 24 | dataIndex: 'mobile', 25 | key: 'mobile' 26 | }, { 27 | title: '用户类型', 28 | dataIndex: 'userRole', 29 | key: 'userRole', 30 | render: (text) => { 31 | if (text == 1) return 管理员; 32 | if (text == 2) return 超级管理员; 33 | return 普通用户 34 | } 35 | }]; 36 | 37 | export interface ListProps { 38 | user: UserVo; 39 | dataSource: Array; 40 | loading: boolean; 41 | onEdit: any; 42 | onDelete: any; 43 | pageConfig:any 44 | } 45 | 46 | export const UserList = (props: ListProps) => { 47 | let oprationCol = { 48 | title: '操作', 49 | dataIndex: 'operator', 50 | key: 'operator', 51 | 52 | render: (text, bean) => { 53 | return ( 54 | 55 | props.onDelete(bean.id)}> 56 | 57 | 58 | ); 59 | } 60 | }; 61 | let finalColumns = columns.concat(oprationCol); 62 | 63 | return
65 | }; 66 | -------------------------------------------------------------------------------- /src/main/webapp/src/user/view/UserRegister.tsx: -------------------------------------------------------------------------------- 1 | import React, {Component} from "react"; 2 | import "../../sys/view/layout/common.less"; 3 | import {withRouter} from "react-router"; 4 | import {inject} from "../../common/utils/IOC"; 5 | import UserRegisterForm from "./UserRegisterForm"; 6 | import {SysUserModel} from "../../sys/model/SysUserModel"; 7 | import {UserVo} from "../model/UserModel"; 8 | import {notification} from "antd"; 9 | 10 | const divStyle = { 11 | width: '100%', 12 | height: '1000px', 13 | backgroundSize: '100%', 14 | }; 15 | 16 | interface RouterI { 17 | router: any 18 | } 19 | 20 | class UserRegister extends Component { 21 | 22 | @inject(SysUserModel) 23 | private sysUserModel: SysUserModel; 24 | 25 | render() { 26 | 27 | let thisV = this; 28 | let registerProps = { 29 | loading: this.sysUserModel.loading, 30 | isUserNameExisted(userName, callback) { 31 | thisV.sysUserModel.checkUserExists(userName, callback); 32 | }, 33 | onOk (user: UserVo) { 34 | thisV.sysUserModel.register(thisV.props.router, user, (message) => { 35 | notification['success']({ 36 | message: message, 37 | description: '', 38 | }); 39 | }) 40 | } 41 | }; 42 | 43 | return (
44 | 45 |
); 46 | } 47 | } 48 | 49 | export default withRouter(UserRegister); -------------------------------------------------------------------------------- /src/main/webapp/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "moduleResolution": "node", 5 | "experimentalDecorators": true, 6 | "emitDecoratorMetadata": true, 7 | "allowSyntheticDefaultImports": true, 8 | "sourceMap": true, 9 | "allowJs": true, 10 | "lib": ["es2017","dom"], 11 | "jsx": "react" 12 | // "noImplicitAny": true 13 | }, 14 | "include": [ 15 | "src" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/com/ucar/zkdoctor/BaseTest.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 6 | import org.springframework.test.context.web.WebAppConfiguration; 7 | 8 | /** 9 | * Description: 测试基类,基本配置 10 | * Created on 2018/1/5 13:41 11 | * 12 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 13 | */ 14 | @RunWith(SpringJUnit4ClassRunner.class) 15 | @SpringBootTest(classes = ZkDoctorMain.class) 16 | @WebAppConfiguration 17 | public class BaseTest { 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/com/ucar/zkdoctor/dao/mysql/UserDaoTest.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.dao.mysql; 2 | 3 | import com.ucar.zkdoctor.BaseTest; 4 | import com.ucar.zkdoctor.pojo.po.User; 5 | import org.junit.Test; 6 | 7 | import javax.annotation.Resource; 8 | 9 | /** 10 | * Description: 用户Dao测试 11 | * Created on 2018/1/5 11:01 12 | * 13 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 14 | */ 15 | public class UserDaoTest extends BaseTest { 16 | 17 | @Resource 18 | private UserDao userDao; 19 | 20 | @Test 21 | public void testInsertNewUser() throws Exception { 22 | User newUser = new User(); 23 | newUser.setUserName("admin"); 24 | newUser.setChName("管理员"); 25 | newUser.setEmail("admin@ucarinc.com"); 26 | newUser.setUserRole(2); 27 | boolean result = userDao.insertNewUser(newUser); 28 | System.out.println("result is : " + result + ",user id is : " + newUser.getId()); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /src/test/java/com/ucar/zkdoctor/pojo/bo/HostAndPortTest.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.pojo.bo; 2 | 3 | import org.apache.commons.collections4.CollectionUtils; 4 | import org.junit.Test; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Description: 工具类测试 10 | * Created on 2018/1/15 14:59 11 | * 12 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 13 | */ 14 | public class HostAndPortTest { 15 | @Test 16 | public void testTransformToHostAndPort() throws Exception { 17 | HostAndPort hostAndPort = HostAndPort.transformToHostAndPort("127.0.0.1:2181"); 18 | System.out.println(hostAndPort == null ? "NULL" : hostAndPort); 19 | } 20 | 21 | @Test 22 | public void testTransformToHostAndPortList() throws Exception { 23 | List hostAndPortList = HostAndPort.transformToHostAndPortList("127.0.0.1:2181\n127.0.0.2:2181"); 24 | if (CollectionUtils.isNotEmpty(hostAndPortList)) { 25 | for (HostAndPort hostAndPort : hostAndPortList) { 26 | System.out.println(hostAndPort); 27 | } 28 | } 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /src/test/java/com/ucar/zkdoctor/service/schedule/impl/SchedulerServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.schedule.impl; 2 | 3 | import com.ucar.zkdoctor.BaseTest; 4 | import com.ucar.zkdoctor.pojo.po.TriggerInfo; 5 | import com.ucar.zkdoctor.service.schedule.SchedulerService; 6 | import org.apache.commons.collections4.CollectionUtils; 7 | import org.junit.Test; 8 | 9 | import javax.annotation.Resource; 10 | import java.util.List; 11 | 12 | /** 13 | * Description: 定时任务测试类 14 | * Created on 2018/2/5 17:09 15 | * 16 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 17 | */ 18 | public class SchedulerServiceImplTest extends BaseTest { 19 | 20 | @Resource 21 | private SchedulerService schedulerService; 22 | 23 | @Test 24 | public void getTrigger() throws Exception { 25 | List triggerInfoList = schedulerService.getAllTriggers(); 26 | if (CollectionUtils.isNotEmpty(triggerInfoList)) { 27 | for (TriggerInfo triggerInfo : triggerInfoList) { 28 | System.out.println(triggerInfo); 29 | } 30 | } else { 31 | System.out.println("triggerInfoList is NULL"); 32 | } 33 | } 34 | 35 | @Test 36 | public void testGetTriggersByNameOrGroup() throws Exception { 37 | List triggerInfoList = schedulerService.getTriggersByNameOrGroup("clean"); 38 | if (CollectionUtils.isNotEmpty(triggerInfoList)) { 39 | for (TriggerInfo triggerInfo : triggerInfoList) { 40 | System.out.println(triggerInfo); 41 | } 42 | } else { 43 | System.out.println("triggerInfoList is NULL"); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /src/test/java/com/ucar/zkdoctor/service/zk/ZKServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.service.zk; 2 | 3 | import com.ucar.zkdoctor.BaseTest; 4 | import com.ucar.zkdoctor.pojo.vo.ZnodeTreeNodeVO; 5 | import org.apache.commons.collections4.CollectionUtils; 6 | import org.junit.Test; 7 | 8 | import javax.annotation.Resource; 9 | import java.util.List; 10 | 11 | /** 12 | * Description: zk服务测试类 13 | * Created on 2018/2/1 18:15 14 | * 15 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 16 | */ 17 | public class ZKServiceTest extends BaseTest { 18 | 19 | @Resource 20 | private ZKService zkService; 21 | 22 | @Test 23 | public void testInitZnodesTree() throws Exception { 24 | List znodeTreeNodeVOList = zkService.initZnodesTree(1); 25 | if (CollectionUtils.isNotEmpty(znodeTreeNodeVOList)) { 26 | for (ZnodeTreeNodeVO znodeTreeNodeVO : znodeTreeNodeVOList) { 27 | System.out.println(znodeTreeNodeVO); 28 | } 29 | } else { 30 | System.out.println("znodeTreeNodeVOList is NULL."); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/test/java/com/ucar/zkdoctor/util/ssh/SSHUtilTest.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.ssh; 2 | 3 | import org.junit.Test; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * Description: SSH工具类测试 9 | * Created on 2018/2/22 10:21 10 | * 11 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 12 | */ 13 | public class SSHUtilTest { 14 | 15 | @Test 16 | public void collectMachineState() throws Exception { 17 | Map result = SSHUtil.collectMachineState("127.0.0.1"); 18 | if (result != null) { 19 | for (Map.Entry entry : result.entrySet()) { 20 | System.out.println("key: " + entry.getKey() + ", value: " + entry.getValue()); 21 | } 22 | } 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /src/test/java/com/ucar/zkdoctor/util/tool/HessianSerializerUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.ucar.zkdoctor.util.tool; 2 | 3 | import org.junit.Test; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Description: 序列化测试类 9 | * Created on 2018/2/5 9:50 10 | * 11 | * @author 吕小玲(xiaoling.lv@ucarinc.com) 12 | */ 13 | public class HessianSerializerUtilsTest implements Serializable { 14 | 15 | private static final long serialVersionUID = 6510936416683102059L; 16 | 17 | private Integer id; 18 | 19 | public Integer getId() { 20 | return id; 21 | } 22 | 23 | public void setId(Integer id) { 24 | this.id = id; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "HessianSerializerUtilsTest{" + 30 | "id=" + id + 31 | '}'; 32 | } 33 | 34 | @Test 35 | public void serialize() throws Exception { 36 | HessianSerializerUtilsTest object = new HessianSerializerUtilsTest(); 37 | object.setId(100); 38 | byte[] data = HessianSerializerUtils.serialize(object); 39 | System.out.println(HessianSerializerUtils.deserialize(data)); 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /src/wikiimages/业务线配置.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/业务线配置.jpg -------------------------------------------------------------------------------- /src/wikiimages/动态扩容.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/动态扩容.jpg -------------------------------------------------------------------------------- /src/wikiimages/实例运维.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/实例运维.jpg -------------------------------------------------------------------------------- /src/wikiimages/新增报警用户.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/新增报警用户.jpg -------------------------------------------------------------------------------- /src/wikiimages/服务升级.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/服务升级.jpg -------------------------------------------------------------------------------- /src/wikiimages/服务部署.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/服务部署.jpg -------------------------------------------------------------------------------- /src/wikiimages/机器信息收集开关.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/机器信息收集开关.jpg -------------------------------------------------------------------------------- /src/wikiimages/注册登录页面.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/注册登录页面.png -------------------------------------------------------------------------------- /src/wikiimages/注册页面.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/注册页面.png -------------------------------------------------------------------------------- /src/wikiimages/添加集群.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/添加集群.jpg -------------------------------------------------------------------------------- /src/wikiimages/登录页面.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/登录页面.png -------------------------------------------------------------------------------- /src/wikiimages/监控报警.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/监控报警.jpg -------------------------------------------------------------------------------- /src/wikiimages/系统架构图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/系统架构图.png -------------------------------------------------------------------------------- /src/wikiimages/系统配置.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/系统配置.jpg -------------------------------------------------------------------------------- /src/wikiimages/连接信息收集开关.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/连接信息收集开关.jpg -------------------------------------------------------------------------------- /src/wikiimages/集群统计.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/集群统计.jpg -------------------------------------------------------------------------------- /src/wikiimages/集群运维.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ucarGroup/zkdoctor/702480b746379ab66bf8c4a749ea4ed0ac10aef9/src/wikiimages/集群运维.jpg --------------------------------------------------------------------------------