/** * Heuristically checks if exception was caused by invalid HDFS version and returns appropriate exception. * * @param e Exception to check. * @param msg Detailed error message. * @return Appropriate exception. */ private IgfsException handleSecondaryFsError(IOException e, String msg) { if (e instanceof FileNotFoundException) return new IgfsPathNotFoundException(e); else return new IgfsException(msg, e); }
/** * Read non-null path from the input. * * @param in Input. * @return IGFS path. * @throws IOException If failed. */ public static IgfsPath readPath(ObjectInput in) throws IOException { IgfsPath res = new IgfsPath(); res.readExternal(in); return res; }
/** {@inheritDoc} */ @Override public boolean equals(Object o) { if (o == this) return true; if (o == null || !(o instanceof LocalFileSystemBlockKey)) return false; LocalFileSystemBlockKey that = (LocalFileSystemBlockKey)o; return blockId == that.blockId && path.equals(that.path); }
/** {@inheritDoc} */ @Override protected FileSystemConfiguration getIgfsConfiguration() throws IgniteCheckedException { FileSystemConfiguration igfsCfg = super.getIgfsConfiguration(); igfsCfg.setDefaultMode(IgfsMode.PRIMARY); IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration(); endpointCfg.setType(IgfsIpcEndpointType.TCP); endpointCfg.setPort(IpcSharedMemoryServerEndpoint.DFLT_IPC_PORT + 1); igfsCfg.setIpcEndpointConfiguration(endpointCfg); return igfsCfg; } }
/** * Get path of the last existing element. * * @return Path of the last existing element. */ public IgfsPath lastExistingPath() { IgfsPath path = IgfsPath.ROOT; for (int i = 1; i <= lastExistingIdx; i++) path = new IgfsPath(path, parts[i]); return path; }
/** * Validate parent resolution is correct. * * @param child Child path. * @param parent Expected parent path. */ private void validateParent(String child, @Nullable String parent) { assertEquals(parent == null ? null : new IgfsPath(parent), new IgfsPath(child).parent()); }
/** {@inheritDoc} */ @SuppressWarnings("ConstantConditions") @Override public Map<String, String> properties(String path) { return igfsEx.info(new IgfsPath(path)).properties(); }
/** * Copying constructor. * * @param cfg Configuration to copy. */ public IgfsIpcEndpointConfiguration(IgfsIpcEndpointConfiguration cfg) { type = cfg.getType(); host = cfg.getHost(); port = cfg.getPort(); memSize = cfg.getMemorySize(); tokenDirPath = cfg.getTokenDirectoryPath(); }
/** {@inheritDoc} */ @Override public long length() { return is.length(); }
/** {@inheritDoc} */ @Override public int read() throws IOException { if (pos < maxLen) { int res = is.read(); if (res != -1) pos++; return res; } else return -1; }
/** {@inheritDoc} */ @Override public IgfsHandshakeResponse handshake(final String logDir) { return IgfsUserContext.doAs(user, new IgniteOutClosure<IgfsHandshakeResponse>() { @Override public IgfsHandshakeResponse apply() { igfs.clientLogDirectory(logDir); return new IgfsHandshakeResponse(igfs.name(), igfs.groupBlockSize(), igfs.globalSampling()); } }); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { return getConfiguration(igniteInstanceName, getIgfsConfiguration()); }
@Override public Long call() throws Exception { return summary0(path).totalLength(); } });
/** {@inheritDoc} */ @Override public int hashCode() { return path.hashCode() + (int)(blockId ^ (blockId >>> 32)); }
/** {@inheritDoc} */ @Override protected FileSystemConfiguration getIgfsConfiguration() throws IgniteCheckedException { FileSystemConfiguration igfsCfg = super.getIgfsConfiguration(); igfsCfg.setDefaultMode(IgfsMode.PRIMARY); IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration(); endpointCfg.setType(IgfsIpcEndpointType.SHMEM); endpointCfg.setPort(IpcSharedMemoryServerEndpoint.DFLT_IPC_PORT + 1); igfsCfg.setIpcEndpointConfiguration(endpointCfg); return igfsCfg; } }
/** * Composes the path of the file. */ private IgfsPath filePath(int j) { return new IgfsPath(SUBDIR, "file" + j); }
/** * @return IGFS configuration for secondary file system. */ protected FileSystemConfiguration getSecondaryIgfsConfiguration() throws IgniteCheckedException { FileSystemConfiguration igfsCfg = super.getIgfsConfiguration(); igfsCfg.setName("igfs-secondary"); igfsCfg.setDefaultMode(PRIMARY); IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration(); endpointCfg.setType(IgfsIpcEndpointType.TCP); endpointCfg.setPort(11500); igfsCfg.setIpcEndpointConfiguration(endpointCfg); return igfsCfg; }
/** * Utility method to make IgfsPath. * * @param p The String path. * @return The IgfsPath object. */ private static IgfsPath path(String p) { return new IgfsPath(p); }
/** * @param path Path. * @return IGFS path. */ private IgfsPath path(String path) { assert path != null; return new IgfsPath(path); }