|
@ -30,7 +30,7 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean runShell(String shell) { |
|
|
public boolean runShell(String shell) { |
|
|
log.info("准备执行shell命令..."); |
|
|
log.info("准备执行>> shell命令..."); |
|
|
try { |
|
|
try { |
|
|
new WinCommandUtil(shell).run(); |
|
|
new WinCommandUtil(shell).run(); |
|
|
}catch (Exception e){ |
|
|
}catch (Exception e){ |
|
@ -42,7 +42,7 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean runBak(String path) { |
|
|
public boolean runBak(String path) { |
|
|
log.info("准备执行备份命令..."); |
|
|
log.info("准备执行>> 备份命令..."); |
|
|
boolean retBool; |
|
|
boolean retBool; |
|
|
log.info("创建备份文件目录..."); |
|
|
log.info("创建备份文件目录..."); |
|
|
String format = DateTimeFormatter.BASIC_ISO_DATE.format(LocalDate.now()); |
|
|
String format = DateTimeFormatter.BASIC_ISO_DATE.format(LocalDate.now()); |
|
@ -103,6 +103,7 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean runRestore(String filePath) { |
|
|
public boolean runRestore(String filePath) { |
|
|
|
|
|
log.info("准备执行>> 还原命令..."); |
|
|
boolean retBool; |
|
|
boolean retBool; |
|
|
boolean b = cn.hutool.core.io.FileUtil.isFile(filePath); |
|
|
boolean b = cn.hutool.core.io.FileUtil.isFile(filePath); |
|
|
if(b){ |
|
|
if(b){ |
|
@ -155,6 +156,7 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean rebuildIndex(List<IndexObj> index) { |
|
|
public boolean rebuildIndex(List<IndexObj> index) { |
|
|
|
|
|
log.info("准备执行>> 重建索引命令..."); |
|
|
boolean retBool = false; |
|
|
boolean retBool = false; |
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.DB, AppCfg.CODE); |
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.DB, AppCfg.CODE); |
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.RUNNING){ |
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.RUNNING){ |
|
@ -192,6 +194,7 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public boolean setDbSize(int ...size) { |
|
|
public boolean setDbSize(int ...size) { |
|
|
|
|
|
log.info("准备执行>> 设置数据库内存命令..."); |
|
|
if(size == null || size.length!=1){ |
|
|
if(size == null || size.length!=1){ |
|
|
log.error("请检测参数是否正确..."); |
|
|
log.error("请检测参数是否正确..."); |
|
|
return false; |
|
|
return false; |
|
@ -218,6 +221,7 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean cleanDbCache(List<String> sqls, List<TabColObj> tabColObjs) { |
|
|
public boolean cleanDbCache(List<String> sqls, List<TabColObj> tabColObjs) { |
|
|
|
|
|
log.info("准备执行>> 清除垃圾数据命令..."); |
|
|
boolean retBool = false; |
|
|
boolean retBool = false; |
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.DB, AppCfg.CODE); |
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.DB, AppCfg.CODE); |
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.RUNNING) { |
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.RUNNING) { |
|
@ -254,6 +258,7 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean registrationDbService() { |
|
|
public boolean registrationDbService() { |
|
|
|
|
|
log.info("准备执行>> 数据库服务注册命令..."); |
|
|
if(WinCommandUtil.RegisterUtil.registerWindows( |
|
|
if(WinCommandUtil.RegisterUtil.registerWindows( |
|
|
String.format("SYSTEM\\ControlSet001\\Services\\%s", AppCfg.DB), |
|
|
String.format("SYSTEM\\ControlSet001\\Services\\%s", AppCfg.DB), |
|
|
AppCfg.DB, |
|
|
AppCfg.DB, |
|
@ -275,7 +280,7 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean cleanMwCache() { |
|
|
public boolean cleanMwCache() { |
|
|
log.info("停止 中间件 服务..."); |
|
|
log.info("准备执行>> 清楚应用缓存命令..."); |
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.MW, AppCfg.CODE); |
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.MW, AppCfg.CODE); |
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.RUNNING){ |
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.RUNNING){ |
|
|
if (canNotRun(ws, WinServiceTool.WindowsService::stopService)) { |
|
|
if (canNotRun(ws, WinServiceTool.WindowsService::stopService)) { |
|
@ -314,6 +319,7 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public boolean setMwSize(int ...size) { |
|
|
public boolean setMwSize(int ...size) { |
|
|
|
|
|
log.info("准备执行>> 设置应用内存命令..."); |
|
|
if(size == null || size.length!=4){ |
|
|
if(size == null || size.length!=4){ |
|
|
log.error("请检测参数是否正确..."); |
|
|
log.error("请检测参数是否正确..."); |
|
|
return false; |
|
|
return false; |
|
@ -339,6 +345,7 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean registrationMwService() { |
|
|
public boolean registrationMwService() { |
|
|
|
|
|
log.info("准备执行>> 注册应用服务命令..."); |
|
|
if(WinCommandUtil.RegisterUtil.registerWindows( |
|
|
if(WinCommandUtil.RegisterUtil.registerWindows( |
|
|
String.format("SYSTEM\\ControlSet001\\Services\\%s", AppCfg.DB), |
|
|
String.format("SYSTEM\\ControlSet001\\Services\\%s", AppCfg.DB), |
|
|
AppCfg.MW, |
|
|
AppCfg.MW, |
|
@ -378,8 +385,7 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean startDbService() { |
|
|
public boolean startDbService() { |
|
|
boolean bool; |
|
|
log.info("准备执行>> 启动数据服务命令..."); |
|
|
log.info("启动 数据库 服务..."); |
|
|
|
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.DB, AppCfg.CODE); |
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.DB, AppCfg.CODE); |
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.STOPPED){ |
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.STOPPED){ |
|
|
if (canNotRun(ws, WinServiceTool.WindowsService::startService)) { |
|
|
if (canNotRun(ws, WinServiceTool.WindowsService::startService)) { |
|
@ -396,8 +402,7 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean stopDbService() { |
|
|
public boolean stopDbService() { |
|
|
boolean bool; |
|
|
log.info("准备执行>> 停止数据库服务命令..."); |
|
|
log.info("停止 数据库 服务..."); |
|
|
|
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.DB, AppCfg.CODE); |
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.DB, AppCfg.CODE); |
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.RUNNING){ |
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.RUNNING){ |
|
|
if (canNotRun(ws, WinServiceTool.WindowsService::stopService)) { |
|
|
if (canNotRun(ws, WinServiceTool.WindowsService::stopService)) { |
|
@ -409,8 +414,7 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean startMwService() { |
|
|
public boolean startMwService() { |
|
|
boolean bool; |
|
|
log.info("准备执行>> 启动应用服务命令..."); |
|
|
log.info("启动 中间件 服务..."); |
|
|
|
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.MW, AppCfg.CODE); |
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.MW, AppCfg.CODE); |
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.STOPPED){ |
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.STOPPED){ |
|
|
return !canNotRun(ws, WinServiceTool.WindowsService::startService); |
|
|
return !canNotRun(ws, WinServiceTool.WindowsService::startService); |
|
@ -423,7 +427,7 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean stopMwService() { |
|
|
public boolean stopMwService() { |
|
|
log.info("停止 中间件 服务..."); |
|
|
log.info("准备执行>> 停止应用服务命令..."); |
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.MW, AppCfg.CODE); |
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.MW, AppCfg.CODE); |
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.RUNNING){ |
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.RUNNING){ |
|
|
if (canNotRun(ws, WinServiceTool.WindowsService::stopService)) { |
|
|
if (canNotRun(ws, WinServiceTool.WindowsService::stopService)) { |
|
@ -436,7 +440,7 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void openServer(){ |
|
|
public void openServer(){ |
|
|
|
|
|
log.info("准备执行>> 打开本地服务命令..."); |
|
|
runShell("SERVICES.MSC"); |
|
|
runShell("SERVICES.MSC"); |
|
|
log.info("打开本地服务完成!"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|