public static CopyableFile createTestCopyableFile(String resourcePath) throws IOException { FileSystem fs = FileSystem.getLocal(new Configuration()); fs.create(new Path(resourcePath)); FileStatus status = new FileStatus(0l, false, 0, 0l, 0l, new Path(resourcePath)); return new CopyableFile(status, new Path(getRandomPath()), null, null, null, PreserveAttributes.fromMnemonicString(""), "", 0 ,0, Maps.<String, String>newHashMap(), ""); }
public static CopyableFile getTestCopyableFile(String resourcePath, String destinationPath, String relativePath, OwnerAndPermission ownerAndPermission) { FileStatus status = null; if (resourcePath == null) { resourcePath = getRandomPath(); status = new FileStatus(0l, false, 0, 0l, 0l, new Path(resourcePath)); } else { String filePath = CopyableFileUtils.class.getClassLoader().getResource(resourcePath).getFile(); status = new FileStatus(0l, false, 0, 0l, 0l, new Path(filePath)); } if (relativePath == null) { relativePath = getRandomPath(); } Path destinationRelativePath = new Path(relativePath); return new CopyableFile(status, new Path(destinationPath), ownerAndPermission, null, null, PreserveAttributes.fromMnemonicString(""), "", 0, 0, Maps.<String, String>newHashMap(), ""); }
public CopyEntity createCopyableFile(int fileNumber) throws IOException { Path originPath = new Path(ORIGIN_PATH, fileNumber + ".file"); FileStatus origin = new FileStatus(0, false, 0, 0, 0, originPath); Path targetPath = new Path(TARGET_PATH, fileNumber + ".file"); return new CopyableFile(origin, targetPath, new OwnerAndPermission(null, null, null), Lists.<OwnerAndPermission>newArrayList(), null, PreserveAttributes.fromMnemonicString(""), "", 0, 0, Maps .<String, String>newHashMap(), ""); }
private static CopyableFile createCopyableFile(String path, String fileSet) { return new CopyableFile(new FileStatus(0, false, 0, 0, 0, new Path(path)), new Path(path), new OwnerAndPermission("owner", "group", FsPermission.getDefault()), null, null, PreserveAttributes.fromMnemonicString(""), fileSet, 0, 0, Maps.<String, String>newHashMap(), ""); }
return new CopyableFile(this.origin, this.destination, this.destinationOwnerAndPermission, this.ancestorsOwnerAndPermission, this.checksum, this.preserve, this.fileSet, this.originTimestamp, this.upstreamTimestamp, this.additionalMetadata, this.datasetOutputPath);
@Test public void testSerializeDeserialzeNulls() throws Exception { CopyableFile copyableFile = new CopyableFile(null, null, new OwnerAndPermission("owner", "group", FsPermission.getDefault()), Lists.newArrayList(new OwnerAndPermission(null, "group2", FsPermission .getDefault())), "checksum".getBytes(), PreserveAttributes.fromMnemonicString(""), "", 0, 0, Maps.<String, String>newHashMap(), ""); String serialized = CopyEntity.serialize(copyableFile); CopyEntity deserialized = CopyEntity.deserialize(serialized); Assert.assertEquals(deserialized, copyableFile); }
@Test public void testSerializeDeserialze() throws Exception { CopyableFile copyableFile = new CopyableFile(new FileStatus(10, false, 12, 100, 12345, new Path("/path")), new Path("/destination"), new OwnerAndPermission("owner", "group", FsPermission.getDefault()), Lists.newArrayList(new OwnerAndPermission("owner2", "group2", FsPermission.getDefault())), "checksum".getBytes(), PreserveAttributes.fromMnemonicString(""), "", 0, 0, Maps .<String, String>newHashMap(), ""); DatasetDescriptor dataset = new DatasetDescriptor("hive", "db.table"); PartitionDescriptor descriptor = new PartitionDescriptor("datepartition=2018/09/05", dataset); copyableFile.setDestinationData(descriptor); String s = CopyEntity.serialize(copyableFile); CopyEntity de = CopyEntity.deserialize(s); Assert.assertEquals(de, copyableFile); }
CopyableFile copyableFile = new CopyableFile(origin, new Path(destinationPath), null, null, null, PreserveAttributes.fromMnemonicString(""), "", 0, 0, Maps.<String, String>newHashMap(), ""); copyableFile.setFsDatasets(originFs, targetFs); destinationPath = targetFsUri + destinationPath; origin = new FileStatus(0l, true, 0, 0l, 0l, new Path(originPath)); copyableFile = new CopyableFile(origin, new Path(destinationPath), null, null, null, PreserveAttributes.fromMnemonicString(""), "", 0, 0, Maps.<String, String>newHashMap(), ""); copyableFile.setFsDatasets(originFs, targetFs);
return new CopyableFile(this.origin, this.destination, this.destinationOwnerAndPermission, this.ancestorsOwnerAndPermission, this.checksum, this.preserve, this.fileSet, this.originTimestamp, this.upstreamTimestamp, this.additionalMetadata, this.datasetOutputPath);