use of org.apache.ignite.igfs.IgfsFile in project ignite by apache.
the class IgfsDualAbstractSelfTest method testListFilesPathMissing.
/**
* Test list files routine when the path doesn't exist locally.
*
* @throws Exception If failed.
*/
public void testListFilesPathMissing() throws Exception {
create(igfsSecondary, paths(DIR, SUBDIR, SUBSUBDIR), paths(FILE));
Collection<IgfsFile> paths = igfs.listFiles(SUBDIR);
assert paths != null;
assert paths.size() == 2;
Iterator<IgfsFile> iter = paths.iterator();
IgfsFile path1 = iter.next();
IgfsFile path2 = iter.next();
assert (SUBSUBDIR.equals(path1.path()) && FILE.equals(path2.path())) || (FILE.equals(path1.path()) && SUBSUBDIR.equals(path2.path()));
}
use of org.apache.ignite.igfs.IgfsFile in project ignite by apache.
the class IgfsDualAbstractSelfTest method testSetTimesMissingPartially.
/**
* Test setTimes method when path is partially missing.
*
* @throws Exception If failed.
*/
public void testSetTimesMissingPartially() throws Exception {
if (!timesSupported())
return;
create(igfs, paths(DIR, SUBDIR), null);
createFile(igfsSecondary, FILE, chunk);
final long MAX_ALIGN_ON_SECOND = (long) Integer.MAX_VALUE * 1000;
igfs.setTimes(FILE, MAX_ALIGN_ON_SECOND, MAX_ALIGN_ON_SECOND - 1000);
IgfsFile info = igfs.info(FILE);
assert info != null;
assertEquals(MAX_ALIGN_ON_SECOND - 1000, info.accessTime());
assertEquals(MAX_ALIGN_ON_SECOND, info.modificationTime());
T2<Long, Long> secondaryTimes = igfsSecondary.times(FILE.toString());
assertEquals(info.modificationTime(), (long) secondaryTimes.get1());
assertEquals(info.accessTime(), (long) secondaryTimes.get2());
try {
igfs.setTimes(FILE2, MAX_ALIGN_ON_SECOND, MAX_ALIGN_ON_SECOND);
fail("Exception is not thrown for missing file.");
} catch (Exception ignore) {
// No-op.
}
}
use of org.apache.ignite.igfs.IgfsFile in project ignite by apache.
the class IgfsAbstractSelfTest method checkRootPropertyUpdate.
/**
* Check root property update.
*
* @throws Exception If failed.
*/
private void checkRootPropertyUpdate(String prop, String setVal, String expGetVal) throws Exception {
igfs.update(IgfsPath.ROOT, Collections.singletonMap(prop, setVal));
igfs.clear();
IgfsFile file = igfs.info(IgfsPath.ROOT);
assert file != null;
Map<String, String> props = file.properties();
assertEquals(expGetVal, props.get(prop));
}
use of org.apache.ignite.igfs.IgfsFile in project ignite by apache.
the class HadoopIgfsSecondaryFileSystemDelegateImpl method listFiles.
/**
* {@inheritDoc}
*/
@Override
public Collection<IgfsFile> listFiles(IgfsPath path) {
try {
FileStatus[] statuses = fileSystemForUser().listStatus(convert(path));
if (statuses == null)
throw new IgfsPathNotFoundException("Failed to list files (path not found): " + path);
Collection<IgfsFile> res = new ArrayList<>(statuses.length);
for (FileStatus s : statuses) {
IgfsEntryInfo fsInfo = s.isDirectory() ? IgfsUtils.createDirectory(IgniteUuid.randomUuid(), null, properties(s), s.getAccessTime(), s.getModificationTime()) : IgfsUtils.createFile(IgniteUuid.randomUuid(), (int) s.getBlockSize(), s.getLen(), null, null, false, properties(s), s.getAccessTime(), s.getModificationTime());
res.add(new IgfsFileImpl(new IgfsPath(path, s.getPath().getName()), fsInfo, 1));
}
return res;
} catch (FileNotFoundException ignored) {
throw new IgfsPathNotFoundException("Failed to list files (path not found): " + path);
} catch (IOException e) {
throw handleSecondaryFsError(e, "Failed to list statuses due to secondary file system exception: " + path);
}
}
use of org.apache.ignite.igfs.IgfsFile in project ignite by apache.
the class IgniteHadoopFileSystemAbstractSelfTest method testZeroReplicationFactor.
/**
* @throws Exception If failed.
*/
public void testZeroReplicationFactor() throws Exception {
// This test doesn't make sense for any mode except of PRIMARY.
if (mode == PRIMARY) {
Path igfsHome = new Path(PRIMARY_URI);
Path file = new Path(igfsHome, "someFile");
try (FSDataOutputStream out = fs.create(file, (short) 0)) {
out.write(new byte[1024 * 1024]);
}
IgniteFileSystem igfs = grid(0).fileSystem("igfs");
IgfsPath filePath = new IgfsPath("/someFile");
IgfsFile fileInfo = igfs.info(filePath);
awaitPartitionMapExchange();
Collection<IgfsBlockLocation> locations = igfs.affinity(filePath, 0, fileInfo.length());
assertEquals(1, locations.size());
IgfsBlockLocation location = F.first(locations);
assertEquals(1, location.nodeIds().size());
}
}
Aggregations