当前位置: 首页>>代码示例>>Java>>正文


Java DirectoryRetriever类代码示例

本文整理汇总了Java中org.apache.tajo.worker.dataserver.retriever.DirectoryRetriever的典型用法代码示例。如果您正苦于以下问题:Java DirectoryRetriever类的具体用法?Java DirectoryRetriever怎么用?Java DirectoryRetriever使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DirectoryRetriever类属于org.apache.tajo.worker.dataserver.retriever包,在下文中一共展示了DirectoryRetriever类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testHttpDataServer

import org.apache.tajo.worker.dataserver.retriever.DirectoryRetriever; //导入依赖的package包/类
@Test
public final void testHttpDataServer() throws Exception {
  Random rnd = new Random();
  FileWriter writer = new FileWriter(TEST_DATA+"/"+"testHttp");
  String watermark = "test_"+rnd.nextInt();
  writer.write(watermark+"\n");
  writer.flush();
  writer.close();

  DataRetriever ret = new DirectoryRetriever(TEST_DATA);
  HttpDataServer server = new HttpDataServer(
      NetUtils.createSocketAddr("127.0.0.1:0"), ret);
  server.start();

  InetSocketAddress addr = server.getBindAddress();
  URL url = new URL("http://127.0.0.1:"+addr.getPort() 
      + "/testHttp");
  BufferedReader in = new BufferedReader(new InputStreamReader(
      url.openStream()));
  String line;
  boolean found = false;
  while ((line = in.readLine()) != null) {
    if (line.equals(watermark))
      found = true;
  }    
  assertTrue(found);
  in.close();    
  server.stop();
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:30,代码来源:TestHttpDataServer.java

示例2: testGet

import org.apache.tajo.worker.dataserver.retriever.DirectoryRetriever; //导入依赖的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());
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:30,代码来源:TestFetcher.java


注:本文中的org.apache.tajo.worker.dataserver.retriever.DirectoryRetriever类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。