1 21 22 package org.apache.derbyTesting.functionTests.util; 23 24 import org.apache.derby.iapi.error.StandardException; 25 26 import org.apache.derby.iapi.sql.dictionary.DataDictionaryContext; 27 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 28 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor; 29 import org.apache.derby.iapi.sql.dictionary.TableDescriptor; 30 import org.apache.derby.iapi.sql.dictionary.ColumnDescriptor; 31 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor; 32 33 import org.apache.derby.iapi.sql.depend.DependencyManager; 34 35 import org.apache.derby.iapi.sql.execute.ExecutionContext; 36 37 import org.apache.derby.iapi.types.DataValueFactory; 38 39 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext; 40 41 import org.apache.derby.iapi.store.access.TransactionController; 42 import org.apache.derby.iapi.types.RowLocation; 43 import org.apache.derby.iapi.store.access.ScanController; 44 import org.apache.derby.iapi.store.access.ConglomerateController; 45 46 import org.apache.derby.iapi.services.context.ContextService; 47 48 import org.apache.derby.iapi.services.io.FormatableBitSet; 49 50 54 public class ConsistencyChecker 55 { 56 57 71 public static String runConsistencyChecker() throws StandardException, java.sql.SQLException 72 { 73 return countOpens() + countDependencies(); 74 } 75 76 86 public static String countOpens() throws StandardException 87 { 88 int numOpens = 0; 89 LanguageConnectionContext lcc; 90 String output = "No open scans, etc.\n"; 91 TransactionController tc; 92 93 lcc = (LanguageConnectionContext) 94 ContextService.getContext(LanguageConnectionContext.CONTEXT_ID); 95 tc = lcc.getTransactionExecute(); 96 97 numOpens = tc.countOpens(TransactionController.OPEN_TOTAL); 98 99 if (numOpens > 0) 100 { 101 output = numOpens + " conglomerates/scans/sorts found open\n"; 102 103 } 104 105 return output; 106 } 107 108 120 public static String countDependencies() throws StandardException, java.sql.SQLException 121 { 122 int numDependencies = 0; 123 DataDictionary dd; 124 DataDictionaryContext ddc; 125 DependencyManager dm; 126 StringBuffer debugBuf = new StringBuffer (); 127 128 ddc = (DataDictionaryContext) 129 (ContextService.getContext(DataDictionaryContext.CONTEXT_ID)); 130 131 dd = ddc.getDataDictionary(); 132 dm = dd.getDependencyManager(); 133 134 numDependencies = dm.countDependencies(); 135 136 if (numDependencies > 0) 137 { 138 debugBuf.append(numDependencies + " dependencies found"); 139 } 140 else 141 { 142 debugBuf.append("No outstanding dependencies.\n"); 143 } 144 145 return debugBuf.toString(); 146 } 147 } 148 | Popular Tags |