001: /*
002:
003: Derby - Class org.apache.derby.impl.store.access.RllRAMAccessManager
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.store.access;
023:
024: import org.apache.derby.iapi.services.monitor.Monitor;
025:
026: import org.apache.derby.iapi.error.StandardException;
027:
028: import org.apache.derby.iapi.store.access.AccessFactoryGlobals;
029: import org.apache.derby.iapi.store.access.TransactionController;
030:
031: import org.apache.derby.iapi.store.raw.LockingPolicy;
032:
033: import org.apache.derby.iapi.services.property.PropertyUtil;
034:
035: import java.util.Properties;
036:
037: import org.apache.derby.iapi.reference.Property;
038:
039: /**
040:
041: Implements the row level locking accessmanager.
042:
043: **/
044:
045: public class RllRAMAccessManager extends RAMAccessManager {
046: private int system_lock_level = TransactionController.MODE_RECORD;
047:
048: /**************************************************************************
049: * Constructors for This class:
050: **************************************************************************
051: */
052: public RllRAMAccessManager() {
053: super ();
054: }
055:
056: /**************************************************************************
057: * Private/Protected methods of This class:
058: **************************************************************************
059: */
060:
061: /***************************************************************************
062: ** Concrete methods of RAMAccessManager, interfaces that control locking
063: ** level of the system.
064: ****************************************************************************
065: */
066:
067: /**
068: * Return the locking level of the system.
069: * <p>
070: * This routine controls the lowest level of locking enabled for all locks
071: * for all tables accessed through this accessmanager. The concrete
072: * implementation may set this value always to table level locking for
073: * a client configuration, or it may set it to row level locking for a
074: * server configuration.
075: * <p>
076: * If TransactionController.MODE_RECORD is returned table may either be
077: * locked at table or row locking depending on the type of access expected
078: * (ie. level 3 will require table locking for heap scans.)
079: *
080: * @return TransactionController.MODE_TABLE if only table locking allowed,
081: * else returns TransactionController.MODE_RECORD.
082: **/
083: protected int getSystemLockLevel() {
084: return (system_lock_level);
085: }
086:
087: /**
088: * Query property system to get the System lock level.
089: * <p>
090: * This routine will be called during boot after access has booted far
091: * enough, to allow access to the property conglomerate. This routine
092: * will call the property system and set the value to be returned by
093: * getSystemLockLevel().
094: * <p>
095: *
096: * @exception StandardException Standard exception policy.
097: **/
098: protected void bootLookupSystemLockLevel(TransactionController tc)
099: throws StandardException {
100: // The default for this module is TransactionController.MODE_RECORD,
101: // only change it if the setting is different.
102:
103: if (isReadOnly()
104: || !PropertyUtil.getServiceBoolean(tc,
105: Property.ROW_LOCKING, true)) {
106: system_lock_level = TransactionController.MODE_TABLE;
107: }
108: }
109: }
|