You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2013/06/06 00:12:42 UTC
svn commit: r1490046 - in
/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger:
ConsumingWatcher.java OperationJournal.java OutriggerServerImpl.java
TxnMonitorTask.java TypeTree.java
Author: peter_firmstone
Date: Wed Jun 5 22:12:42 2013
New Revision: 1490046
URL: http://svn.apache.org/r1490046
Log:
Minor fixes for synchronization and other minor tidy ups.
Modified:
river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/ConsumingWatcher.java
river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OperationJournal.java
river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OutriggerServerImpl.java
river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnMonitorTask.java
river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TypeTree.java
Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/ConsumingWatcher.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/ConsumingWatcher.java?rev=1490046&r1=1490045&r2=1490046&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/ConsumingWatcher.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/ConsumingWatcher.java Wed Jun 5 22:12:42 2013
@@ -17,9 +17,7 @@
*/
package com.sun.jini.outrigger;
-import java.util.Map;
import java.util.Set;
-import java.util.WeakHashMap;
import net.jini.core.transaction.TransactionException;
import net.jini.space.InternalSpaceException;
Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OperationJournal.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OperationJournal.java?rev=1490046&r1=1490045&r2=1490046&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OperationJournal.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OperationJournal.java Wed Jun 5 22:12:42 2013
@@ -17,8 +17,8 @@
*/
package com.sun.jini.outrigger;
-import java.util.SortedSet;
import java.util.Iterator;
+import java.util.SortedSet;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -209,31 +209,33 @@ class OperationJournal extends Thread {
*/
// Skip if payload is not an EntryTransition
- Object payload = current.payload;
- while (true) {
- if (current == end) {
- /* This is the last one...still need to return
- * it's payload if applicable.
- */
- current = null;
- if (payload instanceof EntryTransition)
- // Might be null, but that's ok
- return (EntryTransition)payload;
-
- return null;
- }
-
- current = current.getNext();
- assert current != null : "Iteration when off end";
-
- if ((payload != null) &&
- (payload instanceof EntryTransition))
- {
- return (EntryTransition)payload;
- }
-
- payload = current.payload;
- }
+ synchronized (this){
+ Object payload = current.payload;
+ while (true) {
+ if (current == end) {
+ /* This is the last one...still need to return
+ * it's payload if applicable.
+ */
+ current = null;
+ if (payload instanceof EntryTransition)
+ // Might be null, but that's ok
+ return (EntryTransition)payload;
+
+ return null;
+ }
+
+ current = current.getNext();
+ assert current != null : "Iteration when off end";
+
+ if ((payload != null) &&
+ (payload instanceof EntryTransition))
+ {
+ return (EntryTransition)payload;
+ }
+
+ payload = current.payload;
+ }
+ }
}
/**
@@ -248,25 +250,27 @@ class OperationJournal extends Thread {
* <code>watcherRegistered</code> has been called.
*/
void watcherRegistered() {
- if (end != null)
- throw new IllegalStateException(
- "watcherRegistered() called more than once");
-
- end = lastProcessed(current);
-
- if (current == end) {
- /* Noting has been processed since we were created.
- * There are no elements in the iteration.
- */
- current = null;
- return;
- }
-
- /* Skip the tail when we were created, we don't
- * need to return it since it was in the journal before
- * we were created.
- */
- current = current.getNext();
+ synchronized (this){
+ if (end != null)
+ throw new IllegalStateException(
+ "watcherRegistered() called more than once");
+
+ end = lastProcessed(current);
+
+ if (current == end) {
+ /* Noting has been processed since we were created.
+ * There are no elements in the iteration.
+ */
+ current = null;
+ return;
+ }
+
+ /* Skip the tail when we were created, we don't
+ * need to return it since it was in the journal before
+ * we were created.
+ */
+ current = current.getNext();
+ }
}
/**
@@ -279,7 +283,7 @@ class OperationJournal extends Thread {
* @throws IllegalStateException if
* <code>watcherRegistered</code> has been called.
*/
- long currentOrdinalAtCreation() {
+ synchronized long currentOrdinalAtCreation() {
if (end != null)
throw new IllegalStateException(
"watcherRegistered() has been called");
@@ -347,9 +351,7 @@ class OperationJournal extends Thread {
* @param node The node to post.
*/
private synchronized void post(JournalNode node) {
- synchronized (tail){
- tail.next = node;
- }
+ tail.setNext(node);
tail = node;
notifyAll();
}
@@ -399,9 +401,11 @@ class OperationJournal extends Thread {
/**
* Terminate queue processing.
*/
- synchronized void terminate() {
+ void terminate() {
dead = true;
- notifyAll();
+ synchronized (this){
+ notifyAll();
+ }
}
/**
@@ -444,9 +448,8 @@ class OperationJournal extends Thread {
watchers.allMatches(t, ordinal);
final long now = System.currentTimeMillis();
- for (Iterator<TransitionWatcher> i=set.iterator(); i.hasNext() && !dead; ) {
- final TransitionWatcher watcher =
- i.next();
+ for (Iterator<TransitionWatcher> i = set.iterator(); i.hasNext() && !dead; ) {
+ final TransitionWatcher watcher = i.next();
watcher.process(t, now);
}
} else if (payload instanceof CaughtUpMarker) {
Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OutriggerServerImpl.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OutriggerServerImpl.java?rev=1490046&r1=1490045&r2=1490046&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OutriggerServerImpl.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OutriggerServerImpl.java Wed Jun 5 22:12:42 2013
@@ -94,7 +94,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
-import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnMonitorTask.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnMonitorTask.java?rev=1490046&r1=1490045&r2=1490046&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnMonitorTask.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnMonitorTask.java Wed Jun 5 22:12:42 2013
@@ -249,9 +249,9 @@ class TxnMonitorTask extends RetryTask
if (queries == null || queries.size() == 0)
return;
Collection<Txn> sibling = Collections.nCopies(1, txn);
- Iterator it = queries.keySet().iterator();
+ Iterator<QueryWatcher> it = queries.keySet().iterator();
while (it.hasNext()) {
- QueryWatcher query = (QueryWatcher)it.next();
+ QueryWatcher query = it.next();
if (query != null) // from a weak map, so might be null
monitor.add(query, sibling);
}
@@ -333,7 +333,7 @@ class TxnMonitorTask extends RetryTask
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST, "{0} foundNeed = {1}",
- new Object[]{this, new Boolean(foundNeed)});
+ new Object[]{this, Boolean.valueOf(foundNeed)});
}
if (!foundNeed) // nobody wants it
Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TypeTree.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TypeTree.java?rev=1490046&r1=1490045&r2=1490046&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TypeTree.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TypeTree.java Wed Jun 5 22:12:42 2013
@@ -17,17 +17,12 @@
*/
package com.sun.jini.outrigger;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Random;
import java.util.Set;
-import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentSkipListSet;