public static ConcurrencyException waitFailureOnClientSession(InterruptedException exception) { Object[] args = { }; ConcurrencyException concurrencyException = new ConcurrencyException(ExceptionMessageGenerator.buildMessage(ConcurrencyException.class, WAIT_FAILURE_CLIENT, args), exception); concurrencyException.setErrorCode(WAIT_FAILURE_CLIENT); return concurrencyException; }
/** * Decrement the number of readers. * Used to allow concurrent reads. */ public synchronized void releaseReadLock() throws ConcurrencyException { if (this.numberOfReaders == 0) { throw ConcurrencyException.signalAttemptedBeforeWait(); } else { this.numberOfReaders--; } if (this.numberOfReaders == 0) { notifyAll(); } }
public synchronized Accessor acquireAccessor() { if (isBusy) { try { wait();// Notify is called when connection is released. } catch (InterruptedException exception) { throw ConcurrencyException.waitFailureOnSequencingForDatabaseSession(exception); } } isBusy = true; return accessor; }
/** * Wait on any writer. * Allow concurrent reads. */ public synchronized void acquireReadLock() throws ConcurrencyException { // Cannot check for starving writers as will lead to deadlocks. while ((this.activeThread != null) && (this.activeThread != Thread.currentThread())) { try { wait(); } catch (InterruptedException exception) { throw ConcurrencyException.waitWasInterrupted(exception.getMessage()); } } this.numberOfReaders++; }
public synchronized Object waitForObject(){ try { int count = 0; while (this.object == null && isAcquired()) { if (count > MAX_WAIT_TRIES) throw ConcurrencyException.maxTriesLockOnBuildObjectExceded(getActiveThread(), Thread.currentThread()); wait(10); ++count; } } catch(InterruptedException ex) { //ignore as the loop is broken } return this.object; } }
throw ConcurrencyException.waitFailureOnServerSession(exception);
if ((toWaitOn != null) && ((++tries) > MAXTRIES)) { throw ConcurrencyException.maxTriesLockOnCloneExceded(objectForClone);
wait(this.waitTimeout);// Notify is called when connections are released. } catch (InterruptedException exception) { throw ConcurrencyException.waitFailureOnClientSession(exception);
/** * Wait on any writer. * Allow concurrent reads. */ public synchronized void acquireReadLock() throws ConcurrencyException { // Cannot check for starving writers as will lead to deadlocks. while ((this.activeThread != null) && (this.activeThread != Thread.currentThread())) { try { wait(); } catch (InterruptedException exception) { throw ConcurrencyException.waitWasInterrupted(exception.getMessage()); } } this.numberOfReaders++; }
public synchronized Object waitForObject(){ try { int count = 0; while (this.object == null && isAcquired()) { if (count > MAX_WAIT_TRIES) throw ConcurrencyException.maxTriesLockOnBuildObjectExceded(getActiveThread(), Thread.currentThread()); wait(10); ++count; } } catch(InterruptedException ex) { //ignore as the loop is broken } return this.object; } }
/** * INTERNAL: * Allocate the client's connection resource. */ public void acquireClientConnection(ClientSession clientSession) throws DatabaseException, ConcurrencyException { if (clientSession.getConnectionPolicy().isPooled()) { ConnectionPool pool = this.connectionPools.get(clientSession.getConnectionPolicy().getPoolName()); Accessor accessor = pool.acquireConnection(); clientSession.addWriteConnection(pool.getName(), accessor); } else { if (this.maxNumberOfNonPooledConnections != NO_MAX) { synchronized (this) { while (this.numberOfNonPooledConnectionsUsed >= this.maxNumberOfNonPooledConnections) { try { wait();// Notify is called when connections are released. } catch (InterruptedException exception) { throw ConcurrencyException.waitFailureOnServerSession(exception); } } this.numberOfNonPooledConnectionsUsed++; } } Accessor accessor = clientSession.getLogin().buildAccessor(); clientSession.connect(accessor); clientSession.addWriteConnection(ServerSession.NOT_POOLED, accessor); } }
if ((toWaitOn != null) && ((++tries) > MAXTRIES)) { throw ConcurrencyException.maxTriesLockOnCloneExceded(objectForClone);
wait(this.waitTimeout);// Notify is called when connections are released. } catch (InterruptedException exception) { throw ConcurrencyException.waitFailureOnClientSession(exception);
public static ConcurrencyException activeLockAlreadyTransitioned(Thread currentThread) { Object[] args = { currentThread}; ConcurrencyException concurrencyException = new ConcurrencyException(ExceptionMessageGenerator.buildMessage(ConcurrencyException.class, ACTIVE_LOCK_ALREADY_TRANSITIONED, args)); concurrencyException.setErrorCode(ACTIVE_LOCK_ALREADY_TRANSITIONED); return concurrencyException; }
/** * Wait on any writer. * Allow concurrent reads. */ public synchronized void acquireReadLock() throws ConcurrencyException { // Cannot check for starving writers as will lead to deadlocks. while ((this.activeThread != null) && (this.activeThread != Thread.currentThread())) { try { wait(); } catch (InterruptedException exception) { throw ConcurrencyException.waitWasInterrupted(exception.getMessage()); } } this.numberOfReaders++; }
public Object waitForObject(){ synchronized (getMutex()) { try{ int count = 0; while(this.object == null && this.isAcquired()){ if (count > MAX_WAIT_TRIES) throw ConcurrencyException.maxTriesLockOnBuildObjectExceded(getMutex().getActiveThread(), Thread.currentThread()); getMutex().wait(10); ++count; } }catch(InterruptedException ex){ //ignore as the loop is broken } return this.object; } } }
/** * Decrement the number of readers. * Used to allow concurrent reads. */ public synchronized void releaseReadLock() throws ConcurrencyException { if (this.numberOfReaders == 0) { throw ConcurrencyException.signalAttemptedBeforeWait(); } else { this.numberOfReaders--; } if (this.numberOfReaders == 0) { notifyAll(); } }
public synchronized Accessor acquireAccessor() { if (isBusy) { try { wait();// Notify is called when connection is released. } catch (InterruptedException exception) { throw ConcurrencyException.waitFailureOnSequencingForDatabaseSession(exception); } } isBusy = true; return accessor; }
throw ConcurrencyException.waitFailureOnServerSession(exception);
if ((toWaitOn != null) && ((++tries) > MAXTRIES)) { throw ConcurrencyException.maxTriesLockOnCloneExceded(objectForClone);