DependencyManager
public class BasicDependencyManager extends java.lang.Object implements DependencyManager
A dependency can be either persistent or non-persistent. Persistent dependencies are stored in the data dictionary, and non-persistent dependencies are stored within the dependency manager itself (in memory).
Synchronization: The need for synchronization is different depending
on whether the dependency is an in-memory dependency or a stored dependency.
When accessing and modifying in-memory dependencies, Java synchronization
must be used (specifically, we synchronize on this
). When accessing
and modifying stored dependencies, which are stored in the data dictionary,
we expect that the locking protocols will provide the synchronization needed.
Note that stored dependencies should not be accessed while holding the
monitor of this
, as this may result in deadlocks. So far the need
for synchronization across both in-memory and stored dependencies hasn't
occurred.
Modifier and Type | Field | Description |
---|---|---|
private DataDictionary |
dd |
DataDictionary for this database.
|
private java.util.Map<UUID,java.util.List<Dependency>> |
dependents |
Map of in-memory dependencies for Dependents.
|
private static ProviderInfo[] |
EMPTY_PROVIDER_INFO |
|
private java.util.Map<UUID,java.util.List<Dependency>> |
providers |
Map of in-memory dependencies for Providers.
|
ALTER_TABLE, BULK_INSERT, CHANGED_CURSOR, COMPILE_FAILED, COMPRESS_TABLE, CREATE_CONSTRAINT, CREATE_INDEX, CREATE_TRIGGER, CREATE_VIEW, DROP_AGGREGATE, DROP_COLUMN, DROP_COLUMN_RESTRICT, DROP_CONSTRAINT, DROP_INDEX, DROP_JAR, DROP_METHOD_ALIAS, DROP_SCHEMA, DROP_SEQUENCE, DROP_SPS, DROP_STATISTICS, DROP_SYNONYM, DROP_TABLE, DROP_TRIGGER, DROP_UDT, DROP_VIEW, INTERNAL_RECOMPILE_REQUEST, MAX_ACTION_CODE, MODIFY_COLUMN_DEFAULT, PREPARED_STATEMENT_RELEASE, RECHECK_PRIVILEGES, RENAME, RENAME_INDEX, REPLACE_JAR, REVOKE_PRIVILEGE, REVOKE_PRIVILEGE_RESTRICT, REVOKE_ROLE, ROLLBACK, SET_CONSTRAINTS_DISABLE, SET_CONSTRAINTS_ENABLE, SET_TRIGGERS_DISABLE, SET_TRIGGERS_ENABLE, TRUNCATE_TABLE, UPDATE_STATISTICS, USER_RECOMPILE_REQUEST
Constructor | Description |
---|---|
BasicDependencyManager(DataDictionary dd) |
Modifier and Type | Method | Description |
---|---|---|
void |
addDependency(Dependent d,
Provider p,
ContextManager cm) |
adds a dependency from the dependent on the provider.
|
private void |
addDependency(Dependent d,
Provider p,
ContextManager cm,
TransactionController tc) |
Adds the dependency to the data dictionary or the in-memory dependency
map.
|
private boolean |
addDependencyToTable(java.util.Map<UUID,java.util.List<Dependency>> table,
UUID key,
Dependency dy) |
Add a new dependency to the specified table if it does not
already exist in that table.
|
private void |
addInMemoryDependency(Dependent d,
Provider p,
ContextManager cm) |
Adds the dependency as an in-memory dependency.
|
private void |
addStoredDependency(Dependent d,
Provider p,
ContextManager cm,
TransactionController tc) |
Adds the dependency as a stored dependency.
|
void |
clearColumnInfoInProviders(ProviderList pl) |
Clear the in memory column bit map information in any table descriptor
provider in a provider list.
|
void |
clearDependencies(LanguageConnectionContext lcc,
Dependent d) |
Erases all of the dependencies the dependent has, be they
valid or invalid, of any dependency type.
|
void |
clearDependencies(LanguageConnectionContext lcc,
Dependent d,
TransactionController tc) |
Erases all of the dependencies the dependent has, be they
valid or invalid, of any dependency type.
|
void |
clearInMemoryDependency(Dependency dy) |
Clear the specified in memory dependency.
|
private void |
clearProviderDependency(UUID p,
Dependency d) |
removes a dependency for a given provider. assumes
that the dependent removal is being dealt with elsewhere.
|
void |
copyDependencies(Dependent copy_From,
Dependent copyTo,
boolean persistentOnly,
ContextManager cm) |
Copy dependencies from one dependent to another.
|
void |
copyDependencies(Dependent copy_From,
Dependent copyTo,
boolean persistentOnly,
ContextManager cm,
TransactionController tc) |
Copy dependencies from one dependent to another.
|
private void |
coreInvalidateFor(Provider p,
int action,
LanguageConnectionContext lcc) |
A version of invalidateFor that does not provide synchronization among
invalidators.
|
int |
countDependencies() |
Count the number of active dependencies, both stored and in memory,
in the system.
|
private void |
dropDependency(LanguageConnectionContext lcc,
Dependent d,
Provider p) |
drops a single dependency
|
java.lang.String |
getActionString(int action) |
Returns a string representation of the SQL action, hence no
need to internationalize, which is causing the invokation
of the Dependency Manager.
|
private java.util.List<Dependency> |
getDependencyDescriptorList(java.util.List<DependencyDescriptor> storedList,
Provider providerForList) |
Turn a list of DependencyDescriptors into a list of Dependencies.
|
private java.util.List<Dependency> |
getDependents(Provider p) |
Returns an enumeration of all dependencies that this
provider is supporting for any dependent at all (even
invalid ones).
|
private LanguageConnectionContext |
getLanguageConnectionContext(ContextManager cm) |
Returns the LanguageConnectionContext to use.
|
ProviderInfo[] |
getPersistentProviderInfos(Dependent dependent) |
Get a new array of ProviderInfos representing all the persistent
providers for the given dependent.
|
ProviderInfo[] |
getPersistentProviderInfos(ProviderList pl) |
Get a new array of ProviderInfos representing all the persistent
providers from the given list of providers.
|
private java.util.List<Provider> |
getProviders(Dependent d) |
Returns a list of all providers that this dependent has (even invalid
ones).
|
void |
invalidateFor(Provider p,
int action,
LanguageConnectionContext lcc) |
mark all dependencies on the named provider as invalid.
|
private final DataDictionary dd
private final java.util.Map<UUID,java.util.List<Dependency>> dependents
private final java.util.Map<UUID,java.util.List<Dependency>> providers
private static final ProviderInfo[] EMPTY_PROVIDER_INFO
public BasicDependencyManager(DataDictionary dd)
public void addDependency(Dependent d, Provider p, ContextManager cm) throws StandardException
Implementations of addDependency should be fast -- performing alot of extra actions to add a dependency would be a detriment.
addDependency
in interface DependencyManager
d
- the dependentp
- the providercm
- Current ContextManagerStandardException
- thrown if something goes wrongprivate void addDependency(Dependent d, Provider p, ContextManager cm, TransactionController tc) throws StandardException
The action taken is detmermined by whether the dependent and/or the provider are persistent.
d
- the dependentp
- the providercm
- context managertc
- transaction controller, used to determine if any transactional
operations should be attempted carried out in a nested transaction.
If tc
is null
, the user transaction is used.StandardException
- if adding the dependency failsprivate void addInMemoryDependency(Dependent d, Provider p, ContextManager cm) throws StandardException
d
- the dependentp
- the providercm
- context managerStandardException
- if adding the dependency failsaddStoredDependency(org.apache.derby.iapi.sql.depend.Dependent, org.apache.derby.iapi.sql.depend.Provider, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.store.access.TransactionController)
private void addStoredDependency(Dependent d, Provider p, ContextManager cm, TransactionController tc) throws StandardException
We expect that transactional locking (in the data dictionary) is enough to protect us from concurrent changes when adding stored dependencies. Adding synchronization here and accessing the data dictionary (which is transactional) may cause deadlocks.
d
- the dependentp
- the providercm
- context managertc
- transaction controller (may be null
)StandardException
- if adding the dependency failsaddInMemoryDependency(org.apache.derby.iapi.sql.depend.Dependent, org.apache.derby.iapi.sql.depend.Provider, org.apache.derby.iapi.services.context.ContextManager)
private void dropDependency(LanguageConnectionContext lcc, Dependent d, Provider p) throws StandardException
d
- the dependentp
- the providerStandardException
- thrown if something goes wrongpublic void invalidateFor(Provider p, int action, LanguageConnectionContext lcc) throws StandardException
Implementations of this can take a little time, but are not really expected to recompile things against any changes made to the provider that caused the invalidation. The dependency system makes no guarantees about the state of the provider -- implementations can call this before or after actually changing the provider to its new state.
Implementations should throw StandardException if the invalidation should be disallowed.
invalidateFor
in interface DependencyManager
p
- the provideraction
- The action causing the invalidatelcc
- The LanguageConnectionContextStandardException
- thrown if unable to make it invalidprivate void coreInvalidateFor(Provider p, int action, LanguageConnectionContext lcc) throws StandardException
p
- the provideraction
- the action causing the invalidationlcc
- language connection contextStandardException
- if something goes wrongpublic void clearDependencies(LanguageConnectionContext lcc, Dependent d) throws StandardException
There might be a future want to clear all dependencies for a particular provider, e.g. when destroying the provider. However, at present, they are assumed to stick around and it is the responsibility of the dependent to erase them when revalidating against the new version of the provider.
clearDependencies will delete dependencies if they are stored; the delete is finalized at the next commit.
clearDependencies
in interface DependencyManager
d
- the dependentlcc
- Compiler stateStandardException
- Thrown on failurepublic void clearDependencies(LanguageConnectionContext lcc, Dependent d, TransactionController tc) throws StandardException
DependencyManager
There might be a future want to clear all dependencies for a particular provider, e.g. when destroying the provider. However, at present, they are assumed to stick around and it is the responsibility of the dependent to erase them when revalidating against the new version of the provider.
clearDependencies will delete dependencies if they are stored; the delete is finalized at the next commit.
clearDependencies
in interface DependencyManager
lcc
- Compiler stated
- the dependenttc
- transaction controllerStandardException
- Thrown on failurepublic void clearInMemoryDependency(Dependency dy)
clearInMemoryDependency
in interface DependencyManager
public ProviderInfo[] getPersistentProviderInfos(Dependent dependent) throws StandardException
DependencyManager
getPersistentProviderInfos
in interface DependencyManager
StandardException
- Thrown on errorDependencyManager.getPersistentProviderInfos(org.apache.derby.iapi.sql.depend.Dependent)
public ProviderInfo[] getPersistentProviderInfos(ProviderList pl) throws StandardException
DependencyManager
getPersistentProviderInfos
in interface DependencyManager
StandardException
- Thrown on errorDependencyManager.getPersistentProviderInfos(org.apache.derby.iapi.sql.depend.Dependent)
public void clearColumnInfoInProviders(ProviderList pl) throws StandardException
DependencyManager
clearColumnInfoInProviders
in interface DependencyManager
pl
- provider listStandardException
- Thrown on errorDependencyManager.clearColumnInfoInProviders(org.apache.derby.iapi.sql.depend.ProviderList)
public void copyDependencies(Dependent copy_From, Dependent copyTo, boolean persistentOnly, ContextManager cm) throws StandardException
copyDependencies
in interface DependencyManager
copy_From
- the dependent to copy fromcopyTo
- the dependent to copy topersistentOnly
- only copy persistent dependenciescm
- Current ContextManagerStandardException
- Thrown on error.public void copyDependencies(Dependent copy_From, Dependent copyTo, boolean persistentOnly, ContextManager cm, TransactionController tc) throws StandardException
DependencyManager
copyDependencies
in interface DependencyManager
copy_From
- the dependent to copy fromcopyTo
- the dependent to copy topersistentOnly
- only copy persistent dependenciescm
- Current ContextManagertc
- Transaction ControllerStandardException
- Thrown on error.public java.lang.String getActionString(int action)
getActionString
in interface DependencyManager
action
- The actionpublic int countDependencies() throws StandardException
countDependencies
in interface DependencyManager
StandardException
- thrown if something goes wrongprivate boolean addDependencyToTable(java.util.Map<UUID,java.util.List<Dependency>> table, UUID key, Dependency dy)
private void clearProviderDependency(UUID p, Dependency d)
private java.util.List<Dependency> getDependencyDescriptorList(java.util.List<DependencyDescriptor> storedList, Provider providerForList) throws StandardException
storedList
- The List of DependencyDescriptors representing
stored dependencies.providerForList
- The provider if this list is being created
for a list of dependents. Null otherwise.StandardException
- thrown if something goes wrongprivate LanguageConnectionContext getLanguageConnectionContext(ContextManager cm)
cm
- Current ContextManagerprivate java.util.List<Provider> getProviders(Dependent d) throws StandardException
d
- the dependentStandardException
- thrown if something goes wrongprivate java.util.List<Dependency> getDependents(Provider p) throws StandardException
p
- the providerStandardException
- if something goes wrongApache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.