use of com.arjuna.ats.txoj.exceptions.LockStoreException in project narayana by jbosstm.
the class OptimisticLockManager method loadState.
/*
* Lock and load the concurrency control state. First we grab the semaphore
* to ensure exclusive access and then we build the held lock list by
* retreiving the locks from the lock repository. If there is only one
* server we do not bother doing this since all the locks can stay in the
* server's memory. This is yet another consequence of not having
* multi-threaded servers. Does not require synchronized since it can only
* be called from other synchronized methods.
*/
protected final boolean loadState() {
if (txojLogger.logger.isTraceEnabled()) {
txojLogger.logger.trace("LockManager::loadState()");
}
if (super.objectModel == ObjectModel.SINGLE) {
stateLoaded = true;
return true;
} else {
InputObjectState S = null;
if ((systemKey == null) && !initialise()) {
return false;
/* init failed */
}
if ((mutex == null) || (!mutex.tryLock())) {
return false;
}
stateLoaded = false;
objectLocked = true;
try {
S = lockStore.read_state(get_uid(), type());
if (S != null) {
Uid u = null;
/*
* avoid system calls in Uid
* creation
*/
Lock current = null;
int count = 0;
try {
count = S.unpackInt();
boolean cleanLoad = true;
if (txojLogger.logger.isTraceEnabled()) {
txojLogger.logger.trace("LockManager::loadState() loading " + count + " lock(s)");
}
for (int i = 0; (i < count) && cleanLoad; i++) {
try {
u = UidHelper.unpackFrom(S);
current = new OptimisticLock(u);
if (current != null) {
if (current.restore_state(S, ObjectType.ANDPERSISTENT)) {
locksHeld.push(current);
} else {
current = null;
cleanLoad = false;
}
} else {
cleanLoad = false;
}
} catch (IOException e) {
cleanLoad = false;
}
}
if (cleanLoad)
stateLoaded = true;
else {
while ((current = locksHeld.pop()) != null) current = null;
}
} catch (IOException e) {
}
S = null;
} else
stateLoaded = true;
} catch (LockStoreException e) {
txojLogger.logger.warn(e);
}
}
if (!stateLoaded) {
if (// means object model != SINGLE
mutex != null) {
// and exit mutual exclusion
mutex.unlock();
}
objectLocked = false;
}
return stateLoaded;
}
use of com.arjuna.ats.txoj.exceptions.LockStoreException in project narayana by jbosstm.
the class LockManager method loadState.
/*
* Lock and load the concurrency control state. First we grab the semaphore
* to ensure exclusive access and then we build the held lock list by
* retrieving the locks from the lock repository. If there is only one
* server we do not bother doing this since all the locks can stay in the
* server's memory. This is yet another consequence of not having
* multi-threaded servers. Does not require synchronized since it can only
* be called from other synchronized methods.
*/
/*
* Return to 'protected final boolean' if we address https://issues.jboss.org/browse/JBTM-2399
*/
protected boolean loadState() {
if (txojLogger.logger.isTraceEnabled()) {
txojLogger.logger.trace("LockManager::loadState()");
}
if (super.objectModel == ObjectModel.SINGLE) {
stateLoaded = true;
return true;
} else {
InputObjectState S = null;
if ((systemKey == null) && !initialise()) {
return false;
/* init failed */
}
if ((mutex == null) || (!mutex.tryLock())) {
return false;
}
stateLoaded = false;
objectLocked = true;
try {
S = lockStore.read_state(get_uid(), type());
if (S != null) {
Uid u = null;
/*
* avoid system calls in Uid
* creation
*/
Lock current = null;
int count = 0;
try {
count = S.unpackInt();
boolean cleanLoad = true;
if (txojLogger.logger.isTraceEnabled()) {
txojLogger.logger.trace("LockManager::loadState() loading " + count + " lock(s)");
}
for (int i = 0; (i < count) && cleanLoad; i++) {
try {
u = UidHelper.unpackFrom(S);
current = new Lock(u);
if (current != null) {
if (current.restore_state(S, ObjectType.ANDPERSISTENT)) {
locksHeld.push(current);
} else {
current = null;
cleanLoad = false;
}
} else {
cleanLoad = false;
}
} catch (IOException e) {
cleanLoad = false;
}
}
if (cleanLoad)
stateLoaded = true;
else {
while ((current = locksHeld.pop()) != null) current = null;
}
} catch (IOException e) {
}
S = null;
} else
stateLoaded = true;
} catch (LockStoreException e) {
txojLogger.logger.warn(e);
}
}
if (!stateLoaded) {
if (// means object model != SINGLE
mutex != null) {
// and exit mutual exclusion
mutex.unlock();
}
objectLocked = false;
}
return stateLoaded;
}
use of com.arjuna.ats.txoj.exceptions.LockStoreException in project narayana by jbosstm.
the class LockStoreExceptionUnitTest method test.
@Test
public void test() {
LockStoreException ex = new LockStoreException();
ex = new LockStoreException("Oops foobar!");
ex = new LockStoreException("Another issue!", new NullPointerException());
ex = new LockStoreException(new IllegalArgumentException());
}
Aggregations