Permalink
Browse files

minor refactoring

  • Loading branch information...
Maysam Yabandeh
Maysam Yabandeh committed May 24, 2012
1 parent 49cadfe commit 5637cf73a3acb4644fee3ba16b30dc96023b4e4f
@@ -521,10 +521,10 @@ public long commitTimestamp(long transaction, long startTimestamp) throws IOExce
return commitTimestamp;
if (hasConnectionTimestamp && transaction > connectionTimestamp)
- return transaction <= largestDeletedTimestamp ? -1 : INVALID_READ;
+ return transaction <= largestDeletedTimestamp ? LOST_TC : INVALID_READ;
//TODO: it works only if it runs one transaction at a time
if (transaction <= largestDeletedTimestamp)
- return -1;//committed but the tc is lost
+ return LOST_TC;//committed but the tc is lost
Statistics.partialReport(Statistics.Tag.ASKTSO, 1);
askedTSO++;
@@ -541,11 +541,6 @@ public long commitTimestamp(long transaction, long startTimestamp) throws IOExce
return cb.isCommitted() ? cb.commitTimestamp() : INVALID_READ;
}
- public boolean validRead(long transaction, long startTimestamp) throws IOException {
- long Tc = commitTimestamp(transaction, startTimestamp);
- return (Tc != INVALID_READ);
- }
-
/**
* When a message is received, handle it based on its type
*/
@@ -28,6 +28,7 @@
import com.yahoo.omid.tso.messages.CommittedTransactionReport;
import com.yahoo.omid.tso.messages.TimestampRequest;
import com.yahoo.omid.tso.messages.TimestampResponse;
+import com.yahoo.omid.client.TSOClient;
public class TestReadAlgorithm extends TSOTestBase {
@@ -57,14 +58,19 @@ public void testReadAlgorithm() throws Exception {
TimestampResponse tr4 = secondClientHandler.receiveMessage(TimestampResponse.class);
// Transaction half aborted
- assertFalse(secondClientHandler.validRead(tr3.timestamp, tr4.timestamp));
+ assertFalse(validRead(secondClientHandler, tr3.timestamp, tr4.timestamp));
// Transaction committed after start timestamp
- assertFalse(secondClientHandler.validRead(tr2.timestamp, tr1.timestamp));
+ assertFalse(validRead(secondClientHandler, tr2.timestamp, tr1.timestamp));
// Transaction committed before start timestamp
- assertTrue(secondClientHandler.validRead(tr2.timestamp, tr4.timestamp));
+ assertTrue(validRead(secondClientHandler, tr2.timestamp, tr4.timestamp));
}
+
+ private boolean validRead(TestClientHandler handler, long transaction, long startTimestamp) throws Exception {
+ long Tc = handler.commitTimestamp(transaction, startTimestamp);
+ return (Tc != TSOClient.INVALID_READ);
+ }
-}
+}

0 comments on commit 5637cf7

Please sign in to comment.