📄 basicdependencymanager.java
字号:
{ synchronized(this) { List deps = (List) dependents.get(dy.getDependent().getObjectID()); // NOTE - this is a NEGATIVE Sanity mode check, in sane mode we continue // to ensure the dependency manager is consistent. if (!SanityManager.DEBUG) { // dependency has already been removed if (deps == null) return; } List provs = (List) providers.get(dy.getProvider().getObjectID()); if (SanityManager.DEBUG) { // if both are null then everything is OK if ((deps != null) || (provs != null)) { // ensure that the Dependency dy is either // in both lists or in neither. Even if dy // is out of the list we can have non-null // deps and provs here because other dependencies // with the the same providers or dependents can exist // int depCount = 0; if (deps != null) { for (int ci = 0; ci < deps.size(); ci++) { if (dy.equals(deps.get(ci))) depCount++; } } int provCount = 0; if (provs != null) { for (int ci = 0; ci < provs.size(); ci++) { if (dy.equals(provs.get(ci))) provCount++; } } if (depCount != provCount) { SanityManager.THROWASSERT("Dependency count mismatch count in deps: " + depCount + ", count in provs " + provCount + ", dy.getDependent().getObjectID() = " + dy.getDependent().getObjectID() + ", dy.getProvider().getObjectID() = " + dy.getProvider().getObjectID()); } } // dependency has already been removed, // matches code that is protected by !DEBUG above if (deps == null) return; } // dependency has already been removed if (provs == null) return; deps.remove(dy); if (deps.size() == 0) dependents.remove(dy.getDependent().getObjectID()); provs.remove(dy); if (provs.size() == 0) providers.remove(dy.getProvider().getObjectID()); } } /** * @see DependencyManager#getAllProviders * * @exception StandardException Thrown on error */// public SList getAllProviders(Dependent dependent)// throws StandardException// {// synchronized(this)// {// SList list = getProviders(dependent);// return list;// }// } /** * @see DependencyManager#getAllProviderInfos * * @exception StandardException Thrown on error *//* public ProviderInfo[] getAllProviderInfos(Dependent dependent) throws StandardException { synchronized(this) { ProviderInfo[] retval; SList list = getProviders(dependent); retval = new ProviderInfo[list.size()]; if (list == null) { return retval; } int piCtr = 0; Enumeration enum = list.elements(); while (enum != null && enum.hasMoreElements()) { Dependency dep = (Dependency) enum.nextElement(); retval[piCtr++] = new BasicProviderInfo( dep.getProvider().getObjectID(), dep.getProvider().getDependableFinder(), dep.getProvider().getObjectName() ); } return retval; } }*/ /** * @see DependencyManager#getPersistentProviderInfos * * @exception StandardException Thrown on error */ public synchronized ProviderInfo[] getPersistentProviderInfos(Dependent dependent) throws StandardException { List list = getProviders(dependent); if (list == null) { return EMPTY_PROVIDER_INFO; } java.util.ArrayList pih = new java.util.ArrayList(); for (ListIterator depsIterator = list.listIterator(); depsIterator.hasNext(); ) { Dependency dep = (Dependency) depsIterator.next(); if (dep.getProvider().isPersistent()) { pih.add(new BasicProviderInfo( dep.getProvider().getObjectID(), dep.getProvider().getDependableFinder(), dep.getProvider().getObjectName() )); } } return (ProviderInfo[]) pih.toArray(EMPTY_PROVIDER_INFO); } private static final ProviderInfo[] EMPTY_PROVIDER_INFO = new ProviderInfo[0]; /** * @see DependencyManager#getPersistentProviderInfos * * @exception StandardException Thrown on error */ public ProviderInfo[] getPersistentProviderInfos(ProviderList pl) throws StandardException { Enumeration e = pl.elements(); int numProviders = 0; ProviderInfo[] retval; /* ** We make 2 passes - the first to count the number of persistent ** providers and the second to populate the array of ProviderInfos. */ while (e != null && e.hasMoreElements()) { Provider prov = (Provider) e.nextElement(); if (prov.isPersistent()) { numProviders++; } } e = pl.elements(); retval = new ProviderInfo[numProviders]; int piCtr = 0; while (e != null && e.hasMoreElements()) { Provider prov = (Provider) e.nextElement(); if (prov.isPersistent()) { retval[piCtr++] = new BasicProviderInfo( prov.getObjectID(), prov.getDependableFinder(), prov.getObjectName() ); } } return retval; } /** * @see DependencyManager#clearColumnInfoInProviders * * @param pl provider list * @return void * * @exception StandardException Thrown on error */ public void clearColumnInfoInProviders(ProviderList pl) throws StandardException { Enumeration e = pl.elements(); while (e.hasMoreElements()) { Provider pro = (Provider) e.nextElement(); if (pro instanceof TableDescriptor) ((TableDescriptor) pro).setReferencedColumnMap(null); } } /** * Copy dependencies from one dependent to another. * * @param copy_From the dependent to copy from * @param copyTo the dependent to copy to * @param persistentOnly only copy persistent dependencies * @param cm Current ContextManager * * @exception StandardException Thrown on error. */ public synchronized void copyDependencies( Dependent copy_From, Dependent copyTo, boolean persistentOnly, ContextManager cm) throws StandardException { List list = getProviders(copy_From); if (list == null) return; for (ListIterator depsIterator = list.listIterator(); depsIterator.hasNext(); ) { Provider provider = ((Dependency) depsIterator.next()).getProvider(); if (!persistentOnly || provider.isPersistent()) { this.addDependency(copyTo, provider, cm); } } } /** * Returns a string representation of the SQL action, hence no * need to internationalize, which is causing the invokation * of the Dependency Manager. * * @param int The action * * @return String The String representation */ public String getActionString(int action) { switch (action) { case ALTER_TABLE: return "ALTER TABLE"; case RENAME: //for rename table and column return "RENAME"; case RENAME_INDEX: return "RENAME INDEX"; case COMPILE_FAILED: return "COMPILE FAILED"; case DROP_TABLE: return "DROP TABLE"; case DROP_INDEX: return "DROP INDEX"; case DROP_VIEW: return "DROP VIEW"; case CREATE_INDEX: return "CREATE INDEX"; case ROLLBACK: return "ROLLBACK"; case CHANGED_CURSOR: return "CHANGED CURSOR"; case CREATE_CONSTRAINT: return "CREATE CONSTRAINT"; case DROP_CONSTRAINT: return "DROP CONSTRAINT"; case DROP_METHOD_ALIAS: return "DROP ROUTINE"; case PREPARED_STATEMENT_RELEASE: return "PREPARED STATEMENT RELEASE"; case DROP_SPS: return "DROP STORED PREPARED STATEMENT"; case USER_RECOMPILE_REQUEST: return "USER REQUESTED INVALIDATION"; case BULK_INSERT: return "BULK INSERT"; case CREATE_VIEW: return "CREATE_VIEW"; case DROP_JAR: return "DROP_JAR"; case REPLACE_JAR: return "REPLACE_JAR"; case SET_CONSTRAINTS_ENABLE: return "SET_CONSTRAINTS_ENABLE"; case SET_CONSTRAINTS_DISABLE: return "SET_CONSTRAINTS_DISABLE"; case INTERNAL_RECOMPILE_REQUEST: return "INTERNAL RECOMPILE REQUEST"; case CREATE_TRIGGER: return "CREATE TRIGGER"; case DROP_TRIGGER: return "DROP TRIGGER"; case SET_TRIGGERS_ENABLE: return "SET TRIGGERS ENABLED"; case SET_TRIGGERS_DISABLE: return "SET TRIGGERS DISABLED"; case MODIFY_COLUMN_DEFAULT: return "MODIFY COLUMN DEFAULT"; case COMPRESS_TABLE: return "COMPRESS TABLE"; case DROP_TABLE_CASCADE: return "DROP TABLE CASCADE"; case DROP_VIEW_CASCADE: return "DROP VIEW CASCADE"; case DROP_COLUMN: return "DROP COLUMN"; case DROP_COLUMN_CASCADE: return "DROP COLUMN CASCADE"; case DROP_STATISTICS: return "DROP STATISTICS"; case UPDATE_STATISTICS: return "UPDATE STATISTICS"; case TRUNCATE_TABLE: return "TRUNCATE TABLE"; case DROP_SYNONYM: return "DROP SYNONYM"; default: if (SanityManager.DEBUG) { SanityManager.THROWASSERT("getActionString() passed an invalid value (" + action + ")"); } // NOTE: This is not internationalized because we should never // reach here. return "UNKNOWN"; } } /** * Count the number of active dependencies, both stored and in memory, * in the system. * * @return int The number of active dependencies in the system. @exception StandardException thrown if something goes wrong */ public int countDependencies() throws StandardException { synchronized(this) { int numDependencies = 0; Enumeration deps = dependents.elements(); Enumeration provs = providers.elements(); List storedDeps = getDataDictionary(). getAllDependencyDescriptorsList(); /* Count the in memory dependencies */ while (deps.hasMoreElements()) { numDependencies += ((List) deps.nextElement()).size(); } while (provs.hasMoreElements()) { numDependencies += ((List) provs.nextElement()).size(); } /* Add in the stored dependencies */ numDependencies += storedDeps.size(); return numDependencies; } } /** * Dump out debugging info on all of the dependencies currently * within the system. * * @return String Debugging info on the dependencies. * (null if SanityManger.DEBUG is false) * @exception StandardException thrown if something goes wrong * @exception java.sql.SQLException thrown if something goes wrong */ public String dumpDependencies() throws StandardException, java.sql.SQLException { synchronized(this) { boolean foundInMemory = false; boolean foundStored = false; StringBuffer debugBuf = new StringBuffer(); if (SanityManager.DEBUG) { Enumeration deps = dependents.keys(); UUID[] depKeys = new UUID[dependents.size()]; /* Record the in memory dependencies */ for (int i = 0; deps.hasMoreElements(); i++) { /* ** Get all the keys and sort them, so that they will always
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -