📄 ramaccessmanager.java
字号:
cm, AccessFactoryGlobals.RAMXACT_CONTEXT_ID, xa_tc, false /* abortAll */); // RESOLVE - an XA transaction can only commit once so, if we // acquire readlocks. if (xactProperties != null) { rawtran.setup(xa_tc); // HACK - special support has been added to the commitNoSync // of a global xact, to allow committing of read only xact, // which will allow subsequent activity on the xact keeping // the same global transaction id. xa_tc.commitNoSync( TransactionController.RELEASE_LOCKS | TransactionController.READONLY_TRANSACTION_INITIALIZATION); } rawtran.setDefaultLockingPolicy(system_default_locking_policy); // HACK - special support has been added to the commitNoSync // of a global xact, to allow committing of read only xact, // which will allow subsequent activity on the xact keeping // the same global transaction id. xa_tc.commitNoSync( TransactionController.RELEASE_LOCKS | TransactionController.READONLY_TRANSACTION_INITIALIZATION); } else { // throw an error. if (SanityManager.DEBUG) SanityManager.THROWASSERT( "RAMTransactionContext found on stack."); } return(xa_tc); } /** * Return the XAResourceManager associated with this AccessFactory. * <p> * Returns an object which can be used to implement the "offline" * 2 phase commit interaction between the accessfactory and outstanding * transaction managers taking care of in-doubt transactions. * * @return The XAResourceManager associated with this accessfactory. * **/ public /* XAResourceManager */ Object getXAResourceManager() throws StandardException { return(rawstore.getXAResourceManager()); } public void registerAccessMethod(MethodFactory factory) { // Put the access method's primary implementation type in // a hash table so we can find it quickly. implhash.put(factory.primaryImplementationType(), factory); // Put the access method's primary format in a hash table // so we can find it quickly. formathash.put(factory.primaryFormat(), factory); } public boolean isReadOnly() { return rawstore.isReadOnly(); } private void addPropertySetNotification(PropertySetCallback who, TransactionController tc) { pf.addPropertySetNotification(who); // set up the initial values by calling the validate and apply methods. // the map methods are not called as they will have been called // at runtime when the user set the property. Dictionary d = new Hashtable(); try { xactProperties.getProperties(tc,d,false/*!stringsOnly*/,false/*!defaultsOnly*/); } catch (StandardException se) { return; } boolean dbOnly = PropertyUtil.isDBOnly(d); who.init(dbOnly, d); } public TransactionInfo[] getTransactionInfo() { return rawstore.getTransactionInfo(); } public void freeze() throws StandardException { rawstore.freeze(); } public void unfreeze() throws StandardException { rawstore.unfreeze(); } public void backup(String backupDir) throws StandardException { rawstore.backup(backupDir); } public void backup(File backupDir) throws StandardException { rawstore.backup(backupDir); } public void backupAndEnableLogArchiveMode(String backupDir, boolean deleteOnlineArchivedLogFiles) throws StandardException { rawstore.backupAndEnableLogArchiveMode(backupDir, deleteOnlineArchivedLogFiles); } public void backupAndEnableLogArchiveMode(File backupDir, boolean deleteOnlineArchivedLogFiles) throws StandardException { rawstore.backupAndEnableLogArchiveMode(backupDir, deleteOnlineArchivedLogFiles); } public void disableLogArchiveMode(boolean deleteOnlineArchivedLogFiles) throws StandardException { rawstore.disableLogArchiveMode(deleteOnlineArchivedLogFiles); } public void checkpoint() throws StandardException { rawstore.checkpoint(); } public void waitForPostCommitToFinishWork() { rawstore.getDaemon().waitUntilQueueIsEmpty(); } /************************************************************************** * Public Methods implementing ModuleControl Interface: ************************************************************************** */ public void boot(boolean create, Properties startParams) throws StandardException { this.serviceProperties = startParams; boot_load_conglom_map(); if (create) { // if we are creating the db, then just start the conglomid's at // 1, and proceed from there. If not create, we delay // initialization of this until the first ddl which needs a new // id. conglom_nextid = 1; } // Access depends on a Raw Store implementations. Load it. // rawstore = (RawStoreFactory) Monitor.bootServiceModule( create, this, RawStoreFactory.MODULE, serviceProperties); // Note: we also boot this module here since we may start cloudscape // system from store access layer, as some of the unit test case, // not from JDBC layer.(See // /protocol/Database/Storage/Access/Interface/T_AccessFactory.java) // If this module has already been booted by the JDBC layer, this will // have no effect at all. Monitor.bootServiceModule( create, this, org.apache.derby.iapi.reference.Module.PropertyFactory, startParams); // Create the in-memory conglomerate directory conglomCacheInit(); // Read in the conglomerate directory from the conglom conglom // Create the conglom conglom from within a separate system xact RAMTransaction tc = (RAMTransaction) getAndNameTransaction( ContextService.getFactory().getCurrentContextManager(), AccessFactoryGlobals.USER_TRANS_NAME); // looking up lock_mode is dependant on access booting, but // some boot routines need lock_mode and // system_default_locking_policy, so during boot do table level // locking and then look up the "right" locking level. int lock_mode = LockingPolicy.MODE_CONTAINER; system_default_locking_policy = tc.getRawStoreXact().newLockingPolicy( lock_mode, TransactionController.ISOLATION_SERIALIZABLE, true); // RESOLVE - code reduction - get rid of this table, and somehow // combine it with the raw store one. table_level_policy = new LockingPolicy[6]; table_level_policy[TransactionController.ISOLATION_NOLOCK] = tc.getRawStoreXact().newLockingPolicy( LockingPolicy.MODE_CONTAINER, TransactionController.ISOLATION_NOLOCK, true); table_level_policy[TransactionController.ISOLATION_READ_UNCOMMITTED] = tc.getRawStoreXact().newLockingPolicy( LockingPolicy.MODE_CONTAINER, TransactionController.ISOLATION_READ_UNCOMMITTED, true); table_level_policy[TransactionController.ISOLATION_READ_COMMITTED] = tc.getRawStoreXact().newLockingPolicy( LockingPolicy.MODE_CONTAINER, TransactionController.ISOLATION_READ_COMMITTED, true); table_level_policy[TransactionController.ISOLATION_READ_COMMITTED_NOHOLDLOCK] = tc.getRawStoreXact().newLockingPolicy( LockingPolicy.MODE_CONTAINER, TransactionController.ISOLATION_READ_COMMITTED_NOHOLDLOCK, true); table_level_policy[TransactionController.ISOLATION_REPEATABLE_READ] = tc.getRawStoreXact().newLockingPolicy( LockingPolicy.MODE_CONTAINER, TransactionController.ISOLATION_REPEATABLE_READ, true); table_level_policy[TransactionController.ISOLATION_SERIALIZABLE] = tc.getRawStoreXact().newLockingPolicy( LockingPolicy.MODE_CONTAINER, TransactionController.ISOLATION_SERIALIZABLE, true); record_level_policy = new LockingPolicy[6]; record_level_policy[TransactionController.ISOLATION_NOLOCK] = tc.getRawStoreXact().newLockingPolicy( LockingPolicy.MODE_RECORD, TransactionController.ISOLATION_NOLOCK, true); record_level_policy[TransactionController.ISOLATION_READ_UNCOMMITTED] = tc.getRawStoreXact().newLockingPolicy( LockingPolicy.MODE_RECORD, TransactionController.ISOLATION_READ_UNCOMMITTED, true); record_level_policy[TransactionController.ISOLATION_READ_COMMITTED] = tc.getRawStoreXact().newLockingPolicy( LockingPolicy.MODE_RECORD, TransactionController.ISOLATION_READ_COMMITTED, true); record_level_policy[TransactionController.ISOLATION_READ_COMMITTED_NOHOLDLOCK] = tc.getRawStoreXact().newLockingPolicy( LockingPolicy.MODE_RECORD, TransactionController.ISOLATION_READ_COMMITTED_NOHOLDLOCK, true); record_level_policy[TransactionController.ISOLATION_REPEATABLE_READ] = tc.getRawStoreXact().newLockingPolicy( LockingPolicy.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ, true); record_level_policy[TransactionController.ISOLATION_SERIALIZABLE] = tc.getRawStoreXact().newLockingPolicy( LockingPolicy.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, true); if (SanityManager.DEBUG) { for (int i = 0; i < TransactionController.ISOLATION_SERIALIZABLE; i++) { SanityManager.ASSERT( table_level_policy[i] != null, "table_level_policy[" + i + "] is null"); SanityManager.ASSERT( record_level_policy[i] != null, "record_level_policy[" + i + "] is null"); } } tc.commit(); // set up the property validation pf = (PropertyFactory) Monitor.findServiceModule( this, org.apache.derby.iapi.reference.Module.PropertyFactory); // set up the transaction properties. On J9, over NFS, runing on a // power PC coprossor, the directories were created fine, but create // db would fail when trying to create this first file in seg0. xactProperties = new PropertyConglomerate(tc, create, startParams, pf); // see if there is any properties that raw store needs to know // about rawstore.getRawStoreProperties(tc); // now that access and raw store are booted, do the property lookup // which may do conglomerate access. bootLookupSystemLockLevel(tc); lock_mode = (getSystemLockLevel() == TransactionController.MODE_TABLE ? LockingPolicy.MODE_CONTAINER : LockingPolicy.MODE_RECORD); system_default_locking_policy = tc.getRawStoreXact().newLockingPolicy( lock_mode, TransactionController.ISOLATION_SERIALIZABLE, true); // set up the callbacl for the lock manager with initialization addPropertySetNotification(getLockFactory(), tc); // make sure user cannot change these properties addPropertySetNotification(this,tc); tc.commit(); tc.destroy(); tc = null; if (SanityManager.DEBUG) { // RESOLVE - (mikem) currently these constants need to be the // same, but for modularity reasons there are 2 sets. Probably // should only be one set. For now just make sure they are the // same value. SanityManager.ASSERT( TransactionController.OPENMODE_USE_UPDATE_LOCKS == ContainerHandle.MODE_USE_UPDATE_LOCKS); SanityManager.ASSERT( TransactionController.OPENMODE_SECONDARY_LOCKED == ContainerHandle.MODE_SECONDARY_LOCKED); SanityManager.ASSERT( TransactionController.OPENMODE_BASEROW_INSERT_LOCKED == ContainerHandle.MODE_BASEROW_INSERT_LOCKED); SanityManager.ASSERT( TransactionController.OPENMODE_FORUPDATE == ContainerHandle.MODE_FORUPDATE); SanityManager.ASSERT( TransactionController.OPENMODE_FOR_LOCK_ONLY == ContainerHandle.MODE_OPEN_FOR_LOCK_ONLY); } } public void stop() { } /* Methods of the PropertySetCallback interface */ // This interface is implemented to ensure the user cannot change the // encryption provider or algorithm. public void init(boolean dbOnly, Dictionary p) { } public boolean validate(String key, Serializable value, Dictionary p) throws StandardException { if (key.equals(Attribute.CRYPTO_ALGORITHM)) { throw StandardException.newException(SQLState.ENCRYPTION_NOCHANGE_ALGORITHM); } if (key.equals(Attribute.CRYPTO_PROVIDER)) { throw StandardException.newException(SQLState.ENCRYPTION_NOCHANGE_PROVIDER); } return true; } public Serviceable apply(String key, Serializable value, Dictionary p) throws StandardException { return null; } public Serializable map(String key, Serializable value, Dictionary p) throws StandardException { return null; } // /////////////////////////////////////////////////////////////// /* ** CacheableFactory interface */ public Cacheable newCacheable(CacheManager cm) { return new CacheableConglomerate(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -