RetryingRPC(ScannerCallable callable) { this.callable = callable; // For the Consistency.STRONG (default case), we reuse the caller // to keep compatibility with what is done in the past // For the Consistency.TIMELINE case, we can't reuse the caller // since we could be making parallel RPCs (caller.callWithRetries is synchronized // and we can't invoke it multiple times at the same time) this.caller = ScannerCallableWithReplicas.this.caller; if (scan.getConsistency() == Consistency.TIMELINE) { this.caller = RpcRetryingCallerFactory.instantiate(ScannerCallableWithReplicas.this.conf) .<Result[]>newCaller(); } }
if ((regionReplication == 1) || (scan.getConsistency() == Consistency.STRONG)) { if (scan.getConsistency() == Consistency.STRONG) {
out.setReadType(readTypeFromHBase(in.getReadType())); out.setLimit(in.getLimit()); out.setConsistency(consistencyFromHBase(in.getConsistency())); out.setTargetReplicaId(in.getReplicaId()); for (Map.Entry<byte[], TimeRange> entry : in.getColumnFamilyTimeRange().entrySet()) {
consistency = scan.getConsistency(); this.setIsolationLevel(scan.getIsolationLevel()); reversed = scan.isReversed();
scanBuilder.setReversed(scan.isReversed()); if (scan.getConsistency() == Consistency.TIMELINE) { scanBuilder.setConsistency(toConsistency(scan.getConsistency()));
scanBuilder.setReversed(scan.isReversed()); if (scan.getConsistency() == Consistency.TIMELINE) { scanBuilder.setConsistency(toConsistency(scan.getConsistency()));
@Test public void testConsistency() throws Exception { byte[] rowName = Bytes.toBytes("testConsistency"); TGet tGet = new TGet(wrap(rowName)); tGet.setConsistency(TConsistency.STRONG); Get get = getFromThrift(tGet); assertEquals(Consistency.STRONG, get.getConsistency()); tGet.setConsistency(TConsistency.TIMELINE); tGet.setTargetReplicaId(1); get = getFromThrift(tGet); assertEquals(Consistency.TIMELINE, get.getConsistency()); assertEquals(1, get.getReplicaId()); TScan tScan = new TScan(); tScan.setConsistency(TConsistency.STRONG); Scan scan = scanFromThrift(tScan); assertEquals(Consistency.STRONG, scan.getConsistency()); tScan.setConsistency(TConsistency.TIMELINE); tScan.setTargetReplicaId(1); scan = scanFromThrift(tScan); assertEquals(Consistency.TIMELINE, scan.getConsistency()); assertEquals(1, scan.getReplicaId()); TResult tResult = new TResult(); assertFalse(tResult.isSetStale()); tResult.setStale(true); assertTrue(tResult.isSetStale()); }
RetryingRPC(ScannerCallable callable) { this.callable = callable; // For the Consistency.STRONG (default case), we reuse the caller // to keep compatibility with what is done in the past // For the Consistency.TIMELINE case, we can't reuse the caller // since we could be making parallel RPCs (caller.callWithRetries is synchronized // and we can't invoke it multiple times at the same time) this.caller = ScannerCallableWithReplicas.this.caller; if (scan.getConsistency() == Consistency.TIMELINE) { this.caller = RpcRetryingCallerFactory.instantiate(ScannerCallableWithReplicas.this.conf) .<Result[]>newCaller(); } }
assertEquals(get.getConsistency(), scan.getConsistency()); assertEquals(get.getFilter(), scan.getFilter()); assertEquals(get.getId(), scan.getId());
assertEquals(scan.getCacheBlocks(), scanCopy.getCacheBlocks()); assertEquals(scan.getCaching(), scanCopy.getCaching()); assertEquals(scan.getConsistency(), scanCopy.getConsistency()); assertEquals(scan.getFamilies().length, scanCopy.getFamilies().length); assertEquals(scan.getFamilies()[0], scanCopy.getFamilies()[0]);
Scan scan = context.getScan(); if (scan.getConsistency() != Consistency.STRONG){ buf.append("TIMELINE-CONSISTENCY ");
if ((regionReplication == 1) || (scan.getConsistency() == Consistency.STRONG)) { if (scan.getConsistency() == Consistency.STRONG) {
consistency = scan.getConsistency(); this.setIsolationLevel(scan.getIsolationLevel()); reversed = scan.isReversed();
scanBuilder.setReversed(scan.isReversed()); if (scan.getConsistency() == Consistency.TIMELINE) { scanBuilder.setConsistency(toConsistency(scan.getConsistency()));
scanBuilder.setReversed(scan.isReversed()); if (scan.getConsistency() == Consistency.TIMELINE) { scanBuilder.setConsistency(toConsistency(scan.getConsistency()));
RetryingRPC(ScannerCallable callable) { this.callable = callable; // For the Consistency.STRONG (default case), we reuse the caller // to keep compatibility with what is done in the past // For the Consistency.TIMELINE case, we can't reuse the caller // since we could be making parallel RPCs (caller.callWithRetries is synchronized // and we can't invoke it multiple times at the same time) this.caller = ScannerCallableWithReplicas.this.caller; if (scan.getConsistency() == Consistency.TIMELINE) { this.caller = RpcRetryingCallerFactory.instantiate(ScannerCallableWithReplicas.this.conf) .<Result[]>newCaller(); } }
RetryingRPC(ScannerCallable callable) { this.callable = callable; // For the Consistency.STRONG (default case), we reuse the caller // to keep compatibility with what is done in the past // For the Consistency.TIMELINE case, we can't reuse the caller // since we could be making parallel RPCs (caller.callWithRetries is synchronized // and we can't invoke it multiple times at the same time) this.caller = ScannerCallableWithReplicas.this.caller; if (scan.getConsistency() == Consistency.TIMELINE) { this.caller = RpcRetryingCallerFactory.instantiate(ScannerCallableWithReplicas.this.conf) .<Result[]>newCaller(); } }
assertEquals(get.getConsistency(), scan.getConsistency()); assertEquals(get.getFilter(), scan.getFilter()); assertEquals(get.getId(), scan.getId());
private void addCallsForOtherReplicas( ResultBoundedCompletionService<Pair<Result[], ScannerCallable>> cs, RegionLocations rl, int min, int max) { if (scan.getConsistency() == Consistency.STRONG) { return; // not scheduling on other replicas for strong consistency } for (int id = min; id <= max; id++) { if (currentScannerCallable.id == id) { continue; //this was already scheduled earlier } ScannerCallable s = currentScannerCallable.getScannerCallableForReplica(id); setStartRowForReplicaCallable(s); outstandingCallables.add(s); RetryingRPC retryingOnReplica = new RetryingRPC(s); cs.submit(retryingOnReplica, scannerTimeout, id); } }
assertEquals(scan.getCacheBlocks(), scanCopy.getCacheBlocks()); assertEquals(scan.getCaching(), scanCopy.getCaching()); assertEquals(scan.getConsistency(), scanCopy.getConsistency()); assertEquals(scan.getFamilies().length, scanCopy.getFamilies().length); assertEquals(scan.getFamilies()[0], scanCopy.getFamilies()[0]);