|
|
@ -6,10 +6,7 @@ import com.insigma.entry.IndexObj; |
|
|
|
import com.insigma.entry.TabColObj; |
|
|
|
import com.insigma.service.Computer; |
|
|
|
import com.insigma.service.*; |
|
|
|
import com.insigma.utils.DbUtil; |
|
|
|
import com.insigma.utils.FileUtil; |
|
|
|
import com.insigma.utils.WinCommandUtil; |
|
|
|
import com.insigma.utils.ZipUtil; |
|
|
|
import com.insigma.utils.*; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
import java.sql.SQLException; |
|
|
@ -38,6 +35,7 @@ public class WindowsTomcatMysql extends Computer implements Database, Middleware |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean rebuildIndex(List<IndexObj> index) { |
|
|
|
boolean retBool; |
|
|
|
log.info("创建链接..."); |
|
|
|
final Session session = DbUtil.getSession(DbUtil.url, DbUtil.usr, DbUtil.pwd); |
|
|
|
try { |
|
|
@ -45,31 +43,37 @@ public class WindowsTomcatMysql extends Computer implements Database, Middleware |
|
|
|
session.execute("DROP INDEX ? ON ?", idx.getIdx(), idx.getTab()); |
|
|
|
session.execute("ALTER TABLE ? ADD INDEX ? (?) USING BTREE", idx.getTab(), idx.getIdx(), idx.getCol()); |
|
|
|
} |
|
|
|
retBool = true; |
|
|
|
} catch (SQLException e) { |
|
|
|
log.error("执行更新索引发生异常:{}", e.getMessage()); |
|
|
|
e.printStackTrace(); |
|
|
|
session.close(); |
|
|
|
return false; |
|
|
|
retBool = false; |
|
|
|
} |
|
|
|
session.close(); |
|
|
|
return true; |
|
|
|
return retBool; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean setDbSize(int size) { |
|
|
|
public boolean setDbSize(int size) throws Exception { |
|
|
|
log.info("停止 数据库 服务..."); |
|
|
|
runShell("sc stop " + AppCfg.DB); |
|
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.DB, AppCfg.CODE); |
|
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.RUNNING){ |
|
|
|
ws.stopService(); |
|
|
|
} |
|
|
|
|
|
|
|
log.info("设置 数据库 内存参数..."); |
|
|
|
FileUtil.replaceLine(AppCfg.HZB + "/mysql/my.ini", |
|
|
|
"innodb_buffer_pool_size", |
|
|
|
String.format("innodb_buffer_pool_size=%dM", size)); |
|
|
|
|
|
|
|
log.info("启动 数据库 服务..."); |
|
|
|
runShell("sc start " + AppCfg.DB); |
|
|
|
return Database.super.setDbSize(size); |
|
|
|
ws.startService(); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean cleanDbCache(List<String> sql, List<TabColObj> tabColObjs) { |
|
|
|
boolean retBool; |
|
|
|
log.info("创建链接..."); |
|
|
|
final Session session = DbUtil.getSession(DbUtil.url, DbUtil.usr, DbUtil.pwd); |
|
|
|
try { |
|
|
@ -84,26 +88,32 @@ public class WindowsTomcatMysql extends Computer implements Database, Middleware |
|
|
|
tab.getTab(), tab.getCol(), tab.getCol(), lj, tab.getCol()); |
|
|
|
} |
|
|
|
} |
|
|
|
retBool = true; |
|
|
|
} catch (SQLException e) { |
|
|
|
log.error("执行 清洗数据中特殊字符串 发生异常:{}", e.getMessage()); |
|
|
|
e.printStackTrace(); |
|
|
|
session.close(); |
|
|
|
return false; |
|
|
|
retBool = false; |
|
|
|
} |
|
|
|
log.info("执行 清洗数据中特殊字符串 完成..."); |
|
|
|
session.close(); |
|
|
|
return true; |
|
|
|
return retBool; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean registrationDbService() { |
|
|
|
// TODO
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean cleanMwCache() { |
|
|
|
public boolean cleanMwCache() throws Exception { |
|
|
|
log.info("停止 中间件 服务..."); |
|
|
|
runShell("sc stop " + AppCfg.MW); |
|
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.MW, AppCfg.CODE); |
|
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.RUNNING){ |
|
|
|
ws.stopService(); |
|
|
|
} |
|
|
|
|
|
|
|
log.info("退出 浏览器..."); |
|
|
|
runShell("taskkill /f /im " + AppCfg.BROWSER); |
|
|
|
|
|
|
@ -121,24 +131,32 @@ public class WindowsTomcatMysql extends Computer implements Database, Middleware |
|
|
|
FileUtil.delAllFile(AppCfg.HZB + "/tomcat8/logs"); |
|
|
|
|
|
|
|
log.info("启动 中间件 服务..."); |
|
|
|
runShell("sc start " + AppCfg.MW); |
|
|
|
ws.startService(); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean setMwSize(int size) { |
|
|
|
public boolean setMwSize(int size) throws Exception { |
|
|
|
log.info("停止 中间件 服务..."); |
|
|
|
runShell("sc stop " + AppCfg.MW); |
|
|
|
|
|
|
|
WinServiceTool.WindowsService ws = WinServiceTool.getService(AppCfg.MW, AppCfg.CODE); |
|
|
|
if(ws.getRunningStatus() == WinServiceTool.WindowsService.ServiceState.RUNNING){ |
|
|
|
ws.stopService(); |
|
|
|
} |
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
|
|
|
log.info("启动 中间件 服务..."); |
|
|
|
runShell("sc start " + AppCfg.MW); |
|
|
|
ws.startService(); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean registrationMwService() { |
|
|
|
if(AppCfg.is32Bit){ |
|
|
|
runShell(AppCfg.HZB + "/tomcat8/webapps/qggwy/WEB-INF/classes/static/32bit.bat"); |
|
|
|
}else{ |
|
|
|
runShell(AppCfg.HZB + "/tomcat8/webapps/qggwy/WEB-INF/classes/static/64bit.bat"); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|