use of com.alibaba.datax.plugin.reader.otsreader.model.OTSConf in project DataX by alibaba.
the class OtsReaderSlaveProxy method read.
public void read(RecordSender sender, Configuration configuration) throws Exception {
LOG.info("read begin.");
OTSConf conf = GsonParser.jsonToConf(configuration.getString(OTSConst.OTS_CONF));
OTSRange range = GsonParser.jsonToRange(configuration.getString(OTSConst.OTS_RANGE));
Direction direction = GsonParser.jsonToDirection(configuration.getString(OTSConst.OTS_DIRECTION));
OTSServiceConfiguration configure = new OTSServiceConfiguration();
configure.setRetryStrategy(new DefaultNoRetry());
OTSClientAsync ots = new OTSClientAsync(conf.getEndpoint(), conf.getAccessId(), conf.getAccesskey(), conf.getInstanceName(), null, configure, null);
RowPrimaryKey token = range.getBegin();
List<String> columns = Common.getNormalColumnNameList(conf.getColumns());
RequestItem request = null;
do {
LOG.debug("Next token : {}", GsonParser.rowPrimaryKeyToJson(token));
if (request == null) {
request = generateRequestItem(ots, conf, token, range.getEnd(), direction, columns);
} else {
RequestItem req = request;
GetRangeResult result = RetryHelper.executeWithRetry(new GetRangeCallable(ots, req.getCriteria(), req.getFuture()), conf.getRetry(), conf.getSleepInMilliSecond());
if ((token = result.getNextStartPrimaryKey()) != null) {
request = generateRequestItem(ots, conf, token, range.getEnd(), direction, columns);
}
rowsToSender(result.getRows(), sender, conf.getColumns());
}
} while (token != null);
ots.shutdown();
LOG.info("read end.");
}
Aggregations