|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.derby.impl.sql.depend.BasicDependencyManager
public class BasicDependencyManager
The dependency manager tracks needs that dependents have of providers.
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
occured.
| Field Summary | |
|---|---|
private DataDictionary |
dd
DataDictionary for this database. |
private java.util.Map |
dependents
Map of in-memory dependencies for Dependents. |
private static ProviderInfo[] |
EMPTY_PROVIDER_INFO
|
private java.util.Map |
providers
Map of in-memory dependencies for Providers. |
| Constructor Summary | |
|---|---|
BasicDependencyManager(DataDictionary dd)
|
|
| Method Summary | |
|---|---|
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 table,
java.lang.Object 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 |
getDependencyDescriptorList(java.util.List storedList,
Provider providerForList)
Replace the DependencyDescriptors in an List with Dependencys. |
private java.util.List |
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 |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final DataDictionary dd
private final java.util.Map dependents
private final java.util.Map providers
private static final ProviderInfo[] EMPTY_PROVIDER_INFO
| Constructor Detail |
|---|
public BasicDependencyManager(DataDictionary dd)
| Method Detail |
|---|
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 DependencyManagerd - the dependentp - the providercm - Current ContextManager
StandardException - thrown if something goes wrong
private 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 fails
private void addInMemoryDependency(Dependent d,
Provider p,
ContextManager cm)
throws StandardException
d - the dependentp - the providercm - context manager
StandardException - 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 provider
StandardException - thrown if something goes wrong
public 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 DependencyManagerp - the provideraction - The action causing the invalidatelcc - The LanguageConnectionContext
StandardException - thrown if unable to make it invalid
private void coreInvalidateFor(Provider p,
int action,
LanguageConnectionContext lcc)
throws StandardException
p - the provideraction - the action causing the invalidationlcc - language connection context
StandardException - if something goes wrong
public 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 DependencyManagerd - the dependentlcc - Compiler state
StandardException - Thrown on failure
public void clearDependencies(LanguageConnectionContext lcc,
Dependent d,
TransactionController tc)
throws StandardException
DependencyManagerThere 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 DependencyManagerlcc - Compiler stated - the dependenttc - transaction controller
StandardException - Thrown on failurepublic void clearInMemoryDependency(Dependency dy)
clearInMemoryDependency in interface DependencyManager
public ProviderInfo[] getPersistentProviderInfos(Dependent dependent)
throws StandardException
DependencyManager
getPersistentProviderInfos in interface DependencyManagerStandardException - Thrown on errorDependencyManager.getPersistentProviderInfos(org.apache.derby.iapi.sql.depend.Dependent)
public ProviderInfo[] getPersistentProviderInfos(ProviderList pl)
throws StandardException
DependencyManager
getPersistentProviderInfos in interface DependencyManagerStandardException - Thrown on errorDependencyManager.getPersistentProviderInfos(org.apache.derby.iapi.sql.depend.Dependent)
public void clearColumnInfoInProviders(ProviderList pl)
throws StandardException
DependencyManager
clearColumnInfoInProviders in interface DependencyManagerpl - provider list
StandardException - 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 DependencyManagercopy_From - the dependent to copy fromcopyTo - the dependent to copy topersistentOnly - only copy persistent dependenciescm - Current ContextManager
StandardException - Thrown on error.
public void copyDependencies(Dependent copy_From,
Dependent copyTo,
boolean persistentOnly,
ContextManager cm,
TransactionController tc)
throws StandardException
DependencyManager
copyDependencies in interface DependencyManagercopy_From - the dependent to copy fromcopyTo - the dependent to copy topersistentOnly - only copy persistent dependenciescm - Current ContextManagertc - Transaction Controller
StandardException - Thrown on error.public java.lang.String getActionString(int action)
getActionString in interface DependencyManageraction - The action
public int countDependencies()
throws StandardException
countDependencies in interface DependencyManagerStandardException - thrown if something goes wrong
private boolean addDependencyToTable(java.util.Map table,
java.lang.Object key,
Dependency dy)
private void clearProviderDependency(UUID p,
Dependency d)
private java.util.List getDependencyDescriptorList(java.util.List 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 ContextManager
private java.util.List getProviders(Dependent d)
throws StandardException
d - the dependent
StandardException - thrown if something goes wrong
private java.util.List getDependents(Provider p)
throws StandardException
p - the provider
StandardException - if something goes wrong
|
Built on Wed 2013-06-12 15:21:56+0000, from revision ??? | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||