⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basecontainerhandle.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		}	}	/*	** Methods of RawContainerHandle - methods are called underneath the log	*/	/**		Get the container status.  		@exception StandardException Standard Cloudscape error policy				@see RawContainerHandle#getContainerStatus	*/	public int getContainerStatus() throws StandardException	{		checkOpen();		return container.getContainerStatus();	}	/**		remove the container		@exception StandardException Standard Cloudscape error policy				@see RawContainerHandle#removeContainer	*/	public void removeContainer(LogInstant instant) throws StandardException	{		checkUpdateOpen();		// This call can only be issued by within rawStore.		// while the container is dropped, no client of raw store		// should be able to access the container (it is 		// exclusively locked).  		// Then as postcommit processing, 		// the container iw 		container.removeContainer(instant, true);	}	/**		@see ContainerHandle#getId	 */	public ContainerKey getId()	{		return identity;	}	/**		@see ContainerHandle#getUniqueId	 */	public Object getUniqueId()	{        return(this);	}	/**		@exception StandardException  Standard cloudscape exception policy		@see RawContainerHandle#dropContainer	*/	public void dropContainer(LogInstant instant, boolean drop)         throws StandardException	{		checkUpdateOpen();		container.dropContainer(instant, drop);	}	/**		@exception StandardException  Standard cloudscape exception policy		@see RawContainerHandle#getContainerVersion	*/	public long getContainerVersion()         throws StandardException	{		checkOpen();		return container.getContainerVersion();	}	/**		Get this page with no check - any page type or status is fine.		Caller must be prepared to handle freed, deallocated,or alloc page		Called by recovery ONLY.		@exception StandardException Cloudscape Standard error policy	*/	public Page getAnyPage(long pageNumber) throws StandardException	{		checkOpen();		return container.getAnyPage(this, pageNumber, true /* wait */);	}	/**		Re-create this page for load tran.  Called by recovery redo ONLY		@exception StandardException Cloudscape Standard error policy	 */	public Page reCreatePageForLoadTran(    int     pageFormat,    long    pageNumber,     long    pageOffset)		 throws StandardException	{		checkUpdateOpen();		return container.reCreatePageForLoadTran(					this, pageFormat, pageNumber, pageOffset);	}	/**		Log all information necessary to recreate the container during a load		tran.		@exception StandardException Standard Cloudscape error policy	 */	public ByteArray logCreateContainerInfo()         throws StandardException	{		checkUpdateOpen();		return container.logCreateContainerInfo();	}		/**		Return a record handle that is initialized to the given page number and        record id.		@exception StandardException Standard cloudscape exception policy.		@param pageNumber   the page number of the RecordHandle.		@param recordId     the record id of the RecordHandle.		@see RecordHandle	*/	public RecordHandle makeRecordHandle(long pageNumber, int recordId)		 throws	StandardException    {        return new RecordId(identity, pageNumber, recordId);    }	/*	**	Methods of Observer	*/	/**		Called when the transaction is about to complete.		@see Observer#update	*/	public void update(Observable obj, Object arg)     {		if (SanityManager.DEBUG)         {			if (arg == null)				SanityManager.THROWASSERT("still on observr list " + this);		}		// already been removed from the list		if (xact == null)         {			return;		}		if (SanityManager.DEBUG)         {			// just check reference equality			if (obj != xact)            {				SanityManager.THROWASSERT(                    "Observable passed to update is incorrect expected " +                     xact + " got " + obj);            }		}		// close on a commit, abort or drop of this container.		if (arg.equals(RawTransaction.COMMIT) ||             arg.equals(RawTransaction.ABORT)  ||             arg.equals(identity))         {			// close the container					close();			return;		}				if (arg.equals(RawTransaction.SAVEPOINT_ROLLBACK))         {			// unlatch any pages but remain open			informObservers();			// remain open			return;		}		// Transaction is notifying us that our container		// has undergone some lock escalation. We re-get		// our table lock which will promote us 		// if possible				if (arg.equals(RawTransaction.LOCK_ESCALATE))         {			// only attempt escalation on RowLocking modes.			if (getLockingPolicy().getMode() != LockingPolicy.MODE_RECORD)				return;			try             {				getLockingPolicy().lockContainer(                    getTransaction(), this, false, forUpdate);			}             catch (StandardException se)             {				xact.setObserverException(se);			}		}	}	/*	** Implementation specific methods, these are public so that they can be     ** called in other packages that are specific implementations of Data, ie.	** a directory at the level	**	** com.ibm.db2j.impl.Database.Storage.RawStore.Data.*	*/	public PageActions getActionSet()     {		return actionsSet;	}		public AllocationActions getAllocationActionSet()     {		return allocActionsSet;	}	/**		Attach me to a container. If this method returns false then		I cannot be used anymore, and any reference to me must be discarded.		@param droppedOK if true, use this container even if it is dropped,		otherwise, return false if container is dropped.  		@param waitForLock if true, wait on lock, otherwise, get lock no wait.		@exception StandardException Standard Cloudscape error policy	*/	public boolean useContainer(    boolean droppedOK,     boolean waitForLock)         throws StandardException     {		if (SanityManager.DEBUG)         {			SanityManager.ASSERT(!active);		}		boolean gotLock = 			getLockingPolicy().lockContainer(                getTransaction(), this, waitForLock, forUpdate);		if (gotLock == false)		{			// this is a lockingPolicy error, if waitForLock should either 			// return true or throw a deadlock exception			if (SanityManager.DEBUG)				SanityManager.ASSERT(waitForLock == false, 					"lockContainer wait returns false");			container = null;            throw StandardException.newException(SQLState.LOCK_TIMEOUT);		}		if ((mode & ContainerHandle.MODE_OPEN_FOR_LOCK_ONLY) == 0)         {			if (SanityManager.DEBUG)             {				SanityManager.ASSERT(container != null);			}			if (!container.use(this, forUpdate, droppedOK))             {                // If we got a lock, but for some reason we can't open the                // table (like it doesn't exist), then call unlockContainer().                // In the normal case it would be called when the container                // handle was closed, but in this case the user is never going                // to get an "open" container handle back.  We can't call                 // close() here as we haven't done all the "open" stuff.                getLockingPolicy().unlockContainer(xact, this);				container = null;				return false;			}			active = true;		}         else         {			// lock only, we only observe the transaction if			// we are performing row level locking.			if (getLockingPolicy().getMode() != LockingPolicy.MODE_RECORD)				return true;		}		// watch transaction so we will close handle just before xact completes.		xact.addObserver(this);		// Add special objects implementing certain behaviour at commit/rollback		if ((mode & (ContainerHandle.MODE_READONLY |                      ContainerHandle.MODE_NO_ACTIONS_ON_COMMIT)) == 0)         {			if ((mode & MODE_TRUNCATE_ON_COMMIT) == MODE_TRUNCATE_ON_COMMIT)             {				xact.addObserver(                    new TruncateOnCommit(identity, true /* always */));			}             else if ((mode & MODE_TRUNCATE_ON_ROLLBACK) ==                                         MODE_TRUNCATE_ON_ROLLBACK)             {				xact.addObserver(                    new TruncateOnCommit(identity, false /* rollbacks only */));			}			if ((mode & MODE_DROP_ON_COMMIT) == MODE_DROP_ON_COMMIT)             {				xact.addObserver(new DropOnCommit(identity));							}			if ((mode & MODE_FLUSH_ON_COMMIT) == MODE_FLUSH_ON_COMMIT)             {				xact.addObserver(new SyncOnCommit(identity));			}		}		return true;	}	/**		Return the RawTransaction I was opened in.	*/	public final RawTransaction getTransaction()     {		return xact;	}	/**		Return my locking policy, may be different from the Transaction's		default locking policy.	*/	public final LockingPolicy getLockingPolicy()     {		if (SanityManager.DEBUG)         {			SanityManager.ASSERT(locking != null);		}		return locking;	}	public final void setLockingPolicy(LockingPolicy newLockingPolicy)     {		locking = newLockingPolicy;	}	/**		Was I opened for updates?        <p>		<BR> MT - thread safe	*/	public final boolean updateOK()     {		return forUpdate;	}	/**		Get the mode I was opened with.	*/	public int getMode()     {		return mode;	}	/**	   The container is about to be modified.	   Loggable actions use this to make sure the container gets cleaned if a	   checkpoint is taken after any log record is sent to the log stream but	   before the container is actually dirtied.		@exception StandardException Standard Cloudscape error policy	 */	public void preDirty(boolean preDirtyOn) throws StandardException     {		checkUpdateOpen();		container.preDirty(preDirtyOn);	}	/**		@see ContainerHandle#isTemporaryContainer		@exception StandardException Standard Cloudscape error policy	 */	public boolean isTemporaryContainer() throws StandardException     {		checkOpen();		return (identity != null && 				identity.getSegmentId() == ContainerHandle.TEMPORARY_SEGMENT);	}	/*	** Implementation specific methods for myself and my sub-classes	*/	protected void checkOpen() throws StandardException     {		if (!active)			throw StandardException.newException(                    SQLState.DATA_CONTAINER_CLOSED);	}    private void checkUpdateOpen() throws StandardException     {		if (!active)        {			throw StandardException.newException(                    SQLState.DATA_CONTAINER_CLOSED);        }		if (!forUpdate)        {			throw StandardException.newException(                    SQLState.DATA_CONTAINER_READ_ONLY);        }	}	protected void informObservers()     {		// notify our observers (Pages) that we are closing,         // or undergoing some state change ...		if (countObservers() != 0)         {			setChanged();			notifyObservers();		}	}    /**    Get information about space used by the container.    **/    public SpaceInfo getSpaceInfo()        throws StandardException    {        return container.getSpaceInfo(this);    }        public String toString()    {        if (SanityManager.DEBUG)        {            String str = new String();            str += "BaseContainerHandle:(" + identity.toString() + ")";            return(str);        }        else        {            return(super.toString());        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -