use of com.alibaba.otter.shared.common.model.config.pipeline.PipelineParameter.PipeChooseMode in project otter by alibaba.
the class RowDataPipeDelegate method put.
/**
* 将对应的数据传递到指定的Node id节点上
*/
public List<PipeKey> put(final DbBatch data, Long nid) throws PipeException {
List<PipeKey> keys = new ArrayList<PipeKey>();
if (isLocal(nid)) {
keys.add(rowDataMemoryPipe.put(data));
} else {
Future<PipeKey> future = null;
Pipeline pipeline = configClientService.findPipeline(data.getRowBatch().getIdentity().getPipelineId());
if (data.getFileBatch() != null && !CollectionUtils.isEmpty(data.getFileBatch().getFiles())) {
future = executorService.submit(new Callable<PipeKey>() {
public PipeKey call() throws Exception {
try {
MDC.put(OtterConstants.splitPipelineLogFileKey, String.valueOf(data.getFileBatch().getIdentity().getPipelineId()));
return attachmentHttpPipe.put(data.getFileBatch());
} finally {
MDC.remove(OtterConstants.splitPipelineLogFileKey);
}
}
});
}
try {
PipeChooseMode pipeChooseMode = pipeline.getParameters().getPipeChooseType();
if (pipeChooseMode.isAutomatic()) {
if (calculateSize(data) <= sizeThresold) {
keys.add(rowDataRpcPipe.put(data));
} else {
keys.add(rowDataHttpPipe.put(data));
}
} else if (pipeChooseMode.isRpc()) {
keys.add(rowDataRpcPipe.put(data));
} else if (pipeChooseMode.isHttp()) {
keys.add(rowDataHttpPipe.put(data));
} else {
throw new PipeException("pipeChooseMode is error!" + pipeChooseMode);
}
// 等待一下附件处理
if (future != null) {
keys.add(future.get());
}
} catch (Exception e) {
throw new PipeException(e);
}
}
return keys;
}
Aggregations