本文整理汇总了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();
}
示例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());
}