/SMBMySQLOA/src/com/smb/MMUtil/testcase/MapCompare.java

http://mysqloa.googlecode.com/ · Java · 148 lines · 96 code · 41 blank · 11 comment · 10 complexity · ac7d055d09d3b8393ad373aa4f008a4c MD5 · raw file

  1. /**
  2. *
  3. */
  4. package com.smb.MMUtil.testcase;
  5. import java.util.ArrayList;
  6. import java.util.List;
  7. import org.junit.Test;
  8. import com.smb.MMUtil.handler.IMySQLManagerJdbcUtilTools;
  9. import com.smb.MMUtil.handler.MySQLManagerJdbcUtilTools;
  10. import com.smb.MMUtil.handler.base.JDBCUtilBaseTools;
  11. import com.smb.MMUtil.handler.xml.ReadMySQLConfigXMLFile;
  12. import com.smb.MMUtil.pojo.MySQLDeepOptimize;
  13. import com.smb.MMUtil.pojo.MySQLVariableDescription;
  14. import com.smb.MMUtil.pojo.MySQLVariableObject;
  15. import com.smb.MMUtil.pojo.ReplicationStatusPojo;
  16. /**
  17. * @author huangyi
  18. *
  19. */
  20. public class MapCompare {
  21. private static ReadMySQLConfigXMLFile DescriptionXMLFile= new ReadMySQLConfigXMLFile();
  22. @Test
  23. public void ReadMySQLConfigXMLFile() throws Exception{
  24. DescriptionXMLFile.getMySQLRecentHost();
  25. }
  26. // @Test
  27. @SuppressWarnings("unchecked")
  28. public void DeepOptimizeCaseFinishAction () throws Exception{
  29. ReadMySQLConfigXMLFile read= new ReadMySQLConfigXMLFile();
  30. String optimizeIDs="1,,2,24";
  31. List list = new ArrayList ();
  32. String optimizeID[]=optimizeIDs.split(",");
  33. for (int i=0;i<optimizeID.length ;i++){
  34. list.add( optimizeID[i] );
  35. }
  36. List <MySQLDeepOptimize> Optimizelist=read.getMySQLDeepOptimizeCase();
  37. List deepOptimizeCommand= new ArrayList ();
  38. for (int i=0;i<Optimizelist.size() ;i++){
  39. for (int h=0;h<list.size() ;h++){
  40. if ( list.get(h).equals( Optimizelist.get(i).getQuestionID() ) ){
  41. deepOptimizeCommand.add( Optimizelist.get(i) );
  42. }
  43. }
  44. }
  45. System.out.println ( deepOptimizeCommand );
  46. }
  47. // @Test
  48. public void showMasterReplicationStatus () throws Exception{
  49. JDBCUtilBaseTools orm= new JDBCUtilBaseTools("192.168.12.212",null,"root","123456");
  50. IMySQLManagerJdbcUtilTools mmu= new MySQLManagerJdbcUtilTools(orm);
  51. ReplicationStatusPojo list= mmu.showMasterReplicationStatus();
  52. System.out.println (list.getMasterBinlog_Ignore_DB() );
  53. }
  54. // @Test
  55. @SuppressWarnings("unchecked")
  56. public void fileAndshowTestCase () throws Exception{
  57. JDBCUtilBaseTools orm= new JDBCUtilBaseTools("192.168.12.212",null,"root","123456");
  58. IMySQLManagerJdbcUtilTools mmu= new MySQLManagerJdbcUtilTools(orm);
  59. List <MySQLVariableObject> listS=(List<MySQLVariableObject>) mmu.showVariblesCommand();
  60. List <MySQLVariableDescription> listF=DescriptionXMLFile.getMySQLVariableDescription();
  61. for (int i=0;i<listS.size();i++){
  62. for (int h=0;h<listF.size();h++){
  63. if( listS.get(i).getVariable_name().equals(listF.get(h).getVariable_name() ) ){
  64. System.out.print (listS.get(i).getVariable_name()+" " );
  65. System.out.print (listS.get(i).getValue()+" " );
  66. System.out.print (listF.get(h).getDescription() +" \n " );
  67. }
  68. }
  69. }
  70. System.out.print (listS.size()+" \n " ); System.out.print (listF.size()+" \n " );
  71. List ll=mmu.showProcesslistCommand();
  72. System.out.print (ll+" \n " );
  73. }
  74. // @Test
  75. @SuppressWarnings("unchecked")
  76. public void runTestCase() throws Exception{
  77. List<MySQLVariableObject> list1= new ArrayList ();
  78. MySQLVariableObject v1= new MySQLVariableObject();
  79. v1.setValue("1"); v1.setVariable_name("innodb_lock_wait_timeout");
  80. MySQLVariableObject v2= new MySQLVariableObject();
  81. v2.setValue("1"); v2.setVariable_name("table_lock_wait_timeout");
  82. MySQLVariableObject v3= new MySQLVariableObject();
  83. v3.setValue("2"); v3.setVariable_name("sql_mode");
  84. list1.add(v2);
  85. list1.add(v1);
  86. list1.add(v3);
  87. List<MySQLVariableDescription> list2= new ArrayList ();
  88. MySQLVariableDescription d1= new MySQLVariableDescription();
  89. d1.setDescription("在回�?rooled back)之前,InnoDB 事务将等待超时的时间(单位 �?。InnoDB 会自动检查自身在锁定表与事务回滚时的事务死锁。如果使�?LOCK TABLES 命令,或在同�?��事务中使用其它事务安全型表处理器(transaction safe table handlers than InnoDB),那么可能会发生�?�� InnoDB 无法注意到的死锁。在这种情况下超时将用来解决这个问题。这个参数的默认值为 50 秒�?�?my.cnf 中以数字格式设置�?MySQL可以自动地监测行锁导致的死锁并进行相应的处理,但是对于表锁导致的死锁不能自动的监测,�?��该参数主要被用于在出现类似情况的时�?等待指定的时间后回滚。系统默认�?�?0秒,用户可以根据应用的需要进行调整�?");
  90. d1.setVariable_name("innodb_lock_wait_timeout");
  91. MySQLVariableDescription d2= new MySQLVariableDescription();
  92. d2.setDescription("表示在Mysql服务器锁表的时�?�?��等待的时间长度�?");
  93. d2.setVariable_name("table_lock_wait_timeout");
  94. list2.add(d1); list2.add(d2);
  95. IMySQLManagerJdbcUtilTools mmu= new MySQLManagerJdbcUtilTools(null);
  96. List <MySQLVariableObject> list=mmu.showVariblesCommand();
  97. for (int i=0;i<list.size();i++){
  98. for (int h=0;h<list2.size();h++){
  99. if( list.get(i).getVariable_name().equals(list2.get(h).getVariable_name() ) ){
  100. System.out.print (list.get(i).getVariable_name()+" " );
  101. System.out.print (list.get(i).getValue()+" " );
  102. System.out.print (list2.get(h).getDescription() +" \n " );
  103. }
  104. }
  105. }
  106. }
  107. }