/** * This method completes mini-batch operations by calling postBatchMutate() CP hook (if * required) and completing mvcc. */ public void completeMiniBatchOperations( final MiniBatchOperationInProgress<Mutation> miniBatchOp, final WriteEntry writeEntry) throws IOException { if (writeEntry != null) { region.mvcc.completeAndWait(writeEntry); } }
/** * Wait until the read point catches up to the write point; i.e. wait on all outstanding mvccs * to complete. */ public void await() { // Add a write and then wait on reads to catch up to it. completeAndWait(begin()); }
/** * Method to safely get the next sequence number. * @return Next sequence number unassociated with any actual edit. * @throws IOException */ @VisibleForTesting protected long getNextSequenceId(final WAL wal) throws IOException { WriteEntry we = mvcc.begin(); mvcc.completeAndWait(we); return we.getWriteNumber(); }
@Override public void run() { while (!finished.get()) { MultiVersionConcurrencyControl.WriteEntry e = mvcc.begin(); // System.out.println("Begin write: " + e.getWriteNumber()); // 10 usec - 500usec (including 0) int sleepTime = rnd.nextInt(500); // 500 * 1000 = 500,000ns = 500 usec // 1 * 100 = 100ns = 1usec try { if (sleepTime > 0) Thread.sleep(0, sleepTime * 1000); } catch (InterruptedException e1) { } try { mvcc.completeAndWait(e); } catch (RuntimeException ex) { // got failure System.out.println(ex.toString()); ex.printStackTrace(); status.set(false); return; // Report failure if possible. } } } }
new FlushResultImpl(FlushResult.Result.CANNOT_FLUSH_MEMSTORE_EMPTY, flushOpSeqId, "Nothing to flush", writeFlushRequestMarkerToWAL(wal, writeFlushWalMarker)); mvcc.completeAndWait(writeEntry);
@Test public void testMemstoreConcurrentControl() throws IOException { final byte[] row = Bytes.toBytes(1); final byte[] f = Bytes.toBytes("family"); final byte[] q1 = Bytes.toBytes("q1"); final byte[] q2 = Bytes.toBytes("q2"); final byte[] v = Bytes.toBytes("value"); MultiVersionConcurrencyControl.WriteEntry w = mvcc.begin(); KeyValue kv1 = new KeyValue(row, f, q1, v); kv1.setSequenceId(w.getWriteNumber()); memstore.add(kv1, null); KeyValueScanner s = this.memstore.getScanners(mvcc.getReadPoint()).get(0); assertScannerResults(s, new KeyValue[]{}); mvcc.completeAndWait(w); s = this.memstore.getScanners(mvcc.getReadPoint()).get(0); assertScannerResults(s, new KeyValue[]{kv1}); w = mvcc.begin(); KeyValue kv2 = new KeyValue(row, f, q2, v); kv2.setSequenceId(w.getWriteNumber()); memstore.add(kv2, null); s = this.memstore.getScanners(mvcc.getReadPoint()).get(0); assertScannerResults(s, new KeyValue[]{kv1}); mvcc.completeAndWait(w); s = this.memstore.getScanners(mvcc.getReadPoint()).get(0); assertScannerResults(s, new KeyValue[]{kv1, kv2}); }
applyToMemStore(e.getKey(), e.getValue(), true, memstoreAccounting); mvcc.completeAndWait(writeEntry); if (rsServices != null && rsServices.getNonceManager() != null) { rsServices.getNonceManager().addMvccToOperationContext(nonceGroup, nonce,
mvcc.completeAndWait(writeEntry); writeEntry = null;
private void internalRun() throws IOException { for (long i = 0; i < NUM_TRIES && caughtException.get() == null; i++) { MultiVersionConcurrencyControl.WriteEntry w = mvcc.begin(); // Insert the sequence value (i) byte[] v = Bytes.toBytes(i); KeyValue kv = new KeyValue(row, f, q1, i, v); kv.setSequenceId(w.getWriteNumber()); memstore.add(kv, null); mvcc.completeAndWait(w); // Assert that we can read back KeyValueScanner s = this.memstore.getScanners(mvcc.getReadPoint()).get(0); s.seek(kv); Cell ret = s.next(); assertNotNull("Didnt find own write at all", ret); assertEquals("Didnt read own writes", kv.getTimestamp(), ret.getTimestamp()); } } }
kv12.setSequenceId(w.getWriteNumber()); memstore.add(kv12, null); mvcc.completeAndWait(w); mvcc.completeAndWait(w);
kv12.setSequenceId(w.getWriteNumber()); memstore.add(kv12, null); mvcc.completeAndWait(w); mvcc.completeAndWait(w);
@Test public void testSimpleMvccOps() { MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl(); long readPoint = mvcc.getReadPoint(); MultiVersionConcurrencyControl.WriteEntry writeEntry = mvcc.begin(); mvcc.completeAndWait(writeEntry); assertEquals(readPoint + 1, mvcc.getReadPoint()); writeEntry = mvcc.begin(); // The write point advances even though we may have 'failed'... call complete on fail. mvcc.complete(writeEntry); assertEquals(readPoint + 2, mvcc.getWritePoint()); } }
System.currentTimeMillis(), clusterIds, -1, -1, region.getMVCC(), scopes); wal.append(info, logkey, edits, true); region.getMVCC().completeAndWait(logkey.getWriteEntry());
/** * Wait until the read point catches up to the write point; i.e. wait on all outstanding mvccs * to complete. */ public void await() { // Add a write and then wait on reads to catch up to it. completeAndWait(begin()); }
@Override public void run() { while (!finished.get()) { MultiVersionConcurrencyControl.WriteEntry e = mvcc.begin(); // System.out.println("Begin write: " + e.getWriteNumber()); // 10 usec - 500usec (including 0) int sleepTime = rnd.nextInt(500); // 500 * 1000 = 500,000ns = 500 usec // 1 * 100 = 100ns = 1usec try { if (sleepTime > 0) Thread.sleep(0, sleepTime * 1000); } catch (InterruptedException e1) { } try { mvcc.completeAndWait(e); } catch (RuntimeException ex) { // got failure System.out.println(ex.toString()); ex.printStackTrace(); status.set(false); return; // Report failure if possible. } } } }
@Test public void testMemstoreConcurrentControl() throws IOException { final byte[] row = Bytes.toBytes(1); final byte[] f = Bytes.toBytes("family"); final byte[] q1 = Bytes.toBytes("q1"); final byte[] q2 = Bytes.toBytes("q2"); final byte[] v = Bytes.toBytes("value"); MultiVersionConcurrencyControl.WriteEntry w = mvcc.begin(); KeyValue kv1 = new KeyValue(row, f, q1, v); kv1.setSequenceId(w.getWriteNumber()); memstore.add(kv1, null); KeyValueScanner s = this.memstore.getScanners(mvcc.getReadPoint()).get(0); assertScannerResults(s, new KeyValue[]{}); mvcc.completeAndWait(w); s = this.memstore.getScanners(mvcc.getReadPoint()).get(0); assertScannerResults(s, new KeyValue[]{kv1}); w = mvcc.begin(); KeyValue kv2 = new KeyValue(row, f, q2, v); kv2.setSequenceId(w.getWriteNumber()); memstore.add(kv2, null); s = this.memstore.getScanners(mvcc.getReadPoint()).get(0); assertScannerResults(s, new KeyValue[]{kv1}); mvcc.completeAndWait(w); s = this.memstore.getScanners(mvcc.getReadPoint()).get(0); assertScannerResults(s, new KeyValue[]{kv1, kv2}); }
private void internalRun() throws IOException { for (long i = 0; i < NUM_TRIES && caughtException.get() == null; i++) { MultiVersionConcurrencyControl.WriteEntry w = mvcc.begin(); // Insert the sequence value (i) byte[] v = Bytes.toBytes(i); KeyValue kv = new KeyValue(row, f, q1, i, v); kv.setSequenceId(w.getWriteNumber()); memstore.add(kv, null); mvcc.completeAndWait(w); // Assert that we can read back KeyValueScanner s = this.memstore.getScanners(mvcc.getReadPoint()).get(0); s.seek(kv); Cell ret = s.next(); assertNotNull("Didnt find own write at all", ret); assertEquals("Didnt read own writes", kv.getTimestamp(), ret.getTimestamp()); } } }
kv12.setSequenceId(w.getWriteNumber()); memstore.add(kv12, null); mvcc.completeAndWait(w); mvcc.completeAndWait(w);
kv12.setSequenceId(w.getWriteNumber()); memstore.add(kv12, null); mvcc.completeAndWait(w); mvcc.completeAndWait(w);
@Test public void testSimpleMvccOps() { MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl(); long readPoint = mvcc.getReadPoint(); MultiVersionConcurrencyControl.WriteEntry writeEntry = mvcc.begin(); mvcc.completeAndWait(writeEntry); assertEquals(readPoint + 1, mvcc.getReadPoint()); writeEntry = mvcc.begin(); // The write point advances even though we may have 'failed'... call complete on fail. mvcc.complete(writeEntry); assertEquals(readPoint + 2, mvcc.getWritePoint()); } }