use of org.apache.derby.iapi.store.access.AccessFactory in project derby by apache.
the class FileContainer method createInfoFromProp.
/**
* Set container properties from the passed in createArgs.
* The following container properties are set:
*
* pageSize
* spareSpace
* minimumRecordSize
* isReusableRecordId
* initialPages
*
* RESOLVE - in the future setting parameters should be overridable
* by sub-class, e.g. one implementation of Container may require a
* minimum page size of 4k.
*/
private void createInfoFromProp(Properties createArgs) throws StandardException {
// Need a TransactionController to get database/service wide properties.
AccessFactory af = (AccessFactory) getServiceModule(dataFactory, AccessFactory.MODULE);
// RESOLVE: sku defectid 2014
TransactionController tc = (af == null) ? null : af.getTransaction(getContextService().getCurrentContextManager());
pageSize = PropertyUtil.getServiceInt(tc, createArgs, Property.PAGE_SIZE_PARAMETER, Limits.DB2_MIN_PAGE_SIZE, Limits.DB2_MAX_PAGE_SIZE, RawStoreFactory.PAGE_SIZE_DEFAULT);
// default if bad value given.
if ((pageSize != 4096) && (pageSize != 8192) && (pageSize != 16384) && (pageSize != 32768)) {
pageSize = RawStoreFactory.PAGE_SIZE_DEFAULT;
}
spareSpace = PropertyUtil.getServiceInt(tc, createArgs, RawStoreFactory.PAGE_RESERVED_SPACE_PARAMETER, 0, 100, 20);
PreAllocSize = PropertyUtil.getServiceInt(tc, createArgs, RawStoreFactory.PRE_ALLOCATE_PAGE, MIN_PRE_ALLOC_SIZE, MAX_PRE_ALLOC_SIZE, DEFAULT_PRE_ALLOC_SIZE);
// to be larger than pageSize, when long rows are supported.
if (createArgs == null) {
// if the createArgs is null, then the following method call
// will get the system properties from the appropriete places.
// we want to make sure minimumRecrodSize is set to at least
// the default value MINIMUM_RECORD_SIZE_DEFAULT (12)
// as set in rawStoreFactory.
minimumRecordSize = PropertyUtil.getServiceInt(tc, RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER, // this is different from the next call
RawStoreFactory.MINIMUM_RECORD_SIZE_DEFAULT, // reserving 100 bytes for record/field headers
(pageSize * (1 - spareSpace / 100) - 100), RawStoreFactory.MINIMUM_RECORD_SIZE_DEFAULT);
} else {
// if the createArgs is not null, then it has already been set
// by upper layer or create statement, then, we allow the minimum
// value of this to be MINIMUM_RECORD_SIZE_MINIMUM (1).
minimumRecordSize = PropertyUtil.getServiceInt(tc, createArgs, RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER, // this is different from the last call
RawStoreFactory.MINIMUM_RECORD_SIZE_MINIMUM, // reserving 100 bytes for record/field headers
(pageSize * (1 - spareSpace / 100) - 100), RawStoreFactory.MINIMUM_RECORD_SIZE_DEFAULT);
}
// if container is to be created with a large number of pages
if (createArgs != null) {
String reusableRecordIdParameter = createArgs.getProperty(RawStoreFactory.PAGE_REUSABLE_RECORD_ID);
if (reusableRecordIdParameter != null) {
Boolean reusableRecordId = Boolean.parseBoolean(reusableRecordIdParameter);
setReusableRecordIdState(reusableRecordId.booleanValue());
}
String containerInitialPageParameter = createArgs.getProperty(RawStoreFactory.CONTAINER_INITIAL_PAGES);
if (containerInitialPageParameter != null) {
initialPages = Short.parseShort(containerInitialPageParameter);
if (initialPages > 1) {
if (initialPages > RawStoreFactory.MAX_CONTAINER_INITIAL_PAGES)
initialPages = RawStoreFactory.MAX_CONTAINER_INITIAL_PAGES;
}
}
}
}
use of org.apache.derby.iapi.store.access.AccessFactory in project derby by apache.
the class LogToFile method disableLogArchiveMode.
// disable the log archive mode
public void disableLogArchiveMode() throws StandardException {
AccessFactory af = (AccessFactory) getServiceModule(this, AccessFactory.MODULE);
if (af != null) {
TransactionController tc = null;
tc = af.getTransaction(getContextService().getCurrentContextManager());
tc.setProperty(Property.LOG_ARCHIVE_MODE, "false", true);
}
logArchived = false;
}
use of org.apache.derby.iapi.store.access.AccessFactory in project derby by apache.
the class SequenceUpdater method updateCurrentValueOnDisk.
// /////////////////////////////////////////////////////////////////////////////////
//
// DISK WRITING MINIONS
//
// /////////////////////////////////////////////////////////////////////////////////
/**
* <p>
* Update the value on disk. Does its work in a subtransaction of the user's
* execution transaction. If that fails, raises a TOO MUCH CONTENTION exception.
* </p>
*
* @return Returns true if the value was successfully updated, false if we lost a race with another session.
*/
public synchronized boolean updateCurrentValueOnDisk(Long oldValue, Long newValue) throws StandardException {
LanguageConnectionContext lcc = getLCC();
//
if (lcc == null) {
if (SanityManager.DEBUG) {
SanityManager.ASSERT(oldValue == null, "We should be flushing unused sequence values here.");
}
ContextService csf = getContextService();
ContextManager cm = csf.getCurrentContextManager();
AccessFactory af = _dd.af;
TransactionController dummyTransaction = af.getTransaction(cm);
boolean retval = updateCurrentValueOnDisk(dummyTransaction, oldValue, newValue, false);
dummyTransaction.commit();
dummyTransaction.destroy();
return retval;
}
TransactionController executionTransaction = lcc.getTransactionExecute();
TransactionController nestedTransaction = executionTransaction.startNestedUserTransaction(false, true);
if (nestedTransaction != null) {
boolean retval = false;
boolean escalateToParentTransaction = false;
try {
retval = updateCurrentValueOnDisk(nestedTransaction, oldValue, newValue, false);
} catch (StandardException se) {
if (!se.isLockTimeout()) {
if (se.isSelfDeadlock()) {
// We're blocked by a lock held by our parent transaction.
// Escalate into the parent transaction now. See DERBY-6554.
escalateToParentTransaction = true;
} else {
Monitor.logThrowable(se);
throw se;
}
}
} finally {
// DERBY-5494, if this commit does not flush log then an
// unorderly shutdown could lose the update. Do not use
// commitNoSync(), and store needs to flush user nested update
// transaction commits by default.
nestedTransaction.commit();
nestedTransaction.destroy();
if (escalateToParentTransaction) {
retval = updateCurrentValueOnDisk(executionTransaction, oldValue, newValue, false);
}
return retval;
}
}
throw tooMuchContentionException();
}
use of org.apache.derby.iapi.store.access.AccessFactory in project derby by apache.
the class CacheLock method bootPasswordChange.
private boolean bootPasswordChange(TransactionController tc, String key, Serializable value) throws StandardException {
// boot password in clear text
if (key.equals(Attribute.BOOT_PASSWORD)) {
// The user is trying to change the secret key.
// The secret key is never stored in clear text, but we
// store the encrypted form in the services.properties
// file. Swap the secret key with the encrypted form and
// put that in the services.properties file.
AccessFactory af = ((TransactionManager) tc).getAccessManager();
RawStoreFactory rsf = (RawStoreFactory) findServiceModule(af, RawStoreFactory.MODULE);
// remove secret key from properties list if possible
serviceProperties.remove(Attribute.BOOT_PASSWORD);
value = rsf.changeBootPassword(serviceProperties, value);
serviceProperties.put(RawStoreFactory.ENCRYPTED_KEY, value);
return true;
} else {
return false;
}
}
Aggregations