├── .gitignore ├── README.md ├── document ├── Marble原理之线程中断.MD ├── Marble原理之线程池.MD ├── marble.sql ├── readme └── resource │ ├── 4678905-5d008fef53039e9b.jpg │ ├── 4678905-666cb2fd65393956.png │ ├── 4678905-b192bb1edf275c81.jpg │ ├── 4678905-b2f772e124219867.jpg │ ├── 4678905-b9143c5aeb827d80.png │ ├── image2016-9-23 9-33-3.png │ └── image2016-9-23 9-40-50.png ├── marble-agent ├── marble-agent.iml ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── jxdong │ │ │ └── marble │ │ │ └── agent │ │ │ ├── common │ │ │ ├── server │ │ │ │ ├── MarbleJob.java │ │ │ │ ├── MarbleManager.java │ │ │ │ ├── global │ │ │ │ │ ├── MarbleConfigParser.java │ │ │ │ │ ├── MarbleJobPool.java │ │ │ │ │ ├── MarbleThread.java │ │ │ │ │ ├── MarbleThreadFeature.java │ │ │ │ │ └── ThreadPool.java │ │ │ │ ├── netty │ │ │ │ │ ├── client │ │ │ │ │ │ └── NettyClientManager.java │ │ │ │ │ └── server │ │ │ │ │ │ ├── NettyServer.java │ │ │ │ │ │ └── NettyServerHandler.java │ │ │ │ ├── spring │ │ │ │ │ ├── JobBeanConfig.java │ │ │ │ │ ├── MarbleSchedulerBean.java │ │ │ │ │ ├── SchedulerBeanConfig.java │ │ │ │ │ └── schema │ │ │ │ │ │ ├── MarbleBeanDefinitionParser.java │ │ │ │ │ │ └── MarbleNamespaceHandler.java │ │ │ │ └── thrift │ │ │ │ │ ├── MethodCallback.java │ │ │ │ │ ├── ThriftAuto.java │ │ │ │ │ └── ThriftConnectInfo.java │ │ │ └── util │ │ │ │ ├── ArrayUtils.java │ │ │ │ ├── ClogWrapper.java │ │ │ │ ├── ClogWrapperFactory.java │ │ │ │ ├── CommonUtil.java │ │ │ │ ├── DateUtil.java │ │ │ │ ├── JsonUtil.java │ │ │ │ ├── PropertyUtils.java │ │ │ │ └── StringUtils.java │ │ │ └── entity │ │ │ ├── ClassInfo.java │ │ │ ├── JobExecStatusEnum.java │ │ │ ├── MarbleRequest.java │ │ │ ├── MarbleResponse.java │ │ │ ├── Result.java │ │ │ └── ResultCodeEnum.java │ └── resources │ │ └── META-INF │ │ ├── marble.xsd │ │ ├── spring.handlers │ │ └── spring.schemas │ └── test │ └── java │ └── NettyTest.java ├── marble-common ├── marble-common.iml ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── github │ └── jxdong │ └── marble │ └── common │ └── util │ ├── ArrayUtils.java │ ├── ClogWrapper.java │ ├── ClogWrapperFactory.java │ ├── CommonUtil.java │ ├── DateUtil.java │ ├── JacksonUtil.java │ ├── JsonUtil.java │ ├── PropertyUtils.java │ └── StringUtils.java ├── marble-contract └── pom.xml ├── marble-web ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── jxdong │ │ │ └── marble │ │ │ ├── controller │ │ │ ├── AppController.java │ │ │ ├── BasicController.java │ │ │ ├── ConfigureController.java │ │ │ ├── HelperController.java │ │ │ ├── LabController.java │ │ │ ├── LogController.java │ │ │ ├── LoginController.java │ │ │ ├── MarbleController.java │ │ │ ├── MarbleJobRestfulController.java │ │ │ ├── MonitorController.java │ │ │ ├── QuartzJobDetailController.java │ │ │ └── SchedulerController.java │ │ │ ├── domain │ │ │ ├── dto │ │ │ │ ├── AppDetailDTO.java │ │ │ │ ├── BaseDTO.java │ │ │ │ ├── ConfigureDTO.java │ │ │ │ ├── CronExpressDTO.java │ │ │ │ ├── JobDetailDTO.java │ │ │ │ ├── JobExecResponse.java │ │ │ │ ├── JobExecutionLogDTO.java │ │ │ │ ├── SchedulerDetailDTO.java │ │ │ │ └── ServerDetailDTO.java │ │ │ ├── model │ │ │ │ ├── Account.java │ │ │ │ ├── AppDetail.java │ │ │ │ ├── AppRequest.java │ │ │ │ ├── Configure.java │ │ │ │ ├── ConfigureRequest.java │ │ │ │ ├── DatatablesRequest.java │ │ │ │ ├── Entity.java │ │ │ │ ├── JobBasicInfo.java │ │ │ │ ├── JobDetail.java │ │ │ │ ├── JobExecutionLog.java │ │ │ │ ├── JobLogRequest.java │ │ │ │ ├── MarbleJobProxy.java │ │ │ │ ├── Page.java │ │ │ │ ├── Response.java │ │ │ │ ├── Result.java │ │ │ │ ├── ResultCodeEnum.java │ │ │ │ ├── SchedulerDetail.java │ │ │ │ ├── ServerDetail.java │ │ │ │ └── enums │ │ │ │ │ ├── AppStatusEnum.java │ │ │ │ │ ├── ConfigureEnum.java │ │ │ │ │ ├── ErrorEnum.java │ │ │ │ │ ├── JobExecStatusEnum.java │ │ │ │ │ ├── JobReqStatusEnum.java │ │ │ │ │ ├── JobStatusEnum.java │ │ │ │ │ ├── MisfireInstructionEnum.java │ │ │ │ │ ├── SchedStatusEnum.java │ │ │ │ │ └── ServerStatusEnum.java │ │ │ └── repositories │ │ │ │ ├── AppRepository.java │ │ │ │ ├── ConfigureRepository.java │ │ │ │ ├── Repository.java │ │ │ │ └── SchedRepository.java │ │ │ ├── global │ │ │ ├── exception │ │ │ │ ├── MarbleException.java │ │ │ │ └── MarbleExceptionHandler.java │ │ │ ├── listener │ │ │ │ ├── AppLifeCycleListener.java │ │ │ │ ├── MVCInterceptor.java │ │ │ │ ├── MarbleHiddenHttpMethodFilter.java │ │ │ │ ├── MarbleJobListener.java │ │ │ │ ├── MarbleSchedulerListener.java │ │ │ │ ├── MarbleTriggerListener.java │ │ │ │ ├── MyFreeMarkerView.java │ │ │ │ └── SpringLifeCycleListener.java │ │ │ └── util │ │ │ │ ├── AuthorityUtil.java │ │ │ │ ├── DTOConvert.java │ │ │ │ ├── DateUtil.java │ │ │ │ ├── SpringContextUtil.java │ │ │ │ └── SqlErrorUtil.java │ │ │ └── infrastructure │ │ │ ├── repositories │ │ │ ├── AppRepositoryImpl.java │ │ │ ├── ConfigureRepositoryImpl.java │ │ │ ├── SchedRepositoryImpl.java │ │ │ └── mapper │ │ │ │ └── mysql │ │ │ │ ├── AppMapper.java │ │ │ │ ├── AppMapper.xml │ │ │ │ ├── ConfigureMapper.java │ │ │ │ ├── ConfigureMapper.xml │ │ │ │ ├── JobExecutionLogMapper.java │ │ │ │ ├── JobExecutionLogMapper.xml │ │ │ │ ├── SchedMapper.java │ │ │ │ └── SchedMapper.xml │ │ │ └── service │ │ │ ├── LogManager.java │ │ │ ├── QuartzManager.java │ │ │ ├── RPCClientFactory.java │ │ │ ├── RPCClientManager.java │ │ │ ├── ThriftManager.java │ │ │ ├── job │ │ │ ├── Job1.java │ │ │ └── Job2.java │ │ │ └── netty │ │ │ ├── WebNettyClientManager.java │ │ │ └── WebNettyServerManager.java │ ├── resources │ │ ├── config.properties │ │ ├── datasource-mysql.xml │ │ ├── freemarker.properties │ │ ├── logback.xml │ │ ├── marble-config.properties │ │ ├── rebel.xml │ │ ├── spring-application.xml │ │ └── spring-quartz.xml │ └── webapp │ │ ├── WEB-INF │ │ ├── ftl │ │ │ ├── app-addpopup.ftl │ │ │ ├── app-editpopup.ftl │ │ │ ├── app-server-addpopup.ftl │ │ │ ├── app.ftl │ │ │ ├── common │ │ │ │ ├── bottom.ftl │ │ │ │ ├── header.ftl │ │ │ │ ├── js.ftl │ │ │ │ ├── menu.ftl │ │ │ │ ├── navbar.ftl │ │ │ │ └── successPopup.ftl │ │ │ ├── configure-addpopup.ftl │ │ │ ├── configure.ftl │ │ │ ├── error.ftl │ │ │ ├── helper.ftl │ │ │ ├── monitor-ramscheduler.ftl │ │ │ ├── monitor.ftl │ │ │ ├── quartz-job.ftl │ │ │ ├── scheduler-addpopup.ftl │ │ │ ├── scheduler-editpopup.ftl │ │ │ ├── scheduler-job-addpopup.ftl │ │ │ ├── scheduler-job-editpopup.ftl │ │ │ ├── scheduler-job-execpopup.ftl │ │ │ ├── scheduler-job-stopjobpopup.ftl │ │ │ ├── scheduler-log-delpopup.ftl │ │ │ ├── scheduler-log.ftl │ │ │ ├── scheduler-manage.ftl │ │ │ ├── scheduler-server-checkpopup.ftl │ │ │ └── scheduler.ftl │ │ ├── resources │ │ │ ├── assets │ │ │ │ ├── demo │ │ │ │ │ └── avatars │ │ │ │ │ │ ├── 1.jpg │ │ │ │ │ │ ├── 2.jpg │ │ │ │ │ │ ├── 3.jpg │ │ │ │ │ │ ├── 4.jpg │ │ │ │ │ │ └── 5.jpg │ │ │ │ ├── fonts │ │ │ │ │ └── font-awesome │ │ │ │ │ │ ├── FontAwesome.otf │ │ │ │ │ │ ├── fontawesome-webfont.eot │ │ │ │ │ │ ├── fontawesome-webfont.svg │ │ │ │ │ │ ├── fontawesome-webfont.ttf │ │ │ │ │ │ └── fontawesome-webfont.woff │ │ │ │ ├── images │ │ │ │ │ ├── loading.gif │ │ │ │ │ ├── pixel-admin │ │ │ │ │ │ ├── ajax-loader.gif │ │ │ │ │ │ ├── avatar.png │ │ │ │ │ │ ├── blank.png │ │ │ │ │ │ ├── blur.svg │ │ │ │ │ │ ├── main-menu-bg.png │ │ │ │ │ │ ├── main-navbar-bg.png │ │ │ │ │ │ └── main-navbar-logo.png │ │ │ │ │ ├── plugins │ │ │ │ │ │ ├── bootstrap-editable │ │ │ │ │ │ │ └── loading.gif │ │ │ │ │ │ └── jquery.minicolors.png │ │ │ │ │ └── themes │ │ │ │ │ │ ├── adminflare │ │ │ │ │ │ ├── body-bg.png │ │ │ │ │ │ ├── ie-navbar-bg.png │ │ │ │ │ │ └── menu-bg.png │ │ │ │ │ │ └── clean │ │ │ │ │ │ └── body-bg.gif │ │ │ │ ├── javascripts │ │ │ │ │ ├── bootstrap-editable-demo.js │ │ │ │ │ ├── bootstrap-editable-demo.min.js │ │ │ │ │ ├── bootstrap.js │ │ │ │ │ ├── bootstrap.min.js │ │ │ │ │ ├── demo-mock.js │ │ │ │ │ ├── demo-mock.min.js │ │ │ │ │ ├── ie.js │ │ │ │ │ ├── ie.min.js │ │ │ │ │ ├── jquery-ui-extras.js │ │ │ │ │ ├── jquery-ui-extras.min.js │ │ │ │ │ ├── jquery.mockjax.js │ │ │ │ │ ├── jquery.mockjax.min.js │ │ │ │ │ ├── pixel-admin.js │ │ │ │ │ └── pixel-admin.min.js │ │ │ │ └── stylesheets │ │ │ │ │ ├── bootstrap.css │ │ │ │ │ ├── bootstrap.min.css │ │ │ │ │ ├── pages.css │ │ │ │ │ ├── pages.min.css │ │ │ │ │ ├── pixel-admin.css │ │ │ │ │ ├── pixel-admin.min.css │ │ │ │ │ ├── rtl.css │ │ │ │ │ ├── rtl.min.css │ │ │ │ │ ├── themes.css │ │ │ │ │ ├── themes.min.css │ │ │ │ │ ├── widgets.css │ │ │ │ │ └── widgets.min.css │ │ │ ├── css │ │ │ │ └── bootstrap-switch.min.css │ │ │ ├── js │ │ │ │ ├── bootstrap-switch.min.js │ │ │ │ ├── cronGen.js │ │ │ │ └── jquery.min.js │ │ │ └── view │ │ │ │ ├── pages-404.html │ │ │ │ └── pages-500.html │ │ └── web.xml │ │ └── index.jsp │ └── test │ └── java │ └── com │ └── github │ └── group │ ├── marble │ └── infrastructure │ │ └── service │ │ └── NettyManagerTest.java │ └── marble1 │ └── service │ └── MarbleTest.java └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .gradle/ 3 | *.iml 4 | *.ipr 5 | *.iws 6 | work/ 7 | /data/ 8 | logs/ 9 | .DS_Store 10 | build/ 11 | /target/ 12 | target/ 13 | *-execution-hints.log 14 | docs/html/ 15 | docs/build.log 16 | /tmp/ 17 | backwards/ 18 | html_docs 19 | .vagrant/ 20 | .class 21 | rebel.xml 22 | 23 | .project 24 | .classpath 25 | eclipse-build 26 | .settings 27 | /marble-contract.iml 28 | /marble-agent/*.iml 29 | /marble-agent/target/ 30 | /marble-common/*.iml 31 | /marble-common/target/ 32 | /marble-web/*.iml 33 | /marble-web/target/ 34 | /.idea 35 | /marble-web/__ConfigTemp/ 36 | /__ConfigTemp 37 | 38 | /marble-parent.iml 39 | /marble-contract/marble-contract.iml 40 | /marble-web/marble-web.iml 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Marble是什么 2 | Marble是一款Java实现的计划任务调度框架,包含Marble-OFFLINE和Marble-Agent两部分。 3 | - Marble OFFLINE:JOB调度控制中心,且提供一个可视化的计划任务的操作管理页面; 4 | - Marble Agent:以Jar包形式整合进接入Marble的第三方应用,透明化Job的调度过程; 5 | 6 | # Marble能做什么 7 | 1. Java JOB(同步JOB和异步JOB)调度; 8 | 2. JOB参数支持; 9 | 3. OFFLINE管理平台进行JOB管理; 10 | 4. 支持手动JOB调用; 11 | 5. 基本的权限控制; 12 | 6. JOB线程中断支持; 13 | 7. JOB执行全程追踪; 14 | 15 | # Marble快速接入教程 16 | ## 1 Marble Jar包引入 17 | ``` 18 | 19 | com.github.jeff-dong.marble 20 | marble-agent 21 | 2.0.0 22 | 23 | ``` 24 | ## 2 配置Marble(与Spring整合) 25 | ``` 26 | 27 | 28 | 29 | ... 30 | 31 | ``` 32 | ## 3 自定义实现类(JOB执行逻辑) 33 | 异步JOB 34 | ``` 35 | @Component 36 | public class TestMarbleJob1 extends MarbleJob { 37 | private Logger logger = LoggerFactory.getLogger(TestMarbleJob1.class); 38 | @Override 39 | public void execute(String param) { 40 | logger.info(" 异步 JOB1 执行正常: {}", param); 41 | } 42 | } 43 | ``` 44 | 同步JOB 45 | ``` 46 | @Component 47 | public class TestSyncMarbleJob1 extends MarbleJob { 48 | private Logger logger = LoggerFactory.getLogger(TestSyncMarbleJob1.class); 49 | 50 | @Override 51 | public Result executeSync(String param) { 52 | logger.info(" 同步 JOB1(3S) 执行正常: {}", param); 53 | try { 54 | Thread.sleep(3000); 55 | } catch (InterruptedException e) { 56 | e.printStackTrace(); 57 | } 58 | return Result.SUCCESS(); 59 | } 60 | } 61 | ``` 62 | 63 | ##4 OFFLINE配置JOB执行频率 64 | 65 | ![image.png](https://github.com/jeff-dong/marble/blob/master/document/resource/image2016-9-23%209-33-3.png) 66 | ![image.png](https://github.com/jeff-dong/marble/blob/master/document/resource/image2016-9-23%209-40-50.png) 67 | -------------------------------------------------------------------------------- /document/readme: -------------------------------------------------------------------------------- 1 | #模块划分 2 | marble-agent: 客户端代理,可单独打包到中央仓库 3 | marble-common: 放置公共的类 4 | marble-contract: 放置契约信息,目前空置 5 | marble-web: 主模块,包含offline和调度中心 6 | 7 | 8 | -------------------------------------------------------------------------------- /document/resource/4678905-5d008fef53039e9b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/document/resource/4678905-5d008fef53039e9b.jpg -------------------------------------------------------------------------------- /document/resource/4678905-666cb2fd65393956.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/document/resource/4678905-666cb2fd65393956.png -------------------------------------------------------------------------------- /document/resource/4678905-b192bb1edf275c81.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/document/resource/4678905-b192bb1edf275c81.jpg -------------------------------------------------------------------------------- /document/resource/4678905-b2f772e124219867.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/document/resource/4678905-b2f772e124219867.jpg -------------------------------------------------------------------------------- /document/resource/4678905-b9143c5aeb827d80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/document/resource/4678905-b9143c5aeb827d80.png -------------------------------------------------------------------------------- /document/resource/image2016-9-23 9-33-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/document/resource/image2016-9-23 9-33-3.png -------------------------------------------------------------------------------- /document/resource/image2016-9-23 9-40-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/document/resource/image2016-9-23 9-40-50.png -------------------------------------------------------------------------------- /marble-agent/marble-agent.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/common/server/MarbleJob.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.common.server; 2 | 3 | import com.github.jxdong.marble.agent.entity.Result; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | /** 8 | * @author jeff 9 | * @version 2015/11/10 11:27 10 | */ 11 | public abstract class MarbleJob { 12 | private static final Logger logger = LoggerFactory.getLogger(MarbleJob.class); 13 | 14 | //异步,不等待结果 15 | public void execute(String param) throws Exception{ 16 | logger.info("JOB-{} 执行: {}", this.getClass().getName(), param); 17 | } 18 | 19 | //同步,等待返回结果 20 | public Result executeSync(String param) throws Exception{ 21 | return Result.SUCCESS(); 22 | } 23 | 24 | //中断后处理 25 | public void afterInterruptTreatment(){ 26 | logger.info("JOB-{} 中断后处理", this.getClass().getName()); 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/common/server/global/MarbleJobPool.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.common.server.global; 2 | 3 | import com.github.jxdong.marble.agent.common.util.ClogWrapper; 4 | import com.github.jxdong.marble.agent.common.util.ClogWrapperFactory; 5 | import com.github.jxdong.marble.agent.entity.Result; 6 | import com.github.jxdong.marble.agent.common.server.netty.client.NettyClientManager; 7 | 8 | import java.util.HashMap; 9 | import java.util.Iterator; 10 | import java.util.Map; 11 | import java.util.concurrent.ConcurrentHashMap; 12 | 13 | /** 14 | * Marble JOB pool 15 | * 16 | * @author jeff 17 | * @version 2017/3/31 20:15 18 | */ 19 | public class MarbleJobPool { 20 | private static ClogWrapper logger = ClogWrapperFactory.getClogWrapper(MarbleJobPool.class); 21 | 22 | private Map processingJobMap = new ConcurrentHashMap<>(); 23 | //默认配置 24 | private static final int TPOOL_SIZE = 100;//存储的job数 25 | 26 | public MarbleJobPool addProcessingJob(String reqNo, boolean isSync, String marbleServerIp,Integer marbleServerPort){ 27 | processingJobMap.put(reqNo, new MarbleJob(isSync, marbleServerIp, marbleServerPort)); 28 | return this; 29 | } 30 | 31 | public MarbleJobPool removeProcessingJob(String reqNo){ 32 | processingJobMap.remove(reqNo); 33 | return this; 34 | } 35 | 36 | public Map getProcessingJobMap() { 37 | return processingJobMap; 38 | } 39 | 40 | private MarbleJobPool() { 41 | } 42 | 43 | //单例 44 | private static class SingletonHolder { 45 | private static final MarbleJobPool CONFIG_HELPER = new MarbleJobPool(); 46 | } 47 | 48 | public void destroy(){ 49 | Map data = new HashMap<>(); 50 | data.put("EXEC_RESULT", Result.FAILURE("执行失败, 原因: 服务关闭,执行终止" )); 51 | if (processingJobMap != null && processingJobMap.size() > 0) { 52 | Iterator> it = processingJobMap.entrySet().iterator(); 53 | while(it.hasNext()) { 54 | try{ 55 | Map.Entry entry = it.next(); 56 | NettyClientManager.getInstance().serviceInvoke(entry.getKey(), entry.getValue().getMarbleServerIp(), Integer.valueOf(entry.getValue().getMarbleServerPort()), data); 57 | it.remove(); 58 | }catch (Exception e){ 59 | e.printStackTrace(); 60 | } 61 | } 62 | } 63 | } 64 | 65 | public static MarbleJobPool getInstance() { 66 | return MarbleJobPool.SingletonHolder.CONFIG_HELPER; 67 | } 68 | 69 | 70 | public class MarbleJob { 71 | private boolean isSync; 72 | private String marbleServerIp; 73 | private Integer marbleServerPort; 74 | 75 | public MarbleJob(boolean isSync, String marbleServerIp,Integer marbleServerPort){ 76 | this.isSync = isSync; 77 | this.marbleServerIp = marbleServerIp; 78 | this.marbleServerPort = marbleServerPort; 79 | } 80 | 81 | public boolean isSync() { 82 | return isSync; 83 | } 84 | 85 | public String getMarbleServerIp() { 86 | return marbleServerIp; 87 | } 88 | 89 | public Integer getMarbleServerPort() { 90 | return marbleServerPort; 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/common/server/global/MarbleThread.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.common.server.global; 2 | 3 | import com.github.jxdong.marble.agent.common.server.MarbleJob; 4 | import com.github.jxdong.marble.agent.common.util.ClogWrapper; 5 | import com.github.jxdong.marble.agent.common.util.ClogWrapperFactory; 6 | 7 | import java.util.concurrent.ThreadPoolExecutor; 8 | 9 | /** 10 | * @author jeff 11 | * @version 2017/4/19 16:31 12 | */ 13 | public class MarbleThread implements Runnable { 14 | 15 | private ClogWrapper logger = ClogWrapperFactory.getClogWrapper(MarbleThread.class); 16 | private MarbleJob marbleJob; 17 | private String param; 18 | private Thread runThread; 19 | 20 | 21 | public MarbleThread(MarbleJob marbleJob, String param) { 22 | super(); 23 | this.marbleJob = marbleJob; 24 | this.param = param; 25 | } 26 | 27 | @Override 28 | public void run() { 29 | runThread = Thread.currentThread(); 30 | try { 31 | marbleJob.execute(param); 32 | } catch (Exception e) { 33 | e.printStackTrace(); 34 | } 35 | } 36 | 37 | public boolean isThreadAlive() { 38 | return (runThread != null && runThread.isAlive()); 39 | } 40 | 41 | public String getThreadName() { 42 | return runThread != null ? runThread.getName() : ""; 43 | } 44 | 45 | public void stop() { 46 | //首先尝试在阻塞队列中删除 47 | boolean removeResult = ((ThreadPoolExecutor) ThreadPool.getFixedInstance().getExecutorService()).getQueue().remove(this); 48 | logger.info("Hanging MarbleJob[{}] is removed from the queue success?{}", this.getClass().getSimpleName(), removeResult); 49 | if (runThread != null && !runThread.isInterrupted()) { 50 | logger.info("Thread[{}] is interrupted", runThread.getName()); 51 | runThread.interrupt(); 52 | } 53 | if (marbleJob != null) { 54 | marbleJob.afterInterruptTreatment(); 55 | } 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/common/server/global/MarbleThreadFeature.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.common.server.global; 2 | 3 | import com.github.jxdong.marble.agent.common.util.ClogWrapper; 4 | import com.github.jxdong.marble.agent.common.util.ClogWrapperFactory; 5 | import com.github.jxdong.marble.agent.entity.Result; 6 | import com.github.jxdong.marble.agent.common.server.MarbleJob; 7 | 8 | import java.util.concurrent.*; 9 | 10 | /** 11 | * @author jeff 12 | * @version 2017/4/19 16:31 13 | */ 14 | public class MarbleThreadFeature implements RunnableFuture { 15 | 16 | private ClogWrapper logger = ClogWrapperFactory.getClogWrapper(MarbleThreadFeature.class); 17 | private MarbleJob marbleJob; 18 | private String param; 19 | private FutureTask futureTask; 20 | 21 | 22 | public MarbleThreadFeature(final MarbleJob marbleJob, final String param) { 23 | super(); 24 | this.marbleJob = marbleJob; 25 | this.param = param; 26 | futureTask = new FutureTask<>(new Callable() { 27 | @Override 28 | public Result call() throws Exception { 29 | return marbleJob.executeSync(param); 30 | } 31 | }); 32 | } 33 | 34 | 35 | @Override 36 | public void run() { 37 | futureTask.run(); 38 | } 39 | 40 | @Override 41 | public boolean cancel(boolean mayInterruptIfRunning) { 42 | return futureTask.cancel(mayInterruptIfRunning); 43 | } 44 | 45 | @Override 46 | public boolean isCancelled() { 47 | return futureTask.isCancelled(); 48 | } 49 | 50 | @Override 51 | public boolean isDone() { 52 | return futureTask.isDone(); 53 | } 54 | 55 | @Override 56 | public V get() throws InterruptedException, ExecutionException { 57 | return (V) futureTask.get(); 58 | } 59 | 60 | @Override 61 | public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { 62 | return (V) futureTask.get(timeout, unit); 63 | } 64 | 65 | public void stop(String operator) { 66 | if (futureTask != null && !futureTask.isCancelled()) { 67 | logger.info("Thread-feature[{}] is interrupted", futureTask.getClass().getName()); 68 | futureTask.cancel(true); 69 | }else if(marbleJob != null){ 70 | boolean removeResult = ((ThreadPoolExecutor) ThreadPool.getFixedInstance().getExecutorService()).getQueue().remove(marbleJob); 71 | logger.info("Hanging MarbleJob[{}] is removed from the queue success?{}", marbleJob.getClass().getSimpleName(),removeResult); 72 | } 73 | if(marbleJob != null){ 74 | marbleJob.afterInterruptTreatment(); 75 | } 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/common/server/spring/JobBeanConfig.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.common.server.spring; 2 | 3 | 4 | import com.github.jxdong.marble.agent.common.server.MarbleJob; 5 | 6 | /** 7 | * @author jeff 8 | * @version 2015/8/20 16:34 9 | */ 10 | public class JobBeanConfig { 11 | 12 | private MarbleJob ref; 13 | private String name; 14 | private String description; 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | 24 | public MarbleJob getRef() { 25 | return ref; 26 | } 27 | 28 | public void setRef(MarbleJob ref) { 29 | this.ref = ref; 30 | } 31 | 32 | public String getDescription() { 33 | return description; 34 | } 35 | 36 | public void setDescription(String description) { 37 | this.description = description; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/common/server/spring/SchedulerBeanConfig.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.common.server.spring; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author jeff 7 | * @version 2015/8/20 16:34 8 | */ 9 | public class SchedulerBeanConfig { 10 | 11 | private String id; 12 | // private String name; 13 | private String host; 14 | private int appCode; 15 | private int port; 16 | private List jobs; 17 | 18 | public int getAppCode() { 19 | return appCode; 20 | } 21 | 22 | public void setAppCode(int appCode) { 23 | this.appCode = appCode; 24 | } 25 | 26 | public String getHost() { 27 | return host; 28 | } 29 | 30 | public void setHost(String host) { 31 | this.host = host; 32 | } 33 | 34 | public int getPort() { 35 | return port; 36 | } 37 | 38 | public void setPort(int port) { 39 | this.port = port; 40 | } 41 | 42 | public String getId() { 43 | return id; 44 | } 45 | 46 | public void setId(String id) { 47 | this.id = id; 48 | } 49 | 50 | public List getJobs() { 51 | return jobs; 52 | } 53 | 54 | public void setJobs(List jobs) { 55 | this.jobs = jobs; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/common/server/spring/schema/MarbleNamespaceHandler.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.common.server.spring.schema; 2 | 3 | import com.github.jxdong.marble.agent.common.server.spring.MarbleSchedulerBean; 4 | import org.springframework.beans.factory.xml.NamespaceHandlerSupport; 5 | 6 | public class MarbleNamespaceHandler extends NamespaceHandlerSupport { 7 | 8 | public void init() { 9 | registerBeanDefinitionParser("scheduler", new MarbleBeanDefinitionParser(MarbleSchedulerBean.class, true)); 10 | } 11 | } -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/common/server/thrift/MethodCallback.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.common.server.thrift; 2 | 3 | import org.apache.thrift.async.AsyncMethodCallback; 4 | 5 | public class MethodCallback implements AsyncMethodCallback { 6 | Object response = null; 7 | 8 | public Object getResult() { 9 | // 返回结果值 10 | return this.response; 11 | } 12 | 13 | // 处理服务返回的结果值 14 | @Override 15 | public void onComplete(Object response) { 16 | this.response = response; 17 | } 18 | 19 | @Override 20 | public void onError(Exception e) { 21 | 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/common/server/thrift/ThriftConnectInfo.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.common.server.thrift; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | import com.github.jxdong.marble.agent.common.util.ArrayUtils; 5 | import com.github.jxdong.marble.agent.common.util.CommonUtil; 6 | import org.apache.commons.lang.builder.ToStringBuilder; 7 | import org.apache.commons.lang.builder.ToStringStyle; 8 | import org.codehaus.jackson.annotate.JsonIgnoreProperties; 9 | 10 | import java.io.Serializable; 11 | import java.util.List; 12 | 13 | /** 14 | * @author jeff 15 | * @version 2015/11/11 16:13 16 | */ 17 | @JsonIgnoreProperties(ignoreUnknown = true) 18 | public class ThriftConnectInfo implements Serializable{ 19 | 20 | private String serviceName; 21 | private List serverInfo; 22 | private Server execServer; 23 | 24 | public ThriftConnectInfo(){ 25 | 26 | } 27 | 28 | public ThriftConnectInfo(String appCode, String schedName, String jobName, List serverInfo) { 29 | this.serviceName = schedName + "-"+appCode+"-" + jobName; 30 | this.serverInfo = serverInfo; 31 | } 32 | 33 | 34 | @Override 35 | public String toString() { 36 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 37 | } 38 | 39 | @JSONField(serialize = false) 40 | public Server getOneRandomServer(){ 41 | execServer = null; 42 | if(ArrayUtils.listIsNotBlank(serverInfo)){ 43 | Integer randomIndex[] = CommonUtil.randomCommon(0,serverInfo.size(), 1); 44 | if(randomIndex != null){ 45 | execServer = serverInfo.get(randomIndex[0]); 46 | } 47 | } 48 | return execServer; 49 | } 50 | 51 | public Server getExecServer() { 52 | return execServer; 53 | } 54 | 55 | public void setExecServer(Server execServer) { 56 | this.execServer = execServer; 57 | } 58 | 59 | public String getServiceName() { 60 | return serviceName; 61 | } 62 | 63 | public void setServiceName(String serviceName) { 64 | this.serviceName = serviceName; 65 | } 66 | 67 | public List getServerInfo() { 68 | return serverInfo; 69 | } 70 | 71 | public void setServerInfo(List serverInfo) { 72 | this.serverInfo = serverInfo; 73 | } 74 | 75 | public static class Server implements Serializable{ 76 | private String ip; 77 | private int port; 78 | 79 | public Server(){ 80 | } 81 | 82 | public Server(String ip, int port){ 83 | this.ip = ip; 84 | this.port = port; 85 | } 86 | public String getIp() { 87 | return ip; 88 | } 89 | 90 | public void setIp(String ip) { 91 | this.ip = ip; 92 | } 93 | 94 | public int getPort() { 95 | return port; 96 | } 97 | 98 | public void setPort(int port) { 99 | this.port = port; 100 | } 101 | 102 | @Override 103 | public String toString() { 104 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 105 | } 106 | } 107 | 108 | } 109 | 110 | 111 | -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/common/util/ArrayUtils.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.common.util; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author jeff 7 | * @version 2015/11/11 14:07 8 | */ 9 | public class ArrayUtils { 10 | 11 | public static boolean listIsNotBlank(List list){ 12 | return (list != null && list.size()>0); 13 | } 14 | 15 | public static boolean listIsBlank(List list){ 16 | return (list == null || list.size()==0); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/common/util/ClogWrapperFactory.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.common.util; 2 | 3 | import java.util.Hashtable; 4 | 5 | /** 6 | * @author jeff 7 | * @version 2016/6/27 18:17 8 | */ 9 | public class ClogWrapperFactory { 10 | private static Hashtable loggerCache = new Hashtable<>(); 11 | 12 | public static ClogWrapper getClogWrapper(Class classObj) { 13 | if(classObj == null){ 14 | classObj = ClogWrapper.class; 15 | } 16 | ClogWrapper clogWrapper = loggerCache.get(classObj.getName()); 17 | if(clogWrapper == null){ 18 | clogWrapper = new ClogWrapper(classObj); 19 | loggerCache.put(classObj.getName(), clogWrapper); 20 | } 21 | return clogWrapper; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/common/util/JsonUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.common.util; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONArray; 5 | import com.alibaba.fastjson.JSONObject; 6 | import com.alibaba.fastjson.serializer.SimplePropertyPreFilter; 7 | 8 | /** 9 | * @author jeff 10 | * @version 2016/8/10 16:07 11 | */ 12 | public class JsonUtil { 13 | 14 | public static JSONObject parseObject(String str){ 15 | JSONObject jsonObject = null; 16 | try{ 17 | if(StringUtils.isNotBlank(str)){ 18 | jsonObject = JSON.parseObject(str); 19 | } 20 | }catch (Exception e){ 21 | } 22 | return jsonObject; 23 | } 24 | 25 | public static T parseObject(String text, Class clazz) { 26 | T result = null; 27 | try{ 28 | if(StringUtils.isNotBlank(text)){ 29 | result = JSON.parseObject(text, clazz); 30 | } 31 | }catch (Exception e){ } 32 | return result; 33 | } 34 | 35 | public static JSONArray parseArray(String str){ 36 | JSONArray jsonArray = null; 37 | try{ 38 | if(StringUtils.isNotBlank(str)){ 39 | jsonArray = JSON.parseArray(str); 40 | } 41 | }catch (Exception e){ 42 | } 43 | return jsonArray; 44 | } 45 | 46 | public static String toJsonString(Object object){ 47 | String jsonStr = null; 48 | try{ 49 | if(object !=null){ 50 | jsonStr = JSON.toJSONString(object); 51 | } 52 | }catch (Exception e){ 53 | } 54 | return jsonStr; 55 | } 56 | 57 | // 58 | public static String toJsonStringWithExclude(Object object, String ... fields){ 59 | String jsonStr = null; 60 | try{ 61 | if(object !=null){ 62 | SimplePropertyPreFilter filter = new SimplePropertyPreFilter(); 63 | if(fields != null && fields.length>0){ 64 | for(String field : fields){ 65 | filter.getExcludes().add(field); 66 | } 67 | } 68 | jsonStr = JSON.toJSONString(object, filter); 69 | } 70 | }catch (Exception e){ 71 | } 72 | return jsonStr; 73 | 74 | } 75 | 76 | 77 | } 78 | -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/common/util/PropertyUtils.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.common.util; 2 | 3 | import java.net.InetAddress; 4 | import java.net.NetworkInterface; 5 | import java.util.Enumeration; 6 | import java.util.Properties; 7 | 8 | /** 9 | * @author jeff 10 | * @version 2015/07/01 15:45 11 | */ 12 | public class PropertyUtils { 13 | public static final String CONFIG = "config.properties"; 14 | private static Properties prop; 15 | 16 | static { 17 | prop = new Properties(); 18 | try { 19 | prop.load(PropertyUtils.class.getClassLoader().getResourceAsStream(CONFIG)); 20 | } catch (Exception e) { 21 | e.printStackTrace(); 22 | } 23 | } 24 | 25 | public static String getString(String key) { 26 | String result = prop.getProperty(key.toLowerCase(), ""); 27 | if (StringUtils.isBlank(result)) { 28 | result = prop.getProperty(key, ""); 29 | } 30 | return result; 31 | } 32 | 33 | public static String getCurEnvironment(){ 34 | return getString("RunEnv"); 35 | } 36 | 37 | public static int getMarbleServerPort() { 38 | return getInteger("MarbleServerPort"); 39 | } 40 | 41 | public static Integer getInteger(String key) { 42 | String value = PropertyUtils.getString(key); 43 | Integer result = null; 44 | if (value != null && value.length() > 0) { 45 | result = Integer.parseInt(value); 46 | } 47 | return result; 48 | } 49 | 50 | public static Boolean getBoolean(String key) { 51 | String value = PropertyUtils.getString(key); 52 | Boolean result = false; 53 | if (value != null && value.length() > 0) { 54 | if (value.trim().equals("true")) { 55 | result = true; 56 | } 57 | } 58 | return result; 59 | } 60 | 61 | /** 62 | * 获取本机ip地址,linux操作系统试用 63 | * 64 | * @return String 65 | */ 66 | public static String getLocalIP() { 67 | String sIP = ""; 68 | InetAddress ip = null; 69 | try { 70 | boolean bFindIP = false; 71 | Enumeration netInterfaces = (Enumeration) NetworkInterface.getNetworkInterfaces(); 72 | while (netInterfaces.hasMoreElements()) { 73 | if (bFindIP) { 74 | break; 75 | } 76 | NetworkInterface ni = netInterfaces.nextElement(); 77 | //遍历所有ip 78 | Enumeration ips = ni.getInetAddresses(); 79 | while (ips.hasMoreElements()) { 80 | ip = ips.nextElement(); 81 | if (ip.isSiteLocalAddress() 82 | && !ip.isLoopbackAddress() //127.开头的都是lookback地址 83 | && !ip.getHostAddress().contains(":")) { 84 | bFindIP = true; 85 | break; 86 | } 87 | } 88 | 89 | } 90 | } catch (Exception e) { 91 | e.printStackTrace(); 92 | } 93 | if (null != ip) { 94 | sIP = ip.getHostAddress(); 95 | } 96 | return sIP; 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/entity/ClassInfo.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.entity; 2 | 3 | import org.apache.commons.lang.builder.ToStringBuilder; 4 | import org.apache.commons.lang.builder.ToStringStyle; 5 | 6 | import java.io.Serializable; 7 | 8 | public class ClassInfo implements Serializable { 9 | //class 名称 10 | private String className; 11 | //class 全路径 12 | private String classPath; 13 | //方法名 14 | private String methodName; 15 | //方法参数 16 | private String mathodParam; 17 | 18 | public ClassInfo() { 19 | } 20 | 21 | public ClassInfo(String className, String methodName, String mathodParam) { 22 | this.className = className; 23 | this.methodName = methodName; 24 | this.mathodParam = mathodParam; 25 | } 26 | 27 | public ClassInfo(String className, String classPath, String methodName, String mathodParam) { 28 | this.className = className; 29 | this.classPath = classPath; 30 | this.methodName = methodName; 31 | this.mathodParam = mathodParam; 32 | } 33 | 34 | public String getMathodParam() { 35 | return mathodParam; 36 | } 37 | 38 | public void setMathodParam(String mathodParam) { 39 | this.mathodParam = mathodParam; 40 | } 41 | 42 | public String getClassName() { 43 | return className; 44 | } 45 | 46 | public void setClassName(String className) { 47 | this.className = className; 48 | } 49 | 50 | public String getClassPath() { 51 | return classPath; 52 | } 53 | 54 | public void setClassPath(String classPath) { 55 | this.classPath = classPath; 56 | } 57 | 58 | public String getMethodName() { 59 | return methodName; 60 | } 61 | 62 | public void setMethodName(String methodName) { 63 | this.methodName = methodName; 64 | } 65 | 66 | @Override 67 | public String toString() { 68 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 69 | } 70 | } -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/entity/JobExecStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.entity; 2 | 3 | public enum JobExecStatusEnum { 4 | 5 | REQUESTING(0, "请求中"), 6 | SUCCESS(10, "成功"), 7 | FAILURE(20, "失败"); 8 | 9 | JobExecStatusEnum(int code, String desc) { 10 | this.code = code; 11 | this.desc = desc; 12 | } 13 | 14 | private int code; 15 | private String desc; 16 | 17 | public int getCode() { 18 | return code; 19 | } 20 | 21 | public void setCode(int code) { 22 | this.code = code; 23 | } 24 | 25 | public String getDesc() { 26 | return desc; 27 | } 28 | 29 | public void setDesc(String desc) { 30 | this.desc = desc; 31 | } 32 | } -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/entity/MarbleRequest.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.entity; 2 | 3 | import org.apache.commons.lang.builder.ToStringBuilder; 4 | import org.apache.commons.lang.builder.ToStringStyle; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | import java.util.Map; 9 | 10 | /** 11 | * @author jeff 12 | * @version 2016/1/14 17:31 13 | */ 14 | public class MarbleRequest implements Serializable { 15 | 16 | //请求流水号 17 | private String requestNo; 18 | //请求时间 19 | private Date requestTime; 20 | 21 | //是否需要响应,默认不需要 22 | private boolean needResponse = false; 23 | 24 | private Map data; 25 | 26 | public MarbleRequest(String requestNo, Map data,boolean needResponse) { 27 | this.needResponse = needResponse; 28 | this.requestNo = requestNo; 29 | this.data = data; 30 | } 31 | 32 | public Map getData() { 33 | return data; 34 | } 35 | 36 | public void setData(Map data) { 37 | this.data = data; 38 | } 39 | 40 | public String getRequestNo() { 41 | return requestNo; 42 | } 43 | 44 | public void setRequestNo(String requestNo) { 45 | this.requestNo = requestNo; 46 | } 47 | 48 | public Date getRequestTime() { 49 | return requestTime; 50 | } 51 | 52 | public void setRequestTime(Date requestTime) { 53 | this.requestTime = requestTime; 54 | } 55 | public boolean isNeedResponse() { 56 | return needResponse; 57 | } 58 | 59 | public void setNeedResponse(boolean needResponse) { 60 | this.needResponse = needResponse; 61 | } 62 | 63 | 64 | @Override 65 | public String toString() { 66 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/entity/MarbleResponse.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.entity; 2 | 3 | import org.apache.commons.lang.builder.ToStringBuilder; 4 | import org.apache.commons.lang.builder.ToStringStyle; 5 | 6 | import java.io.Serializable; 7 | import java.util.Date; 8 | 9 | /** 10 | * @author jeff 11 | * @version 2016/1/14 17:31 12 | */ 13 | public class MarbleResponse implements Serializable { 14 | 15 | //原请求流水号 16 | private String requestNo; 17 | //响应时间 18 | private Date responseTime; 19 | //响应码 20 | private String responseCode; 21 | //响应描述 22 | private String resonseMsg; 23 | //响应结果信息 24 | private String responseInfo; 25 | 26 | public boolean isSuccess(){ 27 | return "0000".equals(responseCode); 28 | } 29 | 30 | public MarbleResponse(String requestNo, ResultCodeEnum resultCodeEnum, String detail) { 31 | this.requestNo = requestNo; 32 | this.responseTime = new Date(); 33 | this.responseCode = resultCodeEnum.getCode(); 34 | this.resonseMsg = resultCodeEnum.getDesc(); 35 | this.responseInfo = detail; 36 | } 37 | 38 | public MarbleResponse(ResultCodeEnum resultCodeEnum, String detail) { 39 | this.responseTime = new Date(); 40 | this.responseCode = resultCodeEnum.getCode(); 41 | this.resonseMsg = resultCodeEnum.getDesc(); 42 | this.responseInfo = detail; 43 | } 44 | 45 | public MarbleResponse(Date responseTime, String responseCode, String resonseMsg, String responseInfo) { 46 | this.responseTime = responseTime; 47 | this.responseCode = responseCode; 48 | this.resonseMsg = resonseMsg; 49 | this.responseInfo = responseInfo; 50 | } 51 | 52 | public String getRequestNo() { 53 | return requestNo; 54 | } 55 | 56 | public void setRequestNo(String requestNo) { 57 | this.requestNo = requestNo; 58 | } 59 | 60 | public Date getResponseTime() { 61 | return responseTime; 62 | } 63 | 64 | public void setResponseTime(Date responseTime) { 65 | this.responseTime = responseTime; 66 | } 67 | 68 | public String getResponseCode() { 69 | return responseCode; 70 | } 71 | 72 | public void setResponseCode(String responseCode) { 73 | this.responseCode = responseCode; 74 | } 75 | 76 | public String getResonseMsg() { 77 | return resonseMsg; 78 | } 79 | 80 | public void setResonseMsg(String resonseMsg) { 81 | this.resonseMsg = resonseMsg; 82 | } 83 | 84 | public String getResponseInfo() { 85 | return responseInfo; 86 | } 87 | 88 | public void setResponseInfo(String responseInfo) { 89 | this.responseInfo = responseInfo; 90 | } 91 | 92 | @Override 93 | public String toString() { 94 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 95 | } 96 | } -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/entity/Result.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.entity; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | import com.github.jxdong.marble.agent.common.util.StringUtils; 5 | import org.apache.commons.lang.builder.ToStringBuilder; 6 | import org.apache.commons.lang.builder.ToStringStyle; 7 | 8 | import java.io.Serializable; 9 | import java.util.Map; 10 | import java.util.concurrent.ConcurrentHashMap; 11 | 12 | /** 13 | * @author jeff 14 | * @version 2015/8/26 14:48 15 | */ 16 | public class Result implements Serializable { 17 | 18 | //0成功,其它失败 19 | private int resultCode; 20 | private String resultMsg; 21 | 22 | private Map otherInfo = new ConcurrentHashMap<>(); 23 | 24 | public Result() { 25 | } 26 | 27 | public void putData(String key, Object value){ 28 | if(this.otherInfo == null){ 29 | this.otherInfo = new ConcurrentHashMap<>(); 30 | } 31 | if(StringUtils.isNotBlank(key) && value!=null){ 32 | this.otherInfo.put(key, value); 33 | } 34 | } 35 | 36 | public static Result SUCCESS(){ 37 | Result result = new Result(); 38 | result.setResultCode(0); 39 | result.setResultMsg("成功"); 40 | return result; 41 | } 42 | 43 | public static Result SUCCESS(String msg){ 44 | Result result = new Result(); 45 | result.setResultCode(0); 46 | result.setResultMsg(msg); 47 | return result; 48 | } 49 | 50 | public static Result PROCESSING(){ 51 | Result result = new Result(); 52 | result.setResultCode(10); 53 | result.setResultMsg("处理中"); 54 | return result; 55 | } 56 | 57 | 58 | public static Result SUCCESS(Map data){ 59 | Result result = new Result(); 60 | result.setResultCode(0); 61 | result.setResultMsg("成功"); 62 | result.setOtherInfo(data); 63 | return result; 64 | } 65 | 66 | public static Result FAILURE(String errorMsg){ 67 | return FAILURE(errorMsg, null); 68 | } 69 | 70 | public static Result FAILURE(int code, String errorMsg){ 71 | Result result = new Result(); 72 | result.setResultCode(code); 73 | result.setResultMsg(errorMsg); 74 | return result; 75 | } 76 | 77 | public static Result FAILURE(String errorMsg, Map data){ 78 | Result result = new Result(); 79 | result.setResultCode(20); 80 | result.setResultMsg(errorMsg); 81 | result.setOtherInfo(data); 82 | return result; 83 | } 84 | public int getResultCode() { 85 | return resultCode; 86 | } 87 | 88 | public boolean isSuccess(){ 89 | return this.resultCode == 0; 90 | } 91 | 92 | public Map getOtherInfo() { 93 | return otherInfo; 94 | } 95 | 96 | public void setOtherInfo(Map otherInfo) { 97 | this.otherInfo = otherInfo; 98 | } 99 | 100 | public void setResultCode(int resultCode) { 101 | this.resultCode = resultCode; 102 | } 103 | 104 | public String getResultMsg() { 105 | return resultMsg; 106 | } 107 | 108 | public void setResultMsg(String resultMsg) { 109 | this.resultMsg = resultMsg; 110 | } 111 | 112 | @JSONField(serialize = false) 113 | @Override 114 | public String toString() { 115 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /marble-agent/src/main/java/com/github/jxdong/marble/agent/entity/ResultCodeEnum.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.agent.entity; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 0000未成功,其它为失败 7 | */ 8 | public enum ResultCodeEnum implements Serializable { 9 | 10 | SUCCESS("0000","成功"), 11 | INVALID_ARGUMENTS("1001","参数错误"), 12 | NO_PERMISSION("1002","没有权限"), 13 | OTHER_ERROR("1111","其它错误"); 14 | 15 | private String code; 16 | private String desc; 17 | 18 | ResultCodeEnum(String code, String desc){ 19 | this.code = code; 20 | this.desc = desc; 21 | } 22 | 23 | public String getCode() { 24 | return code; 25 | } 26 | 27 | public void setCode(String code) { 28 | this.code = code; 29 | } 30 | 31 | public String getDesc() { 32 | return desc; 33 | } 34 | 35 | public void setDesc(String desc) { 36 | this.desc = desc; 37 | } 38 | } -------------------------------------------------------------------------------- /marble-agent/src/main/resources/META-INF/marble.xsd: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 42 | 43 | 44 | 45 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /marble-agent/src/main/resources/META-INF/spring.handlers: -------------------------------------------------------------------------------- 1 | http\://www.github.com/jxdong/schema/marble=com.github.jxdong.marble.agent.common.server.spring.schema.MarbleNamespaceHandler 2 | -------------------------------------------------------------------------------- /marble-agent/src/main/resources/META-INF/spring.schemas: -------------------------------------------------------------------------------- 1 | http\://www.github.com/jxdong/schema/marble/marble.xsd=META-INF/marble.xsd -------------------------------------------------------------------------------- /marble-agent/src/test/java/NettyTest.java: -------------------------------------------------------------------------------- 1 | import com.github.jxdong.marble.agent.entity.Result; 2 | import com.github.jxdong.marble.agent.common.server.global.ThreadPool; 3 | import com.github.jxdong.marble.agent.common.server.netty.client.NettyClientManager; 4 | import com.github.jxdong.marble.agent.common.server.netty.server.NettyServer; 5 | import org.junit.Test; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * @author jeff 12 | * @version 2016/5/23 16:06 13 | */ 14 | public class NettyTest{ 15 | 16 | @Test 17 | public void testNettyServer() { 18 | new Thread(new Runnable() { 19 | @Override 20 | public void run() { 21 | //端口 9000 打开 22 | NettyServer.getInstance().run(9003); 23 | } 24 | }).start(); 25 | 26 | } 27 | 28 | public static void main(String args[]) { 29 | ThreadPool.getFixedInstance().execute("", new Runnable() { 30 | @Override 31 | public void run() { 32 | Map data = new HashMap<>(); 33 | data.put("EXECESULT", Result.SUCCESS(new HashMap())); 34 | NettyClientManager.getInstance().serviceInvoke("10000", "10.32.154.19", 9003, data); 35 | } 36 | }); 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /marble-common/marble-common.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /marble-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | marble-parent 7 | com.github.jeff-dong 8 | 1.0 9 | 10 | 4.0.0 11 | marble-common 12 | jar 13 | 14 | 15 | 16 | 17 | com.fasterxml.jackson.core 18 | jackson-core 19 | ${jackson.version} 20 | 21 | 22 | com.fasterxml.jackson.core 23 | jackson-databind 24 | ${jackson.version} 25 | 26 | 27 | com.fasterxml.jackson.core 28 | jackson-annotations 29 | ${jackson.version} 30 | 31 | 32 | 33 | com.alibaba 34 | fastjson 35 | 36 | 37 | 38 | commons-lang 39 | commons-lang 40 | 2.6 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | maven-compiler-plugin 49 | 50 | 1.7 51 | 1.7 52 | UTF-8 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /marble-common/src/main/java/com/github/jxdong/marble/common/util/ArrayUtils.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.common.util; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author jeff 7 | * @version 2015/11/11 14:07 8 | */ 9 | public class ArrayUtils { 10 | 11 | public static boolean listIsNotBlank(List list){ 12 | return (list != null && list.size()>0); 13 | } 14 | 15 | public static boolean listIsBlank(List list){ 16 | return (list == null || list.size()==0); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /marble-common/src/main/java/com/github/jxdong/marble/common/util/ClogWrapperFactory.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.common.util; 2 | 3 | import java.util.concurrent.ConcurrentHashMap; 4 | 5 | /** 6 | * @author jeff 7 | * @version 2016/6/27 18:17 8 | */ 9 | public class ClogWrapperFactory { 10 | private static ConcurrentHashMap loggerCache = new ConcurrentHashMap<>(); 11 | 12 | public static ClogWrapper getClogWrapper(Class classObj) { 13 | if(classObj == null){ 14 | classObj = ClogWrapper.class; 15 | } 16 | ClogWrapper clogWrapper = loggerCache.get(classObj.getName()); 17 | if(clogWrapper == null){ 18 | clogWrapper = new ClogWrapper(classObj); 19 | loggerCache.put(classObj.getName(), clogWrapper); 20 | } 21 | return clogWrapper; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /marble-common/src/main/java/com/github/jxdong/marble/common/util/JacksonUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.common.util; 2 | 3 | import com.fasterxml.jackson.core.type.TypeReference; 4 | import com.fasterxml.jackson.databind.DeserializationFeature; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * @author jeff 13 | * @version 2015/6/29 13:59 14 | */ 15 | public class JacksonUtil { 16 | private final static ObjectMapper objectMapper = new ObjectMapper(); 17 | 18 | private JacksonUtil() { 19 | 20 | } 21 | 22 | public static ObjectMapper getInstance() { 23 | 24 | return objectMapper; 25 | } 26 | 27 | /** 28 | * javaBean,list,array convert to json string 29 | */ 30 | public static String obj2json(Object obj) throws Exception { 31 | return objectMapper.writeValueAsString(obj); 32 | } 33 | 34 | /** 35 | * json string convert to javaBean 36 | */ 37 | public static T json2pojo(String jsonStr, Class clazz) { 38 | T object = null; 39 | if(StringUtils.isNotBlank(jsonStr)){ 40 | try { 41 | objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); 42 | object = objectMapper.readValue(jsonStr, clazz); 43 | } catch (Exception e) { 44 | e.printStackTrace(); 45 | } 46 | } 47 | return object; 48 | } 49 | 50 | /** 51 | * json string convert to map 52 | */ 53 | public static Map json2map(String jsonStr) 54 | throws Exception { 55 | return objectMapper.readValue(jsonStr, Map.class); 56 | } 57 | 58 | /** 59 | * json string convert to map with javaBean 60 | */ 61 | public static Map json2map(String jsonStr, Class clazz) 62 | throws Exception { 63 | Map> map = objectMapper.readValue(jsonStr, 64 | new TypeReference>() { 65 | }); 66 | Map result = new HashMap(); 67 | for (Map.Entry> entry : map.entrySet()) { 68 | result.put(entry.getKey(), map2pojo(entry.getValue(), clazz)); 69 | } 70 | return result; 71 | } 72 | 73 | /** 74 | * json array string convert to list with javaBean 75 | */ 76 | public static List json2list(String jsonArrayStr, Class clazz) 77 | throws Exception { 78 | List> list = objectMapper.readValue(jsonArrayStr, 79 | new TypeReference>() { 80 | }); 81 | List result = new ArrayList(); 82 | for (Map map : list) { 83 | result.add(map2pojo(map, clazz)); 84 | } 85 | return result; 86 | } 87 | 88 | /** 89 | * map convert to javaBean 90 | */ 91 | public static T map2pojo(Map map, Class clazz) { 92 | return objectMapper.convertValue(map, clazz); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /marble-common/src/main/java/com/github/jxdong/marble/common/util/JsonUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.common.util; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONArray; 5 | import com.alibaba.fastjson.JSONObject; 6 | import com.alibaba.fastjson.parser.Feature; 7 | import com.alibaba.fastjson.serializer.SimplePropertyPreFilter; 8 | 9 | /** 10 | * @author jeff 11 | * @version 2016/8/10 16:07 12 | */ 13 | public class JsonUtil { 14 | 15 | 16 | public static T parseObject(String text, Class clazz) { 17 | T re = null; 18 | try{ 19 | re = JSON.parseObject(text, clazz, new Feature[0]); 20 | }catch (Exception e){} 21 | return re; 22 | } 23 | 24 | public static JSONObject parseObject(String str){ 25 | JSONObject jsonObject = null; 26 | try{ 27 | if(StringUtils.isNotBlank(str)){ 28 | jsonObject = JSON.parseObject(str); 29 | } 30 | }catch (Exception e){ 31 | } 32 | return jsonObject; 33 | } 34 | 35 | public static JSONArray parseArray(String str){ 36 | JSONArray jsonArray = null; 37 | try{ 38 | if(StringUtils.isNotBlank(str)){ 39 | jsonArray = JSON.parseArray(str); 40 | } 41 | }catch (Exception e){ 42 | } 43 | return jsonArray; 44 | } 45 | 46 | public static String toJsonString(Object object){ 47 | String jsonStr = null; 48 | try{ 49 | if(object !=null){ 50 | jsonStr = JSON.toJSONString(object); 51 | } 52 | }catch (Exception e){ 53 | } 54 | return jsonStr; 55 | } 56 | 57 | // 58 | public static String toJsonStringWithExclude(Object object, String ... fields){ 59 | String jsonStr = null; 60 | try{ 61 | if(object !=null){ 62 | SimplePropertyPreFilter filter = new SimplePropertyPreFilter(); 63 | if(fields != null && fields.length>0){ 64 | for(String field : fields){ 65 | filter.getExcludes().add(field); 66 | } 67 | } 68 | jsonStr = JSON.toJSONString(object, filter); 69 | } 70 | }catch (Exception e){ 71 | } 72 | return jsonStr; 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /marble-common/src/main/java/com/github/jxdong/marble/common/util/PropertyUtils.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.common.util; 2 | 3 | import java.net.InetAddress; 4 | import java.net.NetworkInterface; 5 | import java.util.Enumeration; 6 | import java.util.Properties; 7 | 8 | /** 9 | * @author jeff 10 | * @version 2015/07/01 15:45 11 | */ 12 | public class PropertyUtils { 13 | public static final String CONFIG = "config.properties"; 14 | private static Properties prop; 15 | 16 | static { 17 | prop = new Properties(); 18 | try { 19 | prop.load(PropertyUtils.class.getClassLoader().getResourceAsStream(CONFIG)); 20 | } catch (Exception e) { 21 | e.printStackTrace(); 22 | } 23 | } 24 | 25 | public static String getString(String key) { 26 | String result = prop.getProperty(key.toLowerCase(), ""); 27 | if (StringUtils.isBlank(result)) { 28 | result = prop.getProperty(key, ""); 29 | } 30 | return result; 31 | } 32 | 33 | public static String getCurEnvironment(){ 34 | return getString("RunEnv"); 35 | } 36 | 37 | public static int getMarbleServerPort() { 38 | return getInteger("MarbleServerPort"); 39 | } 40 | 41 | public static Integer getInteger(String key) { 42 | String value = PropertyUtils.getString(key); 43 | Integer result = null; 44 | if (value != null && value.length() > 0) { 45 | result = Integer.parseInt(value); 46 | } 47 | return result; 48 | } 49 | 50 | public static Boolean getBoolean(String key) { 51 | String value = PropertyUtils.getString(key); 52 | Boolean result = false; 53 | if (value != null && value.length() > 0) { 54 | if (value.trim().equals("true")) { 55 | result = true; 56 | } 57 | } 58 | return result; 59 | } 60 | 61 | /** 62 | * 获取本机ip地址,linux操作系统试用 63 | * 64 | * @return String 65 | */ 66 | public static String getLocalIP() { 67 | String sIP = ""; 68 | InetAddress ip = null; 69 | try { 70 | boolean bFindIP = false; 71 | Enumeration netInterfaces = (Enumeration) NetworkInterface.getNetworkInterfaces(); 72 | while (netInterfaces.hasMoreElements()) { 73 | if (bFindIP) { 74 | break; 75 | } 76 | NetworkInterface ni = netInterfaces.nextElement(); 77 | //遍历所有ip 78 | Enumeration ips = ni.getInetAddresses(); 79 | while (ips.hasMoreElements()) { 80 | ip = ips.nextElement(); 81 | if (ip.isSiteLocalAddress() 82 | && !ip.isLoopbackAddress() //127.开头的都是lookback地址 83 | && !ip.getHostAddress().contains(":")) { 84 | bFindIP = true; 85 | break; 86 | } 87 | } 88 | 89 | } 90 | } catch (Exception e) { 91 | e.printStackTrace(); 92 | } 93 | if (null != ip) { 94 | sIP = ip.getHostAddress(); 95 | } 96 | return sIP; 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /marble-contract/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | marble-parent 7 | com.github.jeff-dong 8 | 1.0 9 | 10 | jar 11 | 4.0.0 12 | 13 | marble-contract 14 | 15 | 16 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/controller/BasicController.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.controller; 2 | 3 | import com.github.jxdong.marble.domain.model.Account; 4 | import com.github.jxdong.marble.domain.model.Response; 5 | import com.github.jxdong.marble.domain.model.enums.ErrorEnum; 6 | import com.github.jxdong.marble.global.exception.MarbleException; 7 | import com.github.jxdong.marble.global.util.AuthorityUtil; 8 | import org.apache.commons.lang.StringUtils; 9 | import org.springframework.web.bind.annotation.ModelAttribute; 10 | import org.springframework.web.servlet.ModelAndView; 11 | 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | import javax.servlet.http.HttpSession; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | /** 19 | * @author jeff 20 | * @version 2015/6/25 14:26 21 | */ 22 | public abstract class BasicController { 23 | protected Account loginedAccount = null; 24 | protected HttpServletResponse httpResponse; 25 | protected HttpServletRequest httpRequest; 26 | protected HttpSession httpSession; 27 | 28 | @ModelAttribute 29 | public void setReqAndRes(HttpServletRequest request, HttpServletResponse response){ 30 | this.httpRequest = request; 31 | this.httpResponse = response; 32 | this.httpSession = request.getSession(); 33 | } 34 | 35 | @ModelAttribute 36 | public void setLoginedAccount() throws Exception{ 37 | loginedAccount = AuthorityUtil.getInstance().getLoginedAccount(); 38 | if(loginedAccount == null){ 39 | throw new MarbleException(ErrorEnum.SESSON_OVERDUE, "请先登录"); 40 | } 41 | } 42 | 43 | protected ModelAndView errorModelAndView(Response.ResultCodeEnum errorEnum, String detail){ 44 | String resultPage = "error"; 45 | Map errorMap = new HashMap<>(); 46 | if(errorEnum != null){ 47 | errorMap.put("errorCode", errorEnum.getCode()); 48 | errorMap.put("errorMsg", errorEnum.getDesc() + (StringUtils.isNotBlank(detail)?": "+ detail:"")); 49 | } 50 | return new ModelAndView(resultPage, errorMap); 51 | } 52 | 53 | protected ModelAndView modelAndView(String page){ 54 | if(StringUtils.isNotBlank(page)){ 55 | return new ModelAndView(page, "Account", AuthorityUtil.getInstance().getLoginedAccount()); 56 | } 57 | return errorModelAndView(Response.ResultCodeEnum.UNKNOWN_ERROR, ""); 58 | } 59 | 60 | protected ModelAndView modelAndView(String page, Map data){ 61 | if(StringUtils.isNotBlank(page) && data != null){ 62 | data.put("Account", AuthorityUtil.getInstance().getLoginedAccount()); 63 | return new ModelAndView(page, data); 64 | } 65 | return errorModelAndView(Response.ResultCodeEnum.UNKNOWN_ERROR, ""); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/controller/HelperController.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | /** 8 | * @author jeff 9 | * @version 2015/6/26 8:40 10 | */ 11 | @Controller @RequestMapping("/helper") 12 | public class HelperController extends BasicController{ 13 | 14 | /** 15 | * 页面跳转 - helper 16 | * @return view 17 | */ 18 | @RequestMapping("") 19 | public ModelAndView pageForward() throws Exception{ 20 | return modelAndView("helper"); 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/controller/LabController.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.controller; 2 | 3 | import com.github.jxdong.marble.domain.model.Configure; 4 | import com.github.jxdong.marble.domain.model.Response; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 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 | /** 13 | * @author jeff 14 | * @version 2015/6/26 8:40 15 | */ 16 | @Controller @RequestMapping("/lab") 17 | public class LabController extends BasicController{ 18 | private static Logger logger = LoggerFactory.getLogger(LabController.class); 19 | 20 | 21 | @RequestMapping(value = "query",method = RequestMethod.GET) 22 | @ResponseBody 23 | public Response queryMultiCondition(String jsonParam){ 24 | logger.info("lab query: "+jsonParam); 25 | 26 | return Response.SUCCESS; 27 | } 28 | 29 | 30 | @RequestMapping(value = "update", method = RequestMethod.PATCH) 31 | @ResponseBody 32 | public Response update(Configure configure){ 33 | logger.info("lab update: "+configure); 34 | 35 | return Response.SUCCESS; 36 | } 37 | 38 | @RequestMapping(value = "add", method = RequestMethod.PUT) 39 | @ResponseBody 40 | public Response insert(Configure configure){ 41 | logger.info("lab add: "+configure); 42 | 43 | return Response.SUCCESS; 44 | } 45 | 46 | @RequestMapping(value = "delete", method = RequestMethod.DELETE) 47 | @ResponseBody 48 | public Response delete(int primaryKey){ 49 | logger.info("lab delete: "+primaryKey); 50 | 51 | return Response.SUCCESS; 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.controller; 2 | 3 | import com.github.jxdong.marble.common.util.PropertyUtils; 4 | import com.github.jxdong.marble.domain.model.Response; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 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 | import javax.servlet.http.Cookie; 13 | 14 | /** 15 | * SSO的登陆/退出 16 | * @author jeff 17 | * @version 2015/12/30 14:05 18 | */ 19 | @Controller 20 | @RequestMapping("/account") 21 | public class LoginController extends BasicController { 22 | private static Logger logger = LoggerFactory.getLogger(LoginController.class); 23 | 24 | @RequestMapping(value = "logout", method = RequestMethod.GET) 25 | @ResponseBody 26 | public Response logout() { 27 | logger.info("logout..."); 28 | return Response.SUCCESS; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/controller/MarbleController.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.controller; 2 | 3 | import com.github.jxdong.marble.domain.model.enums.ErrorEnum; 4 | import com.github.jxdong.marble.global.exception.MarbleException; 5 | import com.github.jxdong.marble.global.util.AuthorityUtil; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.ModelAttribute; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | 12 | /** 13 | * @author jeff 14 | * @version 2015/6/26 8:40 15 | */ 16 | @Controller @RequestMapping("/marble") 17 | public class MarbleController extends BasicController{ 18 | private static Logger logger = LoggerFactory.getLogger(MarbleController.class); 19 | 20 | 21 | //校验管理员权限 22 | @ModelAttribute 23 | public void authority() throws Exception { 24 | loginedAccount = AuthorityUtil.getInstance().getLoginedAccount(); 25 | if(loginedAccount == null || !loginedAccount.getHasAdminRole()){ 26 | throw new MarbleException(ErrorEnum.NO_PERMISSION,""); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/controller/MonitorController.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.controller; 2 | 3 | import com.github.jxdong.marble.domain.model.enums.ErrorEnum; 4 | import com.github.jxdong.marble.global.exception.MarbleException; 5 | import com.github.jxdong.marble.global.util.AuthorityUtil; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.ModelAttribute; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.servlet.ModelAndView; 12 | 13 | /** 14 | * @author jeff 15 | * @version 2015/6/26 8:40 16 | */ 17 | @Controller @RequestMapping("/monitor") 18 | public class MonitorController extends BasicController{ 19 | private static Logger logger = LoggerFactory.getLogger(MonitorController.class); 20 | 21 | //校验管理员权限 22 | @ModelAttribute 23 | public void authority() throws Exception { 24 | loginedAccount = AuthorityUtil.getInstance().getLoginedAccount(); 25 | if(loginedAccount == null || !loginedAccount.getHasAdminRole()){ 26 | throw new MarbleException(ErrorEnum.NO_PERMISSION,""); 27 | } 28 | } 29 | /** 30 | * 页面跳转 - monitor 31 | * @return view 32 | */ 33 | @RequestMapping("") 34 | public ModelAndView pageForward(){ 35 | return modelAndView("monitor"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/controller/QuartzJobDetailController.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.controller; 2 | 3 | import com.github.jxdong.marble.common.util.StringUtils; 4 | import com.github.jxdong.marble.domain.model.Response; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.ResponseBody; 9 | import org.springframework.web.servlet.ModelAndView; 10 | 11 | /** 12 | * @author jeff 13 | * @version 2015/12/29 13:05 14 | */ 15 | @Controller 16 | @RequestMapping("/dataManage/job") 17 | public class QuartzJobDetailController extends BasicController { 18 | 19 | /** 20 | * 页面跳转 21 | * @return view 22 | */ 23 | @RequestMapping("") 24 | public ModelAndView pageForward() throws Exception { 25 | return modelAndView("quartz-job"); 26 | } 27 | 28 | @RequestMapping(value = "query", method = RequestMethod.GET) 29 | @ResponseBody 30 | public Response query(String jsonParam) throws Exception { 31 | 32 | return new Response(); 33 | } 34 | 35 | //删除jobs 36 | @RequestMapping(value = "delete", method = RequestMethod.DELETE) 37 | @ResponseBody 38 | public Response deleteJobs(String schedName, String jobGroup, String jobName) throws Exception{ 39 | if(StringUtils.isBlank(schedName) || StringUtils.isBlank(jobGroup) || StringUtils.isBlank(jobName)){ 40 | return Response.FAILURE(Response.ResultCodeEnum.INVALID_ARGUMENTS); 41 | } 42 | return Response.SUCCESS; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/dto/AppDetailDTO.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.dto; 2 | 3 | import com.github.jxdong.marble.domain.model.ServerDetail; 4 | import com.github.jxdong.marble.domain.model.enums.AppStatusEnum; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 应用信息 10 | * @author jeff 11 | * @version 2015/11/11 12:58 12 | */ 13 | public class AppDetailDTO extends BaseDTO{ 14 | 15 | 16 | private String code; 17 | private String name; 18 | private String description; 19 | //应用联系人-员工号 20 | private String owner; 21 | //应用状态. 0:不可用;1:可用 22 | private int status; 23 | //使用的marble版本号 24 | private String marbleVersion; 25 | //app下的主机信息 26 | private List hosts; 27 | private String soaServiceName; 28 | //SOA服务namespace 29 | private String soaServiceNameSpace; 30 | public AppDetailDTO(){ 31 | 32 | } 33 | public AppDetailDTO(String code, String name, String description, String owner, int status) { 34 | this.code = code; 35 | this.name = name; 36 | this.description = description; 37 | this.owner = owner; 38 | this.status = status; 39 | } 40 | 41 | public String getMarbleVersion() { 42 | return marbleVersion; 43 | } 44 | 45 | public void setMarbleVersion(String marbleVersion) { 46 | this.marbleVersion = marbleVersion; 47 | } 48 | 49 | public String getSoaServiceName() { 50 | return soaServiceName; 51 | } 52 | 53 | public void setSoaServiceName(String soaServiceName) { 54 | this.soaServiceName = soaServiceName; 55 | } 56 | 57 | public String getSoaServiceNameSpace() { 58 | return soaServiceNameSpace; 59 | } 60 | 61 | public void setSoaServiceNameSpace(String soaServiceNameSpace) { 62 | this.soaServiceNameSpace = soaServiceNameSpace; 63 | } 64 | 65 | public String getCode() { 66 | return code; 67 | } 68 | 69 | public void setCode(String code) { 70 | this.code = code; 71 | } 72 | 73 | public String getName() { 74 | return name; 75 | } 76 | 77 | public void setName(String name) { 78 | this.name = name; 79 | } 80 | 81 | public String getDescription() { 82 | return description; 83 | } 84 | 85 | public void setDescription(String description) { 86 | this.description = description; 87 | } 88 | 89 | public String getOwner() { 90 | return owner; 91 | } 92 | 93 | public void setOwner(String owner) { 94 | this.owner = owner; 95 | } 96 | 97 | public String getStatusDesc(){ 98 | return AppStatusEnum.getItemByCode(status).getDesc(); 99 | } 100 | public int getStatus() { 101 | return status; 102 | } 103 | 104 | public void setStatus(int status) { 105 | this.status = status; 106 | } 107 | 108 | public List getHosts() { 109 | return hosts; 110 | } 111 | 112 | public void setHosts(List hosts) { 113 | this.hosts = hosts; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/dto/BaseDTO.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import org.apache.commons.lang.builder.ToStringBuilder; 5 | import org.apache.commons.lang.builder.ToStringStyle; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * @author jeff 11 | * @version 2015/6/26 9:12 12 | */ 13 | public class BaseDTO { 14 | 15 | private int id; 16 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8") 17 | private Date createTime; 18 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8") 19 | private Date updateTime; 20 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8") 21 | private Date version; 22 | 23 | public int getId() { 24 | return id; 25 | } 26 | 27 | public void setId(int id) { 28 | this.id = id; 29 | } 30 | 31 | public void setCreateTime(Date createTime) { 32 | this.createTime = createTime; 33 | } 34 | 35 | public void setUpdateTime(Date updateTime) { 36 | this.updateTime = updateTime; 37 | } 38 | 39 | public void setVersion(Date version) { 40 | this.version = version; 41 | } 42 | 43 | public Date getCreateTime() { 44 | return createTime; 45 | } 46 | 47 | public Date getUpdateTime() { 48 | return updateTime; 49 | } 50 | 51 | public Date getVersion() { 52 | return version; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/dto/ConfigureDTO.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.dto; 2 | 3 | /** 4 | * @author jeff 5 | * @version 2015/6/26 9:12 6 | */ 7 | public class ConfigureDTO extends BaseDTO{ 8 | 9 | private String group; 10 | private String key; 11 | private String value; 12 | private String description; 13 | 14 | public String getGroup() { 15 | return group; 16 | } 17 | 18 | public void setGroup(String group) { 19 | this.group = group; 20 | } 21 | 22 | public String getKey() { 23 | return key; 24 | } 25 | 26 | public void setKey(String key) { 27 | this.key = key; 28 | } 29 | 30 | public String getValue() { 31 | return value; 32 | } 33 | 34 | public void setValue(String value) { 35 | this.value = value; 36 | } 37 | 38 | public String getDescription() { 39 | return description; 40 | } 41 | 42 | public void setDescription(String description) { 43 | this.description = description; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/dto/CronExpressDTO.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.dto; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author jeff 7 | * @version 2015/12/1 16:47 8 | */ 9 | public class CronExpressDTO extends BaseDTO{ 10 | 11 | private boolean isValid; 12 | private String cronExpress; 13 | //下次执行时间列表 14 | private List nextFireTimeList; 15 | 16 | 17 | public boolean isValid() { 18 | return isValid; 19 | } 20 | 21 | public void setIsValid(boolean isValid) { 22 | this.isValid = isValid; 23 | } 24 | 25 | public String getCronExpress() { 26 | return cronExpress; 27 | } 28 | 29 | public void setCronExpress(String cronExpress) { 30 | this.cronExpress = cronExpress; 31 | } 32 | 33 | public List getNextFireTimeList() { 34 | return nextFireTimeList; 35 | } 36 | 37 | public void setNextFireTimeList(List nextFireTimeList) { 38 | this.nextFireTimeList = nextFireTimeList; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/dto/SchedulerDetailDTO.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.dto; 2 | 3 | import com.github.jxdong.marble.domain.model.ServerDetail; 4 | import com.github.jxdong.marble.domain.model.enums.SchedStatusEnum; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 应用信息 10 | * @author jeff 11 | * @version 2015/11/11 12:58 12 | */ 13 | public class SchedulerDetailDTO extends BaseDTO{ 14 | 15 | private AppDetailDTO appDetail; 16 | private String name; 17 | private String description; 18 | private int status; 19 | private List jobs; 20 | private List serverDetails; 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public AppDetailDTO getAppDetail() { 27 | return appDetail; 28 | } 29 | 30 | public void setAppDetail(AppDetailDTO appDetail) { 31 | this.appDetail = appDetail; 32 | } 33 | 34 | public void setName(String name) { 35 | this.name = name; 36 | } 37 | 38 | public List getJobs() { 39 | return jobs; 40 | } 41 | 42 | public void setJobs(List jobs) { 43 | this.jobs = jobs; 44 | } 45 | 46 | public List getServerDetails() { 47 | return serverDetails; 48 | } 49 | 50 | public void setServerDetails(List serverDetails) { 51 | this.serverDetails = serverDetails; 52 | } 53 | 54 | public String getDescription() { 55 | return description; 56 | } 57 | 58 | public void setDescription(String description) { 59 | this.description = description; 60 | } 61 | 62 | public int getStatus() { 63 | return status; 64 | } 65 | public String getStatusDesc(){ 66 | return SchedStatusEnum.getItemByCode(status).getDesc(); 67 | } 68 | public void setStatus(int status) { 69 | this.status = status; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/dto/ServerDetailDTO.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.dto; 2 | 3 | /** 4 | * 主机信息 5 | * @author jeff 6 | * @version 2015/11/11 13:01 7 | */ 8 | public class ServerDetailDTO extends BaseDTO{ 9 | 10 | private String appCode; 11 | private String group; 12 | private String name; 13 | private String ip; 14 | private String description; 15 | private int status; 16 | private int port; 17 | private String schedName; 18 | 19 | public String getAppCode() { 20 | return appCode; 21 | } 22 | 23 | public void setAppCode(String appCode) { 24 | this.appCode = appCode; 25 | } 26 | 27 | public String getGroup() { 28 | return group; 29 | } 30 | 31 | public void setGroup(String group) { 32 | this.group = group; 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | public String getIp() { 44 | return ip; 45 | } 46 | 47 | public void setIp(String ip) { 48 | this.ip = ip; 49 | } 50 | 51 | public String getDescription() { 52 | return description; 53 | } 54 | 55 | public void setDescription(String description) { 56 | this.description = description; 57 | } 58 | 59 | public int getStatus() { 60 | return status; 61 | } 62 | 63 | public void setStatus(int status) { 64 | this.status = status; 65 | } 66 | 67 | public int getPort() { 68 | return port; 69 | } 70 | 71 | public void setPort(int port) { 72 | this.port = port; 73 | } 74 | 75 | public String getSchedName() { 76 | return schedName; 77 | } 78 | 79 | public void setSchedName(String schedName) { 80 | this.schedName = schedName; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/Account.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import java.util.Set; 6 | 7 | /** 8 | * @author jeff 9 | * @version 2015/7/2 14:55 10 | */ 11 | public class Account extends Entity { 12 | 13 | private String mail; 14 | private String department; 15 | private String company; 16 | private String name; 17 | private String displayName; 18 | private List> memberOf; 19 | private String employee; 20 | private String distinguishedName; 21 | private String city; 22 | //权限 23 | private Set authorities; 24 | 25 | //是否为admin 26 | private boolean hasAdminRole; 27 | 28 | public boolean getHasAdminRole() { 29 | return hasAdminRole; 30 | } 31 | 32 | public void setHasAdminRole(boolean hasAdminRole) { 33 | this.hasAdminRole = hasAdminRole; 34 | } 35 | 36 | public String getMail() { 37 | return mail; 38 | } 39 | 40 | public void setMail(String mail) { 41 | this.mail = mail; 42 | } 43 | 44 | 45 | public String getDepartment() { 46 | return department; 47 | } 48 | 49 | public void setDepartment(String department) { 50 | this.department = department; 51 | } 52 | 53 | public String getCompany() { 54 | return company; 55 | } 56 | 57 | public void setCompany(String company) { 58 | this.company = company; 59 | } 60 | 61 | public String getName() { 62 | return name; 63 | } 64 | 65 | public void setName(String name) { 66 | this.name = name; 67 | } 68 | 69 | public String getDisplayName() { 70 | return displayName; 71 | } 72 | 73 | public void setDisplayName(String displayName) { 74 | this.displayName = displayName; 75 | } 76 | 77 | public List> getMemberOf() { 78 | return memberOf; 79 | } 80 | 81 | public void setMemberOf(List> memberOf) { 82 | this.memberOf = memberOf; 83 | } 84 | 85 | public String getEmployee() { 86 | return employee; 87 | } 88 | 89 | public String getUpperEmployee() { 90 | return employee!=null?employee.toUpperCase():employee; 91 | } 92 | 93 | public void setEmployee(String employee) { 94 | this.employee = employee; 95 | } 96 | 97 | public String getDistinguishedName() { 98 | return distinguishedName; 99 | } 100 | 101 | public void setDistinguishedName(String distinguishedName) { 102 | this.distinguishedName = distinguishedName; 103 | } 104 | 105 | public String getCity() { 106 | return city; 107 | } 108 | 109 | public void setCity(String city) { 110 | this.city = city; 111 | } 112 | 113 | public void setAuthorities(Set authorities) { 114 | this.authorities = authorities; 115 | } 116 | 117 | 118 | @Override 119 | public String toString() { 120 | return String.format("name: %s, company:%s, department: %s, employee: %s, isAdmin:%s", 121 | this.getName(), 122 | this.getCompany(), 123 | this.getDepartment(), 124 | this.getEmployee(), 125 | this.getHasAdminRole()); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/AppDetail.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 应用信息 7 | * @author jeff 8 | * @version 2015/11/11 12:58 9 | */ 10 | public class AppDetail extends Entity{ 11 | 12 | private String code; 13 | private String name; 14 | private String description; 15 | //应用联系人-员工号 16 | private String owner; 17 | //应用状态. 0:不可用;1:可用 18 | private int status; 19 | //使用的marble版本号 20 | private String marbleVersion; 21 | //SOA服务名 22 | private String soaServiceName; 23 | //SOA服务namespace 24 | private String soaServiceNameSpace; 25 | 26 | //app下的主机信息 27 | private List hosts; 28 | //app下的scheduler信息 29 | private List schedulers; 30 | public AppDetail(){ 31 | } 32 | 33 | public AppDetail(String code){ 34 | this.code = code; 35 | } 36 | 37 | public List getSchedulers() { 38 | return schedulers; 39 | } 40 | 41 | public void setSchedulers(List schedulers) { 42 | this.schedulers = schedulers; 43 | } 44 | 45 | public String getCode() { 46 | return code; 47 | } 48 | 49 | public void setCode(String code) { 50 | this.code = code; 51 | } 52 | 53 | public String getName() { 54 | return name; 55 | } 56 | 57 | public String getSoaServiceName() { 58 | return soaServiceName; 59 | } 60 | 61 | public void setSoaServiceName(String soaServiceName) { 62 | this.soaServiceName = soaServiceName; 63 | } 64 | 65 | public String getSoaServiceNameSpace() { 66 | return soaServiceNameSpace; 67 | } 68 | 69 | public void setSoaServiceNameSpace(String soaServiceNameSpace) { 70 | this.soaServiceNameSpace = soaServiceNameSpace; 71 | } 72 | 73 | public void setName(String name) { 74 | this.name = name; 75 | } 76 | 77 | public String getDescription() { 78 | return description; 79 | } 80 | 81 | public void setDescription(String description) { 82 | this.description = description; 83 | } 84 | 85 | public String getOwner() { 86 | return owner; 87 | } 88 | 89 | public void setOwner(String owner) { 90 | this.owner = owner; 91 | } 92 | 93 | public int getStatus() { 94 | return status; 95 | } 96 | 97 | public void setStatus(int status) { 98 | this.status = status; 99 | } 100 | 101 | public List getHosts() { 102 | return hosts; 103 | } 104 | 105 | public void setHosts(List hosts) { 106 | this.hosts = hosts; 107 | } 108 | 109 | public String getMarbleVersion() { 110 | return marbleVersion; 111 | } 112 | 113 | public void setMarbleVersion(String marbleVersion) { 114 | this.marbleVersion = marbleVersion; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/AppRequest.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model; 2 | 3 | import com.github.jxdong.marble.common.util.ArrayUtils; 4 | import org.apache.commons.lang.StringUtils; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author jeff 10 | * @version 2015/6/29 14:45 11 | */ 12 | public class AppRequest extends DatatablesRequest{ 13 | 14 | private String appCode; 15 | private String appName; 16 | private String appOwner; 17 | private int[] statusList; 18 | 19 | //获得排序列信息e.g: order by orderId asc.目前只支持单列排序 20 | public String getOrderColumn(){ 21 | String column = "id"; 22 | List orderList = this.getOrder(); 23 | if(ArrayUtils.listIsNotBlank(orderList)){ 24 | String columnIndex = orderList.get(0).getColumn(); 25 | if(StringUtils.isNotBlank(columnIndex)){ 26 | switch (columnIndex){ 27 | case "1":column = "code"; break; 28 | case "2":column = "name"; break; 29 | case "3":column = "description"; break; 30 | case "4":column = "owner"; break; 31 | case "5":column = "status"; break; 32 | case "6":column = "createTime"; break; 33 | case "7":column = "dataChange_lastTime"; break; 34 | } 35 | } 36 | } 37 | return column; 38 | } 39 | 40 | public String getAppCode() { 41 | return appCode; 42 | } 43 | 44 | public void setAppCode(String appCode) { 45 | this.appCode = appCode; 46 | } 47 | 48 | public String getAppName() { 49 | return appName; 50 | } 51 | 52 | public void setAppName(String appName) { 53 | this.appName = appName; 54 | } 55 | 56 | public String getAppOwner() { 57 | return appOwner; 58 | } 59 | 60 | public void setAppOwner(String appOwner) { 61 | this.appOwner = appOwner; 62 | } 63 | 64 | public int[] getStatusList() { 65 | return statusList; 66 | } 67 | 68 | public void setStatusList(int[] statusList) { 69 | this.statusList = statusList; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/Configure.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model; 2 | 3 | /** 4 | * @author jeff 5 | * @version 2015/6/17 13:40 6 | */ 7 | public class Configure extends Entity{ 8 | 9 | private int id; 10 | private String group; 11 | private String key; 12 | private String value; 13 | private String description; 14 | 15 | public String getDescription() { 16 | return description; 17 | } 18 | 19 | public void setDescription(String description) { 20 | this.description = description; 21 | } 22 | 23 | public int getId() { 24 | return id; 25 | } 26 | 27 | public void setId(int id) { 28 | this.id = id; 29 | } 30 | 31 | public String getGroup() { 32 | return group; 33 | } 34 | 35 | public void setGroup(String group) { 36 | this.group = group; 37 | } 38 | 39 | public String getKey() { 40 | return key; 41 | } 42 | 43 | public void setKey(String key) { 44 | this.key = key; 45 | } 46 | 47 | public String getValue() { 48 | return value; 49 | } 50 | 51 | public void setValue(String value) { 52 | this.value = value; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/ConfigureRequest.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model; 2 | 3 | import com.github.jxdong.marble.common.util.ArrayUtils; 4 | import org.apache.commons.lang.StringUtils; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author jeff 10 | * @version 2015/6/29 14:45 11 | */ 12 | public class ConfigureRequest extends DatatablesRequest{ 13 | 14 | private String[] group; 15 | private String[] key; 16 | 17 | //获得排序列信息e.g: order by orderId asc.目前只支持单列排序 18 | public String getOrderColumn(){ 19 | String column = "id"; 20 | List orderList = this.getOrder(); 21 | if(ArrayUtils.listIsNotBlank(orderList)){ 22 | String columnIndex = orderList.get(0).getColumn(); 23 | if(StringUtils.isNotBlank(columnIndex)){ 24 | switch (columnIndex){ 25 | case "1":column = "group"; break; 26 | case "2":column = "key"; break; 27 | case "3":column = "value"; break; 28 | case "4":column = "createTime"; break; 29 | case "5":column = "dataChange_lastTime"; break; 30 | 31 | } 32 | } 33 | } 34 | return column; 35 | } 36 | 37 | public String[] getGroup() { 38 | return group; 39 | } 40 | 41 | public void setGroup(String[] group) { 42 | this.group = group; 43 | } 44 | 45 | public String[] getKey() { 46 | return key; 47 | } 48 | 49 | public void setKey(String[] key) { 50 | this.key = key; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/Entity.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model; 2 | 3 | import org.apache.commons.lang.builder.ToStringBuilder; 4 | import org.apache.commons.lang.builder.ToStringStyle; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * @author jeff 10 | * @version 2015/6/25 14:03 11 | */ 12 | public class Entity { 13 | 14 | private int id; 15 | private Date createTime; 16 | private Date updateTime; 17 | private Date version; 18 | 19 | public Date getCreateTime() { 20 | return createTime; 21 | } 22 | 23 | public void setCreateTime(Date createTime) { 24 | this.createTime = createTime; 25 | } 26 | 27 | public Date getUpdateTime() { 28 | return updateTime; 29 | } 30 | 31 | public void setUpdateTime(Date updateTime) { 32 | this.updateTime = updateTime; 33 | } 34 | 35 | public Date getVersion() { 36 | return version; 37 | } 38 | 39 | public void setVersion(Date version) { 40 | this.version = version; 41 | } 42 | 43 | public int getId() { 44 | return id; 45 | } 46 | 47 | public void setId(int id) { 48 | this.id = id; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/JobLogRequest.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model; 2 | 3 | import com.github.jxdong.marble.common.util.ArrayUtils; 4 | import org.apache.commons.lang.StringUtils; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author jeff 10 | * @version 2015/6/29 14:45 11 | */ 12 | public class JobLogRequest extends DatatablesRequest{ 13 | 14 | private String appCode; 15 | private String schedName; 16 | private String jobName; 17 | private String serverInfo; 18 | private String beginDate; 19 | private String endDate; 20 | private int reqResultCode; 21 | private int execResultCode; 22 | 23 | //获得排序列信息e.g: order by orderId asc.目前只支持单列排序 24 | public String getOrderColumn(){ 25 | String column = "id"; 26 | List orderList = this.getOrder(); 27 | if(ArrayUtils.listIsNotBlank(orderList)){ 28 | String columnIndex = orderList.get(0).getColumn(); 29 | if(StringUtils.isNotBlank(columnIndex)){ 30 | switch (columnIndex){ 31 | case "1":column = "sched_name"; break; 32 | case "2":column = "job_name"; break; 33 | case "3":column = "request_no"; break; 34 | case "5":column = "server_info"; break; 35 | case "9":column = "createTime"; break; 36 | } 37 | } 38 | } 39 | return column; 40 | } 41 | 42 | public int getReqResultCode() { 43 | return reqResultCode; 44 | } 45 | 46 | public void setReqResultCode(int reqResultCode) { 47 | this.reqResultCode = reqResultCode; 48 | } 49 | 50 | public int getExecResultCode() { 51 | return execResultCode; 52 | } 53 | 54 | public void setExecResultCode(int execResultCode) { 55 | this.execResultCode = execResultCode; 56 | } 57 | 58 | public String getBeginDate() { 59 | return beginDate; 60 | } 61 | 62 | public void setBeginDate(String beginDate) { 63 | this.beginDate = beginDate; 64 | } 65 | 66 | public String getEndDate() { 67 | return endDate; 68 | } 69 | 70 | public void setEndDate(String endDate) { 71 | this.endDate = endDate; 72 | } 73 | 74 | public String getAppCode() { 75 | return appCode; 76 | } 77 | 78 | public void setAppCode(String appCode) { 79 | this.appCode = appCode; 80 | } 81 | 82 | public String getSchedName() { 83 | return schedName; 84 | } 85 | 86 | public void setSchedName(String schedName) { 87 | this.schedName = schedName; 88 | } 89 | 90 | public String getJobName() { 91 | return jobName; 92 | } 93 | 94 | public void setJobName(String jobName) { 95 | this.jobName = jobName; 96 | } 97 | 98 | public String getServerInfo() { 99 | return serverInfo; 100 | } 101 | 102 | public void setServerInfo(String serverInfo) { 103 | this.serverInfo = serverInfo; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/Result.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.apache.commons.lang.builder.ToStringBuilder; 5 | import org.apache.commons.lang.builder.ToStringStyle; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | * @author jeff 11 | * @version 2015/8/26 14:48 12 | */ 13 | public class Result { 14 | 15 | //0成功,其它失败 16 | private int resultCode; 17 | private String resultMsg; 18 | 19 | private Map otherInfo; 20 | 21 | public static Result SUCCESS(){ 22 | Result result = new Result(); 23 | result.setResultCode(0); 24 | result.setResultMsg("ok"); 25 | return result; 26 | } 27 | 28 | public static Result SUCCESS(Map data){ 29 | Result result = new Result(); 30 | result.setResultCode(0); 31 | result.setResultMsg("ok"); 32 | result.setOtherInfo(data); 33 | return result; 34 | } 35 | 36 | public static Result FAILURE(String errorMsg){ 37 | Result result = new Result(); 38 | result.setResultCode(1); 39 | result.setResultMsg(errorMsg); 40 | return result; 41 | } 42 | 43 | public int getResultCode() { 44 | return resultCode; 45 | } 46 | 47 | public boolean isSuccess(){ 48 | return this.resultCode == 0; 49 | } 50 | 51 | public Map getOtherInfo() { 52 | return otherInfo; 53 | } 54 | 55 | public void setOtherInfo(Map otherInfo) { 56 | this.otherInfo = otherInfo; 57 | } 58 | 59 | public void setResultCode(int resultCode) { 60 | this.resultCode = resultCode; 61 | } 62 | 63 | public String getResultMsg() { 64 | return resultMsg; 65 | } 66 | 67 | public void setResultMsg(String resultMsg) { 68 | this.resultMsg = resultMsg; 69 | } 70 | 71 | @JsonIgnore 72 | @Override 73 | public String toString() { 74 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/ResultCodeEnum.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model; 2 | 3 | /** 4 | * 返回结果状态enum 5 | * 结果代码: 0.成功;1.其它错误;2.缺少必要参数;3.参数无效; 6 | * @author jxdong 7 | * 8 | */ 9 | public enum ResultCodeEnum { 10 | 11 | SUCCESS(0,"成功"), 12 | OTHER_ERROR(1,"其它错误"), 13 | LACK_PARAM(2,"缺少必要参数"), 14 | INVALID_PARAM(3,"参数无效"); 15 | 16 | private int code; 17 | private String desc; 18 | 19 | ResultCodeEnum(int code, String desc){ 20 | this.code = code; 21 | this.desc = desc; 22 | } 23 | public int getCode() { 24 | return code; 25 | } 26 | public void setCode(int code) { 27 | this.code = code; 28 | } 29 | public String getDesc() { 30 | return desc; 31 | } 32 | public void setDesc(String desc) { 33 | this.desc = desc; 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/SchedulerDetail.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model; 2 | 3 | import com.github.jxdong.marble.common.util.ArrayUtils; 4 | import com.github.jxdong.marble.common.util.StringUtils; 5 | import org.quartz.Scheduler; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 计划任务信息 13 | * @author jeff 14 | * @version 2015/11/11 13:03 15 | */ 16 | public class SchedulerDetail extends Entity{ 17 | private static Logger logger = LoggerFactory.getLogger(SchedulerDetail.class); 18 | 19 | private AppDetail appDetail; 20 | private List serverDetails; 21 | private String name; 22 | private String description; 23 | private int status; 24 | private List jobs; 25 | 26 | //辅助信息 - Quartz的Scheduler对象 27 | private Scheduler scheduler; 28 | 29 | public SchedulerDetail(){ 30 | 31 | } 32 | 33 | public boolean validateParamForInsert(){ 34 | return !(appDetail == null || StringUtils.isBlank(appDetail.getCode()) || StringUtils.isBlank(name) || ArrayUtils.listIsBlank(serverDetails)); 35 | } 36 | 37 | public SchedulerDetail(String name) { 38 | this.name = name; 39 | } 40 | 41 | public void shutdown(boolean waitJobtoComplete){ 42 | try{ 43 | if(this.getScheduler() != null && !this.getScheduler().isShutdown()){ 44 | this.getScheduler().shutdown(waitJobtoComplete); 45 | } 46 | }catch (Exception e){ 47 | logger.error("shutdown scheduler exception. Scheduler: {}, detail: ", scheduler, e); 48 | } 49 | 50 | } 51 | 52 | public boolean isLegal(){ 53 | return (StringUtils.isNotBlank(name) && appDetail != null && StringUtils.isNotBlank(appDetail.getCode()) && ArrayUtils.listIsNotBlank(serverDetails)); 54 | } 55 | 56 | public AppDetail getAppDetail() { 57 | return appDetail; 58 | } 59 | 60 | public void setAppDetail(AppDetail appDetail) { 61 | this.appDetail = appDetail; 62 | } 63 | 64 | public List getServerDetails() { 65 | return serverDetails; 66 | } 67 | 68 | public void setServerDetails(List serverDetails) { 69 | this.serverDetails = serverDetails; 70 | } 71 | 72 | public String getName() { 73 | return name; 74 | } 75 | 76 | public void setName(String name) { 77 | this.name = name; 78 | } 79 | 80 | public String getDescription() { 81 | return description; 82 | } 83 | 84 | public void setDescription(String description) { 85 | this.description = description; 86 | } 87 | 88 | public int getStatus() { 89 | return status; 90 | } 91 | 92 | public void setStatus(int status) { 93 | this.status = status; 94 | } 95 | 96 | public List getJobs() { 97 | return jobs; 98 | } 99 | 100 | public void setJobs(List jobs) { 101 | this.jobs = jobs; 102 | } 103 | 104 | public Scheduler getScheduler() { 105 | return scheduler; 106 | } 107 | 108 | public void setScheduler(Scheduler scheduler) { 109 | this.scheduler = scheduler; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/ServerDetail.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model; 2 | 3 | import com.github.jxdong.marble.common.util.StringUtils; 4 | 5 | /** 6 | * 主机信息 7 | * @author jeff 8 | * @version 2015/11/11 13:01 9 | */ 10 | public class ServerDetail extends Entity{ 11 | 12 | private String appCode; 13 | private String group; 14 | private String name; 15 | private String ip; 16 | private String description; 17 | private int status; 18 | private int port; 19 | public ServerDetail(){ 20 | 21 | } 22 | public ServerDetail(String ip, int port) { 23 | this.ip = ip; 24 | this.port = port; 25 | } 26 | 27 | private String schedName; 28 | 29 | public boolean validateParamForInsert(){ 30 | //参数校验 31 | return !(StringUtils.isBlank(this.getAppCode()) || 32 | StringUtils.isBlank(this.getGroup()) || 33 | StringUtils.isBlank(this.getName()) || 34 | StringUtils.isBlank(this.getIp())); 35 | } 36 | 37 | public String getSchedName() { 38 | return schedName; 39 | } 40 | 41 | public void setSchedName(String schedName) { 42 | this.schedName = schedName; 43 | } 44 | 45 | public String getAppCode() { 46 | return appCode; 47 | } 48 | 49 | public void setAppCode(String appCode) { 50 | this.appCode = appCode; 51 | } 52 | 53 | public int getPort() { 54 | return port; 55 | } 56 | 57 | public void setPort(int port) { 58 | this.port = port; 59 | } 60 | 61 | public String getGroup() { 62 | return group; 63 | } 64 | 65 | public void setGroup(String group) { 66 | this.group = group; 67 | } 68 | 69 | public String getName() { 70 | return name; 71 | } 72 | 73 | public void setName(String name) { 74 | this.name = name; 75 | } 76 | 77 | public String getIp() { 78 | return ip; 79 | } 80 | 81 | public void setIp(String ip) { 82 | this.ip = ip; 83 | } 84 | 85 | public String getDescription() { 86 | return description; 87 | } 88 | 89 | public void setDescription(String description) { 90 | this.description = description; 91 | } 92 | 93 | public int getStatus() { 94 | return status; 95 | } 96 | 97 | public void setStatus(int status) { 98 | this.status = status; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/enums/AppStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model.enums; 2 | 3 | /** 4 | * @author jeff 5 | * @version 2015/11/17 19:23 6 | */ 7 | public enum AppStatusEnum { 8 | UNKNOWN(0, "未知"), 9 | USABLE(10, "可用"), 10 | DISABLE(20, "停用"); 11 | 12 | AppStatusEnum(int code, String desc){ 13 | this.code = code; 14 | this.desc = desc; 15 | } 16 | 17 | public static boolean containItem(int statusCode){ 18 | for(AppStatusEnum statusEnum : AppStatusEnum.values()){ 19 | if(statusEnum.equals(UNKNOWN)){ 20 | continue; 21 | } 22 | if(statusEnum.getCode() == statusCode){ 23 | return true; 24 | } 25 | } 26 | return false; 27 | } 28 | 29 | public static AppStatusEnum getItemByCode(int code){ 30 | if(code > 0){ 31 | for(AppStatusEnum statusEnum : AppStatusEnum.values()){ 32 | if(statusEnum.getCode() == code){ 33 | return statusEnum; 34 | } 35 | } 36 | } 37 | return AppStatusEnum.UNKNOWN; 38 | } 39 | 40 | private int code; 41 | private String desc; 42 | 43 | public int getCode() { 44 | return code; 45 | } 46 | 47 | public void setCode(int code) { 48 | this.code = code; 49 | } 50 | 51 | public String getDesc() { 52 | return desc; 53 | } 54 | 55 | public void setDesc(String desc) { 56 | this.desc = desc; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/enums/ConfigureEnum.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model.enums; 2 | 3 | /** 4 | * Configure表的Group分类enum 5 | * @author jeff 6 | * @version 2015/7/2 14:49 7 | */ 8 | public enum ConfigureEnum { 9 | 10 | ROLE_ADMIN(Group.USER_ROLE, "ADMIN", "管理员"); 11 | 12 | ConfigureEnum(Group group, String code, String desc){ 13 | this.group = group; 14 | this.code = code; 15 | this.desc = desc; 16 | } 17 | 18 | private String code; 19 | private String desc; 20 | private Group group; 21 | 22 | public String getCode() { 23 | return code; 24 | } 25 | 26 | public void setCode(String code) { 27 | this.code = code; 28 | } 29 | 30 | public String getDesc() { 31 | return desc; 32 | } 33 | 34 | public void setDesc(String desc) { 35 | this.desc = desc; 36 | } 37 | 38 | public Group getGroup() { 39 | return group; 40 | } 41 | 42 | public void setGroup(Group group) { 43 | this.group = group; 44 | } 45 | 46 | public enum Group{ 47 | USER_ROLE("USER_ROLE", "用户角色"); 48 | 49 | Group(String code, String desc){ 50 | this.code = code; 51 | this.desc = desc; 52 | } 53 | 54 | private String code; 55 | private String desc; 56 | 57 | public String getCode() { 58 | return code; 59 | } 60 | 61 | public void setCode(String code) { 62 | this.code = code; 63 | } 64 | 65 | public String getDesc() { 66 | return desc; 67 | } 68 | 69 | public void setDesc(String desc) { 70 | this.desc = desc; 71 | } 72 | } 73 | 74 | 75 | 76 | } 77 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/enums/ErrorEnum.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model.enums; 2 | 3 | public enum ErrorEnum { 4 | 5 | OTHER_ERROR("100", "其它错误", 10), 6 | NETWORK_ERROR("101", "网络错误", 10), 7 | SESSON_OVERDUE("102", "session过期", 10), 8 | ILLEGAL_ARGUMENT("103", "参数非法", 10), 9 | NO_PERMISSION("104", "没有权限", 10); 10 | 11 | private String code; 12 | private String message; 13 | private int errorLevel; 14 | 15 | ErrorEnum(String code, String message, int errorLevel){ 16 | this.code = code; 17 | this.message = message; 18 | this.errorLevel = errorLevel; 19 | } 20 | 21 | public String getMessage() { 22 | return message; 23 | } 24 | 25 | public void setMessage(String message) { 26 | this.message = message; 27 | } 28 | 29 | public String getCode() { 30 | return code; 31 | } 32 | 33 | public int getErrorLevel() { 34 | return errorLevel; 35 | } 36 | 37 | public void setErrorLevel(int errorLevel) { 38 | this.errorLevel = errorLevel; 39 | } 40 | 41 | public void setCode(String code) { 42 | this.code = code; 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/enums/JobExecStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model.enums; 2 | 3 | /** 4 | * @author jeff 5 | * @version 2015/11/17 19:23 6 | */ 7 | public enum JobExecStatusEnum { 8 | SUCCESS(0, "成功"), 9 | REQUESTING(10, "请求中"), 10 | FAILURE(20, "失败"); 11 | 12 | JobExecStatusEnum(int code, String desc){ 13 | this.code = code; 14 | this.desc = desc; 15 | } 16 | 17 | public static boolean containItem(int statusCode){ 18 | if(statusCode<0){ 19 | return false; 20 | } 21 | for(JobExecStatusEnum statusEnum : JobExecStatusEnum.values()){ 22 | if(statusEnum.getCode() == statusCode){ 23 | return true; 24 | } 25 | } 26 | return false; 27 | } 28 | 29 | public static JobExecStatusEnum getItemByCode(int code){ 30 | if(code > 0){ 31 | for(JobExecStatusEnum statusEnum : JobExecStatusEnum.values()){ 32 | if(statusEnum.getCode() == code){ 33 | return statusEnum; 34 | } 35 | } 36 | } 37 | return null; 38 | } 39 | 40 | private int code; 41 | private String desc; 42 | 43 | public int getCode() { 44 | return code; 45 | } 46 | 47 | public void setCode(int code) { 48 | this.code = code; 49 | } 50 | 51 | public String getDesc() { 52 | return desc; 53 | } 54 | 55 | public void setDesc(String desc) { 56 | this.desc = desc; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/enums/JobReqStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model.enums; 2 | 3 | /** 4 | * @author jeff 5 | * @version 2015/11/17 19:23 6 | */ 7 | public enum JobReqStatusEnum { 8 | SUCCESS(0, "成功"), 9 | REQUESTING(10, "请求中"), 10 | FAILURE(20, "失败"); 11 | 12 | JobReqStatusEnum(int code, String desc){ 13 | this.code = code; 14 | this.desc = desc; 15 | } 16 | 17 | public static boolean containItem(int statusCode){ 18 | if(statusCode<0){ 19 | return false; 20 | } 21 | for(JobReqStatusEnum statusEnum : JobReqStatusEnum.values()){ 22 | if(statusEnum.getCode() == statusCode){ 23 | return true; 24 | } 25 | } 26 | return false; 27 | } 28 | 29 | public static JobReqStatusEnum getItemByCode(int code){ 30 | if(code > 0){ 31 | for(JobReqStatusEnum statusEnum : JobReqStatusEnum.values()){ 32 | if(statusEnum.getCode() == code){ 33 | return statusEnum; 34 | } 35 | } 36 | } 37 | return null; 38 | } 39 | 40 | private int code; 41 | private String desc; 42 | 43 | public int getCode() { 44 | return code; 45 | } 46 | 47 | public void setCode(int code) { 48 | this.code = code; 49 | } 50 | 51 | public String getDesc() { 52 | return desc; 53 | } 54 | 55 | public void setDesc(String desc) { 56 | this.desc = desc; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/enums/JobStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model.enums; 2 | 3 | import org.apache.commons.lang.StringUtils; 4 | 5 | /** 6 | * @author jeff 7 | * @version 2015/11/17 19:23 8 | */ 9 | public enum JobStatusEnum { 10 | UNKNOWN("UNKNOWN", "未知"), 11 | NONE("NONE", "不存在"), 12 | NORMAL("NORMAL", "运行中"), 13 | PAUSED("PAUSED", "暂停"), 14 | COMPLETE("COMPLETE", "完成"), 15 | ERROR("ERROR", "异常"), 16 | BLOCKED("BLOCKED", "被阻止"); 17 | 18 | JobStatusEnum(String code, String desc){ 19 | this.code = code; 20 | this.desc = desc; 21 | } 22 | 23 | public static boolean containItem(String statusCode){ 24 | for(JobStatusEnum statusEnum : JobStatusEnum.values()){ 25 | if(statusEnum.equals(UNKNOWN)){ 26 | continue; 27 | } 28 | if(statusEnum.getCode().equals(statusCode)){ 29 | return true; 30 | } 31 | } 32 | return false; 33 | } 34 | 35 | public static JobStatusEnum getItemByCode(String code){ 36 | if(StringUtils.isNotBlank(code)){ 37 | for(JobStatusEnum statusEnum : JobStatusEnum.values()){ 38 | if(statusEnum.getCode().equals(code)){ 39 | return statusEnum; 40 | } 41 | } 42 | } 43 | return JobStatusEnum.UNKNOWN; 44 | } 45 | 46 | private String code; 47 | private String desc; 48 | 49 | public String getCode() { 50 | return code; 51 | } 52 | 53 | public void setCode(String code) { 54 | this.code = code; 55 | } 56 | 57 | public String getDesc() { 58 | return desc; 59 | } 60 | 61 | public void setDesc(String desc) { 62 | this.desc = desc; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/enums/MisfireInstructionEnum.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model.enums; 2 | 3 | /** 4 | * @author jeff 5 | * @version 2015/11/17 19:23 6 | */ 7 | public enum MisfireInstructionEnum { 8 | IGNORE_MISFIRES(-1, "以错过的第一个频率时间立刻开始执行"),//withMisfireHandlingInstructionIgnoreMisfires 9 | SMART_POLICY(0, "以当前时间为触发频率立刻触发一次执行"), 10 | FIRE_ONCE_NOW(1,"以当前时间为触发频率立刻触发一次执行"),//默认值。withMisfireHandlingInstructionFireAndProceed 11 | DO_NOTHING(2, "不触发立即执行,等待下次Cron触发频率到达");//withMisfireHandlingInstructionDoNothing 12 | 13 | MisfireInstructionEnum(int code, String desc){ 14 | this.code = code; 15 | this.desc = desc; 16 | } 17 | 18 | public static boolean containItem(int statusCode){ 19 | for(MisfireInstructionEnum statusEnum : MisfireInstructionEnum.values()){ 20 | if(statusEnum.getCode() == statusCode){ 21 | return true; 22 | } 23 | } 24 | return false; 25 | } 26 | 27 | public static MisfireInstructionEnum getItemByCode(int code){ 28 | for(MisfireInstructionEnum statusEnum : MisfireInstructionEnum.values()){ 29 | if(statusEnum.getCode() == code){ 30 | return statusEnum; 31 | } 32 | } 33 | return MisfireInstructionEnum.DO_NOTHING; 34 | } 35 | 36 | private int code; 37 | private String desc; 38 | 39 | public int getCode() { 40 | return code; 41 | } 42 | 43 | public void setCode(int code) { 44 | this.code = code; 45 | } 46 | 47 | public String getDesc() { 48 | return desc; 49 | } 50 | 51 | public void setDesc(String desc) { 52 | this.desc = desc; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/enums/SchedStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model.enums; 2 | 3 | /** 4 | * @author jeff 5 | * @version 2015/11/17 19:23 6 | */ 7 | public enum SchedStatusEnum { 8 | UNKNOWN(0, "未知"), 9 | USABLE(10, "可用"), 10 | DISABLE(20, "停用"); 11 | 12 | SchedStatusEnum(int code, String desc){ 13 | this.code = code; 14 | this.desc = desc; 15 | } 16 | 17 | public static boolean containItem(int statusCode){ 18 | for(SchedStatusEnum statusEnum : SchedStatusEnum.values()){ 19 | if(statusEnum.equals(UNKNOWN)){ 20 | continue; 21 | } 22 | if(statusEnum.getCode() == statusCode){ 23 | return true; 24 | } 25 | } 26 | return false; 27 | } 28 | 29 | public static SchedStatusEnum getItemByCode(int code){ 30 | if(code > 0){ 31 | for(SchedStatusEnum statusEnum : SchedStatusEnum.values()){ 32 | if(statusEnum.getCode() == code){ 33 | return statusEnum; 34 | } 35 | } 36 | } 37 | return SchedStatusEnum.UNKNOWN; 38 | } 39 | 40 | private int code; 41 | private String desc; 42 | 43 | public int getCode() { 44 | return code; 45 | } 46 | 47 | public void setCode(int code) { 48 | this.code = code; 49 | } 50 | 51 | public String getDesc() { 52 | return desc; 53 | } 54 | 55 | public void setDesc(String desc) { 56 | this.desc = desc; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/model/enums/ServerStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.model.enums; 2 | 3 | /** 4 | * @author jeff 5 | * @version 2015/11/17 19:23 6 | */ 7 | public enum ServerStatusEnum { 8 | UNKNOWN(0, "未知"), 9 | USABLE(10, "可用"), 10 | DISABLE(20, "停用"); 11 | 12 | ServerStatusEnum(int code, String desc){ 13 | this.code = code; 14 | this.desc = desc; 15 | } 16 | 17 | public static boolean containItem(int statusCode){ 18 | for(ServerStatusEnum statusEnum : ServerStatusEnum.values()){ 19 | if(statusEnum.equals(UNKNOWN)){ 20 | continue; 21 | } 22 | if(statusEnum.getCode() == statusCode){ 23 | return true; 24 | } 25 | } 26 | return false; 27 | } 28 | 29 | public static ServerStatusEnum getItemByCode(int code){ 30 | if(code > 0){ 31 | for(ServerStatusEnum statusEnum : ServerStatusEnum.values()){ 32 | if(statusEnum.getCode() == code){ 33 | return statusEnum; 34 | } 35 | } 36 | } 37 | return ServerStatusEnum.UNKNOWN; 38 | } 39 | 40 | private int code; 41 | private String desc; 42 | 43 | public int getCode() { 44 | return code; 45 | } 46 | 47 | public void setCode(int code) { 48 | this.code = code; 49 | } 50 | 51 | public String getDesc() { 52 | return desc; 53 | } 54 | 55 | public void setDesc(String desc) { 56 | this.desc = desc; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/repositories/AppRepository.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.repositories; 2 | 3 | 4 | import com.github.jxdong.marble.domain.model.AppDetail; 5 | import com.github.jxdong.marble.domain.model.Page; 6 | import com.github.jxdong.marble.domain.model.Result; 7 | import com.github.jxdong.marble.domain.model.ServerDetail; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author jeff 13 | * @version 2015/1/13 14:04 14 | */ 15 | public interface AppRepository extends Repository{ 16 | 17 | AppDetail queryAppById(int id); 18 | 19 | AppDetail queryAppByCode(String appCode); 20 | 21 | List queryAppByMultiConditions(String appCode, String appName, String owner, int[] statusList, String orderColumn, String orderDir, Page page); 22 | 23 | List queryAppWithSched(String appCode, int appStatus, String schedName); 24 | 25 | List queryServerByAppCode(String appCode); 26 | 27 | Result updateApp(AppDetail appDetail); 28 | 29 | Result insertApp(AppDetail appDetail); 30 | 31 | Result deleteApp(String appCode); 32 | 33 | Result addAppServer(ServerDetail serverDetail); 34 | 35 | Result deleteAppServer(String appCode, String serverGroup, String serverName, String serverIp); 36 | 37 | Result stopApp(String appCode); 38 | 39 | Result startApp(String appCode); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/repositories/ConfigureRepository.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.repositories; 2 | 3 | import com.github.jxdong.marble.domain.model.Configure; 4 | import com.github.jxdong.marble.domain.model.Page; 5 | import com.github.jxdong.marble.domain.model.Result; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author jeff 11 | * @version 2015/11/14 14:04 12 | */ 13 | public interface ConfigureRepository extends Repository { 14 | 15 | Configure queryConfigureById(int id); 16 | 17 | List queryConfigureMultiConditions(String[] groups, String[] keys, String orderColumn, String orderDir, Page page); 18 | 19 | Result updateConfigure(Configure configure); 20 | 21 | Result insertConfigure(Configure configure); 22 | 23 | Result deleteConfigureById(int id); 24 | 25 | } -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/repositories/Repository.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.repositories; 2 | 3 | 4 | /** 5 | * @author jeff 6 | * @version 2015/8/17 20:04 7 | */ 8 | public interface Repository { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/domain/repositories/SchedRepository.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.domain.repositories; 2 | 3 | 4 | import com.github.jxdong.marble.domain.model.JobDetail; 5 | import com.github.jxdong.marble.domain.model.Result; 6 | import com.github.jxdong.marble.domain.model.SchedulerDetail; 7 | import com.github.jxdong.marble.domain.model.ServerDetail; 8 | import com.github.jxdong.marble.agent.entity.ClassInfo; 9 | 10 | import java.util.List; 11 | import java.util.Set; 12 | 13 | /** 14 | * @author jeff 15 | * @version 2015/1/13 14:04 16 | */ 17 | public interface SchedRepository extends Repository{ 18 | 19 | List querySchedByAppCode(String appCode); 20 | 21 | List querySchedServer( String appCode, String schedName); 22 | 23 | List queryJob(String appCode, String schedName, String jobName); 24 | 25 | Result startJob(String appCode, String schedName, String jobName); 26 | 27 | Result pauseJob(String appCode, String schedName, String jobName); 28 | 29 | Result deleteJob(String appCode, String schedName, String jobName); 30 | 31 | Result updateJob(JobDetail jobDetail); 32 | 33 | Result addAppScheduler(SchedulerDetail schedulerDetail); 34 | 35 | Result addJob(JobDetail jobDetail); 36 | 37 | Result deleteScheduler(String appCode, String schedName); 38 | 39 | Result executeJobManually(String type, String serverIp, int serverPort, Set classInfoSet); 40 | 41 | Result stopJobImmediately(String operator, String appCode, String schedName, String jobName, List serverIps); 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/global/exception/MarbleException.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.global.exception; 2 | 3 | import com.github.jxdong.marble.common.util.StringUtils; 4 | import com.github.jxdong.marble.domain.model.enums.ErrorEnum; 5 | 6 | /** 7 | * @author jeff 8 | * @version 2015/11/25 15:46 9 | */ 10 | public class MarbleException extends Exception { 11 | private static final long serialVersionUID = 1L; 12 | protected String code; 13 | protected String message; 14 | 15 | public MarbleException() { 16 | } 17 | 18 | public static void checkArgument(boolean expression, Object errorMessage) throws MarbleException { 19 | if(expression) { 20 | throw new MarbleException(ErrorEnum.ILLEGAL_ARGUMENT, StringUtils.safeString(errorMessage)); 21 | } 22 | } 23 | 24 | public static void check(boolean expression, ErrorEnum codeEnum) throws MarbleException { 25 | if(expression) { 26 | throw new MarbleException(codeEnum.getMessage()+"("+codeEnum.getCode()+")"); 27 | } 28 | } 29 | 30 | public MarbleException(String message) { 31 | super(message); 32 | } 33 | 34 | public MarbleException(Throwable cause) { 35 | super(cause); 36 | } 37 | 38 | public MarbleException(String message, Throwable cause) { 39 | super(message, cause); 40 | } 41 | 42 | public MarbleException(ErrorEnum errorEnum, String messageDetail){ 43 | super(errorEnum.getCode() + ":" +errorEnum.getMessage() + ". "+ StringUtils.safeString(messageDetail)); 44 | this.code = errorEnum.getCode(); 45 | this.message = errorEnum.getMessage() + ". "+ messageDetail; 46 | } 47 | 48 | public String getCode() { 49 | return code; 50 | } 51 | 52 | public void setCode(String code) { 53 | this.code = code; 54 | } 55 | 56 | @Override 57 | public String getMessage() { 58 | return message; 59 | } 60 | 61 | public void setMessage(String message) { 62 | this.message = message; 63 | } 64 | } 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/global/exception/MarbleExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.global.exception; 2 | 3 | import com.github.jxdong.marble.domain.model.enums.ErrorEnum; 4 | import org.springframework.web.bind.annotation.ResponseBody; 5 | import org.springframework.web.method.HandlerMethod; 6 | import org.springframework.web.servlet.ModelAndView; 7 | import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | /** 15 | * @author jeff 16 | * @version 2015/12/2 17:09 17 | */ 18 | 19 | public class MarbleExceptionHandler extends SimpleMappingExceptionResolver { 20 | 21 | @Override 22 | protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { 23 | ModelAndView modelAndView = new ModelAndView(); 24 | Map errorMap = new HashMap<>(); 25 | String errorCode = ErrorEnum.OTHER_ERROR.getCode(); 26 | String errorMsg = ex.getMessage(); 27 | errorMap.put("errorCode", errorCode); 28 | errorMap.put("errorMsg", errorMsg); 29 | 30 | 31 | if(handler instanceof HandlerMethod && ((HandlerMethod) handler).getMethodAnnotation(ResponseBody.class) == null){ 32 | modelAndView = new ModelAndView("error", errorMap); 33 | }else{ 34 | if(ex instanceof MarbleException) { 35 | MarbleException me = (MarbleException)ex; 36 | errorMap.put("errorCode", me.getCode()); 37 | } 38 | // try { 39 | // response.setHeader("Content-type", "text/html;charset=UTF-8"); 40 | // response.setCharacterEncoding("UTF-8"); 41 | // response.getWriter().write(errorMap.toString()); 42 | // } catch (IOException e) { 43 | // e.printStackTrace(); 44 | // } 45 | } 46 | return modelAndView; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/global/listener/AppLifeCycleListener.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.global.listener; 2 | 3 | import com.github.jxdong.marble.common.util.PropertyUtils; 4 | 5 | import javax.servlet.ServletContextEvent; 6 | import javax.servlet.ServletContextListener; 7 | 8 | public class AppLifeCycleListener implements ServletContextListener { 9 | 10 | @Override 11 | public void contextInitialized(ServletContextEvent arg0) { 12 | System.out.println("=== onStartup (" + PropertyUtils.getString("Version") + ") ==="); 13 | } 14 | 15 | @Override 16 | public void contextDestroyed(ServletContextEvent arg0) { 17 | System.out.println("=== onShutdown (" + PropertyUtils.getString("Version") + ") ==="); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/global/listener/MVCInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.global.listener; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.web.servlet.HandlerInterceptor; 6 | import org.springframework.web.servlet.ModelAndView; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | /** 12 | * @author jeff 13 | * @version 2015/12/11 13:56 14 | */ 15 | public class MVCInterceptor implements HandlerInterceptor { 16 | private static final Logger logger = LoggerFactory.getLogger(MVCInterceptor.class); 17 | 18 | /** 19 | * 该方法将在Controller处理之前进行调用 20 | * 1、判断是否为HULK系统调用; 21 | * 2、判断有没有登录; 22 | * 3、参数进行sql+html+js过滤 23 | * @param httpServletRequest request 24 | * @param httpServletResponse response 25 | * @param o 参数 26 | * @return 返回 false表示结束 27 | * @throws Exception 28 | */ 29 | @Override 30 | public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception { 31 | 32 | //登陆状态校验 33 | if(httpServletRequest.getSession() == null){ 34 | logger.warn("not login. request failed !"); 35 | return false; 36 | } 37 | 38 | return true; 39 | } 40 | 41 | /** 42 | * 这个方法只会在当前这个Interceptor的preHandle方法返回值为true的时候才会执行。postHandle是进行处理器拦截用的,它的执行时间是在处理器进行处理之 43 | * 后,也就是在Controller的方法调用之后执行,但是它会在DispatcherServlet进行视图的渲染之前执行,也就是说在这个方法中你可以对ModelAndView进行操作 44 | ** @param httpServletRequest request 45 | * @param httpServletResponse response 46 | * @param o 参数 47 | * @param modelAndView 视图 48 | * @throws Exception 49 | */ 50 | @Override 51 | public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception { 52 | 53 | } 54 | 55 | /** 56 | * 该方法也是需要当前对应的Interceptor的preHandle方法的返回值为true时才会执行。该方法将在整个请求完成之后,也就是DispatcherServlet渲染了视图执行, 57 | * 这个方法的主要作用是用于清理资源的,当然这个方法也只能在当前这个Interceptor的preHandle方法的返回值为true时才会执行。 58 | */ 59 | @Override 60 | public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception { 61 | 62 | } 63 | 64 | // private String printRequest(HttpServletRequest req){ 65 | // StringBuffer sb = new StringBuffer(); 66 | // sb.append("Remote User: ");sb.append(req.getRemoteUser()); sb.append(". "); 67 | // sb.append("Remote address: "); sb.append(req.getRemoteAddr()); sb.append(". "); 68 | // sb.append("Session: "); sb.append(req.getSession() != null ? req.getSession() : ""); 69 | // 70 | // sb.append(". Headers: "); 71 | // Enumeration en = req.getHeaderNames(); 72 | // String header=""; 73 | // while(en.hasMoreElements()){ 74 | // header = en.nextElement(); 75 | // sb.append(header); 76 | // sb.append(": "); 77 | // sb.append(req.getHeader(header)); 78 | // sb.append(", "); 79 | // } 80 | // return sb.toString(); 81 | // 82 | // } 83 | } 84 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/global/listener/MarbleHiddenHttpMethodFilter.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.global.listener; 2 | 3 | import org.springframework.util.StringUtils; 4 | import org.springframework.web.filter.HiddenHttpMethodFilter; 5 | import org.springframework.web.util.WebUtils; 6 | 7 | import javax.servlet.FilterChain; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | 13 | /** 14 | * Created by ccsa on 23/06/2017. 15 | */ 16 | public class MarbleHiddenHttpMethodFilter extends HiddenHttpMethodFilter { 17 | 18 | @Override 19 | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { 20 | //如果请求以 resutful开头,跳过拦截 21 | String servletPath = request.getServletPath(); 22 | if (servletPath != null && servletPath.startsWith("/restful/api/")) { 23 | filterChain.doFilter(request, response); 24 | } else { 25 | super.doFilterInternal(request, response, filterChain); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/global/listener/MarbleJobListener.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.global.listener; 2 | 3 | import com.github.jxdong.marble.common.util.JacksonUtil; 4 | import com.github.jxdong.marble.domain.model.JobBasicInfo; 5 | import org.quartz.JobExecutionContext; 6 | import org.quartz.JobExecutionException; 7 | import org.quartz.JobListener; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | /** 12 | * @author jeff 13 | * @version 2015/11/17 10:16 14 | */ 15 | 16 | public class MarbleJobListener implements JobListener{ 17 | private static final Logger logger = LoggerFactory.getLogger(MarbleJobListener.class); 18 | 19 | @Override 20 | public String getName() { 21 | return "Marble Job Listener1"; 22 | } 23 | @Override 24 | public void jobToBeExecuted(JobExecutionContext jobExecutionContext) { 25 | 26 | //logger.info("Job即将被执行.{}", jobExecutionContext); 27 | } 28 | 29 | @Override 30 | public void jobExecutionVetoed(JobExecutionContext jobExecutionContext) { 31 | logger.info("Job执行被拒绝.{}", jobExecutionContext); 32 | } 33 | 34 | @Override 35 | public void jobWasExecuted(final JobExecutionContext jobExecutionContext, final JobExecutionException e) { 36 | //logger.info("Job执行完成。{}", jobExecutionContext); 37 | /* 38 | final JobBasicInfo jobBasicInfo = getJobInfo(jobExecutionContext); 39 | 40 | ExecutorService executor = Executors.newFixedThreadPool(2); 41 | try{ 42 | //记录日志 43 | executor.submit(new Runnable() { 44 | @Override 45 | public void run() { 46 | LogManager logManager = (LogManager) SpringContextUtil.getBean("logManager", LogManager.class); 47 | logManager.addJobExecutionLog(jobBasicInfo.convert2JobLog(e)); 48 | } 49 | }); 50 | }catch (Exception ex){ 51 | logger.error("Marble Job Listener exception. detail: ", ex); 52 | }finally { 53 | executor.shutdown(); 54 | } 55 | */ 56 | 57 | } 58 | 59 | private JobBasicInfo getJobInfo(JobExecutionContext jec){ 60 | if(jec != null){ 61 | Object jobInfoObject = jec.getMergedJobDataMap().get("JOB_INFO"); 62 | if(jobInfoObject != null){ 63 | return JacksonUtil.json2pojo(jobInfoObject.toString(), JobBasicInfo.class); 64 | } 65 | } 66 | logger.error("cannot get the Job Basic Info from MergedJobDataMap"); 67 | return new JobBasicInfo(); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/global/listener/MarbleSchedulerListener.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.global.listener; 2 | 3 | import org.quartz.*; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | /** 8 | * @author jeff 9 | * @version 2015/11/16 21:19 10 | */ 11 | public class MarbleSchedulerListener implements SchedulerListener{ 12 | private static final Logger logger = LoggerFactory.getLogger(MarbleSchedulerListener.class); 13 | 14 | @Override 15 | public void jobScheduled(Trigger trigger) { 16 | logger.info("Job scheduled. {}", trigger); 17 | } 18 | 19 | @Override 20 | public void jobUnscheduled(TriggerKey triggerKey) { 21 | logger.info("Job unscheduled. {}", triggerKey); 22 | } 23 | 24 | @Override 25 | public void triggerFinalized(Trigger trigger) { 26 | logger.info("Trigger finalized. {}", trigger); 27 | } 28 | 29 | @Override 30 | public void triggerPaused(TriggerKey triggerKey) { 31 | logger.info("Trigger paused. {}", triggerKey); 32 | } 33 | 34 | @Override 35 | public void triggersPaused(String s) { 36 | logger.info("Triggers paused. {}", s); 37 | } 38 | 39 | @Override 40 | public void triggerResumed(TriggerKey triggerKey) { 41 | logger.info("Trigger resumed. {}", triggerKey); 42 | } 43 | 44 | @Override 45 | public void triggersResumed(String s) { 46 | logger.info("Triggers resumed. {}", s); 47 | } 48 | 49 | @Override 50 | public void jobAdded(JobDetail jobDetail) { 51 | logger.info("Job added. {}", jobDetail); 52 | } 53 | 54 | @Override 55 | public void jobDeleted(JobKey jobKey) { 56 | logger.info("Job deleted. {}", jobKey); 57 | } 58 | 59 | @Override 60 | public void jobPaused(JobKey jobKey) { 61 | logger.info("Job paused. {}", jobKey); 62 | } 63 | 64 | @Override 65 | public void jobsPaused(String s) { 66 | logger.info("Jobs paused. {}", s); 67 | } 68 | 69 | @Override 70 | public void jobResumed(JobKey jobKey) { 71 | logger.info("Job resumed. {}", jobKey); 72 | } 73 | 74 | @Override 75 | public void jobsResumed(String s) { 76 | logger.info("Jobs resumed. {}", s); 77 | } 78 | 79 | @Override 80 | public void schedulerError(String s, SchedulerException e) { 81 | logger.info("Scheduler error. {}, {}", s, e); 82 | } 83 | 84 | @Override 85 | public void schedulerInStandbyMode() { 86 | logger.info("Scheduler in standBy."); 87 | } 88 | 89 | @Override 90 | public void schedulerStarted() { 91 | logger.info("Scheduler started."); 92 | } 93 | 94 | @Override 95 | public void schedulerStarting() { 96 | logger.info("Scheduler starting."); 97 | } 98 | 99 | @Override 100 | public void schedulerShutdown() { 101 | logger.info("Scheduler shutdown."); 102 | } 103 | 104 | @Override 105 | public void schedulerShuttingdown() { 106 | logger.info("Scheduler shutting down."); 107 | } 108 | 109 | @Override 110 | public void schedulingDataCleared() { 111 | logger.info("Scheduling data cleared."); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/global/listener/MarbleTriggerListener.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.global.listener; 2 | 3 | import org.quartz.JobExecutionContext; 4 | import org.quartz.Trigger; 5 | import org.quartz.TriggerListener; 6 | 7 | /** 8 | * @author jeff 9 | * @version 2015/12/30 13:01 10 | */ 11 | public class MarbleTriggerListener implements TriggerListener{ 12 | //private static final Logger logger = LoggerFactory.getLogger(MarbleTriggerListener.class); 13 | 14 | @Override 15 | public String getName() { 16 | return "MarbleTrigger"; 17 | } 18 | 19 | @Override 20 | public void triggerFired(Trigger trigger, JobExecutionContext jobExecutionContext) { 21 | //logger.info("Trigger fired. {}", trigger); 22 | } 23 | 24 | @Override 25 | public boolean vetoJobExecution(Trigger trigger, JobExecutionContext jobExecutionContext) { 26 | // logger.info("Trigger veto. {}", trigger); 27 | return false; 28 | } 29 | 30 | @Override 31 | public void triggerMisfired(Trigger trigger) { 32 | // logger.info("Trigger misfire. {}", trigger); 33 | } 34 | 35 | @Override 36 | public void triggerComplete(Trigger trigger, JobExecutionContext jobExecutionContext, Trigger.CompletedExecutionInstruction completedExecutionInstruction) { 37 | // logger.info("Trigger complete. {}", trigger); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/global/listener/MyFreeMarkerView.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.global.listener; 2 | 3 | import org.springframework.web.servlet.view.freemarker.FreeMarkerView; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | import java.util.Map; 7 | 8 | public class MyFreeMarkerView extends FreeMarkerView { 9 | 10 | private static final String CONTEXT_PATH = "basePath"; 11 | 12 | @Override 13 | protected void exposeHelpers(Map model, HttpServletRequest request) throws Exception { 14 | model.put(CONTEXT_PATH, request.getContextPath()); 15 | super.exposeHelpers(model, request); 16 | } 17 | } -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/global/listener/SpringLifeCycleListener.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.global.listener; 2 | 3 | import com.github.jxdong.marble.common.util.PropertyUtils; 4 | import com.github.jxdong.marble.global.util.SpringContextUtil; 5 | import com.github.jxdong.marble.infrastructure.service.netty.WebNettyClientManager; 6 | import com.github.jxdong.marble.infrastructure.service.netty.WebNettyServerManager; 7 | import org.quartz.Scheduler; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.context.ApplicationEvent; 11 | import org.springframework.context.ApplicationListener; 12 | import org.springframework.context.event.ContextClosedEvent; 13 | import org.springframework.context.event.ContextRefreshedEvent; 14 | import org.springframework.context.event.ContextStartedEvent; 15 | import org.springframework.stereotype.Component; 16 | 17 | import java.util.concurrent.ExecutorService; 18 | import java.util.concurrent.Executors; 19 | 20 | /** 21 | * @author tangb 22 | * 该类和TomcatOnOffMonitor为两种不同应用开启和关闭时执行任务的方法。本应用使用Spring 方法。 23 | */ 24 | @Component 25 | public class SpringLifeCycleListener implements ApplicationListener { 26 | private static final Logger logger = LoggerFactory.getLogger(SpringLifeCycleListener.class); 27 | 28 | @Override 29 | public void onApplicationEvent(ApplicationEvent event) { 30 | 31 | if (event instanceof ContextStartedEvent) { 32 | logger.info("The spring starts... , Version: {}", PropertyUtils.getString("Version")); 33 | } else if (event instanceof ContextRefreshedEvent) { 34 | if (((ContextRefreshedEvent) event).getApplicationContext().getParent() == null) { 35 | logger.info("The spring starts successfully. Version: {}", PropertyUtils.getString("Version")); 36 | ExecutorService executorService = Executors.newSingleThreadExecutor(); 37 | executorService.execute(new Runnable() { 38 | @Override 39 | public void run() { 40 | WebNettyServerManager.getInstance().run(PropertyUtils.getMarbleServerPort()); 41 | } 42 | }); 43 | executorService.shutdown(); 44 | } 45 | } else if (event instanceof ContextClosedEvent) { 46 | logger.info("The spring is closing... , Version: {}", PropertyUtils.getString("Version")); 47 | closeQuartzSched(); 48 | closeClog(); 49 | } 50 | } 51 | 52 | private void closeQuartzSched() { 53 | System.out.println("[Marble Scheduler] 开始关闭"); 54 | //ForkJoinPool.defaultForkJoinWorkerThreadFactory; 55 | WebNettyClientManager.getInstance().destroy(); 56 | //关闭Scheduler 57 | Scheduler scheduler = (Scheduler) SpringContextUtil.getBean("marbleScheduler"); 58 | if (scheduler == null) { 59 | return; 60 | } 61 | for (int i = 0; i < 3; i++) { 62 | try { 63 | scheduler.shutdown(false); 64 | if (scheduler.isShutdown()) { 65 | break; 66 | } else { 67 | Thread.sleep(300); 68 | } 69 | } catch (Exception e) { 70 | logger.info("关闭Quartz Scheduler异常: ", e); 71 | } 72 | } 73 | 74 | System.out.println("[Marble Scheduler] 关闭结束"); 75 | } 76 | 77 | private void closeClog() { 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/global/util/DTOConvert.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.global.util; 2 | 3 | import com.github.jxdong.marble.common.util.ArrayUtils; 4 | import com.github.jxdong.marble.domain.dto.BaseDTO; 5 | import com.github.jxdong.marble.domain.model.Entity; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.cglib.beans.BeanCopier; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | /** 14 | * 将内部的entity转化为DTO供网络传输 15 | * @author jeff 16 | * @version 2015/6/26 9:19 17 | */ 18 | public class DTOConvert { 19 | private static Logger logger = LoggerFactory.getLogger(DTOConvert.class); 20 | 21 | public static BaseDTO entity2DTO(Entity entity, Class dtoClass){ 22 | if(entity == null || dtoClass == null ){ 23 | return null; 24 | } 25 | BaseDTO dto = null; 26 | try { 27 | dto = dtoClass.newInstance(); 28 | BeanCopier bc =BeanCopier.create(entity.getClass(), dtoClass, false); 29 | bc.copy(entity, dto, null); 30 | return dto; 31 | } catch (Exception e) { 32 | logger.error("convert POJO to DTO exception. detail: ", e); 33 | } 34 | return dto; 35 | } 36 | 37 | public static List entity2DTO(List entityList, Class dtoClass){ 38 | List dtoList = new ArrayList<>(); 39 | if(ArrayUtils.listIsNotBlank(entityList)){ 40 | for(Entity entity : entityList){ 41 | if(entity != null){ 42 | dtoList.add(entity2DTO(entity, dtoClass)); 43 | } 44 | } 45 | } 46 | return dtoList; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/global/util/SpringContextUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.global.util; 2 | 3 | /** 4 | * @author jeff 5 | * @version 2015/8/18 13:22 6 | */ 7 | import org.springframework.beans.BeansException; 8 | import org.springframework.beans.factory.NoSuchBeanDefinitionException; 9 | import org.springframework.context.ApplicationContext; 10 | import org.springframework.context.ApplicationContextAware; 11 | import org.springframework.stereotype.Component; 12 | 13 | @Component 14 | public class SpringContextUtil implements ApplicationContextAware { 15 | private static ApplicationContext applicationContext; //Spring应用上下文环境 16 | 17 | /** 18 | * 实现ApplicationContextAware接口的回调方法,设置上下文环境 19 | * @param applicationContext applicationContext 20 | * @throws BeansException 21 | */ 22 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 23 | SpringContextUtil.applicationContext = applicationContext; 24 | } 25 | 26 | /** 27 | * @return ApplicationContext 28 | */ 29 | public static ApplicationContext getApplicationContext() { 30 | return applicationContext; 31 | } 32 | 33 | /** 34 | * 获取对象 35 | * @param name name 36 | * @return Object 一个以所给名字注册的bean的实例 37 | * @throws BeansException 38 | */ 39 | public static Object getBean(String name) throws BeansException { 40 | return applicationContext.getBean(name); 41 | } 42 | 43 | /** 44 | * 获取类型为requiredType的对象 45 | * 如果bean不能被类型转换,相应的异常将会被抛出(BeanNotOfRequiredTypeException) 46 | * @param name bean注册名 47 | * @param requiredType 返回对象类型 48 | * @return Object 返回requiredType类型对象 49 | * @throws BeansException 50 | */ 51 | public static Object getBean(String name, Class requiredType) throws BeansException { 52 | return applicationContext.getBean(name, requiredType); 53 | } 54 | 55 | /** 56 | * 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true 57 | * @param name name 58 | * @return boolean 59 | */ 60 | public static boolean containsBean(String name) { 61 | return applicationContext.containsBean(name); 62 | } 63 | 64 | /** 65 | * 判断以给定名字注册的bean定义是一个singleton还是一个prototype。 66 | * 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException) 67 | * @param name 68 | * @return boolean 69 | * @throws NoSuchBeanDefinitionException 70 | */ 71 | public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException { 72 | return applicationContext.isSingleton(name); 73 | } 74 | 75 | /** 76 | * @param name 77 | * @return Class 注册对象的类型 78 | * @throws NoSuchBeanDefinitionException 79 | */ 80 | public static Class getType(String name) throws NoSuchBeanDefinitionException { 81 | return applicationContext.getType(name); 82 | } 83 | 84 | /** 85 | * 如果给定的bean名字在bean定义中有别名,则返回这些别名 86 | * @param name 87 | * @return 88 | * @throws NoSuchBeanDefinitionException 89 | */ 90 | public static String[] getAliases(String name) throws NoSuchBeanDefinitionException { 91 | return applicationContext.getAliases(name); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/global/util/SqlErrorUtil.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.global.util; 2 | 3 | import org.springframework.dao.DataAccessException; 4 | 5 | import java.sql.SQLException; 6 | 7 | public class SqlErrorUtil { 8 | 9 | private static String getErrorMsgByCode(int errorCode) { 10 | String errorMsg; 11 | 12 | switch (errorCode) { 13 | case 1054: 14 | errorMsg = "SQL语法错误"; 15 | break; 16 | case 1064: 17 | errorMsg = "SQL语法错误"; 18 | break; 19 | case 1146: 20 | errorMsg = "SQL语法错误"; 21 | break; 22 | case 1062: 23 | errorMsg = "数据重复"; 24 | break; 25 | case 630: 26 | errorMsg = "数据完整性校验错误"; 27 | break; 28 | case 839: 29 | errorMsg = "数据完整性校验错误"; 30 | break; 31 | case 840: 32 | errorMsg = "数据完整性校验错误"; 33 | break; 34 | case 893: 35 | errorMsg = "数据完整性校验错误"; 36 | break; 37 | case 1169: 38 | errorMsg = "数据完整性校验错误"; 39 | break; 40 | case 1215: 41 | errorMsg = "数据完整性校验错误"; 42 | break; 43 | case 1216: 44 | errorMsg = "数据完整性校验错误"; 45 | break; 46 | case 1217: 47 | errorMsg = "数据完整性校验错误"; 48 | break; 49 | case 1451: 50 | errorMsg = "数据完整性校验错误"; 51 | break; 52 | case 1452: 53 | errorMsg = "数据完整性校验错误"; 54 | break; 55 | case 1557: 56 | errorMsg = "数据完整性校验错误"; 57 | break; 58 | case 1: 59 | errorMsg = "访问数据失败"; 60 | break; 61 | case 1205: 62 | errorMsg = "不能请求锁定的数据"; 63 | break; 64 | case 1213: 65 | errorMsg = "死锁"; 66 | break; 67 | default: 68 | errorMsg = "未知异常"; 69 | break; 70 | } 71 | 72 | return errorMsg; 73 | } 74 | 75 | public static String getDataAccessExceptionMsg(DataAccessException e) { 76 | String errorMsg = "未知异常"; 77 | if (e != null) { 78 | SQLException sqle = null; 79 | try { 80 | sqle = (SQLException) e.getCause(); 81 | if (sqle != null) { 82 | errorMsg = getErrorMsgByCode(sqle.getErrorCode()); 83 | } 84 | } catch (Exception e1) {} 85 | } 86 | return errorMsg; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/infrastructure/repositories/mapper/mysql/AppMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.infrastructure.repositories.mapper.mysql; 2 | 3 | import com.github.jxdong.marble.domain.model.AppDetail; 4 | import com.github.jxdong.marble.domain.model.ServerDetail; 5 | import org.apache.ibatis.annotations.Param; 6 | import org.springframework.dao.DataAccessException; 7 | 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | public interface AppMapper { 12 | 13 | AppDetail selectAppById(@Param("id") int id) throws DataAccessException; 14 | 15 | AppDetail selectAppByCode(@Param("appCode") String appCode) throws DataAccessException; 16 | 17 | List selectAppByMultiConditions(Map params) throws DataAccessException; 18 | //带scheduler信息的app列表 19 | List selectAppWithSched(Map params) throws DataAccessException; 20 | 21 | List selectServerBySched(@Param("appCode") String appCode, @Param("schedName") String schedName) throws DataAccessException; 22 | List selectServerByAppCode(@Param("appCode") String appCode) throws DataAccessException; 23 | 24 | ServerDetail selectServerById(@Param("id") int id) throws DataAccessException; 25 | 26 | ServerDetail selectServerByGroupName(@Param("appCode") String appCode, @Param("serverGroup") String serverGroup, @Param("serverName") String serverName) throws DataAccessException; 27 | 28 | int updateAppById(AppDetail appDetail) throws DataAccessException; 29 | 30 | int insertApp(AppDetail appDetail) throws DataAccessException; 31 | 32 | int insertAppServer(ServerDetail serverDetail) throws DataAccessException; 33 | 34 | int deleteApp(@Param("appCode") String appCode) throws DataAccessException; 35 | 36 | int deleteAppSchedByAppCode(@Param("appCode") String appCode) throws DataAccessException; 37 | 38 | int deleteAppServerByAppCode(@Param("appCode") String appCode) throws DataAccessException; 39 | 40 | int deleteAppServerByServerName(@Param("appCode") String appCode, @Param("serverGroup") String serverGroup,@Param("serverName") String serverName) throws DataAccessException; 41 | 42 | int deleteAppShedServerByAppCode(@Param("appCode") String appCode) throws DataAccessException; 43 | 44 | int deleteAppShedServerByServerIp(@Param("appCode") String appCode, @Param("serverGroup") String serverGroup,@Param("serverIp") String serverIp) throws DataAccessException; 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/infrastructure/repositories/mapper/mysql/ConfigureMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.infrastructure.repositories.mapper.mysql; 2 | 3 | import com.github.jxdong.marble.domain.model.Configure; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.springframework.dao.DataAccessException; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | public interface ConfigureMapper { 11 | 12 | List selectConfigureByMultiConditions(Map paramMap) throws DataAccessException; 13 | 14 | Configure selectConfigureById(@Param("id") int id) throws DataAccessException; 15 | 16 | int updateConfigureById(Configure configure) throws DataAccessException; 17 | 18 | int insertConfigure(Configure configure) throws DataAccessException; 19 | 20 | int deleteConfigureById(@Param("id") int id) throws DataAccessException; 21 | } 22 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/infrastructure/repositories/mapper/mysql/ConfigureMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | con.id, con.group, con.key, con.value, con.description, con.createTime, con.dataChange_lastTime 14 | 15 | 16 | 22 | 23 | 48 | 49 | 50 | DELETE FROM marble_configure 51 | WHERE id = #{id,jdbcType=INTEGER} 52 | 53 | 54 | 55 | INSERT INTO marble_configure 56 | (`group`, 57 | `key`, 58 | `value`, 59 | `description`, 60 | createTime, dataChange_lastTime) 61 | VALUES (#{group,jdbcType=VARCHAR}, #{key,jdbcType=VARCHAR}, 62 | #{value,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, now(), now()) 63 | 64 | 65 | 66 | UPDATE marble_configure con 67 | 68 | 69 | con.value = #{value,jdbcType=VARCHAR}, 70 | 71 | 72 | con.description = #{description,jdbcType=VARCHAR}, 73 | 74 | con.dataChange_lastTime = now() 75 | 76 | WHERE con.id = #{id,jdbcType=INTEGER} and con.dataChange_lastTime = #{version, jdbcType=TIMESTAMP} 77 | 78 | 79 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/infrastructure/repositories/mapper/mysql/JobExecutionLogMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.infrastructure.repositories.mapper.mysql; 2 | 3 | import com.github.jxdong.marble.domain.model.JobExecutionLog; 4 | import org.apache.ibatis.annotations.Param; 5 | import org.springframework.dao.DataAccessException; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | public interface JobExecutionLogMapper { 11 | 12 | JobExecutionLog selectById(long id) throws DataAccessException; 13 | 14 | JobExecutionLog selectByRequestNo(@Param("requestNo")String requestNo) throws DataAccessException; 15 | 16 | List selectByMultiConditions(Map paramMap) throws DataAccessException; 17 | 18 | int insert(JobExecutionLog jobExecutionLog) throws DataAccessException; 19 | 20 | int updateLog(JobExecutionLog jobExecutionLog) throws DataAccessException; 21 | 22 | int deleteById(long id) throws DataAccessException; 23 | 24 | int deleteJobLog(@Param("appCode") String appCode,@Param("schedName") String schedName,@Param("jobName") String jobName, @Param("execResultCodes") List execResultCodes) throws DataAccessException; 25 | 26 | //临时数据清理 27 | int deleteQuartzJobDetail() throws DataAccessException; 28 | int deleteQuartzCronTriggers() throws DataAccessException; 29 | int deleteQuartzFiredTriggers() throws DataAccessException; 30 | int deleteQuartzLocks() throws DataAccessException; 31 | int deleteQuartzPausedTriggerGroups() throws DataAccessException; 32 | int deleteQuartzSchedState() throws DataAccessException; 33 | int deleteQuartzTriggers() throws DataAccessException; 34 | } 35 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/infrastructure/repositories/mapper/mysql/SchedMapper.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.infrastructure.repositories.mapper.mysql; 2 | 3 | import com.github.jxdong.marble.domain.model.SchedulerDetail; 4 | import com.github.jxdong.marble.domain.model.ServerDetail; 5 | import org.apache.ibatis.annotations.Param; 6 | import org.springframework.dao.DataAccessException; 7 | 8 | import java.util.List; 9 | 10 | public interface SchedMapper { 11 | 12 | List selectAppSched(@Param("appCode") String appCode,@Param("schedName") String schedName) throws DataAccessException; 13 | 14 | List selectSchedServer(@Param("appCode") String appCode, 15 | @Param("schedName") String schedName, 16 | @Param("serverIp") String serverIp, 17 | @Param("serverPort") int serverPort) throws DataAccessException; 18 | 19 | 20 | int insertAppSched(SchedulerDetail schedDetail) throws DataAccessException; 21 | 22 | int insertServerSched(ServerDetail serverDetail) throws DataAccessException; 23 | 24 | int deleteSchedById(@Param("id") int id) throws DataAccessException; 25 | 26 | int deleteSchedServerById(@Param("id") int id) throws DataAccessException; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/infrastructure/service/RPCClientFactory.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.infrastructure.service; 2 | 3 | import com.github.jxdong.marble.common.util.ClogWrapper; 4 | import com.github.jxdong.marble.common.util.ClogWrapperFactory; 5 | import com.github.jxdong.marble.common.util.StringUtils; 6 | import com.github.jxdong.marble.infrastructure.service.netty.WebNettyClientManager; 7 | 8 | /** 9 | * @author jeff 10 | * @version 2016/1/15 16:23 11 | */ 12 | public class RPCClientFactory { 13 | private static ClogWrapper logger = ClogWrapperFactory.getClogWrapper(RPCClientFactory.class); 14 | 15 | public static RPCClientManager getClientManager(String reqNo, String marbleVersion){ 16 | logger.REQNO(reqNo).info("RPCClientFactory, Marble Version: {}", marbleVersion); 17 | //默认是Thrift 18 | RPCClientManager manager = ThriftManager.getInstance(); 19 | 20 | if(StringUtils.isNotBlank(marbleVersion)){ 21 | String[] versionArray = marbleVersion.split("\\."); 22 | if(StringUtils.str2Int(versionArray[0],-1) >=2){ 23 | manager = WebNettyClientManager.getInstance(); 24 | } 25 | } 26 | return manager; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/infrastructure/service/RPCClientManager.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.infrastructure.service; 2 | 3 | import com.github.jxdong.marble.domain.model.Result; 4 | import com.github.jxdong.marble.agent.entity.ClassInfo; 5 | 6 | import java.util.Map; 7 | import java.util.Set; 8 | 9 | /** 10 | * @author jeff 11 | * @version 2016/1/15 12:46 12 | */ 13 | public interface RPCClientManager { 14 | 15 | Result checkConnectivity(String host, int port); 16 | 17 | Result serviceInvoke(String requestNo, String host, int port, final Set classInfoSet, boolean isSync, Long maxWaitTime); 18 | 19 | //通用的服务调用方法 20 | Result serviceInvoke(String requestNo, String host, int port, final Map data); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/infrastructure/service/job/Job1.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.infrastructure.service.job; 2 | 3 | import com.github.jxdong.marble.common.util.ClogWrapper; 4 | import com.github.jxdong.marble.common.util.ClogWrapperFactory; 5 | import com.github.jxdong.marble.agent.common.server.MarbleJob; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * @author jeff 10 | * @version 2016/8/26 9:53 11 | */ 12 | @Component("job1") 13 | public class Job1 extends MarbleJob { 14 | private ClogWrapper logger = ClogWrapperFactory.getClogWrapper(Job1.class); 15 | 16 | @Override 17 | public void execute(String param) throws Exception { 18 | logger.info("JOB1开始执行 ..."); 19 | int i = 0; 20 | while (i<10000) {//true 21 | i++; 22 | //用中断状态码进行判断 23 | if (Thread.interrupted()) { 24 | logger.info("JOB1-[{}]-[{}]被打断啦", param, Thread.currentThread().getName()); 25 | return; 26 | } 27 | try { 28 | Thread.sleep(500); 29 | } catch (InterruptedException e) { 30 | // 被中断后return结束 31 | return; 32 | } 33 | logger.info("JOB1-[{}]-[{}]-{}-------", param, Thread.currentThread().getName(), i); 34 | } 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /marble-web/src/main/java/com/github/jxdong/marble/infrastructure/service/job/Job2.java: -------------------------------------------------------------------------------- 1 | package com.github.jxdong.marble.infrastructure.service.job; 2 | 3 | import com.github.jxdong.marble.common.util.ClogWrapper; 4 | import com.github.jxdong.marble.common.util.ClogWrapperFactory; 5 | import com.github.jxdong.marble.agent.entity.Result; 6 | import com.github.jxdong.marble.agent.common.server.MarbleJob; 7 | import org.springframework.stereotype.Component; 8 | 9 | /** 10 | * @author jeff 11 | * @version 2016/8/26 9:53 12 | */ 13 | @Component 14 | public class Job2 extends MarbleJob { 15 | private ClogWrapper logger = ClogWrapperFactory.getClogWrapper(Job2.class); 16 | 17 | @Override 18 | public Result executeSync(String param) { 19 | logger.error("Job2开始执行...{}", this.getClass().hashCode()); 20 | try { 21 | int i=0; 22 | // while (i<1000) { 23 | i++; 24 | if(Thread.interrupted()){ 25 | return Result.FAILURE("被打断"); 26 | } 27 | Thread.sleep(1000 * 10); 28 | logger.info("JOB2-[{}]-{}-------", Thread.currentThread().getName(), i); 29 | // } 30 | } catch (InterruptedException e) { 31 | e.printStackTrace(); 32 | } 33 | return Result.FAILURE("哈哈哈我失败了"); 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /marble-web/src/main/resources/config.properties: -------------------------------------------------------------------------------- 1 | Version=2016-12-22 2 | MarbleServerPort=10592 -------------------------------------------------------------------------------- /marble-web/src/main/resources/datasource-mysql.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 27 | 28 | dialect=mysql 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /marble-web/src/main/resources/freemarker.properties: -------------------------------------------------------------------------------- 1 | tag_syntax=auto_detect 2 | template_update_delay=2 3 | default_encoding=UTF-8 4 | output_encoding=UTF-8 5 | locale=zh_CN 6 | date_format=yyyy-MM-dd 7 | time_format=HH:mm:ss 8 | datetime_format=yyyy-MM-dd HH:mm:ss 9 | -------------------------------------------------------------------------------- /marble-web/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | [%5p][%d{MM-dd HH:mm:ss.SSS}][%c:%L]-%m%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /marble-web/src/main/resources/marble-config.properties: -------------------------------------------------------------------------------- 1 | #线程池最大线程数 2 | tpool_max_size=5 3 | #线程池核心线程数 4 | tpool_core_size=5 5 | #线程池阻塞有界队列长度 6 | tpool_bq_size=3 7 | #线程池满后的处理策略。1-AbortPolicy(抛出RejectedExecutionException异常); 2-CallerRunsPolicy; 3-DiscardOldestPolicy 4-DiscardPolicy(不抛出异常) 8 | tpool_reject_policy=1 -------------------------------------------------------------------------------- /marble-web/src/main/resources/rebel.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /marble-web/src/main/resources/spring-quartz.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | true 16 | MarbleQuartzScheduler 17 | 18 | org.quartz.simpl.SimpleThreadPool 19 | 80 20 | 5 21 | 22 | 30000 23 | 24 | org.quartz.impl.jdbcjobstore.JobStoreTX 25 | true 26 | 27 | AUTO 28 | true 29 | 30 | 60000 31 | 10 32 | 33 | marble_qrtz_ 34 | qzDS 35 | 36 | true 37 | true 38 | 39 | 40 | com.github.jxdong.marble.global.listener.MarbleJobListener 41 | 42 | com.github.jxdong.marble.global.listener.MarbleTriggerListener 43 | 44 | com.github.jxdong.marble.global.listener.MarbleSchedulerListener 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/ftl/common/bottom.ftl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/ftl/common/bottom.ftl -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/ftl/common/header.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | MARBLE OFFLINE 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | <#----> 13 | 14 | 32 | 35 | -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/ftl/common/js.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | <#----> 13 | <#----> 14 | 94 | -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/ftl/common/menu.ftl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/ftl/common/navbar.ftl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/ftl/common/successPopup.ftl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/ftl/error.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Error - Pages 10 | 11 | 12 | <#include "common/header.ftl" encoding="UTF-8"> 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 |
25 |
26 |
27 |
OOPS!
28 |
${errorCode}: ${errorMsg}
29 | 30 | <#include "common/js.ftl" encoding="UTF-8"> 31 | 32 | 33 | -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/ftl/quartz-job.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | <#include "common/header.ftl" encoding="UTF-8"> 8 | 13 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | <#include "common/navbar.ftl" encoding="UTF-8"> 23 | <#include "common/menu.ftl" encoding="UTF-8"> 24 | 25 |
26 | 27 | 33 |
34 | 35 |
36 | 37 |
38 |
39 | 40 | 41 |
42 | 43 | <#include "common/js.ftl" encoding="UTF-8"> 44 | 45 | -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/ftl/scheduler-editpopup.ftl: -------------------------------------------------------------------------------- 1 | 7 | 8 | 29 | 30 | -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/demo/avatars/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/demo/avatars/1.jpg -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/demo/avatars/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/demo/avatars/2.jpg -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/demo/avatars/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/demo/avatars/3.jpg -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/demo/avatars/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/demo/avatars/4.jpg -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/demo/avatars/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/demo/avatars/5.jpg -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/fonts/font-awesome/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/fonts/font-awesome/FontAwesome.otf -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/fonts/font-awesome/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/fonts/font-awesome/fontawesome-webfont.eot -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/fonts/font-awesome/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/fonts/font-awesome/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/fonts/font-awesome/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/fonts/font-awesome/fontawesome-webfont.woff -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/images/loading.gif -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/images/pixel-admin/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/images/pixel-admin/ajax-loader.gif -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/images/pixel-admin/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/images/pixel-admin/avatar.png -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/images/pixel-admin/blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/images/pixel-admin/blank.png -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/images/pixel-admin/blur.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/images/pixel-admin/main-menu-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/images/pixel-admin/main-menu-bg.png -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/images/pixel-admin/main-navbar-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/images/pixel-admin/main-navbar-bg.png -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/images/pixel-admin/main-navbar-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/images/pixel-admin/main-navbar-logo.png -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/images/plugins/bootstrap-editable/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/images/plugins/bootstrap-editable/loading.gif -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/images/plugins/jquery.minicolors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/images/plugins/jquery.minicolors.png -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/images/themes/adminflare/body-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/images/themes/adminflare/body-bg.png -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/images/themes/adminflare/ie-navbar-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/images/themes/adminflare/ie-navbar-bg.png -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/images/themes/adminflare/menu-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/images/themes/adminflare/menu-bg.png -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/images/themes/clean/body-bg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeff-dong/marble/4ab1d312ea738a84e7fb8ed59ad1742bb6b140b6/marble-web/src/main/webapp/WEB-INF/resources/assets/images/themes/clean/body-bg.gif -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/javascripts/demo-mock.js: -------------------------------------------------------------------------------- 1 | $(function(){function a(a,b){var c,d=[];d.push(a.type.toUpperCase()+' url = "'+a.url+'"');for(var e in a.data){if(a.data[e]&&"object"==typeof a.data[e]){c=[];for(var f in a.data[e])c.push(f+': "'+a.data[e][f]+'"');c="{ "+c.join(", ")+" }"}else c='"'+a.data[e]+'"';d.push(e+" = "+c)}d.push("RESPONSE: status = "+b.status),b.responseText&&($.isArray(b.responseText)?(d.push("["),$.each(b.responseText,function(a,b){d.push("{value: "+b.value+', text: "'+b.text+'"}')}),d.push("]")):d.push($.trim(b.responseText))),d.push("--------------------------------------\n")}$.mockjaxSettings.responseTime=500,$.mockjax({url:"/post",response:function(b){try{a(b,this)}catch(c){}}}),$.mockjax({url:"/error",status:400,statusText:"Bad Request",response:function(b){this.responseText="Please input correct value";try{a(b,this)}catch(c){}}}),$.mockjax({url:"/status",status:500,response:function(b){this.responseText="Internal Server Error";try{a(b,this)}catch(c){}}}),$.mockjax({url:"/groups",response:function(b){this.responseText=[{value:0,text:"Guest"},{value:1,text:"Service"},{value:2,text:"Customer"},{value:3,text:"Operator"},{value:4,text:"Support"},{value:5,text:"Admin"}];try{a(b,this)}catch(c){}}})}); -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/assets/javascripts/demo-mock.min.js: -------------------------------------------------------------------------------- 1 | $(function(){function a(a,b){var c,d=[];d.push(a.type.toUpperCase()+' url = "'+a.url+'"');for(var e in a.data){if(a.data[e]&&"object"==typeof a.data[e]){c=[];for(var f in a.data[e])c.push(f+': "'+a.data[e][f]+'"');c="{ "+c.join(", ")+" }"}else c='"'+a.data[e]+'"';d.push(e+" = "+c)}d.push("RESPONSE: status = "+b.status),b.responseText&&($.isArray(b.responseText)?(d.push("["),$.each(b.responseText,function(a,b){d.push("{value: "+b.value+', text: "'+b.text+'"}')}),d.push("]")):d.push($.trim(b.responseText))),d.push("--------------------------------------\n")}$.mockjaxSettings.responseTime=500,$.mockjax({"url":"/post","response":function(b){try{a(b,this)}catch(c){}}}),$.mockjax({"url":"/error","status":400,"statusText":"Bad Request","response":function(b){this.responseText="Please input correct value";try{a(b,this)}catch(c){}}}),$.mockjax({"url":"/status","status":500,"response":function(b){this.responseText="Internal Server Error";try{a(b,this)}catch(c){}}}),$.mockjax({"url":"/groups","response":function(b){this.responseText=[{"value":0,"text":"Guest"},{"value":1,"text":"Service"},{"value":2,"text":"Customer"},{"value":3,"text":"Operator"},{"value":4,"text":"Support"},{"value":5,"text":"Admin"}];try{a(b,this)}catch(c){}}})}); -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/view/pages-404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

404

14 | 15 | -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/resources/view/pages-500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

500

14 | 15 | -------------------------------------------------------------------------------- /marble-web/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | se.jiderhamn.classloader.leak.prevention.ClassLoaderLeakPreventor 6 | 7 | 8 | 9 | encodingFilter 10 | org.springframework.web.filter.CharacterEncodingFilter 11 | 12 | encoding 13 | UTF-8 14 | 15 | 16 | forceEncoding 17 | true 18 | 19 | 20 | 21 | 22 | encodingFilter 23 | /* 24 | 25 | 26 | 27 | HiddenHttpMethodFilter 28 | com.github.jxdong.marble.global.listener.MarbleHiddenHttpMethodFilter 29 | 30 | methodParam 31 | _method_ 32 | 33 | 34 | 35 | HiddenHttpMethodFilter 36 | /* 37 | 38 | 39 | Marble Project 40 | 41 | com.github.jxdong.marble.global.listener.AppLifeCycleListener 42 | 43 | 44 | 45 | 46 | spring-mvc 47 | org.springframework.web.servlet.DispatcherServlet 48 | 49 | contextConfigLocation 50 | classpath:spring-application.xml 51 | 52 | 1 53 | 54 | 55 | spring-mvc 56 | / 57 | 58 | 59 | -------------------------------------------------------------------------------- /marble-web/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | forwarding.... 9 | 10 | 11 | -------------------------------------------------------------------------------- /marble-web/src/test/java/com/github/group/marble/infrastructure/service/NettyManagerTest.java: -------------------------------------------------------------------------------- 1 | package com.github.group.marble.infrastructure.service; 2 | 3 | import com.github.jxdong.marble.common.util.StringUtils; 4 | import com.github.jxdong.marble.domain.model.Result; 5 | import com.github.jxdong.marble.infrastructure.service.netty.WebNettyClientManager; 6 | import com.github.jxdong.marble.agent.entity.ClassInfo; 7 | import junit.framework.TestCase; 8 | import org.junit.Test; 9 | 10 | import java.util.HashSet; 11 | import java.util.Set; 12 | 13 | /** 14 | * @author jeff 15 | * @version 2016/1/15 13:00 16 | */ 17 | public class NettyManagerTest extends TestCase { 18 | 19 | @Test 20 | public void testCheckConnectivity() throws Exception { 21 | Result ressult = WebNettyClientManager.getInstance().checkConnectivity("127.0.0.1", 9091); 22 | System.out.println(ressult); 23 | } 24 | 25 | @Test 26 | public void testServiceInvoke() throws Exception { 27 | 28 | Set classInfoSet = new HashSet<>(); 29 | classInfoSet.add(new ClassInfo("testJob","execute","参数1")); 30 | WebNettyClientManager.getInstance().serviceInvoke(StringUtils.genUUID(),"127.0.0.1", 9091, classInfoSet, false, null); 31 | 32 | } 33 | } -------------------------------------------------------------------------------- /marble-web/src/test/java/com/github/group/marble1/service/MarbleTest.java: -------------------------------------------------------------------------------- 1 | package com.github.group.marble1.service; 2 | 3 | import com.github.jxdong.marble.domain.model.JobExecutionLog; 4 | import com.github.jxdong.marble.domain.model.enums.JobExecStatusEnum; 5 | import com.github.jxdong.marble.global.util.DateUtil; 6 | import com.github.jxdong.marble.infrastructure.service.LogManager; 7 | import com.github.jxdong.marble.infrastructure.service.netty.WebNettyServerManager; 8 | import org.junit.Test; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | 11 | import java.util.Date; 12 | import java.util.concurrent.ExecutorService; 13 | import java.util.concurrent.Executors; 14 | 15 | /** 16 | * @author jeff 17 | * @version 2015/11/16 17:06 18 | */ 19 | public class MarbleTest { 20 | 21 | @Autowired 22 | private LogManager logManager; 23 | 24 | @Test 25 | public void testJob(){ 26 | System.out.println("开始:" + DateUtil.formateDate(new Date())); 27 | ExecutorService executor = Executors.newFixedThreadPool(1); 28 | for(int i=0;i<10;i++){ 29 | System.out.println("执行第" + i + "条"); 30 | executor.submit(new Runnable() { 31 | @Override 32 | public void run() { 33 | logManager.addJobExecutionLog(new JobExecutionLog("reqNo","appCode", "schedName", "jobName", "jobCronExpress", "serverInfo", JobExecStatusEnum.SUCCESS, null, "")); 34 | try { 35 | Thread.sleep(2000); 36 | } catch (InterruptedException e) { 37 | e.printStackTrace(); 38 | } 39 | } 40 | }); 41 | } 42 | executor.shutdown(); 43 | System.out.println("结束:"+DateUtil.formateDate(new Date())); 44 | } 45 | 46 | 47 | public static void main(String args[]) { 48 | WebNettyServerManager.getInstance().run(9001); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | com.github.jeff-dong 8 | marble-parent 9 | pom 10 | 1.0 11 | 12 | marble-common 13 | marble-web 14 | marble-contract 15 | 16 | 17 | 18 | UTF-8 19 | 0.8.13 20 | 4.3.7.RELEASE 21 | 1.1.7 22 | 1.7.21 23 | 2.8.9 24 | 25 | 26 | 27 | 28 | 29 | org.quartz-scheduler 30 | quartz 31 | 2.2.2 32 | 33 | 34 | 35 | org.apache.thrift 36 | libthrift 37 | 0.9.3 38 | 39 | 40 | 41 | javax.servlet 42 | javax.servlet-api 43 | 3.1.0 44 | 45 | 46 | 47 | com.alibaba 48 | fastjson 49 | 1.2.28 50 | 51 | 52 | 53 | io.netty 54 | netty-all 55 | 4.1.4.Final 56 | 57 | 58 | com.google.guava 59 | guava 60 | 22.0 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | ch.qos.logback 69 | logback-core 70 | ${logback.version} 71 | 72 | 73 | ch.qos.logback 74 | logback-classic 75 | ${logback.version} 76 | 77 | 78 | 79 | org.slf4j 80 | slf4j-api 81 | ${logback.slf4j.version} 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | --------------------------------------------------------------------------------