[infinispan-commits] Infinispan SVN: r966 - in trunk/core/src/main/java/org/infinispan/remoting/transport: jgroups and 1 other directory.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Sat Oct 17 11:28:43 EDT 2009
Author: manik.surtani at jboss.com
Date: 2009-10-17 11:28:43 -0400 (Sat, 17 Oct 2009)
New Revision: 966
Modified:
trunk/core/src/main/java/org/infinispan/remoting/transport/DistributedSync.java
trunk/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsDistSync.java
Log:
Updated to propagate InterruptedExceptions
Modified: trunk/core/src/main/java/org/infinispan/remoting/transport/DistributedSync.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/remoting/transport/DistributedSync.java 2009-10-16 13:20:11 UTC (rev 965)
+++ trunk/core/src/main/java/org/infinispan/remoting/transport/DistributedSync.java 2009-10-17 15:28:43 UTC (rev 966)
@@ -28,7 +28,7 @@
* @param timeUnit time unit
* @throws TimeoutException if waiting for the sync times out.
*/
- SyncResponse blockUntilAcquired(long timeout, TimeUnit timeUnit) throws TimeoutException;
+ SyncResponse blockUntilAcquired(long timeout, TimeUnit timeUnit) throws TimeoutException, InterruptedException;
/**
* Blocks until an ongoing sync ends. This is returns immediately if there is no ongoing sync.
@@ -37,7 +37,7 @@
* @param timeUnit time unit
* @throws TimeoutException if waiting for an ongoing sync to end times out.
*/
- SyncResponse blockUntilReleased(long timeout, TimeUnit timeUnit) throws TimeoutException;
+ SyncResponse blockUntilReleased(long timeout, TimeUnit timeUnit) throws TimeoutException, InterruptedException;
/**
* Acquires the sync. This could be from a local or remote source.
@@ -58,7 +58,7 @@
* @param timeUnit time unit
* @throws TimeoutException if waiting for the lock times out
*/
- void acquireProcessingLock(boolean exclusive, long timeout, TimeUnit timeUnit) throws TimeoutException;
+ void acquireProcessingLock(boolean exclusive, long timeout, TimeUnit timeUnit) throws TimeoutException, InterruptedException;
/**
* Releases any processing locks that may be held by the current thread.
Modified: trunk/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsDistSync.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsDistSync.java 2009-10-16 13:20:11 UTC (rev 965)
+++ trunk/core/src/main/java/org/infinispan/remoting/transport/jgroups/JGroupsDistSync.java 2009-10-17 15:28:43 UTC (rev 966)
@@ -32,45 +32,25 @@
public static final boolean trace = log.isTraceEnabled();
- public void blockUntilNoJoinsInProgress() {
- while (Thread.currentThread().isInterrupted()) {
- try {
- joinInProgress.await();
- return;
- } catch (InterruptedException ie) {
- if (trace)
- log.trace("Interrupted while waiting for the joinInProgress gate");
- Thread.currentThread().interrupt();
- }
- }
+ public void blockUntilNoJoinsInProgress() throws InterruptedException {
+ joinInProgress.await();
}
- public SyncResponse blockUntilAcquired(long timeout, TimeUnit timeUnit) throws TimeoutException {
+ public SyncResponse blockUntilAcquired(long timeout, TimeUnit timeUnit) throws TimeoutException, InterruptedException {
int initState = flushWaitGateCount.get();
- while (true) {
- try {
- if (!flushWaitGate.await(timeout, timeUnit))
- throw new TimeoutException("Timed out waiting for a cluster-wide sync to be acquired. (timeout = " + Util.prettyPrintTime(timeout) + ")");
+ if (!flushWaitGate.await(timeout, timeUnit))
+ throw new TimeoutException("Timed out waiting for a cluster-wide sync to be acquired. (timeout = " + Util.prettyPrintTime(timeout) + ")");
- return initState == flushWaitGateCount.get() ? SyncResponse.STATE_PREEXISTED : SyncResponse.STATE_ACHIEVED;
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- }
- }
+ return initState == flushWaitGateCount.get() ? SyncResponse.STATE_PREEXISTED : SyncResponse.STATE_ACHIEVED;
+
}
- public SyncResponse blockUntilReleased(long timeout, TimeUnit timeUnit) throws TimeoutException {
+ public SyncResponse blockUntilReleased(long timeout, TimeUnit timeUnit) throws TimeoutException, InterruptedException {
int initState = flushBlockGateCount.get();
- while (true) {
- try {
- if (!flushBlockGate.await(timeout, timeUnit))
- throw new TimeoutException("Timed out waiting for a cluster-wide sync to be released. (timeout = " + Util.prettyPrintTime(timeout) + ")");
+ if (!flushBlockGate.await(timeout, timeUnit))
+ throw new TimeoutException("Timed out waiting for a cluster-wide sync to be released. (timeout = " + Util.prettyPrintTime(timeout) + ")");
- return initState == flushWaitGateCount.get() ? SyncResponse.STATE_PREEXISTED : SyncResponse.STATE_ACHIEVED;
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- }
- }
+ return initState == flushWaitGateCount.get() ? SyncResponse.STATE_PREEXISTED : SyncResponse.STATE_ACHIEVED;
}
public void acquireSync() {
@@ -85,17 +65,10 @@
flushBlockGate.open();
}
- public void acquireProcessingLock(boolean exclusive, long timeout, TimeUnit timeUnit) throws TimeoutException {
- while (true) {
- try {
- Lock lock = exclusive ? processingLock.writeLock() : processingLock.readLock();
- if (!lock.tryLock(timeout, timeUnit))
- throw new TimeoutException("Could not obtain " + (exclusive ? "exclusive" : "shared") + " processing lock");
- break;
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- }
- }
+ public void acquireProcessingLock(boolean exclusive, long timeout, TimeUnit timeUnit) throws InterruptedException, TimeoutException {
+ Lock lock = exclusive ? processingLock.writeLock() : processingLock.readLock();
+ if (!lock.tryLock(timeout, timeUnit))
+ throw new TimeoutException("Could not obtain " + (exclusive ? "exclusive" : "shared") + " processing lock");
}
public void releaseProcessingLock() {
More information about the infinispan-commits
mailing list