/** * Returns a root for this path. * * @return Root for this path. */ public GridGgfsPath root() { return new GridGgfsPath(); }
/** {@inheritDoc} */ @Override public int read() throws IOException { if (pos < maxLen) { int res = is.read(); if (res != -1) pos++; return res; } else return -1; }
/** * @param errCode Error code. * @param err Error. * @throws GridException Based on error code. */ public static void throwError(Integer errCode, String err) throws GridException { assert err != null; assert errCode != -1; if (errCode == ERR_FILE_NOT_FOUND) throw new GridGgfsFileNotFoundException(err); else if (errCode == ERR_PATH_ALREADY_EXISTS) throw new GridGgfsPathAlreadyExistsException(err); else if (errCode == ERR_DIRECTORY_NOT_EMPTY) throw new GridGgfsDirectoryNotEmptyException(err); else if (errCode == ERR_PARENT_NOT_DIRECTORY) throw new GridGgfsParentNotDirectoryException(err); else if (errCode == ERR_INVALID_HDFS_VERSION) throw new GridGgfsInvalidHdfsVersionException(err); else if (errCode == ERR_CORRUPTED_FILE) throw new GridGgfsCorruptedFileException(err); else if (errCode == ERR_GGFS_GENERIC) throw new GridGgfsException(err); throw new GridException(err); }
/** * @param ggfs Source GGFS. * @return Data transfer object for given GGFS. * @throws GridException */ public static VisorGgfs from(GridGgfs ggfs) throws GridException { assert ggfs != null; return new VisorGgfs( ggfs.name(), ggfs.configuration().getDefaultMode(), VisorGgfsMetrics.from(ggfs.metrics()), ggfs.configuration().getSecondaryFileSystem() != null ); }
@Override public GridGgfsSecondaryInputStreamDescriptor onSuccess( Map<GridGgfsPath, GridGgfsFileInfo> infos) throws Exception { GridGgfsFileInfo info = infos.get(path); if (info == null) throw new GridGgfsFileNotFoundException("File not found: " + path); if (!info.isFile()) throw new GridGgfsInvalidPathException("Failed to open file (not a file): " + path); return new GridGgfsSecondaryInputStreamDescriptor(infos.get(path), fs.open(path, bufSize)); }
/** {@inheritDoc} */ @Override public boolean isProxy(URI path) { GridGgfsMode mode = F.isEmpty(cfg.getPathModes()) ? cfg.getDefaultMode() : modeRslvr.resolveMode(new GridGgfsPath(path)); return mode == PROXY; } }
@Override public GridGgfsFileInfo onSuccess(Map<GridGgfsPath, GridGgfsFileInfo> infos) throws Exception { if (infos.get(path) == null) return null; fs.update(path, props); assert path.parent() == null || infos.get(path.parent()) != null; return updatePropertiesNonTx(infos.get(path.parent()).id(), infos.get(path).id(), path.name(), props); }
/** {@inheritDoc} */ @Override public int hashCode() { return path.hashCode(); }
/** {@inheritDoc} */ @Override public boolean equals(Object o) { if (o == this) return true; if (o == null || getClass() != o.getClass()) return false; GridGgfsFileImpl that = (GridGgfsFileImpl)o; return path.equals(that.path); }
@Override public GridGgfsSecondaryOutputStreamDescriptor onFailure(Exception err) throws GridException { U.closeQuiet(out); U.error(log, "File create in DUAL mode failed [path=" + path + ", simpleCreate=" + simpleCreate + ", props=" + props + ", overwrite=" + overwrite + ", bufferSize=" + bufSize + ", replication=" + replication + ", blockSize=" + blockSize + ']', err); if (err instanceof GridGgfsException) throw (GridGgfsException)err; else throw new GridGgfsException("Failed to create the file due to secondary file system " + "exception: " + path, err); } };
/** {@inheritDoc} */ @Override public void close() throws IOException { is.close(); }
/** {@inheritDoc} */ @Override public long length() { return is.length(); }
@Override public GridGgfsSecondaryInputStreamDescriptor onSuccess( Map<GridGgfsPath, GridGgfsFileInfo> infos) throws Exception { GridGgfsFileInfo info = infos.get(path); if (info == null) throw new GridGgfsFileNotFoundException("File not found: " + path); if (!info.isFile()) throw new GridGgfsInvalidPathException("Failed to open file (not a file): " + path); return new GridGgfsSecondaryInputStreamDescriptor(infos.get(path), fs.open(path, bufSize)); }
/** {@inheritDoc} */ @Override public boolean isProxy(URI path) { GridGgfsMode mode = F.isEmpty(cfg.getPathModes()) ? cfg.getDefaultMode() : modeRslvr.resolveMode(new GridGgfsPath(path)); return mode == PROXY; } }
@Override public GridGgfsFileInfo onSuccess(Map<GridGgfsPath, GridGgfsFileInfo> infos) throws Exception { if (infos.get(path) == null) return null; fs.update(path, props); assert path.parent() == null || infos.get(path.parent()) != null; return updatePropertiesNonTx(infos.get(path.parent()).id(), infos.get(path).id(), path.name(), props); }
@Override public GridGgfsPath apply(String e) { return new GridGgfsPath(path, e); } });
/** {@inheritDoc} */ @Override public int hashCode() { return path.hashCode(); }
@Override public GridGgfsPath apply(String e) { return new GridGgfsPath(path, e); } });