本文整理汇总了Java中org.apache.tajo.rpc.RpcChannelFactory.createClientChannelFactory方法的典型用法代码示例。如果您正苦于以下问题:Java RpcChannelFactory.createClientChannelFactory方法的具体用法?Java RpcChannelFactory.createClientChannelFactory怎么用?Java RpcChannelFactory.createClientChannelFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tajo.rpc.RpcChannelFactory
的用法示例。
在下文中一共展示了RpcChannelFactory.createClientChannelFactory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFetchRunners
import org.apache.tajo.rpc.RpcChannelFactory; //导入方法依赖的package包/类
private List<Fetcher> getFetchRunners(TaskAttemptContext ctx,
List<Fetch> fetches) throws IOException {
if (fetches.size() > 0) {
releaseChannelFactory();
int workerNum = ctx.getConf().getIntVar(TajoConf.ConfVars.SHUFFLE_FETCHER_PARALLEL_EXECUTION_MAX_NUM);
channelFactory = RpcChannelFactory.createClientChannelFactory("Fetcher", workerNum);
Path inputDir = lDirAllocator.
getLocalPathToRead(
getTaskAttemptDir(ctx.getTaskId()).toString(), systemConf);
File storeDir;
int i = 0;
File storeFile;
List<Fetcher> runnerList = Lists.newArrayList();
for (Fetch f : fetches) {
storeDir = new File(inputDir.toString(), f.getName());
if (!storeDir.exists()) {
storeDir.mkdirs();
}
storeFile = new File(storeDir, "in_" + i);
Fetcher fetcher = new Fetcher(URI.create(f.getUrls()), storeFile, channelFactory);
runnerList.add(fetcher);
i++;
}
ctx.addFetchPhase(runnerList.size(), new File(inputDir.toString()));
return runnerList;
} else {
return Lists.newArrayList();
}
}
示例2: testGet
import org.apache.tajo.rpc.RpcChannelFactory; //导入方法依赖的package包/类
@Test
public void testGet() throws IOException {
Random rnd = new Random();
FileWriter writer = new FileWriter(INPUT_DIR + "data");
String data;
for (int i = 0; i < 100; i++) {
data = ""+rnd.nextInt();
writer.write(data);
}
writer.flush();
writer.close();
DataRetriever ret = new DirectoryRetriever(INPUT_DIR);
HttpDataServer server = new HttpDataServer(
NetUtils.createSocketAddr("127.0.0.1:0"), ret);
server.start();
InetSocketAddress addr = server.getBindAddress();
URI uri = URI.create("http://127.0.0.1:"+addr.getPort() + "/data");
ClientSocketChannelFactory channelFactory = RpcChannelFactory.createClientChannelFactory("Fetcher", 1);
Fetcher fetcher = new Fetcher(uri, new File(OUTPUT_DIR + "data"), channelFactory);
fetcher.get();
server.stop();
FileSystem fs = FileSystem.getLocal(new TajoConf());
FileStatus inStatus = fs.getFileStatus(new Path(INPUT_DIR, "data"));
FileStatus outStatus = fs.getFileStatus(new Path(OUTPUT_DIR, "data"));
assertEquals(inStatus.getLen(), outStatus.getLen());
}