use of com.qlangtech.tis.fs.TISFSDataOutputStream in project plugins by qlangtech.
the class TestDataXHdfsWriter method testdataDump.
// @Test
public void testdataDump() throws Exception {
// final DataxWriter dataxWriter = DataxWriter.load(null, mysql2hdfsDataXName);
HdfsFileSystemFactory fsFactory = HdfsFileSystemFactoryTestUtils.getFileSystemFactory();
ITISFileSystem fileSystem = fsFactory.getFileSystem();
// assertNotNull("fileSystem can not be null", fileSystem);
// new Path(fsFactory.rootDir
// , this.cfg.getNecessaryValue(Key.PATH, HdfsWriterErrorCode.REQUIRED_VALUE));
//
// fileSystem.getPath("");
HdfsPath p = new HdfsPath(fsFactory.rootDir + "/tis/order");
HdfsPath subWriterPath = new HdfsPath(p, "test");
try (TISFSDataOutputStream outputStream = fileSystem.create(subWriterPath, true)) {
org.apache.commons.io.IOUtils.write(IOUtils.loadResourceFromClasspath(DataXHdfsWriter.class, "hdfs-datax-writer-assert-without-option-val.json"), outputStream, TisUTF8.get());
}
System.out.println("write file success");
List<IPathInfo> iPathInfos = fileSystem.listChildren(p);
for (IPathInfo child : iPathInfos) {
fileSystem.delete(child.getPath(), true);
}
final DataXHdfsWriter hdfsWriter = new DataXHdfsWriter() {
@Override
public FileSystemFactory getFs() {
return fsFactory;
}
@Override
public Class<?> getOwnerClass() {
return DataXHdfsWriter.class;
}
};
DataxWriter.dataxWriterGetter = (name) -> {
assertEquals("mysql2hdfs", name);
return hdfsWriter;
};
// IPath path = fileSystem.getPath(fileSystem.getPath(fileSystem.getRootDir()), hdfsRelativePath);
// System.out.println("clear path:" + path);
// fileSystem.delete(path, true);
//
WriterTemplate.realExecuteDump("hdfs-datax-writer-assert-without-option-val.json", hdfsWriter);
}
Aggregations