[jboss-svn-commits] JBL Code SVN: r35068 - in labs/jbosstm/trunk: ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging and 13 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Sep 8 10:23:17 EDT 2010
Author: jhalliday
Date: 2010-09-08 10:23:15 -0400 (Wed, 08 Sep 2010)
New Revision: 35068
Removed:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/ObjectStoreType.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/type/ObjectStoreTypeManager.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/type/ObjectStoreTypeMap.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/ObjectStoreTypeManagerTest.java
Modified:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/CoordinatorEnvironmentBean.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/CoordinatorEnvironmentBeanMBean.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/arjunaI18NLogger.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/arjunaI18NLoggerImpl.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/BaseStore.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/ObjectStore.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/StoreManager.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/PersistenceRecord.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/common/ClassloadingUtility.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/ActionStore.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/CacheStore.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/FileLockingStore.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/FileSystemStore.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/HashedActionStore.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/HashedStore.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/JDBCActionStore.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/JDBCStore.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/LogStore.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/NullActionStore.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/ShadowNoFileLockStore.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/ShadowingStore.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/VolatileStore.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/TypesUnitTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/CachedTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest2.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest2.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest2.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest2.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/ObjectStoreTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/PersistenceTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/RemoveCachedTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/WriteCachedTest.java
labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/lockstore/BasicLockStore.java
labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/lockstore/BasicPersistentLockStore.java
labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockManager.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/PersistenceTest.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/common/JTAEnvironmentBean.java
labs/jbosstm/trunk/ArjunaJTA/tsmx/bin/com/arjuna/ats/tools/objectstorebrowser/rootprovider/InFlightTransactionPseudoStore.java
labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/jacorb/recoverycoordinators/JacOrbRCManager.java
Log:
Refactor ObjectStore config and initialization. JBTM-788
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/CoordinatorEnvironmentBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/CoordinatorEnvironmentBean.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/CoordinatorEnvironmentBean.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -215,30 +215,6 @@
}
/**
- * Returns true if the transaction log should be distinct from the action store.
- *
- * Default: false
- * Equivalent deprecated property: com.arjuna.ats.arjuna.coordinator.transactionLog
- *
- * @return true for separate transaction log, false otherwise.
- */
- public boolean isTransactionLog()
- {
- return transactionLog;
- }
-
- /**
- * Sets if the transaction log should be distinct from the action store.
- *
- * @param transactionLog true for sepatate store, false to disable.
- */
- public void setTransactionLog(boolean transactionLog)
- {
- this.transactionLog = transactionLog;
- }
-
-
- /**
* Returns true if write optimisation protocol should be used for PersistenceRecord.
*
* Default: false
@@ -614,7 +590,7 @@
{
synchronized (this) {
if(checkedActionFactory == null && checkedActionFactoryClassName != null) {
- CheckedActionFactory instance = ClassloadingUtility.loadAndInstantiateClass(CheckedActionFactory.class, checkedActionFactoryClassName);
+ CheckedActionFactory instance = ClassloadingUtility.loadAndInstantiateClass(CheckedActionFactory.class, checkedActionFactoryClassName, null);
checkedActionFactory = instance;
}
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/CoordinatorEnvironmentBeanMBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/CoordinatorEnvironmentBeanMBean.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/CoordinatorEnvironmentBeanMBean.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -39,8 +39,6 @@
boolean isMaintainHeuristics();
- boolean isTransactionLog();
-
boolean isWriteOptimisation();
boolean isReadonlyOptimisation();
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/arjunaI18NLogger.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/arjunaI18NLogger.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/arjunaI18NLogger.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -903,7 +903,7 @@
@Message(id = 12225, value = "FileSystemStore::setupStore - cannot access root of object store: {0}", format = MESSAGE_FORMAT)
@LogMessage(level = WARN)
- public void warn_objectstore_FileSystemStore_1(String arg0);
+ public String get_objectstore_FileSystemStore_1(String arg0);
@Message(id = 12226, value = "FileSystemStore.removeFromCache - no entry for {0}", format = MESSAGE_FORMAT)
@LogMessage(level = WARN)
@@ -1047,9 +1047,9 @@
@Message(id = 12263, value = "No JDBCAccess implementation provided!", format = MESSAGE_FORMAT)
public String get_objectstore_JDBCStore_5();
- @Message(id = 12264, value = "ShadowingStore.commit_state - store invalid!", format = MESSAGE_FORMAT)
- @LogMessage(level = WARN)
- public void warn_objectstore_ShadowingStore_1();
+// @Message(id = 12264, value = "ShadowingStore.commit_state - store invalid!", format = MESSAGE_FORMAT)
+// @LogMessage(level = WARN)
+// public void warn_objectstore_ShadowingStore_1();
@Message(id = 12265, value = "ShadowingStore::remove_state() - state {0} does not exist for type {1}", format = MESSAGE_FORMAT)
@LogMessage(level = WARN)
@@ -1115,9 +1115,9 @@
// @LogMessage(level = WARN)
// public void warn_objectstore_ShadowingStore_5(String arg0);
- @Message(id = 12281, value = "ShadowingStore.read_state - store invalid!", format = MESSAGE_FORMAT)
- @LogMessage(level = WARN)
- public void warn_objectstore_ShadowingStore_6();
+// @Message(id = 12281, value = "ShadowingStore.read_state - store invalid!", format = MESSAGE_FORMAT)
+// @LogMessage(level = WARN)
+// public void warn_objectstore_ShadowingStore_6();
@Message(id = 12282, value = "ShadowingStore::read_state() failed", format = MESSAGE_FORMAT)
@LogMessage(level = WARN)
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/arjunaI18NLoggerImpl.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/arjunaI18NLoggerImpl.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/arjunaI18NLoggerImpl.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -808,15 +808,15 @@
}
public void warn_common_ClassloadingUtility_4(String arg0, Throwable arg1) {
- logger.logv(WARN, arg1, "ARJUNA-12218 can't create new instance of {0}", arg0);
+ logger.logv(WARN, arg1, "ARJUNA-12218 can''t create new instance of {0}", arg0);
}
public void warn_common_ClassloadingUtility_5(String arg0, Throwable arg1) {
- logger.logv(WARN, arg1, "ARJUNA-12219 can't access {0}", arg0);
+ logger.logv(WARN, arg1, "ARJUNA-12219 can''t access {0}", arg0);
}
public void warn_common_ClassloadingUtility_6(String arg0, Throwable arg1) {
- logger.logv(WARN, arg1, "ARJUNA-12220 can't initialize from string {0}", arg0);
+ logger.logv(WARN, arg1, "ARJUNA-12220 can''t initialize from string {0}", arg0);
}
public void warn_objectstore_CacheStore_1(Uid arg0, String arg1) {
@@ -835,8 +835,8 @@
logger.logv(WARN, "ARJUNA-12224 Unknown work type {0}", arg0);
}
- public void warn_objectstore_FileSystemStore_1(String arg0) {
- logger.logv(WARN, "ARJUNA-12225 FileSystemStore::setupStore - cannot access root of object store: {0}", arg0);
+ public String get_objectstore_FileSystemStore_1(String arg0) {
+ return MessageFormat.format("ARJUNA-12225 FileSystemStore::setupStore - cannot access root of object store: {0}", arg0);
}
public void warn_objectstore_FileSystemStore_2(String arg0) {
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/BaseStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/BaseStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/BaseStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -42,16 +42,6 @@
public interface BaseStore
{
/**
- * The type of the object store. This is used to order the
- * instances in the intentions list.
- *
- * @return the type of the record.
- * @see com.arjuna.ats.arjuna.coordinator.RecordType
- */
-
- public int typeIs ();
-
- /**
* @return the "name" of the object store. Where in the hierarchy it appears, e.g., /ObjectStore/MyName/...
*/
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/ObjectStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/ObjectStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/ObjectStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -43,7 +43,7 @@
* The object store interface is the application's route to using
* a specific object store implementation. The interface dynamically
* binds to an implementation of the right type.
- *
+ *
* This is the base class from which all object store types are derived.
* Note that because object store instances are stateless, to improve
* efficiency we try to only create one instance of each type per process.
@@ -89,26 +89,6 @@
public String locateStore (String localOSRoot) throws ObjectStoreException
{
- if (_objectStoreRoot == null)
- _objectStoreRoot = arjPropertyManager.getObjectStoreEnvironmentBean().getLocalOSRoot();
-
- if (_objectStoreDir == null)
- {
- _objectStoreDir = arjPropertyManager.getObjectStoreEnvironmentBean().getObjectStoreDir();
- if (_objectStoreDir == null || _objectStoreDir.length() == 0)
- throw new ObjectStoreException("object store location property not set.");
-
- if (!_objectStoreDir.endsWith(File.separator))
- _objectStoreDir = _objectStoreDir + File.separator;
-
- /*
- * We use the classname of the object store implementation to
- * specify the directory for the object store.
- */
-
- _objectStoreDir = _objectStoreDir + this.getClass().getSimpleName();
- }
-
String toReturn = null;
if ((localOSRoot == null) || (localOSRoot.length() == 0))
@@ -180,14 +160,31 @@
return _objectStoreRoot;
}
- protected ObjectStore ()
+ protected ObjectStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
{
- this(StateType.OS_SHARED);
- }
+ shareStatus = objectStoreEnvironmentBean.getShare();
- protected ObjectStore (int ss)
- {
- shareStatus = ss;
+ if (objectStoreEnvironmentBean.getObjectStoreDir() == null || objectStoreEnvironmentBean.getObjectStoreDir().length() == 0) {
+ throw new ObjectStoreException("object store location property not set."); // TODO i18n
+ }
+
+ if (objectStoreEnvironmentBean.getLocalOSRoot() == null) {
+ _objectStoreRoot = "";
+ } else {
+ _objectStoreRoot = objectStoreEnvironmentBean.getLocalOSRoot();
+ }
+
+ String storeDir = objectStoreEnvironmentBean.getObjectStoreDir();
+ if (!storeDir.endsWith(File.separator)) {
+ storeDir = storeDir + File.separator;
+ }
+
+ /*
+ * We use the classname of the object store implementation to
+ * specify the directory for the object store.
+ */
+
+ _objectStoreDir = storeDir + this.getClass().getSimpleName();
}
/**
@@ -207,9 +204,9 @@
return name;
}
- protected int shareStatus = arjPropertyManager.getObjectStoreEnvironmentBean().getShare(); // is the implementation sharing states between VMs?
+ protected final int shareStatus; // is the implementation sharing states between VMs?
- private String _objectStoreRoot = arjPropertyManager.getObjectStoreEnvironmentBean().getLocalOSRoot();
- private String _objectStoreDir = arjPropertyManager.getObjectStoreEnvironmentBean().getObjectStoreDir();
+ protected final String _objectStoreRoot;
+ private final String _objectStoreDir;
}
Deleted: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/ObjectStoreType.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/ObjectStoreType.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/ObjectStoreType.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -1,242 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: ObjectStoreType.java 2342 2006-03-30 13:06:17Z $
- */
-
-package com.arjuna.ats.arjuna.objectstore;
-
-import java.io.*;
-
-import com.arjuna.ats.arjuna.common.arjPropertyManager;
-import com.arjuna.ats.arjuna.exceptions.FatalError;
-import com.arjuna.ats.arjuna.logging.tsLogger;
-import com.arjuna.ats.arjuna.objectstore.type.ObjectStoreTypeManager;
-import com.arjuna.ats.internal.arjuna.objectstore.ActionStore;
-import com.arjuna.ats.internal.arjuna.objectstore.CacheStore;
-import com.arjuna.ats.internal.arjuna.objectstore.HashedActionStore;
-import com.arjuna.ats.internal.arjuna.objectstore.HashedStore;
-import com.arjuna.ats.internal.arjuna.objectstore.JDBCActionStore;
-import com.arjuna.ats.internal.arjuna.objectstore.JDBCStore;
-import com.arjuna.ats.internal.arjuna.objectstore.LogStore;
-import com.arjuna.ats.internal.arjuna.objectstore.NullActionStore;
-import com.arjuna.ats.internal.arjuna.objectstore.ShadowNoFileLockStore;
-import com.arjuna.ats.internal.arjuna.objectstore.ShadowingStore;
-import com.arjuna.ats.internal.arjuna.objectstore.VolatileStore;
-
-/**
- * The various types of object store implementations that are available.
- *
- * @author Mark Little (mark at arjuna.com)
- * @version $Id: ObjectStoreType.java 2342 2006-03-30 13:06:17Z $
- * @since JTS 1.0.
- */
-
-public class ObjectStoreType
-{
-
- /*
- * Do not re-order these!
- */
-
- public static final int ACTION = 0;
-
- public static final int ACTIONLOG = 1;
-
- public static final int SHADOWING = 2;
-
- public static final int FRAGMENTED = 3;
-
- public static final int VOLATILE = 4;
-
- public static final int HASHED = 5;
-
- public static final int REPLICATED = 6;
-
- public static final int MAPPED = 7;
-
- public static final int SINGLETYPEMAPPED = 8;
-
- public static final int USER_DEF_0 = 9;
-
- public static final int USER_DEF_1 = 10;
-
- public static final int USER_DEF_2 = 11;
-
- public static final int USER_DEF_3 = 12;
-
- public static final int USER_DEF_4 = 13;
-
- public static final int SHADOWNOFILELOCK = 14;
-
- public static final int JDBC = 15;
-
- public static final int JDBC_ACTION = 16;
-
- public static final int HASHED_ACTION = 17;
-
- public static final int CACHED = 18;
-
- public static final int NULL_ACTION = 19;
-
- public static final int USER_DEF_5 = 30;
-
- public static final int USER_DEF_6 = 31;
-
- public static final int USER_DEF_7 = 32;
-
- public static final int USER_DEF_8 = 33;
-
- public static final int USER_DEF_9 = 34;
-
- /**
- * @return the <code>Class</code> for this object store value.
- */
-
- @SuppressWarnings("unchecked")
- public final static Class<? extends ObjectStore> typeToClass (int rt)
- {
- switch (rt)
- {
- case ACTION:
- return ActionStore.class;
- case NULL_ACTION:
- return NullActionStore.class;
- case ACTIONLOG:
- return LogStore.class;
- case SHADOWING:
- return ShadowingStore.class;
- case VOLATILE:
- return VolatileStore.class;
- case HASHED:
- return HashedStore.class;
- case SHADOWNOFILELOCK:
- return ShadowNoFileLockStore.class;
- case JDBC:
- return JDBCStore.class;
- case JDBC_ACTION:
- return JDBCActionStore.class;
- case HASHED_ACTION:
- return HashedActionStore.class;
- case CACHED:
- return CacheStore.class;
- default:
- return ObjectStoreTypeManager.manager().getObjectStoreClass(rt);
- }
- }
-
- /**
- * @return the <code>int</code> value for this object store.
- * <code>Class</code>.
- */
-
- @SuppressWarnings("unchecked")
- public final static int classToType (Class c)
- {
- if (c.equals(ActionStore.class))
- return ACTION;
- if (c.equals(NullActionStore.class))
- return NULL_ACTION;
- if (c.equals(LogStore.class))
- return ACTIONLOG;
- if (c.equals(ShadowingStore.class))
- return SHADOWING;
- if (c.equals(VolatileStore.class))
- return VOLATILE;
- if (c.equals(HashedStore.class))
- return HASHED;
- if (c.equals(ShadowNoFileLockStore.class))
- return SHADOWNOFILELOCK;
- if (c.equals(JDBCStore.class))
- return JDBC;
- if (c.equals(JDBCActionStore.class))
- return JDBC_ACTION;
- if (c.equals(HashedActionStore.class))
- return HASHED_ACTION;
- if (c.equals(CacheStore.class))
- return CACHED;
-
- int type = ObjectStoreTypeManager.manager().getType(c);
-
- if (type >= 0)
- return type;
-
- tsLogger.i18NLogger.warn_objectstore_ObjectStoreType_1(c.getCanonicalName());
-
- throw new FatalError(
- tsLogger.i18NLogger.get_objectstore_ObjectStoreType_2()
- + c);
- }
-
- /**
- * Print on the specified <code>PrintWriter</code> a string representation
- * of the object store value.
- */
-
- @SuppressWarnings("unchecked")
- public final static void print (PrintWriter strm, int rt)
- {
- Class c = typeToClass(rt);
-
- strm.print(c);
-
- c = null;
- }
-
- /**
- * @return <code>true</code> if the value is valid, <code>false</code>
- * otherwise.
- */
-
- public static final boolean valid (int rt)
- {
- if (typeToClass(rt) != null)
- return true;
- else
- return false;
- }
-
- public static final String getDefaultStoreType ()
- {
- /*
- * Check once per application. At present this means that all objects
- * have the same object store implementation. However, this need not be
- * the case, and could be an attribute of the object, or derived from
- * the object's name.
- */
-
- if (objectStoreType == null)
- objectStoreType = arjPropertyManager
- .getObjectStoreEnvironmentBean().getObjectStoreType();
-
- return objectStoreType;
- }
-
- static String objectStoreType = null;
-
-}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/StoreManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/StoreManager.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/StoreManager.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -20,10 +20,14 @@
*/
package com.arjuna.ats.arjuna.objectstore;
+import com.arjuna.ats.arjuna.common.CoordinatorEnvironmentBean;
+import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
import com.arjuna.ats.arjuna.common.arjPropertyManager;
import com.arjuna.ats.arjuna.exceptions.FatalError;
import com.arjuna.ats.arjuna.logging.tsLogger;
+import com.arjuna.ats.internal.arjuna.common.ClassloadingUtility;
import com.arjuna.ats.internal.arjuna.objectstore.LogStore;
+import com.arjuna.common.internal.util.propertyservice.BeanPopulator;
/**
* Single point of control for the management of storage instances.
@@ -73,46 +77,21 @@
}
public static final ParticipantStore getCommunicationStore() {
- return getCommunicationStoreInternal();
- }
-
- private static final ObjectStoreAPI getCommunicationStoreInternal()
- {
if(communicationStore != null) {
return communicationStore;
}
synchronized(StoreManager.class) {
-
if(communicationStore != null) {
return communicationStore;
}
- String communicationStoreType = arjPropertyManager.getCoordinatorEnvironmentBean().getCommunicationStore();
-
- try
- {
- Class osc = Class.forName(communicationStoreType);
-
- communicationStore = (ObjectStoreAPI) osc.newInstance();
- }
- catch (final Throwable ex)
- {
- throw new FatalError(tsLogger.i18NLogger.get_StoreManager_invalidtype() + " " + communicationStoreType, ex);
- }
-
- communicationStore.start();
+ communicationStore = initStore("communicationStore");
}
return communicationStore;
}
- /**
- * @return the <code>ObjectStore</code> implementation which the
- * transaction coordinator will use.
- * @see ObjectStore
- */
-
private static final ObjectStoreAPI getActionStore()
{
if(actionStore != null) {
@@ -120,51 +99,18 @@
}
synchronized(StoreManager.class) {
-
if(actionStore != null) {
return actionStore;
}
-
- /*
- * Check for action store once per application. The second parameter is
- * the default value, which is returned if no other value is specified.
- */
-
- String actionStoreType = null;
-
- if (arjPropertyManager.getCoordinatorEnvironmentBean().isTransactionLog()) {
- actionStoreType = LogStore.class.getName();
- } else {
- actionStoreType = arjPropertyManager.getCoordinatorEnvironmentBean().getActionStore();
- }
-
- // Defaults to ObjectStore.OS_UNSHARED
-
- if (arjPropertyManager.getCoordinatorEnvironmentBean().isSharedTransactionLog()) {
- arjPropertyManager.getObjectStoreEnvironmentBean().setShare(StateType.OS_SHARED);
- }
-
- try
- {
- Class osc = Class.forName(actionStoreType);
-
- actionStore = (ObjectStoreAPI) osc.newInstance();
- }
- catch (final Throwable ex)
- {
- throw new FatalError(tsLogger.i18NLogger.get_StoreManager_invalidtype() + " " + actionStoreType, ex);
- }
-
- actionStore.start();
+
+ actionStore = initStore(null); // default
}
+ //arjPropertyManager.getCoordinatorEnvironmentBean().isSharedTransactionLog()
+
return actionStore;
}
- public static ObjectStoreAPI getTxOJStore() {
- return (ObjectStoreAPI) setupStore(null, StateType.OS_UNSHARED);
- }
-
public static ParticipantStore setupStore (String rootName, int sharedStatus)
{
if(stateStore != null) {
@@ -172,34 +118,39 @@
}
synchronized(StoreManager.class) {
-
if(stateStore != null) {
return stateStore;
}
- if(sharedStatus != arjPropertyManager.getObjectStoreEnvironmentBean().getShare()) {
- arjPropertyManager.getObjectStoreEnvironmentBean().setShare(sharedStatus);
- }
+ stateStore = initStore("stateStore");
+ }
- if(rootName != null && !rootName.equals(arjPropertyManager.getObjectStoreEnvironmentBean().getLocalOSRoot())) {
- throw new IllegalArgumentException(tsLogger.i18NLogger.get_StoreManager_invalidroot(
- arjPropertyManager.getObjectStoreEnvironmentBean().getLocalOSRoot(), rootName));
- }
+ // arjPropertyManager.getObjectStoreEnvironmentBean().getLocalOSRoot()
- String storeType = arjPropertyManager.getObjectStoreEnvironmentBean().getObjectStoreType();
+ return stateStore;
+ }
- try {
- Class osc = Class.forName(storeType);
+ private static final ObjectStoreAPI initStore(String name)
+ {
+ ObjectStoreEnvironmentBean storeEnvBean = BeanPopulator.getNamedInstance(ObjectStoreEnvironmentBean.class, name);
+ String storeType = storeEnvBean.getObjectStoreType();
+ ObjectStoreAPI store;
- stateStore = (ObjectStoreAPI) osc.newInstance();
+ try
+ {
+ store = ClassloadingUtility.loadAndInstantiateClass(ObjectStoreAPI.class, storeType, new Object[] {storeEnvBean});
+ }
+ catch (final Throwable ex)
+ {
+ throw new FatalError(tsLogger.i18NLogger.get_StoreManager_invalidtype() + " " + storeType, ex);
+ }
- } catch (final Throwable ex)
- {
- throw new FatalError(tsLogger.i18NLogger.get_StoreManager_invalidtype() + " " + storeType, ex);
- }
+ store.start();
- stateStore.start();
- }
- return stateStore;
+ return store;
}
+
+ public static ObjectStoreAPI getTxOJStore() {
+ return (ObjectStoreAPI) setupStore(null, StateType.OS_UNSHARED);
+ }
}
Deleted: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/type/ObjectStoreTypeManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/type/ObjectStoreTypeManager.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/type/ObjectStoreTypeManager.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -1,100 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: RecordType.java 2342 2006-03-30 13:06:17Z $
- */
-
-package com.arjuna.ats.arjuna.objectstore.type;
-
-import java.util.ArrayList;
-
-import com.arjuna.ats.arjuna.objectstore.ObjectStore;
-
-/**
- * This allows users to define a mapping between record type integers
- * and specific Class-es. This replaces Gandiva from previous releases.
- */
-
-public class ObjectStoreTypeManager
-{
- public synchronized Class<? extends ObjectStore> getObjectStoreClass (int type)
- {
- /*
- * Stop at first hit.
- */
-
- for (int i = 0; i < _map.size(); i++)
- {
- if (_map.get(i).getType() == type)
- return _map.get(i).getObjectStoreClass();
- }
-
- return null;
- }
-
- public synchronized int getType (Class<? extends ObjectStore> c)
- {
- for (int i = 0; i < _map.size(); i++)
- {
- if (_map.get(i).getObjectStoreClass().equals(c))
- return _map.get(i).getType();
- }
-
- return -1;
- }
-
- public synchronized void add (ObjectStoreTypeMap map)
- {
- _map.add(map);
- }
-
- public static ObjectStoreTypeManager manager ()
- {
- return _instance;
- }
-
- private ObjectStoreTypeManager ()
- {
- _map = new ArrayList<ObjectStoreTypeMap>();
- }
-
- private final ArrayList<ObjectStoreTypeMap> _map;
-
- private static final ObjectStoreTypeManager _instance = new ObjectStoreTypeManager();
-
- static
- {
- /*
- * TODO
- * At present all record types that we need are known at compile time or can be
- * added programmatically. We may want to allow them to be specified dynamically,
- * e.g., on the command line or in a configuration file, but when that requirement
- * happens we can fill in this block ...
- */
- }
-}
Deleted: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/type/ObjectStoreTypeMap.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/type/ObjectStoreTypeMap.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/objectstore/type/ObjectStoreTypeMap.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: RecordType.java 2342 2006-03-30 13:06:17Z $
- */
-
-package com.arjuna.ats.arjuna.objectstore.type;
-
-import com.arjuna.ats.arjuna.objectstore.ObjectStore;
-
-/**
- * This allows users to define a mapping between record type integers
- * and specific Class-es. This replaces Gandiva from previous releases.
- */
-
-public interface ObjectStoreTypeMap
-{
- public Class<? extends ObjectStore> getObjectStoreClass ();
-
- public int getType ();
-}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/PersistenceRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/PersistenceRecord.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/PersistenceRecord.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -153,7 +153,7 @@
{
if (targetParticipantStore != null) {
tsLogger.logger.trace(", store = "
- + targetParticipantStore + "(" + targetParticipantStore.typeIs() + ")");
+ + targetParticipantStore + "(" + targetParticipantStore.getClass().getCanonicalName() + ")");
}
else {
tsLogger.logger.trace("");
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/common/ClassloadingUtility.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/common/ClassloadingUtility.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/common/ClassloadingUtility.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -22,6 +22,8 @@
import com.arjuna.ats.arjuna.logging.tsLogger;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
@@ -44,10 +46,10 @@
*
* @param iface the expected interface type.
* @param className the name of the class to load and instantiate.
- * @param <T>
+ * @param constructorArgs optional set of arguments to pass to the class constructor. null for default ctor.
* @return an instantiate of the specified class, or null.
*/
- public static <T> T loadAndInstantiateClass(Class<T> iface, String className)
+ public static <T> T loadAndInstantiateClass(Class<T> iface, String className, Object[] constructorArgs)
{
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("Loading class " + className);
@@ -72,7 +74,16 @@
try {
Class<? extends T> clazz2 = clazz.asSubclass(iface);
- instance = (T)clazz2.newInstance();
+ if(constructorArgs == null) {
+ instance = (T)clazz2.newInstance();
+ } else {
+ Class[] paramTypes = new Class[constructorArgs.length];
+ for(int i = 0; i < constructorArgs.length; i++) {
+ paramTypes[i] = constructorArgs[i].getClass();
+ }
+ Constructor ctor = clazz2.getConstructor(paramTypes);
+ instance = (T)ctor.newInstance(constructorArgs);
+ }
} catch (ClassCastException e) {
tsLogger.i18NLogger.warn_common_ClassloadingUtility_3(className, iface.getName(), e);
}
@@ -80,6 +91,10 @@
tsLogger.i18NLogger.warn_common_ClassloadingUtility_4(className, e);
} catch (IllegalAccessException e) {
tsLogger.i18NLogger.warn_common_ClassloadingUtility_5(className, e);
+ } catch(NoSuchMethodException e) {
+ tsLogger.i18NLogger.warn_common_ClassloadingUtility_4(className, e);
+ } catch(InvocationTargetException e) {
+ tsLogger.i18NLogger.warn_common_ClassloadingUtility_4(className, e);
}
return instance;
@@ -108,7 +123,7 @@
theClass = theClassAndParameter;
}
- T instance = loadAndInstantiateClass(iface, theClass);
+ T instance = loadAndInstantiateClass(iface, theClass, null);
if (theClass != null && theParameter != null)
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/ActionStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/ActionStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/ActionStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -31,8 +31,6 @@
package com.arjuna.ats.internal.arjuna.objectstore;
-import com.arjuna.ats.arjuna.exceptions.FatalError;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
import com.arjuna.ats.arjuna.objectstore.StateStatus;
import com.arjuna.ats.arjuna.objectstore.StateType;
import com.arjuna.ats.arjuna.common.*;
@@ -46,7 +44,7 @@
* The basic transaction log implementation. Uses the no file-level locking
* implementation of the file system store since only a single user (the
* coordinator) can ever be manipulating the action's state.
- *
+ *
* @author Mark Little (mark at arjuna.com)
* @version $Id: ActionStore.java 2342 2006-03-30 13:06:17Z $
* @since JTS 1.0.
@@ -54,12 +52,6 @@
public class ActionStore extends ShadowNoFileLockStore
{
-
- public int typeIs ()
- {
- return ObjectStoreType.ACTION;
- }
-
/**
* @return current state of object. Assumes that genPathName allocates
* enough extra space to allow extra chars to be added. Action
@@ -71,15 +63,12 @@
{
int theState = StateStatus.OS_UNKNOWN;
- if (storeValid())
- {
- String path = genPathName(objUid, tName, StateType.OS_ORIGINAL);
+ String path = genPathName(objUid, tName, StateType.OS_ORIGINAL);
- if (exists(path))
- theState = StateStatus.OS_COMMITTED;
+ if (exists(path))
+ theState = StateStatus.OS_COMMITTED;
- path = null;
- }
+ path = null;
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("ActionStore.currentState("+objUid+", "+tName+") - returning "+
@@ -104,11 +93,6 @@
boolean result = false;
- /* Bail out if the object store is not set up */
-
- if (!storeValid())
- return false;
-
if (currentState(objUid, tName) == StateStatus.OS_COMMITTED)
result = true;
@@ -176,7 +160,7 @@
}
public boolean write_committed (Uid storeUid, String tName,
- OutputObjectState state) throws ObjectStoreException
+ OutputObjectState state) throws ObjectStoreException
{
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("ActionStore.write_committed(" + storeUid + ", " + tName
@@ -197,61 +181,11 @@
return false;
}
- public ActionStore(String locationOfStore)
+ public ActionStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
{
- this(locationOfStore, StateType.OS_SHARED);
- }
+ super(objectStoreEnvironmentBean);
- public ActionStore(String locationOfStore, int shareStatus)
- {
- super(shareStatus);
-
- try
- {
- setupStore(locationOfStore);
- }
- catch (ObjectStoreException e) {
- tsLogger.logger.warn(e);
-
- super.makeInvalid();
-
- throw new FatalError(e.toString(),
- e);
- }
+ // overrides parents use of isObjectStoreSync
+ doSync = objectStoreEnvironmentBean.isTransactionSync();
}
-
- public ActionStore()
- {
- this(StateType.OS_SHARED);
- }
-
- public ActionStore(int shareStatus)
- {
- this(arjPropertyManager.getObjectStoreEnvironmentBean()
- .getLocalOSRoot(), shareStatus);
- }
-
- protected synchronized boolean setupStore (String location)
- throws ObjectStoreException
- {
- if (!checkSync)
- {
- if (arjPropertyManager.getObjectStoreEnvironmentBean()
- .isTransactionSync())
- {
- syncOn();
- }
- else
- {
- syncOff();
- }
- }
-
- checkSync = true;
-
- return super.setupStore(location);
- }
-
- private static boolean checkSync = false;
-
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/CacheStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/CacheStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/CacheStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -32,7 +32,6 @@
package com.arjuna.ats.internal.arjuna.objectstore;
import com.arjuna.ats.arjuna.common.*;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
import com.arjuna.ats.arjuna.objectstore.StateStatus;
import com.arjuna.ats.arjuna.objectstore.StateType;
import com.arjuna.ats.arjuna.state.*;
@@ -67,11 +66,6 @@
CacheStore._storeManager.flush();
}
- public int typeIs ()
- {
- return ObjectStoreType.CACHED;
- }
-
protected boolean remove_state (Uid objUid, String name, int ft)
throws ObjectStoreException
{
@@ -161,53 +155,14 @@
return super.write_state(objUid, tName, state, ft);
}
- public CacheStore(String locationOfStore)
+ public CacheStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
{
- this(locationOfStore, StateType.OS_SHARED);
- }
+ super(objectStoreEnvironmentBean);
- public CacheStore(String locationOfStore, int shareStatus)
- {
- super(locationOfStore, shareStatus);
-
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("CacheStore.CacheStore(" + locationOfStore + ")");
- }
-
- /*
- * Since this is a cached store, there is not a lot of point in doing
- * synchronous writes. Disable them.
- */
-
- super.syncWrites = _cacheSync;
+ super.syncWrites = objectStoreEnvironmentBean.isCacheStoreSync();
}
- public CacheStore ()
- {
- this(StateType.OS_UNSHARED);
- }
-
- public CacheStore (int shareStatus)
- {
- super(shareStatus);
-
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("CacheStore.CacheStore( " + shareStatus + " )");
- }
-
- this.syncWrites = false;
- }
-
static AsyncStore _storeManager = new AsyncStore();
-
- private static boolean _cacheSync = false;
-
- static
- {
- _cacheSync = arjPropertyManager.getObjectStoreEnvironmentBean()
- .isCacheStoreSync();
- }
-
}
class StoreElement
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/FileLockingStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/FileLockingStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/FileLockingStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -61,14 +61,9 @@
protected abstract boolean write_state (Uid u, String tn,
OutputObjectState buff, int s) throws ObjectStoreException;
- public FileLockingStore(String locationOfStore, int ss)
+ public FileLockingStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
{
- super(locationOfStore, ss);
-
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("FileLockingStore.FileLockingStore(" + locationOfStore
- + ")");
- }
+ super(objectStoreEnvironmentBean);
}
/**
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/FileSystemStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/FileSystemStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/FileSystemStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -71,43 +71,17 @@
public boolean accept (File dir, String name)
{
File f = new File(name);
-
+
if (f.isDirectory())
return false;
else
return true;
- }
- }
-
- public FileSystemStore (String locationOfStore, int ss)
- {
- super(ss);
-
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("FileSystemStore.FileSystemStore(" + locationOfStore + ")");
}
-
- fullStoreName = null;
- localStoreRoot = null;
- isValid = true;
-
- try
- {
- setupStore(locationOfStore);
- }
- catch (ObjectStoreException e)
- {
- isValid = false;
-
- tsLogger.logger.warn(e);
-
- throw new com.arjuna.ats.arjuna.exceptions.FatalError(e.toString(), e);
- }
}
public String getStoreName ()
{
- return localStoreRoot;
+ return _objectStoreRoot;
}
/*
@@ -169,21 +143,6 @@
return write_state(storeUid, tName, state, StateType.OS_SHADOW);
}
- public final synchronized boolean storeValid ()
- {
- return isValid;
- }
-
- public final synchronized void makeInvalid ()
- {
- isValid = false;
- }
-
- public final synchronized void makeValid ()
- {
- isValid = true;
- }
-
/**
* Given a type name initialise the <code>state</code> to contains all of
* the Uids of objects of that type
@@ -236,7 +195,7 @@
if ((aUid != null) && (aUid.valid()))
{
if ((aUid.notEquals(Uid.nullUid())) && ((match == StateStatus.OS_UNKNOWN) ||
- (isType(aUid, tName, match))))
+ (isType(aUid, tName, match))))
{
UidHelper.packInto(aUid, store);
}
@@ -325,57 +284,17 @@
return result;
}
- public synchronized void packInto (OutputBuffer buff) throws IOException
- {
- if (localStoreRoot != null)
- {
- if (localStoreRoot.compareTo("") == 0)
- {
- buff.packString(null);
- return;
- }
- }
-
- buff.packString(localStoreRoot);
- }
-
- public synchronized void unpackFrom (InputBuffer buff) throws IOException
- {
- try
- {
- setupStore(buff.unpackString());
- }
- catch (ObjectStoreException e)
- {
- throw new IOException(tsLogger.i18NLogger.get_objectstore_FileSystemStore_6());
- }
- }
-
protected abstract InputObjectState read_state (Uid u, String tn, int s) throws ObjectStoreException;
protected abstract boolean remove_state (Uid u, String tn, int s) throws ObjectStoreException;
protected abstract boolean write_state (Uid u, String tn, OutputObjectState buff, int s) throws ObjectStoreException;
/**
- * Turn file sync on and off.
- */
-
- protected synchronized final void syncOn ()
- {
- FileSystemStore.doSync = true;
- }
-
- protected synchronized final void syncOff ()
- {
- FileSystemStore.doSync = false;
- }
-
- /**
* Are synchronous write enabled?
*/
protected synchronized final boolean synchronousWrites ()
{
- return FileSystemStore.doSync && syncWrites;
+ return doSync && syncWrites;
}
/**
@@ -545,23 +464,18 @@
}
}
- public FileSystemStore (int ss)
+ public FileSystemStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
{
- super(ss);
+ super(objectStoreEnvironmentBean);
- fullStoreName = null;
- localStoreRoot = null;
- isValid = true;
-
- try
- {
- setupStore(arjPropertyManager.getObjectStoreEnvironmentBean().getLocalOSRoot());
- }
- catch (ObjectStoreException e)
- {
- isValid = false;
+ fullStoreName = locateStore(_objectStoreRoot);
- throw new com.arjuna.ats.arjuna.exceptions.FatalError(e.toString(), e);
+ doSync = objectStoreEnvironmentBean.isObjectStoreSync();
+
+ /* The root of the objectstore must exist and be writable */
+
+ if ((fullStoreName == null) || !createHierarchy(fullStoreName)) {
+ throw new ObjectStoreException( tsLogger.i18NLogger.get_objectstore_FileSystemStore_1(fullStoreName) );
}
}
@@ -590,12 +504,12 @@
{
String pack = truncate(entry[i]);
- if ( pack.length() > 0 )
- {
+ if ( pack.length() > 0 )
+ {
foundTypes.packString(root+File.separator+pack);
result = allTypes(foundTypes, root+File.separator+pack);
- }
+ }
}
tmpFile = null;
@@ -670,31 +584,6 @@
return fname;
}
- protected synchronized boolean setupStore (String localOSRoot) throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("FileSystemStore.setupStore(" + localOSRoot + ")");
- }
-
- isValid = true;
-
- if (localOSRoot == null)
- localOSRoot = "";
-
- localStoreRoot = localOSRoot;
- fullStoreName = locateStore(localStoreRoot);
-
- /* The root of the objectstore must exist and be writable */
-
- if ((fullStoreName == null) || !createHierarchy(fullStoreName)) {
- tsLogger.i18NLogger.warn_objectstore_FileSystemStore_1(fullStoreName);
-
- isValid = false;
- }
-
- return isValid;
- }
-
protected boolean supressEntry (String name)
{
if ((name.compareTo(".") == 0) || (name.compareTo("..") == 0))
@@ -868,29 +757,17 @@
protected boolean syncWrites = true;
- private String fullStoreName;
- private String localStoreRoot;
- private boolean isValid;
+ private final String fullStoreName;
+ protected volatile boolean doSync = true;
- /*
- * These values should be determined via something like pathconf
- */
-
- private static final int MAXPNAMELEN = 255;
- private static final int MAXNAMELENGTH = 255;
- private static final int SLOP = 9;
-
// global values (some of which may be reset on a per instance basis).
-
- private static boolean doSync = true;
+
private static Hashtable fileCache = new Hashtable();
private static int createRetry = 100;
private static int createTimeout = 100;
static
{
- FileSystemStore.doSync = arjPropertyManager.getObjectStoreEnvironmentBean().isObjectStoreSync();
-
if (File.separatorChar != FileSystemStore.unixSeparator)
rewriteSeparator = true;
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/HashedActionStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/HashedActionStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/HashedActionStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -32,11 +32,7 @@
package com.arjuna.ats.internal.arjuna.objectstore;
import com.arjuna.ats.arjuna.common.*;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
-import com.arjuna.ats.arjuna.objectstore.StateType;
-import com.arjuna.ats.arjuna.logging.tsLogger;
-
import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
/**
@@ -56,102 +52,11 @@
public class HashedActionStore extends HashedStore
{
-
- public int typeIs ()
+ public HashedActionStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
{
- return ObjectStoreType.HASHED_ACTION;
- }
+ super(objectStoreEnvironmentBean);
- /*
- * Protected constructors and destructor
- */
-
- public HashedActionStore()
- {
- this(StateType.OS_SHARED);
+ // overrides parents use of isObjectStoreSync
+ doSync = objectStoreEnvironmentBean.isTransactionSync();
}
-
- public HashedActionStore(int shareStatus)
- {
- super(shareStatus);
-
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("HashedStore.HashedActionStore( " + shareStatus + " )");
- }
-
- try
- {
- setupStore(arjPropertyManager.getObjectStoreEnvironmentBean().getLocalOSRoot());
- }
- catch (ObjectStoreException e)
- {
- throw new com.arjuna.ats.arjuna.exceptions.FatalError(e.toString(),
- e);
- }
- }
-
- public HashedActionStore(String locationOfStore)
- {
- this(locationOfStore, StateType.OS_SHARED);
-
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("HashedStore.HashedActionStore(" + locationOfStore + ")");
- }
-
- try
- {
- setupStore(locationOfStore);
- }
- catch (ObjectStoreException e)
- {
- tsLogger.logger.warn(e);
-
- throw new com.arjuna.ats.arjuna.exceptions.FatalError(e.toString(), e);
- }
- }
-
- public HashedActionStore(String locationOfStore, int shareStatus)
- {
- super(shareStatus);
-
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("HashedStore.HashedActionStore(" + locationOfStore + ")");
- }
-
- try
- {
- setupStore(locationOfStore);
- }
- catch (ObjectStoreException e)
- {
- tsLogger.logger.warn(e);
-
- throw new com.arjuna.ats.arjuna.exceptions.FatalError(e.toString(),
- e);
- }
- }
-
- protected synchronized boolean setupStore (String location)
- throws ObjectStoreException
- {
- if (!checkSync)
- {
- if (arjPropertyManager.getObjectStoreEnvironmentBean()
- .isTransactionSync())
- {
- syncOn();
- }
- else
- {
- syncOff();
- }
- }
-
- checkSync = true;
-
- return super.setupStore(location);
- }
-
- private static boolean checkSync = false;
-
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/HashedStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/HashedStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/HashedStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -32,7 +32,6 @@
package com.arjuna.ats.internal.arjuna.objectstore;
import com.arjuna.ats.arjuna.common.*;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
import com.arjuna.ats.arjuna.objectstore.StateStatus;
import com.arjuna.ats.arjuna.objectstore.StateType;
import com.arjuna.ats.arjuna.state.*;
@@ -69,12 +68,6 @@
public class HashedStore extends ShadowNoFileLockStore
{
-
- public int typeIs ()
- {
- return ObjectStoreType.HASHED;
- }
-
/**
* Given a type name initialise <code>state</code> to contains all of the
* Uids of objects of that type
@@ -180,60 +173,11 @@
return true;
}
- /*
- * Protected constructors and destructor
- */
-
- public HashedStore ()
+ public HashedStore (ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
{
- this(StateType.OS_SHARED);
+ super(objectStoreEnvironmentBean);
}
- public HashedStore (int shareStatus)
- {
- super(shareStatus);
-
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("HashedStore.HashedStore( " + shareStatus + " )");
- }
-
- try
- {
- setupStore(arjPropertyManager.getObjectStoreEnvironmentBean().getLocalOSRoot());
- }
- catch (ObjectStoreException e)
- {
- tsLogger.logger.warn(e);
-
- throw new com.arjuna.ats.arjuna.exceptions.FatalError(e.toString());
- }
- }
-
- public HashedStore (String locationOfStore)
- {
- this(locationOfStore, StateType.OS_SHARED);
- }
-
- public HashedStore (String locationOfStore, int shareStatus)
- {
- super(shareStatus);
-
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("HashedStore.HashedStore(" + locationOfStore + ")");
- }
-
- try
- {
- setupStore(locationOfStore);
- }
- catch (ObjectStoreException e)
- {
- tsLogger.logger.warn(e);
-
- throw new com.arjuna.ats.arjuna.exceptions.FatalError(e.toString());
- }
- }
-
protected String truncate (String value)
{
int lastIndex = value.lastIndexOf(HashedStore.HASH_SEPARATOR);
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/JDBCActionStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/JDBCActionStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/JDBCActionStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -35,7 +35,6 @@
import com.arjuna.ats.arjuna.logging.tsLogger;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
import com.arjuna.ats.arjuna.objectstore.StateStatus;
import com.arjuna.ats.arjuna.objectstore.jdbc.JDBCAccess;
import com.arjuna.ats.arjuna.common.*;
@@ -48,11 +47,6 @@
public class JDBCActionStore extends JDBCStore
{
- public int typeIs ()
- {
- return ObjectStoreType.JDBC_ACTION;
- }
-
/**
* The following operation commits a previous write_state operation which
* was made with the SHADOW StateType argument. This is achieved by
@@ -151,16 +145,11 @@
return false;
}
- public JDBCActionStore()
+ public JDBCActionStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
{
- super() ;
+ super(objectStoreEnvironmentBean);
}
- public JDBCActionStore(final String tableName)
- {
- super(tableName) ;
- }
-
protected String getAccessClassName()
{
if (_txClassName == null)
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/JDBCStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/JDBCStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/JDBCStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -36,7 +36,6 @@
import com.arjuna.ats.arjuna.logging.tsLogger;
import com.arjuna.ats.arjuna.objectstore.ObjectStore;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
import com.arjuna.ats.arjuna.objectstore.StateStatus;
import com.arjuna.ats.arjuna.objectstore.StateType;
import com.arjuna.ats.arjuna.objectstore.jdbc.JDBCAccess;
@@ -46,7 +45,6 @@
import java.util.HashMap;
import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
-import com.arjuna.ats.arjuna.exceptions.ObjectStoreError;
import com.arjuna.ats.arjuna.exceptions.FatalError;
import java.io.IOException;
@@ -62,595 +60,581 @@
public class JDBCStore extends ObjectStore
{
- public String getStoreName()
- {
- if (storeValid())
- return getAccessClassName() + ":" + getTableName();
- else
- return "Invalid";
- }
+ public String getStoreName()
+ {
+ if (storeValid())
+ return getAccessClassName() + ":" + getTableName();
+ else
+ return "Invalid";
+ }
- public int typeIs()
- {
- return ObjectStoreType.JDBC;
+ public boolean commit_state(Uid objUid, String tName)
+ throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
+ tsLogger.logger.trace("JDBCStore.commit_state(" + objUid + ", " + tName + ")");
}
- public boolean commit_state(Uid objUid, String tName)
- throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("JDBCStore.commit_state(" + objUid + ", " + tName + ")");
- }
+ /* Bail out if the object store is not set up */
- /* Bail out if the object store is not set up */
+ if (!storeValid())
+ return false;
+ else
+ return _theImple.commit_state(objUid, tName, getTableName());
+ }
- if (!storeValid())
- return false;
- else
- return _theImple.commit_state(objUid, tName, getTableName());
+ public boolean hide_state(Uid objUid, String tName)
+ throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
+ tsLogger.logger.trace("ShadowingStore.hide_state(" + objUid + ", " + tName + ")");
}
- public boolean hide_state(Uid objUid, String tName)
- throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("ShadowingStore.hide_state(" + objUid + ", " + tName + ")");
- }
+ /* Bail out if the object store is not set up */
- /* Bail out if the object store is not set up */
+ if (storeValid())
+ return _theImple.hide_state(objUid, tName, getTableName());
+ else
+ return false;
+ }
- if (storeValid())
- return _theImple.hide_state(objUid, tName, getTableName());
- else
- return false;
+ public boolean reveal_state(Uid objUid, String tName)
+ throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
+ tsLogger.logger.trace("ShadowingStore.reveal_state(" + objUid + ", " + tName
+ + ")");
}
- public boolean reveal_state(Uid objUid, String tName)
- throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("ShadowingStore.reveal_state(" + objUid + ", " + tName
- + ")");
- }
+ if (storeValid())
+ return _theImple.reveal_state(objUid, tName, getTableName());
+ else
+ return false;
+ }
- if (storeValid())
- return _theImple.reveal_state(objUid, tName, getTableName());
- else
- return false;
- }
+ /*
+ * Determine current state of object. State search is ordered
+ * OS_UNCOMMITTED, OS_UNCOMMITTED_HIDDEN, OS_COMMITTED, OS_COMMITTED_HIDDEN
+ */
- /*
- * Determine current state of object. State search is ordered
- * OS_UNCOMMITTED, OS_UNCOMMITTED_HIDDEN, OS_COMMITTED, OS_COMMITTED_HIDDEN
- */
+ public int currentState(Uid objUid, String tName)
+ throws ObjectStoreException
+ {
+ if (storeValid())
+ return _theImple.currentState(objUid, tName, getTableName());
+ else
+ return StateStatus.OS_UNKNOWN;
+ }
- public int currentState(Uid objUid, String tName)
- throws ObjectStoreException
- {
- if (storeValid())
- return _theImple.currentState(objUid, tName, getTableName());
- else
- return StateStatus.OS_UNKNOWN;
+ /**
+ * Read an uncommitted instance of State out of the object store. The
+ * instance is identified by the unique id and type
+ */
+
+ public InputObjectState read_committed(Uid storeUid, String tName)
+ throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
+ tsLogger.logger.trace("JDBCStore.read_committed(" + storeUid + ", "
+ + tName + ")");
}
- /**
- * Read an uncommitted instance of State out of the object store. The
- * instance is identified by the unique id and type
- */
+ return read_state(storeUid, tName, StateStatus.OS_COMMITTED);
+ }
- public InputObjectState read_committed(Uid storeUid, String tName)
- throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("JDBCStore.read_committed(" + storeUid + ", "
- + tName + ")");
- }
-
- return read_state(storeUid, tName, StateStatus.OS_COMMITTED);
+ public InputObjectState read_uncommitted(Uid storeUid, String tName)
+ throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
+ tsLogger.logger.trace("JDBCStore.read_uncommitted(" + storeUid + ", " + tName
+ + ")");
}
- public InputObjectState read_uncommitted(Uid storeUid, String tName)
- throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("JDBCStore.read_uncommitted(" + storeUid + ", " + tName
- + ")");
- }
+ return read_state(storeUid, tName, StateStatus.OS_UNCOMMITTED);
+ }
- return read_state(storeUid, tName, StateStatus.OS_UNCOMMITTED);
+ public boolean remove_committed(Uid storeUid, String tName)
+ throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
+ tsLogger.logger.trace("JDBCStore.remove_committed(" + storeUid + ", " + tName
+ + ")");
}
- public boolean remove_committed(Uid storeUid, String tName)
- throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("JDBCStore.remove_committed(" + storeUid + ", " + tName
- + ")");
- }
+ return remove_state(storeUid, tName, StateStatus.OS_COMMITTED);
+ }
- return remove_state(storeUid, tName, StateStatus.OS_COMMITTED);
+ public boolean remove_uncommitted(Uid storeUid, String tName)
+ throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
+ tsLogger.logger.trace("JDBCStore.remove_uncommitted(" + storeUid + ", " + tName
+ + ")");
}
- public boolean remove_uncommitted(Uid storeUid, String tName)
- throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("JDBCStore.remove_uncommitted(" + storeUid + ", " + tName
- + ")");
- }
+ return remove_state(storeUid, tName, StateStatus.OS_UNCOMMITTED);
+ }
- return remove_state(storeUid, tName, StateStatus.OS_UNCOMMITTED);
+ public boolean write_committed(Uid storeUid, String tName,
+ OutputObjectState state) throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
+ tsLogger.logger.trace("JDBCStore.write_committed(" + storeUid + ", " + tName
+ + ")");
}
- public boolean write_committed(Uid storeUid, String tName,
- OutputObjectState state) throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("JDBCStore.write_committed(" + storeUid + ", " + tName
- + ")");
- }
+ return write_state(storeUid, tName, state, StateStatus.OS_COMMITTED);
+ }
- return write_state(storeUid, tName, state, StateStatus.OS_COMMITTED);
+ public boolean write_uncommitted(Uid storeUid, String tName,
+ OutputObjectState state) throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
+ tsLogger.logger.trace("JDBCStore.write_uncommitted(" + storeUid + ", " + tName
+ + ", " + state + ")");
}
- public boolean write_uncommitted(Uid storeUid, String tName,
- OutputObjectState state) throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("JDBCStore.write_uncommitted(" + storeUid + ", " + tName
- + ", " + state + ")");
- }
+ return write_state(storeUid, tName, state, StateStatus.OS_UNCOMMITTED);
+ }
- return write_state(storeUid, tName, state, StateStatus.OS_UNCOMMITTED);
+ public final boolean storeValid()
+ {
+ return _isValid;
+ }
+
+ /*
+ * Given a type name return an ObjectState that contains all of the uids of
+ * objects of that type
+ */
+
+ public boolean allObjUids(String tName, InputObjectState state, int match)
+ throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
+ tsLogger.logger.trace("JDBCStore.allObjUids(" + tName + ", " + state + ", "
+ + match + ")");
}
- public final boolean storeValid()
- {
- return _isValid;
+ if (storeValid())
+ return _theImple.allObjUids(tName, state, match, getTableName());
+ else
+ return false;
+ }
+
+ public boolean allTypes(InputObjectState foundTypes)
+ throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
+ tsLogger.logger.trace("JDBCStore.allTypes(" + foundTypes + ")");
}
- /*
- * Given a type name return an ObjectState that contains all of the uids of
- * objects of that type
- */
+ if (storeValid())
+ return _theImple.allTypes(foundTypes, getTableName());
+ else
+ return false;
+ }
- public boolean allObjUids(String tName, InputObjectState state, int match)
- throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("JDBCStore.allObjUids(" + tName + ", " + state + ", "
- + match + ")");
- }
+ public synchronized void packInto(OutputBuffer buff) throws IOException
+ {
+ buff.packString(getAccessClassName());
+ buff.packString(getTableName());
+ }
- if (storeValid())
- return _theImple.allObjUids(tName, state, match, getTableName());
- else
- return false;
- }
+ public synchronized void unpackFrom(InputBuffer buff) throws IOException
+ {
+ setAccessClassName(buff.unpackString());
+ setTableName(buff.unpackString());
+ }
- public boolean allTypes(InputObjectState foundTypes)
- throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("JDBCStore.allTypes(" + foundTypes + ")");
- }
+ protected InputObjectState read_state(Uid objUid, String tName, int ft)
+ throws ObjectStoreException
+ {
+ if (!storeValid())
+ return null;
+ else
+ return _theImple.read_state(objUid, tName, ft, getTableName());
+ }
- if (storeValid())
- return _theImple.allTypes(foundTypes, getTableName());
- else
- return false;
- }
+ /**
+ * We don't actually delete the state entry, only change its type.
+ */
- public synchronized void packInto(OutputBuffer buff) throws IOException
- {
- buff.packString(getAccessClassName());
- buff.packString(getTableName());
+ protected boolean remove_state(Uid objUid, String name, int ft)
+ throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
+ tsLogger.logger.trace("JDBCStore.remove_state("
+ + objUid + ", " + name + ", "
+ + StateType.stateTypeString(ft) + ")");
}
- public synchronized void unpackFrom(InputBuffer buff) throws IOException
- {
- setAccessClassName(buff.unpackString());
- setTableName(buff.unpackString());
- }
+ if (!storeValid())
+ return false;
+ else
+ return _theImple.remove_state(objUid, name, ft, getTableName());
+ }
- protected InputObjectState read_state(Uid objUid, String tName, int ft)
- throws ObjectStoreException
- {
- if (!storeValid())
- return null;
- else
- return _theImple.read_state(objUid, tName, ft, getTableName());
- }
+ protected boolean write_state(Uid objUid, String tName,
+ OutputObjectState state, int s) throws ObjectStoreException
+ {
+ if (!storeValid())
+ return false;
+ else
+ return _theImple.write_state(objUid, tName, state, s,
+ getTableName());
+ }
- /**
- * We don't actually delete the state entry, only change its type.
- */
+ protected JDBCStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
+ {
+ super(objectStoreEnvironmentBean);
- protected boolean remove_state(Uid objUid, String name, int ft)
- throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("JDBCStore.remove_state("
- + objUid + ", " + name + ", "
- + StateType.stateTypeString(ft) + ")");
- }
+ _jdbcAccessClassName = objectStoreEnvironmentBean.getJdbcUserDbAccess();
- if (!storeValid())
- return false;
- else
- return _theImple.remove_state(objUid, name, ft, getTableName());
+ if(_jdbcAccessClassName == null) {
+ throw new ObjectStoreException(tsLogger.i18NLogger.get_objectstore_JDBCStore_5());
}
- protected boolean write_state(Uid objUid, String tName,
- OutputObjectState state, int s) throws ObjectStoreException
+ setTableName(_defaultTableName);
+
+ try
{
- if (!storeValid())
- return false;
- else
- return _theImple.write_state(objUid, tName, state, s,
- getTableName());
+ setupStore(_jdbcAccessClassName, getTableName());
}
-
- protected JDBCStore()
+ catch (Exception e)
{
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace(getClass().getName() + "()");
- }
-
- try
- {
- initialise("");
- }
- catch (Exception e)
- {
- throw new ObjectStoreError(e.toString(), e);
- }
+ tsLogger.i18NLogger.fatal_objectstore_JDBCStore_1(getJDBCAccess().toString(), getTableName());
+ throw new ObjectStoreException(e);
}
- protected JDBCStore(String tableName)
- {
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace(getClass().getName() + "(" + tableName + ")");
- }
+ _isValid = true;
+ }
- try
- {
- initialise(tableName);
- }
- catch (Exception e)
- {
- throw new ObjectStoreError(e.toString(), e);
- }
- }
+ /**
+ * Get the JDBC access class name.
+ *
+ * @return The access class name.
+ */
+ protected String getAccessClassName()
+ {
+ return _jdbcAccessClassName;
+ }
- /**
- * Get the JDBC access class name.
- *
- * @return The access class name.
- */
- protected String getAccessClassName()
- {
- if (_jdbcAccessClassName == null)
- _jdbcAccessClassName = arjPropertyManager.getObjectStoreEnvironmentBean().getJdbcUserDbAccess();
- return _jdbcAccessClassName;
- }
+ /**
+ * Set the JDBC access class name.
+ *
+ * @param jdbcAccessClassName access class name.
+ */
+ protected void setAccessClassName(String jdbcAccessClassName)
+ {
+ _jdbcAccessClassName = jdbcAccessClassName;
+ }
- /**
- * Set the JDBC access class name.
- *
- * @param jdbcAccessClassName access class name.
- */
- protected void setAccessClassName(String jdbcAccessClassName)
- {
- _jdbcAccessClassName = jdbcAccessClassName;
- }
+ /**
+ * Get the JDBC default table name.
+ *
+ * @return The default table name.
+ */
+ protected String getDefaultTableName()
+ {
+ return _defaultTableName;
+ }
- /**
- * Get the JDBC default table name.
- *
- * @return The default table name.
- */
- protected String getDefaultTableName()
- {
- return _defaultTableName;
- }
+ /**
+ * Get the JDBC access class.
+ *
+ * @return The jdbc access variable.
+ */
+ protected JDBCAccess getJDBCAccess()
+ {
+ return _jdbcAccess;
+ }
- /**
- * Get the JDBC access class.
- *
- * @return The jdbc access variable.
- */
- protected JDBCAccess getJDBCAccess()
- {
- return _jdbcAccess;
- }
+ /**
+ * Set the JDBC access class.
+ *
+ * @param jdbcAccess
+ * The jdbc access variable.
+ */
+ protected void setJDBCAccess(JDBCAccess jdbcAccess)
+ {
+ _jdbcAccess = jdbcAccess;
+ }
- /**
- * Set the JDBC access class.
- *
- * @param jdbcAccess
- * The jdbc access variable.
- */
- protected void setJDBCAccess(JDBCAccess jdbcAccess)
+ /**
+ * Get the JDBC table name.
+ *
+ * @return The table name.
+ */
+ protected String getTableName()
+ {
+ return _jdbcTableName;
+ }
+
+ /**
+ * Set the JDBC table name.
+ *
+ * @param tableName
+ * The table name.
+ */
+ protected void setTableName(String tableName)
+ {
+ _jdbcTableName = tableName;
+ }
+
+ protected void initialise(String tableName) throws Exception
+ {
+ String jdbcAccessClassName = getAccessClassName();
+
+ if (jdbcAccessClassName == null)
{
- _jdbcAccess = jdbcAccess;
+ throw new FatalError(tsLogger.i18NLogger.get_objectstore_JDBCStore_5());
}
- /**
- * Get the JDBC table name.
- *
- * @return The table name.
- */
- protected String getTableName()
+ try
{
- return _jdbcTableName;
+ setupStore(jdbcAccessClassName, tableName);
}
-
- /**
- * Set the JDBC table name.
- *
- * @param tableName
- * The table name.
- */
- protected void setTableName(String tableName)
+ catch (Exception e)
{
- _jdbcTableName = tableName;
+ tsLogger.i18NLogger.fatal_objectstore_JDBCStore_1(getJDBCAccess().toString(), getTableName());
+ throw e;
}
- protected void initialise(String tableName) throws Exception
- {
- String jdbcAccessClassName = getAccessClassName();
+ _isValid = true;
+ }
- if (jdbcAccessClassName == null)
- {
- throw new FatalError(tsLogger.i18NLogger.get_objectstore_JDBCStore_5());
- }
+ /*
+ * Try to create the original and shadow/hidden tables. If this fails, then
+ * we will exit.
+ */
+ @SuppressWarnings("unchecked")
+ protected void setupStore(String jdbcAccessClassName, String tableName)
+ throws Exception
+ {
+ if (jdbcAccessClassName == null || jdbcAccessClassName.length() == 0)
+ throw new ObjectStoreException();
+ final JDBCAccess jdbcAccess;
+ synchronized (_theAccesses)
+ {
+ final Object jdbcAccessObject = _theAccesses
+ .get(jdbcAccessClassName);
+ if (jdbcAccessObject != null)
+ {
+ jdbcAccess = (JDBCAccess) jdbcAccessObject;
+ }
+ else
+ {
try
{
- setupStore(jdbcAccessClassName, tableName);
+ final Class jdbcAccessClass = Thread.currentThread()
+ .getContextClassLoader().loadClass(
+ jdbcAccessClassName);
+ jdbcAccess = (JDBCAccess) jdbcAccessClass.newInstance();
}
- catch (Exception e)
+ catch (final Exception ex)
{
- tsLogger.i18NLogger.fatal_objectstore_JDBCStore_1(getJDBCAccess().toString(), getTableName());
- throw e;
+ tsLogger.i18NLogger.fatal_objectstore_JDBCStore_2(jdbcAccessClassName, ex);
+ throw ex;
}
+ _theAccesses.put(jdbcAccessClassName, jdbcAccess);
+ }
+ }
+ setJDBCAccess(jdbcAccess);
- _isValid = true;
+ final String impleTableName;
+ if ((tableName != null) && (tableName.length() > 0))
+ {
+ impleTableName = tableName;
}
-
- /*
- * Try to create the original and shadow/hidden tables. If this fails, then
- * we will exit.
- */
- @SuppressWarnings("unchecked")
- protected void setupStore(String jdbcAccessClassName, String tableName)
- throws Exception
+ else
{
- if (jdbcAccessClassName == null || jdbcAccessClassName.length() == 0)
- throw new ObjectStoreException();
+ final String jdbcAccessTableName = jdbcAccess.tableName();
+ if ((jdbcAccessTableName != null)
+ && (jdbcAccessTableName.length() > 0))
+ {
+ impleTableName = jdbcAccessTableName;
+ }
+ else
+ {
+ impleTableName = getDefaultTableName();
+ }
+ }
- final JDBCAccess jdbcAccess;
- synchronized (_theAccesses)
+ setTableName(impleTableName);
+
+ final String impleKey = jdbcAccessClassName + ":" + impleTableName;
+
+ synchronized (_theImples)
+ {
+ final Object currentImple = _theImples.get(impleKey);
+ if (currentImple != null)
+ {
+ _theImple = (JDBCImple) currentImple;
+ }
+ else
+ {
+ try
{
- final Object jdbcAccessObject = _theAccesses
- .get(jdbcAccessClassName);
- if (jdbcAccessObject != null)
+ /*
+ * This had better not be an Arjuna jdbc connection!
+ */
+ final Connection connection;
+
+ try
+ {
+ connection = jdbcAccess.getConnection();
+ }
+ catch (final SQLException sqle)
+ {
+ tsLogger.i18NLogger.fatal_objectstore_JDBCStore_2("getConnection()", sqle);
+ throw sqle;
+ }
+
+ if (connection == null)
+ {
+ tsLogger.i18NLogger.fatal_objectstore_JDBCStore_1(getJDBCAccess().toString(), getTableName());
+ throw new SQLException("getConnection returned null");
+ }
+ boolean success = false;
+ try
+ {
+ connection.setAutoCommit(true);
+ final JDBCImple jdbcImple;
+ try
{
- jdbcAccess = (JDBCAccess) jdbcAccessObject;
+ final Class jdbcImpleClass = getJDBCClass(connection);
+ jdbcImple = (JDBCImple) jdbcImpleClass
+ .newInstance();
+ jdbcImple.setShareStatus(shareStatus);
}
- else
+ catch (final Exception ex)
{
- try
- {
- final Class jdbcAccessClass = Thread.currentThread()
- .getContextClassLoader().loadClass(
- jdbcAccessClassName);
- jdbcAccess = (JDBCAccess) jdbcAccessClass.newInstance();
- }
- catch (final Exception ex)
- {
- tsLogger.i18NLogger.fatal_objectstore_JDBCStore_2(jdbcAccessClassName, ex);
- throw ex;
- }
- _theAccesses.put(jdbcAccessClassName, jdbcAccess);
+ tsLogger.i18NLogger.fatal_objectstore_JDBCStore_2(getJDBCAccess().toString(), ex);
+ throw ex;
}
- }
- setJDBCAccess(jdbcAccess);
- final String impleTableName;
- if ((tableName != null) && (tableName.length() > 0))
- {
- impleTableName = tableName;
- }
- else
- {
- final String jdbcAccessTableName = jdbcAccess.tableName();
- if ((jdbcAccessTableName != null)
- && (jdbcAccessTableName.length() > 0))
- {
- impleTableName = jdbcAccessTableName;
+ if (!jdbcImple.initialise(connection, jdbcAccess,
+ impleTableName)) {
+ tsLogger.i18NLogger.warn_objectstore_JDBCStore_3();
+ throw new ObjectStoreException();
}
else
{
- impleTableName = getDefaultTableName();
+ _theImples.put(impleKey, jdbcImple);
+ _theImple = jdbcImple;
+ success = true;
}
- }
-
- setTableName(impleTableName);
-
- final String impleKey = jdbcAccessClassName + ":" + impleTableName;
-
- synchronized (_theImples)
- {
- final Object currentImple = _theImples.get(impleKey);
- if (currentImple != null)
+ }
+ finally
+ {
+ if (!success)
{
- _theImple = (JDBCImple) currentImple;
+ try
+ {
+ connection.close();
+ }
+ catch (final SQLException sqle)
+ {
+ } // Ignore exception
}
- else
- {
- try
- {
- /*
- * This had better not be an Arjuna jdbc connection!
- */
- final Connection connection;
-
- try
- {
- connection = jdbcAccess.getConnection();
- }
- catch (final SQLException sqle)
- {
- tsLogger.i18NLogger.fatal_objectstore_JDBCStore_2("getConnection()", sqle);
- throw sqle;
- }
-
- if (connection == null)
- {
- tsLogger.i18NLogger.fatal_objectstore_JDBCStore_1(getJDBCAccess().toString(), getTableName());
- throw new SQLException("getConnection returned null");
- }
- boolean success = false;
- try
- {
- connection.setAutoCommit(true);
- final JDBCImple jdbcImple;
- try
- {
- final Class jdbcImpleClass = getJDBCClass(connection);
- jdbcImple = (JDBCImple) jdbcImpleClass
- .newInstance();
- jdbcImple.setShareStatus(shareStatus);
- }
- catch (final Exception ex)
- {
- tsLogger.i18NLogger.fatal_objectstore_JDBCStore_2(getJDBCAccess().toString(), ex);
- throw ex;
- }
-
- if (!jdbcImple.initialise(connection, jdbcAccess,
- impleTableName)) {
- tsLogger.i18NLogger.warn_objectstore_JDBCStore_3();
- throw new ObjectStoreException();
- }
- else
- {
- _theImples.put(impleKey, jdbcImple);
- _theImple = jdbcImple;
- success = true;
- }
- }
- finally
- {
- if (!success)
- {
- try
- {
- connection.close();
- }
- catch (final SQLException sqle)
- {
- } // Ignore exception
- }
- }
- }
- catch (Exception e)
- {
- tsLogger.logger.warn(e);
- throw e;
- }
- }
- _isValid = true;
+ }
}
+ catch (Exception e)
+ {
+ tsLogger.logger.warn(e);
+ throw e;
+ }
+ }
+ _isValid = true;
}
+ }
- /**
- * Attempt to load the database class. This method searches for a
- * class called <name>_<major>_<minor>, then <name>_<major> and finally
- * <dbName>
- *
- * @param conn
- * A database connection.
- * @return The database class.
- * @throws ClassNotFoundException
- * If no database class can be found.
- * @throws SQLException
- * If the database connection cannot be interrogated.
- */
- @SuppressWarnings("unchecked")
+ /**
+ * Attempt to load the database class. This method searches for a
+ * class called <name>_<major>_<minor>, then <name>_<major> and finally
+ * <dbName>
+ *
+ * @param conn
+ * A database connection.
+ * @return The database class.
+ * @throws ClassNotFoundException
+ * If no database class can be found.
+ * @throws SQLException
+ * If the database connection cannot be interrogated.
+ */
+ @SuppressWarnings("unchecked")
protected Class getJDBCClass(Connection conn)
- throws ClassNotFoundException, SQLException
- {
- DatabaseMetaData md = conn.getMetaData();
+ throws ClassNotFoundException, SQLException
+ {
+ DatabaseMetaData md = conn.getMetaData();
- String name = md.getDriverName();
- int major = md.getDriverMajorVersion();
- int minor = md.getDriverMinorVersion();
+ String name = md.getDriverName();
+ int major = md.getDriverMajorVersion();
+ int minor = md.getDriverMinorVersion();
- /*
- * Check for spaces in the name - our implementation classes are always
- * just the first part of such names.
- */
+ /*
+ * Check for spaces in the name - our implementation classes are always
+ * just the first part of such names.
+ */
- int index = name.indexOf(' ');
+ int index = name.indexOf(' ');
- if (index != -1)
- name = name.substring(0, index);
+ if (index != -1)
+ name = name.substring(0, index);
name = name.replaceAll("-", "_");
- name = name.toLowerCase();
+ name = name.toLowerCase();
- final ClassLoader classLoader = Thread.currentThread()
- .getContextClassLoader();
- final String packageName = getClass().getPackage().getName() + ".jdbc.";
- try
- {
- return classLoader.loadClass(packageName + name + "_" + major + "_"
- + minor + "_driver");
- }
- catch (final ClassNotFoundException cnfe)
- {
- }
- try
- {
- return classLoader.loadClass(packageName + name + "_" + major
- + "_driver");
- }
- catch (final ClassNotFoundException cnfe)
- {
- }
- return classLoader.loadClass(packageName + name + "_driver");
+ final ClassLoader classLoader = Thread.currentThread()
+ .getContextClassLoader();
+ final String packageName = getClass().getPackage().getName() + ".jdbc.";
+ try
+ {
+ return classLoader.loadClass(packageName + name + "_" + major + "_"
+ + minor + "_driver");
}
-
- protected boolean supressEntry(String name)
+ catch (final ClassNotFoundException cnfe)
{
- return true;
}
+ try
+ {
+ return classLoader.loadClass(packageName + name + "_" + major
+ + "_driver");
+ }
+ catch (final ClassNotFoundException cnfe)
+ {
+ }
+ return classLoader.loadClass(packageName + name + "_driver");
+ }
- /*
- * Instance specific data.
- */
+ protected boolean supressEntry(String name)
+ {
+ return true;
+ }
- protected boolean _isValid;
+ /*
+ * Instance specific data.
+ */
- protected JDBCImple _theImple;
+ protected boolean _isValid;
- private JDBCAccess _jdbcAccess;
+ protected JDBCImple _theImple;
- private String _jdbcAccessClassName;
+ private JDBCAccess _jdbcAccess;
- private String _jdbcTableName;
+ private String _jdbcAccessClassName;
- private static String _defaultTableName = "JBossTSTable";
+ private String _jdbcTableName;
- /*
- * Class data.
- */
+ private static String _defaultTableName = "JBossTSTable";
- protected static final HashMap _theImples = new HashMap();
+ /*
+ * Class data.
+ */
- protected static final HashMap _theAccesses = new HashMap();
+ protected static final HashMap _theImples = new HashMap();
+
+ protected static final HashMap _theAccesses = new HashMap();
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/LogStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/LogStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/LogStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -24,10 +24,8 @@
import java.util.Iterator;
import java.util.Stack;
+import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.arjuna.common.arjPropertyManager;
-import com.arjuna.ats.arjuna.exceptions.FatalError;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
import com.arjuna.ats.arjuna.objectstore.StateStatus;
import com.arjuna.ats.arjuna.objectstore.StateType;
import com.arjuna.ats.arjuna.state.*;
@@ -126,129 +124,129 @@
class LogInstance
{
- public class TransactionData
- {
- TransactionData (final Uid tx, final long off, final LogInstance parent)
- {
- txId = tx;
- offset = off;
- container = parent;
- }
+ public class TransactionData
+ {
+ TransactionData (final Uid tx, final long off, final LogInstance parent)
+ {
+ txId = tx;
+ offset = off;
+ container = parent;
+ }
- public final Uid txId;
- public final long offset;
- public final LogInstance container;
- }
+ public final Uid txId;
+ public final long offset;
+ public final LogInstance container;
+ }
- public LogInstance(String tn, long size)
- {
- _logName = new Uid();
- _typeName = tn;
- _frozen = false;
- _totalSize = size;
- }
+ public LogInstance(String tn, long size)
+ {
+ _logName = new Uid();
+ _typeName = tn;
+ _frozen = false;
+ _totalSize = size;
+ }
- /*
- * Once frozen we will not use the log again except for recovery and
- * pruning.
- *
- * We could consider another algorithm that reuses the log once it has
- * dropped below a threshold size. Probably not worth it at the moment.
- */
+ /*
+ * Once frozen we will not use the log again except for recovery and
+ * pruning.
+ *
+ * We could consider another algorithm that reuses the log once it has
+ * dropped below a threshold size. Probably not worth it at the moment.
+ */
- public final boolean isFrozen()
- {
- return _frozen;
- }
+ public final boolean isFrozen()
+ {
+ return _frozen;
+ }
- public final void freeze() // one way operation.
- {
- _frozen = true;
- }
+ public final void freeze() // one way operation.
+ {
+ _frozen = true;
+ }
- public final int numberOfUsers()
- {
- return _transactions.size();
- }
+ public final int numberOfUsers()
+ {
+ return _transactions.size();
+ }
- public final Uid getName()
- {
- return _logName;
- }
+ public final Uid getName()
+ {
+ return _logName;
+ }
- public final String getTypeName()
- {
- return _typeName;
- }
+ public final String getTypeName()
+ {
+ return _typeName;
+ }
- public final InputObjectState allObjUids () throws ObjectStoreException
- {
- OutputObjectState state = new OutputObjectState();
- Iterator<Uid> iter = _ids.keySet().iterator();
+ public final InputObjectState allObjUids () throws ObjectStoreException
+ {
+ OutputObjectState state = new OutputObjectState();
+ Iterator<Uid> iter = _ids.keySet().iterator();
- try
- {
- while (iter.hasNext())
- {
- UidHelper.packInto(iter.next(), state);
- }
+ try
+ {
+ while (iter.hasNext())
+ {
+ UidHelper.packInto(iter.next(), state);
+ }
- // don't forget to null terminate
+ // don't forget to null terminate
- UidHelper.packInto(Uid.nullUid(), state);
- }
- catch (final IOException ex)
- {
- throw new ObjectStoreException(ex);
- }
+ UidHelper.packInto(Uid.nullUid(), state);
+ }
+ catch (final IOException ex)
+ {
+ throw new ObjectStoreException(ex);
+ }
- return new InputObjectState(state);
- }
+ return new InputObjectState(state);
+ }
- public final boolean present(Uid id)
- {
- return _ids.containsKey(id);
- }
+ public final boolean present(Uid id)
+ {
+ return _ids.containsKey(id);
+ }
- public final TransactionData getTxId (Uid txId)
- {
- return new TransactionData(txId, _used, this);
- }
+ public final TransactionData getTxId (Uid txId)
+ {
+ return new TransactionData(txId, _used, this);
+ }
- public final TransactionData addTxId (Uid txId, long size)
- {
- TransactionData td = new TransactionData(txId, _used, this);
+ public final TransactionData addTxId (Uid txId, long size)
+ {
+ TransactionData td = new TransactionData(txId, _used, this);
- _transactions.add(td); // allow multiple entries in the same log
- _ids.put(txId, txId);
- _used += size;
+ _transactions.add(td); // allow multiple entries in the same log
+ _ids.put(txId, txId);
+ _used += size;
- return td;
- }
+ return td;
+ }
- public final long remaining()
- {
- return _totalSize - _used;
- }
+ public final long remaining()
+ {
+ return _totalSize - _used;
+ }
- public final void resize (long size)
- {
- _totalSize = size;
- }
+ public final void resize (long size)
+ {
+ _totalSize = size;
+ }
- public String toString()
- {
- return "LogInstance < " + _logName + ", " + _typeName + ", "
- + numberOfUsers() + ", " + remaining() + " >";
- }
+ public String toString()
+ {
+ return "LogInstance < " + _logName + ", " + _typeName + ", "
+ + numberOfUsers() + ", " + remaining() + " >";
+ }
- private Uid _logName;
- private String _typeName;
- private boolean _frozen;
- private Stack<TransactionData> _transactions = new Stack<TransactionData>();
- private HashMap<Uid, Uid> _ids = new HashMap<Uid, Uid>();
- private long _used = 0;
- private long _totalSize;
+ private Uid _logName;
+ private String _typeName;
+ private boolean _frozen;
+ private Stack<TransactionData> _transactions = new Stack<TransactionData>();
+ private HashMap<Uid, Uid> _ids = new HashMap<Uid, Uid>();
+ private long _used = 0;
+ private long _totalSize;
}
/*
@@ -258,166 +256,166 @@
class LogPurger extends Thread
{
- private enum Status {ACTIVE, PASSIVE, TERMINATED};
+ private enum Status {ACTIVE, PASSIVE, TERMINATED};
- class LogElement
- {
- public LogElement(final String t, final Uid u, final int s)
- {
- tn = t;
- uid = u;
- state = s;
- }
+ class LogElement
+ {
+ public LogElement(final String t, final Uid u, final int s)
+ {
+ tn = t;
+ uid = u;
+ state = s;
+ }
- public String tn;
- public Uid uid;
- public int state;
- };
+ public String tn;
+ public Uid uid;
+ public int state;
+ };
- /*
- * Purge every N seconds.
- *
- * TODO purge after number of logs > M
- */
+ /*
+ * Purge every N seconds.
+ *
+ * TODO purge after number of logs > M
+ */
- public static final long DEFAULT_PURGE_TIME = 100000; // 100 seconds
+ public static final long DEFAULT_PURGE_TIME = 100000; // 100 seconds
- public LogPurger(LogStore instance)
- {
- this(instance, DEFAULT_PURGE_TIME);
- }
+ public LogPurger(LogStore instance)
+ {
+ this(instance, DEFAULT_PURGE_TIME);
+ }
- public LogPurger(LogStore instance, long purgeTime)
- {
+ public LogPurger(LogStore instance, long purgeTime)
+ {
super("Log Purger");
- _objStore = instance;
- _purgeTime = purgeTime;
- }
+ _objStore = instance;
+ _purgeTime = purgeTime;
+ }
- public void addRemovedState(final Uid u, final String tn, final int state)
- {
- synchronized (_entries)
- {
- _entries.put(u, new LogElement(tn, u, state));
- }
- }
+ public void addRemovedState(final Uid u, final String tn, final int state)
+ {
+ synchronized (_entries)
+ {
+ _entries.put(u, new LogElement(tn, u, state));
+ }
+ }
- public void purge()
- {
- try
- {
- _objStore.truncateLogs(true);
- }
- catch (final Exception ex)
- {
- }
- }
+ public void purge()
+ {
+ try
+ {
+ _objStore.truncateLogs(true);
+ }
+ catch (final Exception ex)
+ {
+ }
+ }
- public void writeRemovalEntries()
- {
- synchronized (_entries)
- {
- if (_entries.size() > 0)
- {
- Collection<LogElement> entries = _entries.values();
- Iterator<LogElement> iter = entries.iterator();
+ public void writeRemovalEntries()
+ {
+ synchronized (_entries)
+ {
+ if (_entries.size() > 0)
+ {
+ Collection<LogElement> entries = _entries.values();
+ Iterator<LogElement> iter = entries.iterator();
- while (iter.hasNext())
- {
- LogElement val = iter.next();
+ while (iter.hasNext())
+ {
+ LogElement val = iter.next();
- try
- {
- _objStore.removeState(val.uid, val.tn, val.state);
- }
- catch (final Exception ex)
- {
- // TODO log warning, but there's nothing else we can do.
- }
- }
+ try
+ {
+ _objStore.removeState(val.uid, val.tn, val.state);
+ }
+ catch (final Exception ex)
+ {
+ // TODO log warning, but there's nothing else we can do.
+ }
+ }
- _entries.clear();
- }
- }
- }
+ _entries.clear();
+ }
+ }
+ }
- /**
- * Poke the thread into doing some work even if it normally
- * would not.
- */
+ /**
+ * Poke the thread into doing some work even if it normally
+ * would not.
+ */
- public void trigger ()
- {
- synchronized (_lock)
- {
- if (_status == Status.PASSIVE)
- _lock.notify();
- }
- }
+ public void trigger ()
+ {
+ synchronized (_lock)
+ {
+ if (_status == Status.PASSIVE)
+ _lock.notify();
+ }
+ }
- public void run()
- {
- for (;;)
- {
- // TODO activate thread during read and get it to write deleted states
+ public void run()
+ {
+ for (;;)
+ {
+ // TODO activate thread during read and get it to write deleted states
- try
- {
- synchronized (_lock)
- {
- _status = Status.PASSIVE;
+ try
+ {
+ synchronized (_lock)
+ {
+ _status = Status.PASSIVE;
- _lock.wait(_purgeTime);
- }
- }
- catch (final Exception ex)
- {
- _status = Status.ACTIVE;
- }
+ _lock.wait(_purgeTime);
+ }
+ }
+ catch (final Exception ex)
+ {
+ _status = Status.ACTIVE;
+ }
- /*
- * Write any asynchronous delete records.
- */
+ /*
+ * Write any asynchronous delete records.
+ */
- writeRemovalEntries();
+ writeRemovalEntries();
- /*
- * Now truncate any logs we've been working on.
- */
+ /*
+ * Now truncate any logs we've been working on.
+ */
- try
- {
- _objStore.truncateLogs();
- }
- catch (final Exception ex)
- {
- }
- }
+ try
+ {
+ _objStore.truncateLogs();
+ }
+ catch (final Exception ex)
+ {
+ }
+ }
- // _status = Status.TERMINATED;
- }
+ // _status = Status.TERMINATED;
+ }
- private HashMap<Uid, LogElement> _entries = new HashMap<Uid, LogElement>();
- private long _purgeTime;
- private LogStore _objStore;
- private Status _status;
- private Object _lock = new Object();
+ private HashMap<Uid, LogElement> _entries = new HashMap<Uid, LogElement>();
+ private long _purgeTime;
+ private LogStore _objStore;
+ private Status _status;
+ private Object _lock = new Object();
}
class PurgeShutdownHook extends Thread
{
- public PurgeShutdownHook(LogPurger purger)
- {
- _purger = purger;
- }
+ public PurgeShutdownHook(LogPurger purger)
+ {
+ _purger = purger;
+ }
- public void run()
- {
- _purger.writeRemovalEntries(); // flush everything in the cache first.
- _purger.purge();
- }
+ public void run()
+ {
+ _purger.writeRemovalEntries(); // flush everything in the cache first.
+ _purger.purge();
+ }
- private LogPurger _purger;
+ private LogPurger _purger;
}
/*
@@ -428,1032 +426,973 @@
public class LogStore extends FileSystemStore
{
- public static final long LOG_SIZE = 10 * 1024 * 1024; // default maximum log size in bytes
+ public static final long LOG_SIZE = 10 * 1024 * 1024; // default maximum log size in bytes
- private static final String FILE_MODE = "rwd";
+ private static final String FILE_MODE = "rwd";
- public int typeIs()
- {
- return ObjectStoreType.ACTIONLOG;
- }
+ /**
+ * Normally returns the current state of the log entry. However, this is
+ * never called during normal (non-recovery) execution. Therefore, the
+ * overhead of having to scan all of the logs (if it's not one we're using)
+ * is minimal.
+ */
- /**
- * Normally returns the current state of the log entry. However, this is
- * never called during normal (non-recovery) execution. Therefore, the
- * overhead of having to scan all of the logs (if it's not one we're using)
- * is minimal.
- */
+ public int currentState(Uid objUid, String tName)
+ throws ObjectStoreException
+ {
+ InputObjectState ios = new InputObjectState();
- public int currentState(Uid objUid, String tName)
- throws ObjectStoreException
- {
- InputObjectState ios = new InputObjectState();
+ /*
+ * TODO
+ *
+ * It's possible that the entry has been marked to be deleted but
+ * that the removal entry hasn't been written yet. We could check the
+ * async cache. However, since we really only care about this during
+ * recovery, it's not going to cause us problems anyway.
+ */
- /*
- * TODO
- *
- * It's possible that the entry has been marked to be deleted but
- * that the removal entry hasn't been written yet. We could check the
- * async cache. However, since we really only care about this during
- * recovery, it's not going to cause us problems anyway.
- */
+ if (allObjUids(tName, ios, StateStatus.OS_UNKNOWN))
+ {
+ Uid tempUid = new Uid(Uid.nullUid());
- if (allObjUids(tName, ios, StateStatus.OS_UNKNOWN))
- {
- Uid tempUid = new Uid(Uid.nullUid());
+ do
+ {
+ try
+ {
+ tempUid = UidHelper.unpackFrom(ios);
+ }
+ catch (final Exception ex)
+ {
+ ex.printStackTrace();
- do
- {
- try
- {
- tempUid = UidHelper.unpackFrom(ios);
- }
- catch (final Exception ex)
- {
- ex.printStackTrace();
+ return StateStatus.OS_UNKNOWN;
+ }
- return StateStatus.OS_UNKNOWN;
- }
+ if (tempUid.equals(objUid))
+ return StateStatus.OS_COMMITTED;
- if (tempUid.equals(objUid))
- return StateStatus.OS_COMMITTED;
+ } while (tempUid.notEquals(Uid.nullUid()));
- } while (tempUid.notEquals(Uid.nullUid()));
+ return StateStatus.OS_UNKNOWN;
+ }
+ else
+ return StateStatus.OS_UNKNOWN;
+ }
- return StateStatus.OS_UNKNOWN;
- }
- else
- return StateStatus.OS_UNKNOWN;
- }
+ /**
+ * Commit a previous write_state operation which was made with the SHADOW
+ * StateType argument. This is achieved by renaming the shadow and removing
+ * the hidden version.
+ */
- /**
- * Commit a previous write_state operation which was made with the SHADOW
- * StateType argument. This is achieved by renaming the shadow and removing
- * the hidden version.
- */
+ public boolean commit_state(Uid objUid, String tName)
+ throws ObjectStoreException
+ {
+ return true;
+ }
- public boolean commit_state(Uid objUid, String tName)
- throws ObjectStoreException
- {
- return true;
- }
-
- public boolean hide_state(Uid u, String tn) throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
+ public boolean hide_state(Uid u, String tn) throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("LogStore.hide_state(" + u + ", " + tn + ")");
}
- return false;
- }
+ return false;
+ }
- public boolean reveal_state(Uid u, String tn) throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
+ public boolean reveal_state(Uid u, String tn) throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("LogStore.reveal_state(" + u + ", " + tn + ")");
}
- return false;
- }
+ return false;
+ }
- public InputObjectState read_uncommitted(Uid u, String tn)
- throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
+ public InputObjectState read_uncommitted(Uid u, String tn)
+ throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("LogStore.read_uncommitted(" + u + ", " + tn + ")");
}
- return null;
- }
+ return null;
+ }
- public boolean remove_uncommitted(Uid u, String tn)
- throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
+ public boolean remove_uncommitted(Uid u, String tn)
+ throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("LogStore.remove_uncommitted(" + u + ", " + tn + ")");
}
- return false;
- }
+ return false;
+ }
- public boolean write_committed(Uid storeUid, String tName,
- OutputObjectState state) throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
+ public boolean write_committed(Uid storeUid, String tName,
+ OutputObjectState state) throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("LogStore.write_committed(" + storeUid + ", "
+ tName + ")");
}
- try
- {
- return super.write_committed(storeUid, tName, state);
- }
- catch (ObjectStoreException ex)
- {
- removeFromLog(storeUid);
+ try
+ {
+ return super.write_committed(storeUid, tName, state);
+ }
+ catch (ObjectStoreException ex)
+ {
+ removeFromLog(storeUid);
- throw ex;
- }
- }
+ throw ex;
+ }
+ }
- public boolean write_uncommitted(Uid u, String tn, OutputObjectState s)
- throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
+ public boolean write_uncommitted(Uid u, String tn, OutputObjectState s)
+ throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("LogStore.write_uncommitted(" + u + ", " + tn + ", " + s
+ ")");
}
- return false;
- }
+ return false;
+ }
- public boolean allLogUids (String tName, InputObjectState state, int match) throws ObjectStoreException
- {
- return super.allObjUids(tName, state, match);
- }
+ public boolean allLogUids (String tName, InputObjectState state, int match) throws ObjectStoreException
+ {
+ return super.allObjUids(tName, state, match);
+ }
- /**
- * This is a recovery-only method and should not be called during normal
- * execution. As such we need to load in all of the logs we can find that
- * aren't already loaded (or activated).
- */
+ /**
+ * This is a recovery-only method and should not be called during normal
+ * execution. As such we need to load in all of the logs we can find that
+ * aren't already loaded (or activated).
+ */
- public boolean allObjUids(String tName, InputObjectState state, int match)
- throws ObjectStoreException
- {
- /*
- * match will always be OS_COMMITTED since that's all we ever write for
- * the logs.
- */
+ public boolean allObjUids(String tName, InputObjectState state, int match)
+ throws ObjectStoreException
+ {
+ /*
+ * match will always be OS_COMMITTED since that's all we ever write for
+ * the logs.
+ */
- // in case of asynchronous removals trigger the purger now.
+ // in case of asynchronous removals trigger the purger now.
- _purger.trigger();
+ _purger.trigger();
- /*
- * Get a list of logs. Load them in to memory if we aren't already
- * working on them/it. But we can prune the entry once we're
- * finished or the memory footprint will grow. We should do this
- * for all frozen entries eventually too.
- */
+ /*
+ * Get a list of logs. Load them in to memory if we aren't already
+ * working on them/it. But we can prune the entry once we're
+ * finished or the memory footprint will grow. We should do this
+ * for all frozen entries eventually too.
+ */
- InputObjectState logs = new InputObjectState();
- OutputObjectState objUids = new OutputObjectState();
+ InputObjectState logs = new InputObjectState();
+ OutputObjectState objUids = new OutputObjectState();
- /*
- * We never call this method except during recovery. As such we shouldn't
- * need to worry about optimizations such as checking whether or not the
- * log is in current working memory.
- */
+ /*
+ * We never call this method except during recovery. As such we shouldn't
+ * need to worry about optimizations such as checking whether or not the
+ * log is in current working memory.
+ */
- if (!super.allObjUids(tName, logs, match))
- return false;
- else
- {
- /*
- * Now we have all of the log names let's attach to each one
- * and locate the committed instances (not deleted.)
- */
+ if (!super.allObjUids(tName, logs, match))
+ return false;
+ else
+ {
+ /*
+ * Now we have all of the log names let's attach to each one
+ * and locate the committed instances (not deleted.)
+ */
- Uid logName = new Uid(Uid.nullUid());
+ Uid logName = new Uid(Uid.nullUid());
- try
- {
- do
- {
- logName = UidHelper.unpackFrom(logs);
+ try
+ {
+ do
+ {
+ logName = UidHelper.unpackFrom(logs);
- if (logName.notEquals(Uid.nullUid()))
- {
- /*
- * Could check to see if log is in current working memory.
- */
+ if (logName.notEquals(Uid.nullUid()))
+ {
+ /*
+ * Could check to see if log is in current working memory.
+ */
- /*
- * TODO
- *
- * First purge the log if we can, but we need to know that
- * we're not playing with an instance that is being manipulated
- * from another VM instance.
- */
+ /*
+ * TODO
+ *
+ * First purge the log if we can, but we need to know that
+ * we're not playing with an instance that is being manipulated
+ * from another VM instance.
+ */
- ArrayList<InputObjectState> txs = scanLog(logName, tName);
+ ArrayList<InputObjectState> txs = scanLog(logName, tName);
- if (txs.size() > 0)
- {
- for (int i = 0; i < txs.size(); i++)
- {
- UidHelper.packInto(txs.get(i).stateUid(), objUids);
- }
- }
- }
- } while (logName.notEquals(Uid.nullUid()));
+ if (txs.size() > 0)
+ {
+ for (int i = 0; i < txs.size(); i++)
+ {
+ UidHelper.packInto(txs.get(i).stateUid(), objUids);
+ }
+ }
+ }
+ } while (logName.notEquals(Uid.nullUid()));
- // remember null terminator
+ // remember null terminator
- UidHelper.packInto(Uid.nullUid(), objUids);
+ UidHelper.packInto(Uid.nullUid(), objUids);
- state.setBuffer(objUids.buffer());
- }
- catch (final IOException ex)
- {
- ex.printStackTrace();
+ state.setBuffer(objUids.buffer());
+ }
+ catch (final IOException ex)
+ {
+ ex.printStackTrace();
- return false;
- }
+ return false;
+ }
- return true;
- }
- }
-
- public LogStore(String locationOfStore)
- {
- this(locationOfStore, StateType.OS_SHARED);
- }
-
- public LogStore(String locationOfStore, int shareStatus)
- {
- super(shareStatus);
-
- try
- {
- setupStore(locationOfStore);
- }
- catch (ObjectStoreException e) {
- tsLogger.logger.warn(e);
-
- super.makeInvalid();
-
- throw new FatalError(e.toString(), e);
+ return true;
}
- }
+ }
- public LogStore()
- {
- this(StateType.OS_SHARED);
- }
+ public LogStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
+ {
+ super(objectStoreEnvironmentBean);
- public LogStore(int shareStatus)
- {
- super(shareStatus);
-
- try
- {
- setupStore(arjPropertyManager.getObjectStoreEnvironmentBean().getLocalOSRoot());
- }
- catch (ObjectStoreException e) {
- tsLogger.logger.warn(e);
+ // overrides parents use of isObjectStoreSync
+ doSync = objectStoreEnvironmentBean.isTransactionSync();
- super.makeInvalid();
+ _synchronousRemoval = objectStoreEnvironmentBean.isSynchronousRemoval();
- throw new FatalError(e.toString(), e);
- }
- }
+ _purgeTime = objectStoreEnvironmentBean.getPurgeTime();
- protected synchronized boolean setupStore(String location)
- throws ObjectStoreException
- {
- if (!checkSync)
- {
- if(arjPropertyManager.getObjectStoreEnvironmentBean().isTransactionSync()) {
- syncOn();
- } else {
- syncOff();
- }
- }
+ _maxFileSize = objectStoreEnvironmentBean.getTxLogSize();
- checkSync = true;
+ _purger = new LogPurger(this, _purgeTime);
+ _purger.setDaemon(true);
- if (_purger == null)
- {
- _purger = new LogPurger(this, _purgeTime);
- _purger.setDaemon(true);
+ Runtime.getRuntime().addShutdownHook(new PurgeShutdownHook(_purger));
- Runtime.getRuntime()
- .addShutdownHook(new PurgeShutdownHook(_purger));
+ _purger.start();
+ }
- _purger.start();
- }
+ /**
+ * Unlock and close the file. Note that if the unlock fails we set the
+ * return value to false to indicate an error but rely on the close to
+ * really do the unlock.
+ */
- return super.setupStore(location);
- }
-
- /**
- * Unlock and close the file. Note that if the unlock fails we set the
- * return value to false to indicate an error but rely on the close to
- * really do the unlock.
- */
-
- protected boolean unlockAndClose(File fd, RandomAccessFile rf)
- {
- if (tsLogger.logger.isTraceEnabled()) {
+ protected boolean unlockAndClose(File fd, RandomAccessFile rf)
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("RandomAccessFile.unlockAndClose(" + fd + ", " + rf + ")");
}
- boolean closedOk = unlock(fd);
+ boolean closedOk = unlock(fd);
- try
- {
- rf.close();
- }
- catch (Exception e)
- {
- closedOk = false;
- }
+ try
+ {
+ rf.close();
+ }
+ catch (Exception e)
+ {
+ closedOk = false;
+ }
- return closedOk;
- }
+ return closedOk;
+ }
- /**
- * write_state saves the ObjectState in a file named by the type and Uid of
- * the ObjectState. If the second argument is SHADOW, then the file name is
- * different so that a subsequent commit_state invocation will rename the
- * file.
- *
- * We need to make sure that each entry is written to the next empty location
- * in the log even if there's already an entry for this tx.
- */
+ /**
+ * write_state saves the ObjectState in a file named by the type and Uid of
+ * the ObjectState. If the second argument is SHADOW, then the file name is
+ * different so that a subsequent commit_state invocation will rename the
+ * file.
+ *
+ * We need to make sure that each entry is written to the next empty location
+ * in the log even if there's already an entry for this tx.
+ */
- protected boolean write_state(Uid objUid, String tName,
- OutputObjectState state, int ft) throws ObjectStoreException
- {
- if (tsLogger.logger.isTraceEnabled()) {
+ protected boolean write_state(Uid objUid, String tName,
+ OutputObjectState state, int ft) throws ObjectStoreException
+ {
+ if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("ShadowingStore.write_state(" + objUid + ", " + tName
+ ", " + StateType.stateTypeString(ft) + ")");
}
- if (!storeValid())
- return false;
+ String fname = null;
+ File fd = null;
- String fname = null;
- File fd = null;
+ if (tName != null)
+ {
+ int imageSize = (int) state.length();
+ byte[] uidString = objUid.stringForm().getBytes();
+ int buffSize = _redzone.length + uidString.length + imageSize + 8; // don't put in endOfLog since we keep overwriting that.
+ RandomAccessFile ofile = null;
+ java.nio.channels.FileLock lock = null;
- if (tName != null)
- {
- int imageSize = (int) state.length();
- byte[] uidString = objUid.stringForm().getBytes();
- int buffSize = _redzone.length + uidString.length + imageSize + 8; // don't put in endOfLog since we keep overwriting that.
- RandomAccessFile ofile = null;
- java.nio.channels.FileLock lock = null;
+ if (imageSize > 0)
+ {
+ TransactionData theLogEntry = getLogName(objUid, tName, buffSize); // always adds entry to log
+ LogInstance theLog = theLogEntry.container;
- if (imageSize > 0)
- {
- TransactionData theLogEntry = getLogName(objUid, tName, buffSize); // always adds entry to log
- LogInstance theLog = theLogEntry.container;
+ if (theLog == null)
+ throw new ObjectStoreException();
- if (theLog == null)
- throw new ObjectStoreException();
+ fname = genPathName(theLog.getName(), tName, ft);
+ fd = openAndLock(fname, FileLock.F_WRLCK, true);
- fname = genPathName(theLog.getName(), tName, ft);
- fd = openAndLock(fname, FileLock.F_WRLCK, true);
-
- if (fd == null) {
+ if (fd == null) {
tsLogger.i18NLogger.warn_objectstore_ShadowingStore_18(fname);
return false;
}
- boolean setLength = !fd.exists();
+ boolean setLength = !fd.exists();
- try
- {
- ofile = new RandomAccessFile(fd, FILE_MODE);
+ try
+ {
+ ofile = new RandomAccessFile(fd, FILE_MODE);
- if (setLength)
- {
- ofile.setLength(_maxFileSize);
- }
- else
- {
- // may have to resize file if we keep updating this transaction info
+ if (setLength)
+ {
+ ofile.setLength(_maxFileSize);
+ }
+ else
+ {
+ // may have to resize file if we keep updating this transaction info
- if (theLog.remaining() < buffSize)
- {
- long size = ofile.length() + buffSize - theLog.remaining();
+ if (theLog.remaining() < buffSize)
+ {
+ long size = ofile.length() + buffSize - theLog.remaining();
- ofile.setLength(size);
+ ofile.setLength(size);
- theLog.resize(size);
- }
- }
+ theLog.resize(size);
+ }
+ }
- java.nio.ByteBuffer buff = java.nio.ByteBuffer.allocate(buffSize);
+ java.nio.ByteBuffer buff = java.nio.ByteBuffer.allocate(buffSize);
- buff.put(_redzone);
- buff.putInt(uidString.length);
- buff.put(uidString);
- buff.putInt(imageSize);
- buff.put(state.buffer());
+ buff.put(_redzone);
+ buff.putInt(uidString.length);
+ buff.put(uidString);
+ buff.putInt(imageSize);
+ buff.put(state.buffer());
- synchronized (_lock)
- {
- ofile.seek(theLogEntry.offset);
+ synchronized (_lock)
+ {
+ ofile.seek(theLogEntry.offset);
- ofile.write(buff.array());
- }
- }
- catch (SyncFailedException e)
- {
- unlockAndClose(fd, ofile);
+ ofile.write(buff.array());
+ }
+ }
+ catch (SyncFailedException e)
+ {
+ unlockAndClose(fd, ofile);
- throw new ObjectStoreException(
- "ShadowingStore::write_state() - write failed to sync for "
- + fname, e);
- }
- catch (FileNotFoundException e)
- {
- unlockAndClose(fd, ofile);
+ throw new ObjectStoreException(
+ "ShadowingStore::write_state() - write failed to sync for "
+ + fname, e);
+ }
+ catch (FileNotFoundException e)
+ {
+ unlockAndClose(fd, ofile);
- e.printStackTrace();
+ e.printStackTrace();
- throw new ObjectStoreException(
- "ShadowingStore::write_state() - write failed to locate file "
- + fname + ": " + e, e);
- }
- catch (IOException e)
- {
- unlockAndClose(fd, ofile);
+ throw new ObjectStoreException(
+ "ShadowingStore::write_state() - write failed to locate file "
+ + fname + ": " + e, e);
+ }
+ catch (IOException e)
+ {
+ unlockAndClose(fd, ofile);
- e.printStackTrace();
+ e.printStackTrace();
- throw new ObjectStoreException(
- "ShadowingStore::write_state() - write failed for "
- + fname + ": " + e, e);
- }
- finally
- {
- try
- {
- if (lock != null)
- lock.release();
- }
- catch (IOException ex)
- {
- ex.printStackTrace();
- }
- }
- }
+ throw new ObjectStoreException(
+ "ShadowingStore::write_state() - write failed for "
+ + fname + ": " + e, e);
+ }
+ finally
+ {
+ try
+ {
+ if (lock != null)
+ lock.release();
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
- if (!unlockAndClose(fd, ofile)) {
+ if (!unlockAndClose(fd, ofile)) {
tsLogger.i18NLogger.warn_objectstore_ShadowingStore_19(fname);
}
- super.addToCache(fname);
+ super.addToCache(fname);
- return true;
- }
- else
- throw new ObjectStoreException(
+ return true;
+ }
+ else
+ throw new ObjectStoreException(
"ShadowStore::write_state - "
+ tsLogger.i18NLogger.get_objectstore_notypenameuid()
- + objUid);
- }
+ + objUid);
+ }
- /**
- * Shouldn't be called during normal execution only during recovery.
- */
+ /**
+ * Shouldn't be called during normal execution only during recovery.
+ */
- protected InputObjectState read_state(Uid u, String tn, int s)
- throws ObjectStoreException
- {
- /*
- * In case of asynchronous removals of state, let's trigger the purger
- * thread to flush its cache now. Try to avoid false positives during
- * recovery wherever possible!
- */
+ protected InputObjectState read_state(Uid u, String tn, int s)
+ throws ObjectStoreException
+ {
+ /*
+ * In case of asynchronous removals of state, let's trigger the purger
+ * thread to flush its cache now. Try to avoid false positives during
+ * recovery wherever possible!
+ */
- _purger.trigger();
+ _purger.trigger();
- /*
- * It's possible that recovery got hold of a state id while it was
- * being deleted (marker written and pruning thread not yet active).
- * In which case when it comes to do a read it's not going to find
- * the state there any longer. Conversely it's possible that it could do
- * a read on a state that is about to be deleted. Recovery should be
- * able to cope with these edge cases.
- */
+ /*
+ * It's possible that recovery got hold of a state id while it was
+ * being deleted (marker written and pruning thread not yet active).
+ * In which case when it comes to do a read it's not going to find
+ * the state there any longer. Conversely it's possible that it could do
+ * a read on a state that is about to be deleted. Recovery should be
+ * able to cope with these edge cases.
+ */
- TransactionData td = getLogName(u, tn, -1);
+ TransactionData td = getLogName(u, tn, -1);
- if (td == null)
- throw new ObjectStoreException();
+ if (td == null)
+ throw new ObjectStoreException();
- ArrayList<InputObjectState> states = scanLog(td.container.getName(), tn);
+ ArrayList<InputObjectState> states = scanLog(td.container.getName(), tn);
- if ((states == null) || (states.size() == 0))
- return null;
+ if ((states == null) || (states.size() == 0))
+ return null;
- for (int i = 0; i < states.size(); i++)
- {
- if (states.get(i).stateUid().equals(u))
- return states.get(i);
- }
+ for (int i = 0; i < states.size(); i++)
+ {
+ if (states.get(i).stateUid().equals(u))
+ return states.get(i);
+ }
- /*
- * Not in the log, so probably removed by now.
- */
+ /*
+ * Not in the log, so probably removed by now.
+ */
- return null;
- }
+ return null;
+ }
- /**
- * Does nothing except indicate that this thread is finished with the log on
- * behalf of this transaction.
- */
+ /**
+ * Does nothing except indicate that this thread is finished with the log on
+ * behalf of this transaction.
+ */
- protected boolean remove_state(Uid u, String tn, int s)
- throws ObjectStoreException
- {
- // maybe write a removal entry into the log.
+ protected boolean remove_state(Uid u, String tn, int s)
+ throws ObjectStoreException
+ {
+ // maybe write a removal entry into the log.
- try
- {
- /*
- * If we don't add a removal entry then recovery has to work a
- * little harder to figure things out. But it has to cater for the
- * situation where a removal record write fails anyway, so this
- * shouldn't be a big deal. On the up side it improves performance
- * by 30% for this implementation, which is a 40% improvement over
- * the basic file-based log!
- */
+ try
+ {
+ /*
+ * If we don't add a removal entry then recovery has to work a
+ * little harder to figure things out. But it has to cater for the
+ * situation where a removal record write fails anyway, so this
+ * shouldn't be a big deal. On the up side it improves performance
+ * by 30% for this implementation, which is a 40% improvement over
+ * the basic file-based log!
+ */
- /*
- * If we write a removal record as a separate entity to the original
- * data item then we cannot ensure that they will go into the same
- * log with a pre-set size for the log. Therefore, we have two
- * options:
- *
- * (i) find the old entry in the log and mark it as deleted.
- * (ii) increase the size of the log to accommodate the removal entry.
- *
- * We currently go for option (ii) as this is the quickest.
- */
+ /*
+ * If we write a removal record as a separate entity to the original
+ * data item then we cannot ensure that they will go into the same
+ * log with a pre-set size for the log. Therefore, we have two
+ * options:
+ *
+ * (i) find the old entry in the log and mark it as deleted.
+ * (ii) increase the size of the log to accommodate the removal entry.
+ *
+ * We currently go for option (ii) as this is the quickest.
+ */
- if (_synchronousRemoval)
- {
- OutputObjectState removalState = new OutputObjectState(u, tn);
+ if (_synchronousRemoval)
+ {
+ OutputObjectState removalState = new OutputObjectState(u, tn);
- removalState.packBytes(_removedState);
+ removalState.packBytes(_removedState);
- if (!write_state(u, tn, removalState, s))
- throw new ObjectStoreException();
- }
- else
- _purger.addRemovedState(u, tn, s);
- }
- catch (IOException ex)
- {
- throw new ObjectStoreException(ex.toString(), ex);
- }
- catch (final Throwable ex)
- {
- ex.printStackTrace();
-
- throw new ObjectStoreException(ex.toString(), ex);
- }
- finally
- {
- removeFromLog(u);
- }
+ if (!write_state(u, tn, removalState, s))
+ throw new ObjectStoreException();
+ }
+ else
+ _purger.addRemovedState(u, tn, s);
+ }
+ catch (IOException ex)
+ {
+ throw new ObjectStoreException(ex.toString(), ex);
+ }
+ catch (final Throwable ex)
+ {
+ ex.printStackTrace();
- return true;
- }
+ throw new ObjectStoreException(ex.toString(), ex);
+ }
+ finally
+ {
+ removeFromLog(u);
+ }
- protected boolean lock(File fd, int lmode, boolean create)
- {
- return true;
- }
+ return true;
+ }
- protected boolean unlock(File fd)
- {
- return true;
- }
+ protected boolean lock(File fd, int lmode, boolean create)
+ {
+ return true;
+ }
- protected String genPathName (Uid objUid, String tName, int ft) throws ObjectStoreException
+ protected boolean unlock(File fd)
{
- String fname = super.genPathName(objUid, tName, ft);
+ return true;
+ }
- if (ft == StateStatus.OS_UNCOMMITTED)
- fname = fname + HIDDENCHAR;
+ protected String genPathName (Uid objUid, String tName, int ft) throws ObjectStoreException
+ {
+ String fname = super.genPathName(objUid, tName, ft);
- return fname;
+ if (ft == StateStatus.OS_UNCOMMITTED)
+ fname = fname + HIDDENCHAR;
+
+ return fname;
}
- boolean removeState(Uid u, String tn, int s) throws ObjectStoreException
- {
- try
- {
- OutputObjectState removalState = new OutputObjectState(u, tn);
+ boolean removeState(Uid u, String tn, int s) throws ObjectStoreException
+ {
+ try
+ {
+ OutputObjectState removalState = new OutputObjectState(u, tn);
- removalState.packBytes(_removedState);
+ removalState.packBytes(_removedState);
- if (!write_state(u, tn, removalState, s))
- throw new ObjectStoreException();
- }
- catch (IOException ex)
- {
- throw new ObjectStoreException(ex.toString(), ex);
- }
+ if (!write_state(u, tn, removalState, s))
+ throw new ObjectStoreException();
+ }
+ catch (IOException ex)
+ {
+ throw new ObjectStoreException(ex.toString(), ex);
+ }
- return true;
- }
+ return true;
+ }
- boolean truncateLogs () throws ObjectStoreException
- {
- return truncateLogs(false);
- }
+ boolean truncateLogs () throws ObjectStoreException
+ {
+ return truncateLogs(false);
+ }
- boolean truncateLogs (boolean force) throws ObjectStoreException
- {
- synchronized (_logNames)
- {
- Iterator<LogInstance> iter = _logNames.iterator();
+ boolean truncateLogs (boolean force) throws ObjectStoreException
+ {
+ synchronized (_logNames)
+ {
+ Iterator<LogInstance> iter = _logNames.iterator();
- /*
- * Only do this for logs that are full to save time,
- * except if we are terminating.
- */
+ /*
+ * Only do this for logs that are full to save time,
+ * except if we are terminating.
+ */
- while (iter.hasNext())
- {
- boolean delete = false;
- LogInstance log = null;
+ while (iter.hasNext())
+ {
+ boolean delete = false;
+ LogInstance log = null;
- try
- {
- log = iter.next();
+ try
+ {
+ log = iter.next();
- if (log.isFrozen() || force)
- delete = truncateLog(log, force);
- }
- catch (final Exception ex)
- {
- // TODO log
- }
+ if (log.isFrozen() || force)
+ delete = truncateLog(log, force);
+ }
+ catch (final Exception ex)
+ {
+ // TODO log
+ }
- if (delete)
- iter.remove();
- }
- }
+ if (delete)
+ iter.remove();
+ }
+ }
- return true;
- }
+ return true;
+ }
- /*
- * Return true if the log needs to be deleted.
- */
+ /*
+ * Return true if the log needs to be deleted.
+ */
- private final boolean truncateLog(final LogInstance log, boolean force) throws ObjectStoreException
- {
- boolean delete = false;
+ private final boolean truncateLog(final LogInstance log, boolean force) throws ObjectStoreException
+ {
+ boolean delete = false;
- synchronized (_lock)
- {
- File fd = new File(genPathName(log.getName(), log.getTypeName(), StateStatus.OS_COMMITTED));
+ synchronized (_lock)
+ {
+ File fd = new File(genPathName(log.getName(), log.getTypeName(), StateStatus.OS_COMMITTED));
- try
- {
- /*
- * Create a list of ObjectState entries.
- */
+ try
+ {
+ /*
+ * Create a list of ObjectState entries.
+ */
- ArrayList<InputObjectState> objectStates = scanLog(log.getName(), log.getTypeName());
+ ArrayList<InputObjectState> objectStates = scanLog(log.getName(), log.getTypeName());
- /*
- * At this stage we should now have a list of unique
- * entries. Write them back to the log. Do this
- * atomically! If the list is empty then delete the
- * file!
- */
+ /*
+ * At this stage we should now have a list of unique
+ * entries. Write them back to the log. Do this
+ * atomically! If the list is empty then delete the
+ * file!
+ */
- if ((objectStates != null) && (objectStates.size() > 0))
- {
- /*
- * If we are terminating then we can truncate the log to the
- * real size needed to contain the existing entries since we
- * will not use it again within another VM except for
- * recovery purposes.
- */
+ if ((objectStates != null) && (objectStates.size() > 0))
+ {
+ /*
+ * If we are terminating then we can truncate the log to the
+ * real size needed to contain the existing entries since we
+ * will not use it again within another VM except for
+ * recovery purposes.
+ */
- String fname = genPathName(log.getName(), log.getTypeName(), StateStatus.OS_UNCOMMITTED);
- File fd2 = openAndLock(fname, FileLock.F_WRLCK, true);
- RandomAccessFile oFile = new RandomAccessFile(fd2, FILE_MODE);
- int size = 0;
+ String fname = genPathName(log.getName(), log.getTypeName(), StateStatus.OS_UNCOMMITTED);
+ File fd2 = openAndLock(fname, FileLock.F_WRLCK, true);
+ RandomAccessFile oFile = new RandomAccessFile(fd2, FILE_MODE);
+ int size = 0;
- oFile.setLength(_maxFileSize);
+ oFile.setLength(_maxFileSize);
- for (int i = 0; i < objectStates.size(); i++)
- {
- byte[] uidString = objectStates.get(i).stateUid().stringForm().getBytes();
- int buffSize = _redzone.length + uidString.length + objectStates.get(i).buffer().length + 8;
- java.nio.ByteBuffer buff = java.nio.ByteBuffer.allocate(buffSize);
+ for (int i = 0; i < objectStates.size(); i++)
+ {
+ byte[] uidString = objectStates.get(i).stateUid().stringForm().getBytes();
+ int buffSize = _redzone.length + uidString.length + objectStates.get(i).buffer().length + 8;
+ java.nio.ByteBuffer buff = java.nio.ByteBuffer.allocate(buffSize);
- size += buffSize;
+ size += buffSize;
- try
- {
- buff.put(_redzone);
- buff.putInt(uidString.length);
- buff.put(uidString);
- buff.putInt(objectStates.get(i).buffer().length);
- buff.put(objectStates.get(i).buffer(),0, objectStates.get(i).buffer().length);
- }
- catch (final Exception ex)
- {
- ex.printStackTrace();
+ try
+ {
+ buff.put(_redzone);
+ buff.putInt(uidString.length);
+ buff.put(uidString);
+ buff.putInt(objectStates.get(i).buffer().length);
+ buff.put(objectStates.get(i).buffer(),0, objectStates.get(i).buffer().length);
+ }
+ catch (final Exception ex)
+ {
+ ex.printStackTrace();
- // TODO log
+ // TODO log
- fd2.delete();
+ fd2.delete();
- unlockAndClose(fd2, oFile);
+ unlockAndClose(fd2, oFile);
- throw new ObjectStoreException(ex.toString(), ex);
- }
- }
+ throw new ObjectStoreException(ex.toString(), ex);
+ }
+ }
- try
- {
- if (force)
- {
- oFile.setLength(size);
+ try
+ {
+ if (force)
+ {
+ oFile.setLength(size);
- log.freeze();
- }
+ log.freeze();
+ }
- fd2.renameTo(fd);
- }
- catch (final Exception ex)
- {
- ex.printStackTrace();
+ fd2.renameTo(fd);
+ }
+ catch (final Exception ex)
+ {
+ ex.printStackTrace();
- // TODO log
+ // TODO log
- throw new ObjectStoreException(ex.toString(), ex);
- }
- finally
- {
- unlockAndClose(fd2, oFile);
- }
- }
- else
- {
- /*
- * Delete the log if there are no states in it. We could
- * keep the file around and reuse it, but the advantage of
- * this is small compared to having to cope with reusing old
- * log instances.
- */
+ throw new ObjectStoreException(ex.toString(), ex);
+ }
+ finally
+ {
+ unlockAndClose(fd2, oFile);
+ }
+ }
+ else
+ {
+ /*
+ * Delete the log if there are no states in it. We could
+ * keep the file around and reuse it, but the advantage of
+ * this is small compared to having to cope with reusing old
+ * log instances.
+ */
- fd.delete();
+ fd.delete();
- /*
- * Remember to remove the information from the memory cache.
- */
+ /*
+ * Remember to remove the information from the memory cache.
+ */
- delete = true;
- }
- }
- catch (final ObjectStoreException ex)
- {
- ex.printStackTrace();
+ delete = true;
+ }
+ }
+ catch (final ObjectStoreException ex)
+ {
+ ex.printStackTrace();
- throw ex;
- }
- catch (final Exception ex)
- {
- ex.printStackTrace();
+ throw ex;
+ }
+ catch (final Exception ex)
+ {
+ ex.printStackTrace();
- throw new ObjectStoreException(ex.toString(), ex);
- }
- }
+ throw new ObjectStoreException(ex.toString(), ex);
+ }
+ }
- return delete;
- }
+ return delete;
+ }
- private final ArrayList<InputObjectState> scanLog (final Uid logName, final String typeName) throws ObjectStoreException
- {
- /*
- * Make sure no new entries can be created while we scan.
- */
+ private final ArrayList<InputObjectState> scanLog (final Uid logName, final String typeName) throws ObjectStoreException
+ {
+ /*
+ * Make sure no new entries can be created while we scan.
+ */
- synchronized (_lock)
- {
- try
- {
- String fname = genPathName(logName, typeName, StateStatus.OS_COMMITTED);
- File fd = openAndLock(fname, FileLock.F_WRLCK, true);
- RandomAccessFile iFile = new RandomAccessFile(fd, FILE_MODE);
- // iFile.getChannel().lock();
+ synchronized (_lock)
+ {
+ try
+ {
+ String fname = genPathName(logName, typeName, StateStatus.OS_COMMITTED);
+ File fd = openAndLock(fname, FileLock.F_WRLCK, true);
+ RandomAccessFile iFile = new RandomAccessFile(fd, FILE_MODE);
+ // iFile.getChannel().lock();
- try
- {
- /*
- * Create a list of ObjectState entries.
- */
+ try
+ {
+ /*
+ * Create a list of ObjectState entries.
+ */
- ArrayList<InputObjectState> objectStates = new ArrayList<InputObjectState>();
+ ArrayList<InputObjectState> objectStates = new ArrayList<InputObjectState>();
- iFile.seek(0); // make sure we're at the start
+ iFile.seek(0); // make sure we're at the start
- while (iFile.getFilePointer() < iFile.length())
- {
- byte[] buff = new byte[_redzone.length];
+ while (iFile.getFilePointer() < iFile.length())
+ {
+ byte[] buff = new byte[_redzone.length];
- iFile.read(buff);
+ iFile.read(buff);
- if (!redzoneProtected(buff))
- {
- // end
+ if (!redzoneProtected(buff))
+ {
+ // end
- break;
+ break;
- /*
- * TODO add an end-of-log entry and check for that. Currently just assume
- * that no RZ means end, rather than corruption.
- */
- }
- else
- {
- int uidSize = iFile.readInt();
- byte[] uidString = new byte[uidSize];
+ /*
+ * TODO add an end-of-log entry and check for that. Currently just assume
+ * that no RZ means end, rather than corruption.
+ */
+ }
+ else
+ {
+ int uidSize = iFile.readInt();
+ byte[] uidString = new byte[uidSize];
- iFile.read(uidString);
+ iFile.read(uidString);
- Uid txId = new Uid(new String(uidString));
- int imageSize = iFile.readInt();
- byte[] imageState = new byte[imageSize];
+ Uid txId = new Uid(new String(uidString));
+ int imageSize = iFile.readInt();
+ byte[] imageState = new byte[imageSize];
- iFile.read(imageState);
+ iFile.read(imageState);
- try
- {
- InputObjectState state = new InputObjectState(
- txId, "", imageState);
+ try
+ {
+ InputObjectState state = new InputObjectState(
+ txId, "", imageState);
- objectStates.add(state);
- }
- catch (final Exception ex)
- {
- ex.printStackTrace();
+ objectStates.add(state);
+ }
+ catch (final Exception ex)
+ {
+ ex.printStackTrace();
- throw new ObjectStoreException(ex.toString(), ex);
- }
- }
- }
+ throw new ObjectStoreException(ex.toString(), ex);
+ }
+ }
+ }
- unlockAndClose(fd, iFile);
- iFile = null;
+ unlockAndClose(fd, iFile);
+ iFile = null;
- /*
- * At this stage we now have a list of ObjectState entries.
- * Now we need to go through and prune the list. This is
- * complicated by the fact that there can be 1.. entries for
- * a specific transaction since we continually update the
- * log as we drive recovery. If an entry hasn't been deleted
- * then we will keep the latest one we find.
- */
+ /*
+ * At this stage we now have a list of ObjectState entries.
+ * Now we need to go through and prune the list. This is
+ * complicated by the fact that there can be 1.. entries for
+ * a specific transaction since we continually update the
+ * log as we drive recovery. If an entry hasn't been deleted
+ * then we will keep the latest one we find.
+ */
- /*
- * First search for those entries that have been deleted.
- */
+ /*
+ * First search for those entries that have been deleted.
+ */
- ArrayList<InputObjectState> deletedLogs = new ArrayList<InputObjectState>();
+ ArrayList<InputObjectState> deletedLogs = new ArrayList<InputObjectState>();
- for (int i = 0; i < objectStates.size(); i++)
- {
- InputObjectState curr = objectStates.get(i);
+ for (int i = 0; i < objectStates.size(); i++)
+ {
+ InputObjectState curr = objectStates.get(i);
- try
- {
- if (Arrays.equals(curr.unpackBytes(), _removedState))
- {
- deletedLogs.add(curr);
- }
- else
- curr.reread(); // don't forget to reset the read pointer!
- }
- catch (final Exception ex)
- {
- // if not a delete record then the first entry won't
- // be an the defined byte array.
+ try
+ {
+ if (Arrays.equals(curr.unpackBytes(), _removedState))
+ {
+ deletedLogs.add(curr);
+ }
+ else
+ curr.reread(); // don't forget to reset the read pointer!
+ }
+ catch (final Exception ex)
+ {
+ // if not a delete record then the first entry won't
+ // be an the defined byte array.
curr.reread(); // don't forget to reset the read pointer!
- }
- }
+ }
+ }
- if (deletedLogs.size() > 0)
- {
- /*
- * make sure we remove them from the first list to save time.
- */
+ if (deletedLogs.size() > 0)
+ {
+ /*
+ * make sure we remove them from the first list to save time.
+ */
- objectStates.removeAll(deletedLogs);
+ objectStates.removeAll(deletedLogs);
- deleteEntries(objectStates, deletedLogs);
+ deleteEntries(objectStates, deletedLogs);
- /*
- * At this stage we should only have entries that refer
- * to in-flight transactions. Go through the list and
- * remove N-1 references for each transaction id.
- */
+ /*
+ * At this stage we should only have entries that refer
+ * to in-flight transactions. Go through the list and
+ * remove N-1 references for each transaction id.
+ */
- pruneEntries(objectStates);
+ pruneEntries(objectStates);
- /*
- * Now return the list of committed entries.
- */
+ /*
+ * Now return the list of committed entries.
+ */
- return objectStates;
- }
- else
- return objectStates;
- }
- finally
- {
- if (iFile != null)
- unlockAndClose(fd, iFile);
- }
- }
- catch (final ObjectStoreException ex)
- {
- ex.printStackTrace();
+ return objectStates;
+ }
+ else
+ return objectStates;
+ }
+ finally
+ {
+ if (iFile != null)
+ unlockAndClose(fd, iFile);
+ }
+ }
+ catch (final ObjectStoreException ex)
+ {
+ ex.printStackTrace();
- throw ex;
- }
- catch (final Exception ex)
- {
- ex.printStackTrace();
+ throw ex;
+ }
+ catch (final Exception ex)
+ {
+ ex.printStackTrace();
- throw new ObjectStoreException(ex.toString(), ex);
- }
- }
- }
+ throw new ObjectStoreException(ex.toString(), ex);
+ }
+ }
+ }
- private final boolean redzoneProtected(final byte[] buff)
- {
- for (int i = 0; i < _redzone.length; i++)
- {
- if (buff[i] != _redzone[i])
- return false;
- }
+ private final boolean redzoneProtected(final byte[] buff)
+ {
+ for (int i = 0; i < _redzone.length; i++)
+ {
+ if (buff[i] != _redzone[i])
+ return false;
+ }
- return true;
- }
+ return true;
+ }
- private final void deleteEntries(ArrayList<InputObjectState> allStates,
- ArrayList<InputObjectState> deletedStates)
- {
- /*
- * Look through the remaining states for entries that have been deleted.
- */
+ private final void deleteEntries(ArrayList<InputObjectState> allStates,
+ ArrayList<InputObjectState> deletedStates)
+ {
+ /*
+ * Look through the remaining states for entries that have been deleted.
+ */
- for (int i = 0; i < deletedStates.size(); i++)
- {
- Uid txId = deletedStates.get(i).stateUid();
+ for (int i = 0; i < deletedStates.size(); i++)
+ {
+ Uid txId = deletedStates.get(i).stateUid();
- for (int j = 0; j < allStates.size(); j++)
- {
- if (allStates.get(j).stateUid().equals(txId))
- allStates.remove(j);
- }
- }
+ for (int j = 0; j < allStates.size(); j++)
+ {
+ if (allStates.get(j).stateUid().equals(txId))
+ allStates.remove(j);
+ }
+ }
- deletedStates.clear();
- }
+ deletedStates.clear();
+ }
- private final void pruneEntries(ArrayList<InputObjectState> allStates)
- {
- /*
- * The ArrayList is ordered with the earliest entries first.
- */
+ private final void pruneEntries(ArrayList<InputObjectState> allStates)
+ {
+ /*
+ * The ArrayList is ordered with the earliest entries first.
+ */
- for (int j = allStates.size() - 1; j >= 0; j--)
- {
- Uid txId = allStates.get(j).stateUid();
+ for (int j = allStates.size() - 1; j >= 0; j--)
+ {
+ Uid txId = allStates.get(j).stateUid();
- for (int i = 0; i < j; i++)
- {
- if (allStates.get(i).stateUid().equals(txId))
- allStates.remove(i);
- }
- }
- }
+ for (int i = 0; i < j; i++)
+ {
+ if (allStates.get(i).stateUid().equals(txId))
+ allStates.remove(i);
+ }
+ }
+ }
- /*
- * We maintain a list of log identifiers and the number of threads using
- * them. If a log size goes over the maximum allowed, then we swap all
- * threads to a new log with the exception of those that are currently using
- * the old log.
- *
- * We always add a new entry to the log even if one already exists.
- *
- * Because normally we are writing to the log we pass in the size that we need to
- * accommodate. However, during recovery we need to read the state yet still
- * need the log name. So if we pass a size of -1 this signifies only to
- * return the log data and not allocate space for a new instance.
- */
+ /*
+ * We maintain a list of log identifiers and the number of threads using
+ * them. If a log size goes over the maximum allowed, then we swap all
+ * threads to a new log with the exception of those that are currently using
+ * the old log.
+ *
+ * We always add a new entry to the log even if one already exists.
+ *
+ * Because normally we are writing to the log we pass in the size that we need to
+ * accommodate. However, during recovery we need to read the state yet still
+ * need the log name. So if we pass a size of -1 this signifies only to
+ * return the log data and not allocate space for a new instance.
+ */
- private final TransactionData getLogName (Uid txid, String tName, long size)
+ private final TransactionData getLogName (Uid txid, String tName, long size)
throws ObjectStoreException
{
synchronized (_logNames)
@@ -1476,10 +1415,10 @@
if (entry.present(txid))
{
- if (size == -1) // we are reading only
- return entry.getTxId(txid);
- else
- return entry.addTxId(txid, size);
+ if (size == -1) // we are reading only
+ return entry.getTxId(txid);
+ else
+ return entry.addTxId(txid, size);
}
}
@@ -1498,23 +1437,23 @@
if (!entry.isFrozen())
{
- if (entry.remaining() > size)
- {
+ if (entry.remaining() > size)
+ {
return entry.addTxId(txid, size);
}
else
{
- /*
- * TODO
- *
- * When can we remove the information about this
- * log from memory? If we do it too soon then it's possible
- * that delete entries will not go into the right log. If we
- * leave it too late then the memory footprint increases. Prune
- * the entry when we prune the log from disk?
- */
+ /*
+ * TODO
+ *
+ * When can we remove the information about this
+ * log from memory? If we do it too soon then it's possible
+ * that delete entries will not go into the right log. If we
+ * leave it too late then the memory footprint increases. Prune
+ * the entry when we prune the log from disk?
+ */
- entry.freeze();
+ entry.freeze();
}
}
}
@@ -1528,53 +1467,42 @@
}
}
- private final void removeFromLog(Uid txid)
- {
- if (_synchronousRemoval)
- {
- synchronized (_logNames)
- {
- Iterator<LogInstance> iter = _logNames.iterator();
- LogInstance entry = null;
+ private final void removeFromLog(Uid txid)
+ {
+ if (_synchronousRemoval)
+ {
+ synchronized (_logNames)
+ {
+ Iterator<LogInstance> iter = _logNames.iterator();
+ LogInstance entry = null;
- while (iter.hasNext())
- {
- entry = (LogInstance) iter.next();
+ while (iter.hasNext())
+ {
+ entry = (LogInstance) iter.next();
- if (entry.present(txid))
- {
- //entry.removeTxId(txid);
- break;
- }
- }
- }
- }
- }
+ if (entry.present(txid))
+ {
+ //entry.removeTxId(txid);
+ break;
+ }
+ }
+ }
+ }
+ }
- private static boolean checkSync = false;
+ private static Object _lock = new Object();
- private static Object _lock = new Object();
+ private static ArrayList<LogInstance> _logNames = new ArrayList<LogInstance>();
- private static ArrayList<LogInstance> _logNames = new ArrayList<LogInstance>();
+ private final long _maxFileSize;
+ private final long _purgeTime;
- private static long _maxFileSize = LOG_SIZE;
- private static long _purgeTime = LogPurger.DEFAULT_PURGE_TIME;
+ private final LogPurger _purger;
+ private final boolean _synchronousRemoval;
- private static LogPurger _purger;
- private static boolean _synchronousRemoval = false;
+ private static final byte[] _redzone = { 0x2, 0x4, 0x6, 0x8 };
- private static final byte[] _redzone = { 0x2, 0x4, 0x6, 0x8 };
+ private static final byte[] _removedState = { 0xd, 0xe, 0xa, 0xd, 0xb, 0xe, 0xe, 0xf };
- private static final byte[] _removedState = { 0xd, 0xe, 0xa, 0xd, 0xb, 0xe, 0xe, 0xf };
-
- private static final char HIDDENCHAR = '~';
-
- static
- {
- _synchronousRemoval = arjPropertyManager.getObjectStoreEnvironmentBean().isSynchronousRemoval();
-
- _purgeTime = arjPropertyManager.getObjectStoreEnvironmentBean().getPurgeTime();
-
- _maxFileSize = arjPropertyManager.getObjectStoreEnvironmentBean().getTxLogSize();
- }
+ private static final char HIDDENCHAR = '~';
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/NullActionStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/NullActionStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/NullActionStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -31,17 +31,12 @@
package com.arjuna.ats.internal.arjuna.objectstore;
-import com.arjuna.ats.arjuna.exceptions.FatalError;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
import com.arjuna.ats.arjuna.objectstore.StateStatus;
-import com.arjuna.ats.arjuna.objectstore.StateType;
import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.arjuna.state.*;
import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
-import com.arjuna.ats.arjuna.logging.tsLogger;
-
/**
* The basic transaction log implementation. Uses the no file-level locking
* implementation of the file system store since only a single user (the
@@ -54,12 +49,6 @@
public class NullActionStore extends ShadowNoFileLockStore
{
-
- public int typeIs ()
- {
- return ObjectStoreType.NULL_ACTION;
- }
-
/**
* @return current state of object. Assumes that genPathName allocates
* enough extra space to allow extra chars to be added. Action
@@ -130,68 +119,8 @@
return false;
}
- public NullActionStore(String locationOfStore)
+ public NullActionStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
{
- this(locationOfStore, StateType.OS_SHARED);
-
- try
- {
- setupStore(arjPropertyManager.getObjectStoreEnvironmentBean().getLocalOSRoot());
- }
- catch (ObjectStoreException e) {
- tsLogger.logger.warn(e);
-
- super.makeInvalid();
-
- throw new FatalError(e.toString(),
- e);
- }
+ super(objectStoreEnvironmentBean);
}
-
- public NullActionStore(String locationOfStore, int shareStatus)
- {
- super(shareStatus);
-
- try
- {
- setupStore(locationOfStore);
- }
- catch (ObjectStoreException e) {
- tsLogger.logger.warn(e);
-
- super.makeInvalid();
-
- throw new FatalError(e.toString(),
- e);
- }
- }
-
- public NullActionStore()
- {
- this(StateType.OS_SHARED);
- }
-
- public NullActionStore(int shareStatus)
- {
- super(shareStatus);
- }
-
- protected synchronized boolean setupStore (String location)
- throws ObjectStoreException
- {
- try
- {
- super.setupStore(location);
- }
- catch (ObjectStoreException e) {
- tsLogger.logger.warn(e);
-
- super.makeInvalid();
-
- throw new FatalError(e.toString(), e);
- }
-
- return true;
- }
-
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/ShadowNoFileLockStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/ShadowNoFileLockStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/ShadowNoFileLockStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -31,11 +31,9 @@
package com.arjuna.ats.internal.arjuna.objectstore;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
-import com.arjuna.ats.arjuna.objectstore.StateType;
+import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
-import com.arjuna.ats.arjuna.logging.tsLogger;
-
import java.io.File;
/**
@@ -50,39 +48,11 @@
public class ShadowNoFileLockStore extends ShadowingStore
{
-
- public int typeIs ()
+ public ShadowNoFileLockStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
{
- return ObjectStoreType.SHADOWNOFILELOCK;
+ super(objectStoreEnvironmentBean);
}
- public ShadowNoFileLockStore(String locationOfStore)
- {
- this(locationOfStore, StateType.OS_SHARED);
- }
-
- public ShadowNoFileLockStore(String locationOfStore, int shareStatus)
- {
- super(locationOfStore, shareStatus);
-
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("ShadowNoFileLockStore.ShadowNoFileLockStore("
- + locationOfStore + ")");
- }
- }
-
- public ShadowNoFileLockStore()
- {
- this(StateType.OS_SHARED);
- }
-
- public ShadowNoFileLockStore(int shareStatus)
- {
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("ShadowNoFileLockStore.ShadowNoFileLockStore(" + shareStatus + ")");
- }
- }
-
/**
* Override the default lock/unlock implementations to do nothing.
*/
@@ -97,4 +67,4 @@
return true;
}
-}
+}
\ No newline at end of file
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/ShadowingStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/ShadowingStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/ShadowingStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -31,7 +31,6 @@
package com.arjuna.ats.internal.arjuna.objectstore;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
import com.arjuna.ats.arjuna.objectstore.StateStatus;
import com.arjuna.ats.arjuna.objectstore.StateType;
import com.arjuna.ats.arjuna.common.*;
@@ -53,7 +52,7 @@
* the shadow (the updated state) is stored in another. When the transaction
* commits, the shadow is made the original. If the transaction rolls back then
* the shadow is simply removed from the object store.
- *
+ *
* @author Mark Little (mark at arjuna.com)
* @version $Id: ShadowingStore.java 2342 2006-03-30 13:06:17Z $
* @since 1.0
@@ -61,12 +60,6 @@
public class ShadowingStore extends FileSystemStore
{
-
- public int typeIs ()
- {
- return ObjectStoreType.SHADOWING;
- }
-
/**
* @return current state of object. Assumes that genPathName allocates
* enough extra space to allow extra chars to be added. State search
@@ -79,42 +72,39 @@
{
int theState = StateStatus.OS_UNKNOWN;
- if (storeValid())
+ String path = genPathName(objUid, tName, StateType.OS_SHADOW);
+
+ if (exists(path))
{
- String path = genPathName(objUid, tName, StateType.OS_SHADOW);
+ theState = StateStatus.OS_UNCOMMITTED;
+ }
+ else
+ {
+ path = path + HIDDINGCHAR;
if (exists(path))
{
- theState = StateStatus.OS_UNCOMMITTED;
+ theState = StateStatus.OS_UNCOMMITTED_HIDDEN;
}
else
{
- path = path + HIDDINGCHAR;
+ path = genPathName(objUid, tName, StateType.OS_ORIGINAL);
if (exists(path))
{
- theState = StateStatus.OS_UNCOMMITTED_HIDDEN;
+ theState = StateStatus.OS_COMMITTED;
}
else
{
- path = genPathName(objUid, tName, StateType.OS_ORIGINAL);
+ path = path + HIDDINGCHAR;
if (exists(path))
{
- theState = StateStatus.OS_COMMITTED;
+ theState = StateStatus.OS_COMMITTED_HIDDEN;
}
- else
- {
- path = path + HIDDINGCHAR;
-
- if (exists(path))
- {
- theState = StateStatus.OS_COMMITTED_HIDDEN;
- }
- }
}
}
- }
+ }
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("ShadowingStore.currentState("+objUid+", "+tName+") - returning "+
@@ -139,14 +129,6 @@
boolean result = false;
- /* Bail out if the object store is not set up */
-
- if (!storeValid()) {
- tsLogger.i18NLogger.warn_objectstore_ShadowingStore_1();
-
- return false;
- }
-
if (tName != null)
{
String shadow = null;
@@ -216,16 +198,12 @@
boolean hiddenOk = true;
- /* Bail out if the object store is not set up */
+ int state = currentState(objUid, tName);
+ String path1 = null;
+ String path2 = null;
- if (storeValid())
+ switch (state)
{
- int state = currentState(objUid, tName);
- String path1 = null;
- String path2 = null;
-
- switch (state)
- {
case StateStatus.OS_UNCOMMITTED_HIDDEN:
case StateStatus.OS_COMMITTED_HIDDEN:
break;
@@ -275,10 +253,7 @@
}
default:
hiddenOk = false;
- }
}
- else
- hiddenOk = false;
return hiddenOk;
}
@@ -292,14 +267,12 @@
boolean revealedOk = true;
- if (storeValid())
- {
- int state = currentState(objUid, tName);
- String path1 = null;
- String path2 = null;
+ int state = currentState(objUid, tName);
+ String path1 = null;
+ String path2 = null;
- switch (state)
- {
+ switch (state)
+ {
case StateStatus.OS_UNCOMMITTED_HIDDEN:
{
path1 = genPathName(objUid, tName, StateType.OS_SHADOW);
@@ -349,10 +322,7 @@
break;
default:
revealedOk = false;
- }
}
- else
- revealedOk = false;
return revealedOk;
}
@@ -400,12 +370,6 @@
tsLogger.logger.trace("ShadowingStore.read_state(" + objUid + ", " + tName + ", " + StateType.stateTypeString(ft) + ")");
}
- if (!storeValid()) {
- tsLogger.i18NLogger.warn_objectstore_ShadowingStore_6();
-
- return null;
- }
-
InputObjectState new_image = null;
if (tName != null)
@@ -492,9 +456,6 @@
boolean removeOk = true;
- if (!storeValid())
- return false;
-
if (name != null)
{
int state = currentState(objUid, name);
@@ -569,15 +530,12 @@
*/
protected boolean write_state (Uid objUid, String tName,
- OutputObjectState state, int ft) throws ObjectStoreException
+ OutputObjectState state, int ft) throws ObjectStoreException
{
if (tsLogger.logger.isTraceEnabled()) {
tsLogger.logger.trace("ShadowingStore.write_state(" + objUid + ", " + tName + ", " + StateType.stateTypeString(ft) + ")");
}
- if (!storeValid())
- return false;
-
if (tName != null)
{
String fname = genPathName(objUid, tName, ft);
@@ -607,7 +565,7 @@
ofile.flush();
FileDescriptor fileDesc = ofile.getFD(); // assume it's
- // valid!
+ // valid!
fileDesc.sync();
}
}
@@ -656,61 +614,12 @@
+ objUid);
}
- public ShadowingStore(String locationOfStore)
+ public ShadowingStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
{
- this(locationOfStore, StateType.OS_SHARED);
+ super(objectStoreEnvironmentBean);
}
- public ShadowingStore(String locationOfStore, int shareStatus)
- {
- super(shareStatus);
-
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("ShadowingStore.ShadowingStore(" + locationOfStore + ")");
- }
-
- try
- {
- setupStore(locationOfStore);
- }
- catch (ObjectStoreException e)
- {
- tsLogger.logger.fatal(e);
-
- throw new com.arjuna.ats.arjuna.exceptions.FatalError(e.toString(),
- e);
- }
- }
-
- public ShadowingStore()
- {
- this(StateType.OS_SHARED);
- }
-
- public ShadowingStore(int shareStatus)
- {
- super(shareStatus);
-
- if (tsLogger.logger.isTraceEnabled()) {
- tsLogger.logger.trace("ShadowingStore.ShadowingStore( " + shareStatus + " )");
- }
-
- try
- {
- setupStore(arjPropertyManager.getObjectStoreEnvironmentBean()
- .getLocalOSRoot());
- }
- catch (ObjectStoreException e)
- {
- tsLogger.logger.fatal(e);
-
- throw new com.arjuna.ats.arjuna.exceptions.FatalError(e.toString(),
- e);
- }
- }
-
public static final char HIDDINGCHAR = '#';
public static final char SHADOWCHAR = '!';
-
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/VolatileStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/VolatileStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/VolatileStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -20,8 +20,8 @@
*/
package com.arjuna.ats.internal.arjuna.objectstore;
+import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
import com.arjuna.ats.arjuna.objectstore.ObjectStore;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
import com.arjuna.ats.arjuna.objectstore.StateStatus;
import com.arjuna.ats.arjuna.state.InputObjectState;
import com.arjuna.ats.arjuna.state.OutputObjectState;
@@ -41,17 +41,8 @@
*/
public class VolatileStore extends ObjectStore
{
- /**
- * The type of the object store. This is used to order the
- * instances in the intentions list.
- *
- * @return the type of the record.
- * @see com.arjuna.ats.arjuna.coordinator.RecordType
- */
-
- public int typeIs()
- {
- return ObjectStoreType.VOLATILE;
+ public VolatileStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException {
+ super(objectStoreEnvironmentBean);
}
/**
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/TypesUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/TypesUnitTest.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/TypesUnitTest.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -33,17 +33,10 @@
import com.arjuna.ats.arjuna.coordinator.AddOutcome;
import com.arjuna.ats.arjuna.coordinator.RecordType;
import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
-import com.arjuna.ats.arjuna.exceptions.FatalError;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
import com.arjuna.ats.arjuna.objectstore.StateStatus;
import com.arjuna.ats.arjuna.objectstore.StateType;
import com.arjuna.ats.internal.arjuna.abstractrecords.ActivationRecord;
import com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord;
-import com.arjuna.ats.internal.arjuna.objectstore.ActionStore;
-import com.arjuna.ats.internal.arjuna.objectstore.CacheStore;
-import com.arjuna.ats.internal.arjuna.objectstore.HashedStore;
-import com.arjuna.ats.internal.arjuna.objectstore.JDBCStore;
-import com.arjuna.ats.internal.arjuna.objectstore.LogStore;
import static org.junit.Assert.*;
@@ -167,39 +160,7 @@
for (int i = 0; i < ActionStatus.NO_ACTION; i++)
assertTrue(ActionStatus.stringForm(i) != null);
}
-
- @Test
- public void testObjectStoreType ()
- {
- PrintWriter pw = new PrintWriter(new StringWriter());
-
- ObjectStoreType.print(pw, ObjectStoreType.ACTION);
-
- assertEquals(ObjectStoreType.typeToClass(ObjectStoreType.ACTION), ActionStore.class);
- assertEquals(ObjectStoreType.typeToClass(ObjectStoreType.JDBC), JDBCStore.class);
- assertEquals(ObjectStoreType.typeToClass(ObjectStoreType.ACTIONLOG), LogStore.class);
- assertEquals(ObjectStoreType.typeToClass(ObjectStoreType.CACHED), CacheStore.class);
- assertEquals(ObjectStoreType.typeToClass(ObjectStoreType.HASHED), HashedStore.class);
-
- assertEquals(ObjectStoreType.typeToClass(30), null);
- assertEquals(ObjectStoreType.classToType(ActionStore.class), ObjectStoreType.ACTION);
- assertEquals(ObjectStoreType.classToType(JDBCStore.class), ObjectStoreType.JDBC);
- assertEquals(ObjectStoreType.classToType(LogStore.class), ObjectStoreType.ACTIONLOG);
- assertEquals(ObjectStoreType.classToType(CacheStore.class), ObjectStoreType.CACHED);
- assertEquals(ObjectStoreType.classToType(HashedStore.class), ObjectStoreType.HASHED);
-
- try
- {
- ObjectStoreType.classToType(RecordType.class);
-
- fail();
- }
- catch (final FatalError ex)
- {
- }
- }
-
@Test
public void testRecordType ()
{
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/CachedTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/CachedTest.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/CachedTest.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -96,9 +96,11 @@
int threads = 100;
Thread[] t = new Thread[threads];
- arjPropertyManager.getObjectStoreEnvironmentBean().setCacheStoreSize(cacheSize);
+ ObjectStoreEnvironmentBean objectStoreEnvironmentBean = arjPropertyManager.getObjectStoreEnvironmentBean();
- ParticipantStore store = new CacheStore();
+ objectStoreEnvironmentBean.setCacheStoreSize(cacheSize);
+
+ ParticipantStore store = new CacheStore(objectStoreEnvironmentBean);
long stime = Calendar.getInstance().getTime().getTime();
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -49,7 +49,6 @@
{
arjPropertyManager.getCoordinatorEnvironmentBean().setCommitOnePhase(false);
arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(LogStore.class.getName());
- arjPropertyManager.getCoordinatorEnvironmentBean().setTransactionLog(true);
arjPropertyManager.getObjectStoreEnvironmentBean().setSynchronousRemoval(false);
// the byteman script will enforce this
//System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "1000000"); // essentially infinite
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest2.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest2.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest2.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -49,7 +49,6 @@
{
arjPropertyManager.getCoordinatorEnvironmentBean().setCommitOnePhase(false);
arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(LogStore.class.getName());
- arjPropertyManager.getCoordinatorEnvironmentBean().setTransactionLog(true);
arjPropertyManager.getObjectStoreEnvironmentBean().setSynchronousRemoval(true);
// the byteman script will enforce this
//System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "1000000"); // essentially infinite
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -52,7 +52,6 @@
public void setUp()
{
arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(LogStore.class.getName());
- arjPropertyManager.getCoordinatorEnvironmentBean().setTransactionLog(true);
super.setUp();
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest2.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest2.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest2.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -83,7 +83,6 @@
arjPropertyManager.getCoordinatorEnvironmentBean().setCommitOnePhase(false);
arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(LogStore.class.getName());
- arjPropertyManager.getCoordinatorEnvironmentBean().setTransactionLog(true);
arjPropertyManager.getObjectStoreEnvironmentBean().setSynchronousRemoval(false);
// the byteman script will enforce this
//System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "1000000"); // essentially infinite
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -49,7 +49,6 @@
public void test()
{
arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(LogStore.class.getName());
- arjPropertyManager.getCoordinatorEnvironmentBean().setTransactionLog(true);
RecoveryStore recoveryStore = StoreManager.getRecoveryStore();
final int numberOfTransactions = 1000;
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest2.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest2.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest2.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -49,7 +49,6 @@
public void test()
{
arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(LogStore.class.getName());
- arjPropertyManager.getCoordinatorEnvironmentBean().setTransactionLog(true);
// the byteman script will manage this
//System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "10000");
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -99,8 +99,7 @@
arjPropertyManager.getCoordinatorEnvironmentBean().setCommitOnePhase(false);
arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(LogStore.class.getName());
- arjPropertyManager.getCoordinatorEnvironmentBean().setTransactionLog(true);
-
+
// the byteman script will manage this
//System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "10000");
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest2.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest2.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest2.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -51,7 +51,6 @@
{
arjPropertyManager.getCoordinatorEnvironmentBean().setCommitOnePhase(false);
arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(LogStore.class.getName());
- arjPropertyManager.getCoordinatorEnvironmentBean().setTransactionLog(true);
arjPropertyManager.getObjectStoreEnvironmentBean().setTxLogSize(10000);
int timeLimit = 4; // hours
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/ObjectStoreTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/ObjectStoreTest.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/ObjectStoreTest.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -31,6 +31,7 @@
* $Id: ObjectStoreTest.java 2342 2006-03-30 13:06:17Z $
*/
+import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
import com.arjuna.ats.arjuna.common.Uid;
import com.arjuna.ats.arjuna.common.arjPropertyManager;
import com.arjuna.ats.arjuna.coordinator.TxControl;
@@ -58,15 +59,10 @@
class DummyOS extends FileLockingStore
{
- public DummyOS ()
+ public DummyOS(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
{
- this(null, 0);
+ super(objectStoreEnvironmentBean);
}
-
- public DummyOS(String locationOfStore, int ss)
- {
- super(locationOfStore, ss);
- }
public boolean lock ()
{
@@ -136,51 +132,14 @@
public class ObjectStoreTest
{
- @SuppressWarnings("unchecked")
@Test
- public void test() throws IOException
+ public void testActionStore () throws Exception
{
- String localOSRoot = "foo";
- String objectStoreDir = System.getProperty("java.io.tmpdir")+"/bar";
- String oldOSRoot = arjPropertyManager.getObjectStoreEnvironmentBean().getLocalOSRoot();
- String oldStoreDir = arjPropertyManager.getObjectStoreEnvironmentBean().getObjectStoreDir();
-
- arjPropertyManager.getCoordinatorEnvironmentBean().setTransactionLog(true);
- arjPropertyManager.getObjectStoreEnvironmentBean().setLocalOSRoot(localOSRoot);
- arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreDir(objectStoreDir);
- arjPropertyManager.getObjectStoreEnvironmentBean().setShare(StateType.OS_SHARED);
+ ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+ objectStoreEnvironmentBean.setLocalOSRoot( System.getProperty("java.io.tmpdir") );
- // check with a known valid implementation
-
- ObjectStore objStore = null;
+ ActionStore as = new ActionStore(objectStoreEnvironmentBean);
- try
- {
- Class cn = Class.forName(ObjectStoreType.getDefaultStoreType());
- objStore = (ObjectStore) cn.newInstance();
- }
- catch (final Exception ex)
- {
- ex.printStackTrace();
-
- objStore = null;
- }
-
- arjPropertyManager.getObjectStoreEnvironmentBean().setLocalOSRoot(oldOSRoot);
- arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreDir(oldStoreDir);
-
- assertTrue(validate(objStore));
- }
-
- @Test
- public void testActionStore () throws Exception
- {
- ActionStore as = new ActionStore();
-
- as = new ActionStore(System.getProperty("java.io.tmpdir"));
-
- assertTrue(as.typeIs() != -1);
-
final OutputObjectState buff = new OutputObjectState();
final String tn = "/StateManager/junit";
@@ -211,25 +170,16 @@
assertTrue(!as.reveal_state(u, tn));
}
-
- final OutputObjectState os = new OutputObjectState();
-
- as.packInto(os);
-
- final InputObjectState is = new InputObjectState(os);
-
- as.unpackFrom(is);
}
@Test
public void testShadowNoFileLockStore () throws Exception
{
- ShadowNoFileLockStore as = new ShadowNoFileLockStore();
+ ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+ objectStoreEnvironmentBean.setLocalOSRoot( System.getProperty("java.io.tmpdir") );
+
+ ShadowNoFileLockStore as = new ShadowNoFileLockStore(objectStoreEnvironmentBean);
- as = new ShadowNoFileLockStore(System.getProperty("java.io.tmpdir"), StateType.OS_SHARED);
-
- assertTrue(as.typeIs() != -1);
-
final OutputObjectState buff = new OutputObjectState();
final String tn = "/StateManager/junit";
@@ -265,12 +215,11 @@
@Test
public void testHashedStore () throws Exception
{
- HashedStore as = new HashedStore();
+ ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+ objectStoreEnvironmentBean.setLocalOSRoot( System.getProperty("java.io.tmpdir") );
+
+ HashedStore as = new HashedStore(objectStoreEnvironmentBean);
- as = new HashedStore(System.getProperty("java.io.tmpdir"));
-
- assertTrue(as.typeIs() != -1);
-
final OutputObjectState buff = new OutputObjectState();
final String tn = "/StateManager/junit";
@@ -306,12 +255,11 @@
//@Test
public void testCacheStore () throws Exception
{
- CacheStore as = new CacheStore();
+ ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+ objectStoreEnvironmentBean.setLocalOSRoot( System.getProperty("java.io.tmpdir") );
+
+ CacheStore as = new CacheStore(objectStoreEnvironmentBean);
- as = new CacheStore(System.getProperty("java.io.tmpdir"));
-
- assertTrue(as.typeIs() != -1);
-
final OutputObjectState buff = new OutputObjectState();
final String tn = "/StateManager/junit";
@@ -347,12 +295,11 @@
@Test
public void testHashedActionStore () throws Exception
{
- HashedActionStore as = new HashedActionStore();
+ ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+ objectStoreEnvironmentBean.setLocalOSRoot( System.getProperty("java.io.tmpdir") );
+
+ HashedActionStore as = new HashedActionStore(objectStoreEnvironmentBean);
- as = new HashedActionStore(System.getProperty("java.io.tmpdir"));
-
- assertTrue(as.typeIs() != -1);
-
final OutputObjectState buff = new OutputObjectState();
final String tn = "/StateManager/junit";
@@ -388,12 +335,11 @@
@Test
public void testShadowingStore () throws Exception
{
- ShadowingStore as = new ShadowingStore();
+ ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+ objectStoreEnvironmentBean.setLocalOSRoot( System.getProperty("java.io.tmpdir") );
+
+ ShadowingStore as = new ShadowingStore(objectStoreEnvironmentBean);
- as = new ShadowingStore(System.getProperty("java.io.tmpdir"));
-
- assertTrue(as.typeIs() != -1);
-
final OutputObjectState buff = new OutputObjectState();
final String tn = "/StateManager/junit";
@@ -429,12 +375,11 @@
@Test
public void testNullActionStore () throws Exception
{
- NullActionStore as = new NullActionStore();
+ ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+ objectStoreEnvironmentBean.setLocalOSRoot( System.getProperty("java.io.tmpdir") );
+
+ NullActionStore as = new NullActionStore(objectStoreEnvironmentBean);
- as = new NullActionStore(System.getProperty("java.io.tmpdir"), StateType.OS_SHARED);
-
- assertTrue(as.typeIs() != -1);
-
final OutputObjectState buff = new OutputObjectState();
final String tn = "/StateManager/junit";
@@ -465,23 +410,16 @@
assertTrue(!as.reveal_state(u, tn));
}
-
- assertTrue(as.storeValid());
-
- as.makeInvalid();
-
- assertFalse(as.storeValid());
-
- new NullActionStore("foo");
}
@Test
public void testVolatileStore () throws Exception
{
- VolatileStore as = new VolatileStore();
+ ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+ objectStoreEnvironmentBean.setLocalOSRoot( System.getProperty("java.io.tmpdir") );
+
+ VolatileStore as = new VolatileStore(objectStoreEnvironmentBean);
- assertTrue(as.typeIs() != -1);
-
final OutputObjectState buff = new OutputObjectState();
final String tn = "/StateManager/junit";
@@ -552,7 +490,10 @@
@Test
public void testFileLockingStore () throws Exception
{
- DummyOS as = new DummyOS();
+ ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+ objectStoreEnvironmentBean.setLocalOSRoot( System.getProperty("java.io.tmpdir") );
+
+ DummyOS as = new DummyOS(objectStoreEnvironmentBean);
assertTrue(as.typeIs() != -1);
@@ -570,12 +511,17 @@
StoreManager.getTxLog().write_committed(u2, "foo", new OutputObjectState());
ObjectStoreIterator iter = new ObjectStoreIterator(StoreManager.getRecoveryStore(), "foo");
+
+ // iteration ordering is not guaranteed.
+
Uid x = iter.iterate();
-
assertTrue(x.notEquals(Uid.nullUid()));
- assertTrue(x.equals(u1));
-
- assertTrue(iter.iterate().notEquals(Uid.nullUid()));
+ assertTrue(x.equals(u1) || x.equals(u2));
+
+ Uid y = iter.iterate();
+ assertTrue(y.notEquals(Uid.nullUid()));
+ assertTrue(y.equals(u1) || y.equals(u2));
+
assertTrue(iter.iterate().equals(Uid.nullUid()));
}
@@ -607,6 +553,5 @@
private static String imple = arjPropertyManager.getObjectStoreEnvironmentBean().getObjectStoreType();
private static String localOSRoot = "foo";
private static String objectStoreDir = System.getProperty("java.io.tmpdir")+"/bar";
- private static String shareStatus = "OS_SHARED";
}
Deleted: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/ObjectStoreTypeManagerTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/ObjectStoreTypeManagerTest.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/ObjectStoreTypeManagerTest.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and/or its affiliates,
- * and individual contributors as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2010,
- * @author JBoss, by Red Hat.
- */
-package com.hp.mwtests.ts.arjuna.objectstore;
-
-import com.arjuna.ats.arjuna.objectstore.ObjectStore;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
-import com.arjuna.ats.arjuna.objectstore.type.ObjectStoreTypeManager;
-import com.arjuna.ats.arjuna.objectstore.type.ObjectStoreTypeMap;
-import com.arjuna.ats.internal.arjuna.objectstore.VolatileStore;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class ObjectStoreTypeManagerTest
-{
- @Test
- public void testObjectStoreTypeManager()
- {
- Class<? extends ObjectStore> clazz = ObjectStoreType.typeToClass(ObjectStoreType.VOLATILE);
- int typeCode = ObjectStoreType.classToType(clazz);
-
- assertEquals(ObjectStoreType.VOLATILE, typeCode);
-
- ObjectStoreTypeManager manager = ObjectStoreTypeManager.manager();
-
- manager.add(new DummyObjectStoreTypeMap());
-
- assertTrue(manager.getObjectStoreClass(1001) != null);
- assertEquals(1001, manager.getType(DummyObjectStoreImpl.class));
-
- assertEquals(ObjectStoreType.typeToClass(1001), DummyObjectStoreImpl.class);
- assertEquals(1001, ObjectStoreType.classToType(DummyObjectStoreImpl.class));
-
- manager.add(new DummyObjectStoreTypeMap());
-
- assertEquals(DummyObjectStoreImpl.class, manager.getObjectStoreClass(1001));
- assertEquals(1001, manager.getType(DummyObjectStoreImpl.class));
-
- assertEquals(DummyObjectStoreImpl.class, ObjectStoreType.typeToClass(1001));
- assertEquals(1001, ObjectStoreType.classToType(DummyObjectStoreImpl.class));
- }
-
- class DummyObjectStoreTypeMap implements ObjectStoreTypeMap
- {
- @Override
- public Class<? extends ObjectStore> getObjectStoreClass()
- {
- return DummyObjectStoreImpl.class;
- }
-
- @Override
- public int getType()
- {
- return 1001;
- }
- }
-
- class DummyObjectStoreImpl extends VolatileStore{}
-}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/PersistenceTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/PersistenceTest.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/PersistenceTest.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -55,14 +55,16 @@
boolean threaded = false;
long stime = Calendar.getInstance().getTime().getTime();
+ ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+
for (int i = 0; i < 1000; i++) {
try {
ParticipantStore store = null;
if (!threaded)
- store = new ShadowingStore();
+ store = new ShadowingStore(objectStoreEnvironmentBean);
else
- store = new CacheStore();
+ store = new CacheStore(objectStoreEnvironmentBean);
byte[] data = new byte[10240];
OutputObjectState state = new OutputObjectState();
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/RemoveCachedTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/RemoveCachedTest.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/RemoveCachedTest.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -50,7 +50,7 @@
public void test() throws IOException, ObjectStoreException
{
boolean passed = true;
- RecoveryStore store = new CacheStore();
+ RecoveryStore store = new CacheStore(new ObjectStoreEnvironmentBean());
String type = "ArjunaMS/Destinations/a3d6227_dc656_3b77ce7e_2/Messages";
InputObjectState buff = new InputObjectState();
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/WriteCachedTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/WriteCachedTest.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/WriteCachedTest.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -31,6 +31,7 @@
package com.hp.mwtests.ts.arjuna.objectstore;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
import com.arjuna.ats.arjuna.objectstore.ParticipantStore;
import com.arjuna.ats.arjuna.state.*;
import com.arjuna.ats.arjuna.common.*;
@@ -83,7 +84,7 @@
public class WriteCachedTest
{
@Test
- public void test()
+ public void test() throws ObjectStoreException
{
boolean passed = true;
String cacheSize = "20480";
@@ -93,7 +94,7 @@
System.setProperty("com.arjuna.ats.internal.arjuna.objectstore.cacheStore.size", cacheSize);
- ParticipantStore store = new CacheStore();
+ ParticipantStore store = new CacheStore(new ObjectStoreEnvironmentBean());
long stime = Calendar.getInstance().getTime().getTime();
for (int i = 0; (i < threads) && passed; i++) {
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/lockstore/BasicLockStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/lockstore/BasicLockStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/lockstore/BasicLockStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -56,10 +56,10 @@
* the key.
*/
- public BasicLockStore(String key)
+ public BasicLockStore()
{
if (txojLogger.logger.isTraceEnabled()) {
- txojLogger.logger.trace("BasicLockStore.BasicLockStore(" + key + ")");
+ txojLogger.logger.trace("BasicLockStore.BasicLockStore()");
}
}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/lockstore/BasicPersistentLockStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/lockstore/BasicPersistentLockStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/lockstore/BasicPersistentLockStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -31,6 +31,7 @@
package com.arjuna.ats.internal.txoj.lockstore;
+import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
import com.arjuna.ats.arjuna.objectstore.ParticipantStore;
import com.arjuna.ats.txoj.lockstore.LockStore;
import com.arjuna.ats.txoj.common.txojPropertyManager;
@@ -61,21 +62,19 @@
* of store. Really only need it for shared memory.
*/
- public BasicPersistentLockStore(String key)
+ public BasicPersistentLockStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException
{
if (txojLogger.logger.isTraceEnabled()) {
- txojLogger.logger.trace("BasicPersistentLockStore.BasicPersistentLockStore(" + key + ")");
+ txojLogger.logger.trace("BasicPersistentLockStore.BasicPersistentLockStore()");
}
- _key = txojPropertyManager.getTxojEnvironmentBean().getLockStoreDir();
-
/*
* Use the ShadowingStore since it has file-level locking which we
* require. The default object store assumes locking is provided
* entirely by the object.
*/
- _lockStore = new ShadowingStore(_key);
+ _lockStore = new ShadowingStore(objectStoreEnvironmentBean);
}
public InputObjectState read_state (Uid u, String tName)
@@ -127,7 +126,5 @@
}
}
- private String _key;
-
private ParticipantStore _lockStore;
}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockManager.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockManager.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -930,10 +930,13 @@
{
try
{
- if (lockStoreType.equals(BasicLockStore.class.getName()))
- lockStore = new BasicLockStore(systemKey);
- else
- lockStore = new BasicPersistentLockStore(systemKey);
+ if (lockStoreType.equals(BasicLockStore.class.getName())) {
+ lockStore = new BasicLockStore();
+ } else {
+ ObjectStoreEnvironmentBean objectStoreEnvironmentBean = new ObjectStoreEnvironmentBean();
+ objectStoreEnvironmentBean.setLocalOSRoot(systemKey);
+ lockStore = new BasicPersistentLockStore(objectStoreEnvironmentBean);
+ }
}
catch (final Exception ex)
{
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/PersistenceTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/PersistenceTest.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/PersistenceTest.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -46,7 +46,7 @@
@Test
public void test () throws ObjectStoreException
{
- ParticipantStore store = new ShadowingStore();
+ ParticipantStore store = new ShadowingStore(new ObjectStoreEnvironmentBean());
OutputObjectState state = new OutputObjectState();
Uid u = new Uid();
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/common/JTAEnvironmentBean.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/common/JTAEnvironmentBean.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/common/JTAEnvironmentBean.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -153,7 +153,7 @@
{
synchronized(this) {
if(transactionManager == null && transactionManagerClassName != null) {
- TransactionManager instance = ClassloadingUtility.loadAndInstantiateClass(TransactionManager.class, transactionManagerClassName);
+ TransactionManager instance = ClassloadingUtility.loadAndInstantiateClass(TransactionManager.class, transactionManagerClassName, null);
transactionManager = instance;
}
}
@@ -234,7 +234,7 @@
{
synchronized (this) {
if(userTransaction == null && userTransactionClassName != null) {
- UserTransaction instance = ClassloadingUtility.loadAndInstantiateClass(UserTransaction.class, userTransactionClassName);
+ UserTransaction instance = ClassloadingUtility.loadAndInstantiateClass(UserTransaction.class, userTransactionClassName, null);
userTransaction = instance;
}
}
@@ -315,7 +315,7 @@
{
synchronized (this) {
if(transactionSynchronizationRegistry == null && transactionSynchronizationRegistryClassName != null) {
- TransactionSynchronizationRegistry instance = ClassloadingUtility.loadAndInstantiateClass(TransactionSynchronizationRegistry.class, transactionSynchronizationRegistryClassName);
+ TransactionSynchronizationRegistry instance = ClassloadingUtility.loadAndInstantiateClass(TransactionSynchronizationRegistry.class, transactionSynchronizationRegistryClassName, null);
transactionSynchronizationRegistry = instance;
}
}
Modified: labs/jbosstm/trunk/ArjunaJTA/tsmx/bin/com/arjuna/ats/tools/objectstorebrowser/rootprovider/InFlightTransactionPseudoStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/tsmx/bin/com/arjuna/ats/tools/objectstorebrowser/rootprovider/InFlightTransactionPseudoStore.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaJTA/tsmx/bin/com/arjuna/ats/tools/objectstorebrowser/rootprovider/InFlightTransactionPseudoStore.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -20,7 +20,7 @@
*/
package com.arjuna.ats.tools.objectstorebrowser.rootprovider;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
+import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
import com.arjuna.ats.arjuna.objectstore.ObjectStore;
import com.arjuna.ats.arjuna.objectstore.StateStatus;
import com.arjuna.ats.arjuna.state.InputObjectState;
@@ -47,6 +47,10 @@
private static final String TX_TYPE_WS = "Transaction/";
private static TransactionLister transactionLister;
+ public InFlightTransactionPseudoStore(ObjectStoreEnvironmentBean objectStoreEnvironmentBean) throws ObjectStoreException {
+ super(objectStoreEnvironmentBean);
+ }
+
/**
* Abstract the mechanism used to discover which transactions are currently in existence
*
@@ -57,11 +61,6 @@
InFlightTransactionPseudoStore.transactionLister = transactionLister;
}
- public int typeIs()
- {
- return ObjectStoreType.USER_DEF_0;
- }
-
/*
* allObjUids - Given a type name, return an ObjectState that contains all
* of the uids of objects of that type.
Modified: labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/jacorb/recoverycoordinators/JacOrbRCManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/jacorb/recoverycoordinators/JacOrbRCManager.java 2010-09-08 14:21:23 UTC (rev 35067)
+++ labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/jacorb/recoverycoordinators/JacOrbRCManager.java 2010-09-08 14:23:15 UTC (rev 35068)
@@ -151,12 +151,7 @@
{
try
{
- //Retrieve from Object Store
- if (participantStore == null)
- {
- participantStore = StoreManager.getParticipantStore();
- }
-
+ ParticipantStore participantStore = StoreManager.getCommunicationStore();
InputObjectState iState = participantStore.read_committed(new Uid( JacOrbRCServiceInit.uid4Recovery), JacOrbRCServiceInit.type());
if (iState != null)
@@ -183,8 +178,8 @@
private static boolean _runWithoutDaemon = false;
private static boolean _initialised = false;
- private ParticipantStore participantStore;
+
static
{
/*
More information about the jboss-svn-commits
mailing list