|
@ -33,15 +33,28 @@ public class WindowsTomcatMysql extends Computer implements Database, Middleware |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean runBak() { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean rebuildIndex(List<IndexObj> index) { |
|
|
public boolean rebuildIndex(List<IndexObj> index) { |
|
|
boolean retBool; |
|
|
boolean retBool; |
|
|
log.info("创建链接..."); |
|
|
log.info("创建链接..."); |
|
|
final Session session = DbUtil.getSession(DbUtil.url, DbUtil.usr, DbUtil.pwd); |
|
|
final Session session = DbUtil.getSession(DbUtil.url, DbUtil.usr, DbUtil.pwd, DbUtil.drive); |
|
|
|
|
|
String sql; |
|
|
try { |
|
|
try { |
|
|
for (IndexObj idx : index) { |
|
|
for (IndexObj idx : index) { |
|
|
session.execute("DROP INDEX ? ON ?", idx.getIdx(), idx.getTab()); |
|
|
try { |
|
|
session.execute("ALTER TABLE ? ADD INDEX ? (?) USING BTREE", idx.getTab(), idx.getIdx(), idx.getCol()); |
|
|
sql = String.format("DROP INDEX %s ON %s", idx.getIdx(), idx.getTab()); |
|
|
|
|
|
log.debug(sql); |
|
|
|
|
|
session.execute(sql); |
|
|
|
|
|
}finally { |
|
|
|
|
|
sql = String.format("ALTER TABLE %s ADD INDEX %s (%s) USING BTREE", idx.getTab(), idx.getIdx(), idx.getCol()); |
|
|
|
|
|
log.debug(sql); |
|
|
|
|
|
session.execute(sql); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
retBool = true; |
|
|
retBool = true; |
|
|
} catch (SQLException e) { |
|
|
} catch (SQLException e) { |
|
@ -53,8 +66,18 @@ public class WindowsTomcatMysql extends Computer implements Database, Middleware |
|
|
return retBool; |
|
|
return retBool; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
* 设置数据库参数 :注意参数的个数和位置 |
|
|
|
|
|
* @param size 顺序为 innodb_buffer_pool_size |
|
|
|
|
|
* @return |
|
|
|
|
|
* @throws Exception |
|
|
|
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public boolean setDbSize(int size) throws Exception { |
|
|
public boolean setDbSize(int ...size) throws Exception { |
|
|
|
|
|
if(size == null || size.length!=1){ |
|
|
|
|
|
log.error("请检测参数是否正确..."); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
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){ |
|
@ -64,7 +87,7 @@ public class WindowsTomcatMysql extends Computer implements Database, Middleware |
|
|
log.info("设置 数据库 内存参数..."); |
|
|
log.info("设置 数据库 内存参数..."); |
|
|
FileUtil.replaceLine(AppCfg.HZB + "/mysql/my.ini", |
|
|
FileUtil.replaceLine(AppCfg.HZB + "/mysql/my.ini", |
|
|
"innodb_buffer_pool_size", |
|
|
"innodb_buffer_pool_size", |
|
|
String.format("innodb_buffer_pool_size=%dM", size)); |
|
|
String.format("innodb_buffer_pool_size=%dM", size[0])); |
|
|
|
|
|
|
|
|
log.info("启动 数据库 服务..."); |
|
|
log.info("启动 数据库 服务..."); |
|
|
ws.startService(); |
|
|
ws.startService(); |
|
@ -72,20 +95,24 @@ public class WindowsTomcatMysql extends Computer implements Database, Middleware |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean cleanDbCache(List<String> sql, List<TabColObj> tabColObjs) { |
|
|
public boolean cleanDbCache(List<String> sqls, List<TabColObj> tabColObjs) { |
|
|
boolean retBool; |
|
|
boolean retBool; |
|
|
log.info("创建链接..."); |
|
|
log.info("创建链接..."); |
|
|
final Session session = DbUtil.getSession(DbUtil.url, DbUtil.usr, DbUtil.pwd); |
|
|
final Session session = DbUtil.getSession(DbUtil.url, DbUtil.usr, DbUtil.pwd, DbUtil.drive); |
|
|
try { |
|
|
try { |
|
|
log.info("执行 预置 SQL 脚本..."); |
|
|
log.info("执行 预置 SQL 脚本..."); |
|
|
for (String s : sql) { |
|
|
for (String sql : sqls) { |
|
|
session.execute(s); |
|
|
log.debug(sql); |
|
|
|
|
|
session.execute(sql); |
|
|
} |
|
|
} |
|
|
log.info("执行 清洗数据中特殊字符串 脚本..."); |
|
|
log.info("执行 清洗数据中特殊字符串 脚本..."); |
|
|
|
|
|
String sql; |
|
|
for (String lj : DbUtil.RUBBISH) { |
|
|
for (String lj : DbUtil.RUBBISH) { |
|
|
for (TabColObj tab : tabColObjs) { |
|
|
for (TabColObj tab : tabColObjs) { |
|
|
session.execute("update ? set ?=replace(?, '?', '') where ? is not null", |
|
|
sql = String.format("update %s set %s=replace(%s, '%s', '') where %s is not null", |
|
|
tab.getTab(), tab.getCol(), tab.getCol(), lj, tab.getCol()); |
|
|
tab.getTab(), tab.getCol(), tab.getCol(), lj, tab.getCol()); |
|
|
|
|
|
log.debug(sql); |
|
|
|
|
|
session.execute(sql); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
retBool = true; |
|
|
retBool = true; |
|
@ -150,15 +177,25 @@ public class WindowsTomcatMysql extends Computer implements Database, Middleware |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
|
* 设置中间件参数 :注意参数的个数和位置 |
|
|
|
|
|
* @param size 顺序为 permSize, maxPermSize, xms, xmx |
|
|
|
|
|
* @return |
|
|
|
|
|
* @throws Exception |
|
|
|
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public boolean setMwSize(int permSize, int maxPermSize, int xms, int xmx) throws Exception { |
|
|
public boolean setMwSize(int ...size) throws Exception { |
|
|
|
|
|
if(size == null || size.length!=4){ |
|
|
|
|
|
log.error("请检测参数是否正确..."); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
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){ |
|
|
ws.stopService(); |
|
|
ws.stopService(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(WinCommandUtil.RegisterUtil.registerJava(AppCfg.HZB, permSize, maxPermSize, xms, xmx)){ |
|
|
if(WinCommandUtil.RegisterUtil.registerJava(AppCfg.HZB, size[0], size[1], size[2], size[3])){ |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|