scanner.setRanges(Collections.singletonList(getRange(cl, interpeter))); scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);
@Override public void setTimeout(long timeout, TimeUnit timeUnit) { bs.setTimeout(timeout, timeUnit); }
BatchScanner bscanner = conn.createBatchScanner(opts.getTableName(), opts.auths, bsOpts.scanThreads); bscanner.setTimeout(bsOpts.scanTimeout, TimeUnit.MILLISECONDS); List<Range> refs = new ArrayList<>();
scanner.setRanges(Collections.singletonList(getRange(cl, interpeter))); scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);
public static void main(String[] args) throws Exception { Opts opts = new Opts(); ScannerOpts scanOpts = new ScannerOpts(); BatchScannerOpts bsOpts = new BatchScannerOpts(); ClientOnDefaultTable clientOpts = new ClientOnDefaultTable("ci"); clientOpts.parseArgs(ContinuousBatchWalker.class.getName(), args, scanOpts, bsOpts, opts); Random r = new Random(); Authorizations auths = opts.randomAuths.getAuths(r); Connector conn = clientOpts.getConnector(); Scanner scanner = ContinuousUtil.createScanner(conn, clientOpts.getTableName(), auths); scanner.setBatchSize(scanOpts.scanBatchSize); while (true) { BatchScanner bs = conn.createBatchScanner(clientOpts.getTableName(), auths, bsOpts.scanThreads); bs.setTimeout(bsOpts.scanTimeout, TimeUnit.MILLISECONDS); Set<Text> batch = getBatch(scanner, opts.min, opts.max, scanOpts.scanBatchSize, r); List<Range> ranges = new ArrayList<>(batch.size()); for (Text row : batch) { ranges.add(new Range(row)); } runBatchScan(scanOpts.scanBatchSize, bs, batch, ranges); sleepUninterruptibly(opts.sleepTime, TimeUnit.MILLISECONDS); } }
public void testBatchScannerTimeout(Connector conn, String tableName) throws Exception { getConnector().tableOperations().create(tableName); BatchWriter bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig()); Mutation m = new Mutation("r1"); m.put("cf1", "cq1", "v1"); m.put("cf1", "cq2", "v2"); m.put("cf1", "cq3", "v3"); m.put("cf1", "cq4", "v4"); bw.addMutation(m); bw.close(); BatchScanner bs = getConnector().createBatchScanner(tableName, Authorizations.EMPTY, 2); bs.setRanges(Collections.singletonList(new Range())); // should not timeout for (Entry<Key,Value> entry : bs) { entry.getKey(); } bs.setTimeout(5, TimeUnit.SECONDS); IteratorSetting iterSetting = new IteratorSetting(100, SlowIterator.class); iterSetting.addOption("sleepTime", 2000 + ""); bs.addScanIterator(iterSetting); try { for (Entry<Key,Value> entry : bs) { entry.getKey(); } fail("batch scanner did not time out"); } catch (TimedOutException toe) { // toe.printStackTrace(); } bs.close(); }