/** * Processes handshake request. * * @param req Handshake request. * @return Response message. * @throws GridException In case of handshake failure. */ private GridGgfsMessage processHandshakeRequest(GridGgfsHandshakeRequest req) throws GridException { if (!F.eq(ctx.gridName(), req.gridName())) throw new GridException("Failed to perform handshake because actual Grid name differs from expected " + "[expected=" + req.gridName() + ", actual=" + ctx.gridName() + ']'); if (!F.eq(ggfs.name(), req.ggfsName())) throw new GridException("Failed to perform handshake because actual GGFS name differs from expected " + "[expected=" + req.ggfsName() + ", actual=" + ggfs.name() + ']'); GridGgfsControlResponse res = new GridGgfsControlResponse(); ggfs.clientLogDirectory(req.logDirectory()); GridGgfsHandshakeResponse handshake = new GridGgfsHandshakeResponse(ggfs.name(), ggfs.proxyPaths(), ggfs.groupBlockSize(), ggfs.globalSampling()); res.handshake(handshake); return res; }
/** * Processes status request. * * @return Status response. */ private GridGgfsMessage processStatusRequest() throws GridException { GridGgfsStatus status = ggfs.globalSpace(); GridGgfsControlResponse res = new GridGgfsControlResponse(); res.status(status); return res; }
log.debug("Processing path control request [ggfsName=" + ggfs.name() + ", req=" + req + ']'); res.response(ggfs.exists(req.path())); res.response(ggfs.info(req.path())); res.response(ggfs.summary(req.path())); res.response(ggfs.update(req.path(), req.properties())); ggfs.rename(req.path(), req.destinationPath()); res.response(ggfs.delete(req.path(), req.flag())); ggfs.mkdirs(req.path(), req.properties()); res.paths(ggfs.listPaths(req.path())); res.files(ggfs.listFiles(req.path())); ggfs.setTimes(req.path(), req.accessTime(), req.modificationTime()); res.locations(ggfs.affinity(req.path(), req.start(), req.length())); GridGgfsInputStreamAdapter ggfsIn = !req.flag() ? ggfs.open(req.path(), bufSize) : ggfs.open(req.path(), bufSize, req.sequentialReadsBeforePrefetch()); log.debug("Opened GGFS input stream for file read [ggfsName=" + ggfs.name() + ", path=" + req.path() + ", streamId=" + streamId + ", ses=" + ses + ']');
/** * @param blocks Blocks to write. * @return Future that will be completed after put is done. */ @SuppressWarnings("unchecked") private GridFuture<?> storeBlocksAsync(Map<GridGgfsBlockKey, byte[]> blocks) { assert !blocks.isEmpty(); if (dataCachePrj.ggfsDataSpaceUsed() >= dataCachePrj.ggfsDataSpaceMax()) { try { try { ggfs.awaitDeletesAsync().get(trashPurgeTimeout); } catch (GridFutureTimeoutException ignore) { // Ignore. } // Additional size check. if (dataCachePrj.ggfsDataSpaceUsed() >= dataCachePrj.ggfsDataSpaceMax()) return new GridFinishedFuture<Object>(ggfsCtx.kernalContext(), new GridGgfsOutOfSpaceException("Failed to write data block (GGFS maximum data size " + "exceeded) [used=" + dataCachePrj.ggfsDataSpaceUsed() + ", allowed=" + dataCachePrj.ggfsDataSpaceMax() + ']')); } catch (GridException e) { return new GridFinishedFuture<>(ggfsCtx.kernalContext(), new GridException("Failed to store data " + "block due to unexpected exception.", e)); } } return dataCachePrj.putAllAsync(blocks); }
ggfsCtx.ggfs().evictExclude(curPath, false), status.properties());
/** {@inheritDoc} */ @Override protected Void run(GridBiTuple<String, Boolean> arg) throws GridException { try { ((GridGgfsEx) g.ggfs(arg.get1())).globalSampling(arg.get2()); return null; } catch (IllegalArgumentException iae) { throw new GridException("Failed to set sampling state for GGFS: " + arg.get1(), iae); } }
/** * Resolve GGFS profiler logs directory. * * @param ggfs GGFS instance to resolve logs dir for. * @return {@link Path} to log dir or {@code null} if not found. * @throws GridException if failed to resolve. */ public static Path resolveGgfsProfilerLogsDir(GridGgfs ggfs) throws GridException { String logsDir; if (ggfs instanceof GridGgfsEx) logsDir = ((GridGgfsEx) ggfs).clientLogDirectory(); else if (ggfs == null) throw new GridException("Failed to get profiler log folder (GGFS instance not found)"); else throw new GridException("Failed to get profiler log folder (unexpected GGFS instance type)"); URL logsDirUrl = U.resolveGridGainUrl(logsDir != null ? logsDir : DFLT_GGFS_LOG_DIR); return logsDirUrl != null ? new File(logsDirUrl.getPath()).toPath() : null; } }
log.debug("Processing path control request [ggfsName=" + ggfs.name() + ", req=" + req + ']'); res.response(ggfs.exists(req.path())); res.response(ggfs.info(req.path())); res.response(ggfs.summary(req.path())); res.response(ggfs.update(req.path(), req.properties())); ggfs.rename(req.path(), req.destinationPath()); res.response(ggfs.delete(req.path(), req.flag())); ggfs.mkdirs(req.path(), req.properties()); res.paths(ggfs.listPaths(req.path())); res.files(ggfs.listFiles(req.path())); ggfs.setTimes(req.path(), req.accessTime(), req.modificationTime()); res.locations(ggfs.affinity(req.path(), req.start(), req.length())); GridGgfsInputStreamAdapter ggfsIn = !req.flag() ? ggfs.open(req.path(), bufSize) : ggfs.open(req.path(), bufSize, req.sequentialReadsBeforePrefetch()); log.debug("Opened GGFS input stream for file read [ggfsName=" + ggfs.name() + ", path=" + req.path() + ", streamId=" + streamId + ", ses=" + ses + ']');
/** * @param blocks Blocks to write. * @return Future that will be completed after put is done. */ @SuppressWarnings("unchecked") private GridFuture<?> storeBlocksAsync(Map<GridGgfsBlockKey, byte[]> blocks) { assert !blocks.isEmpty(); if (dataCachePrj.ggfsDataSpaceUsed() >= dataCachePrj.ggfsDataSpaceMax()) { try { try { ggfs.awaitDeletesAsync().get(trashPurgeTimeout); } catch (GridFutureTimeoutException ignore) { // Ignore. } // Additional size check. if (dataCachePrj.ggfsDataSpaceUsed() >= dataCachePrj.ggfsDataSpaceMax()) return new GridFinishedFuture<Object>(ggfsCtx.kernalContext(), new GridGgfsOutOfSpaceException("Failed to write data block (GGFS maximum data size " + "exceeded) [used=" + dataCachePrj.ggfsDataSpaceUsed() + ", allowed=" + dataCachePrj.ggfsDataSpaceMax() + ']')); } catch (GridException e) { return new GridFinishedFuture<>(ggfsCtx.kernalContext(), new GridException("Failed to store data " + "block due to unexpected exception.", e)); } } return dataCachePrj.putAllAsync(blocks); }
ggfsCtx.ggfs().evictExclude(curPath, false), status.properties());
/** {@inheritDoc} */ @Override protected Void run(GridBiTuple<String, Boolean> arg) throws GridException { try { ((GridGgfsEx) g.ggfs(arg.get1())).globalSampling(arg.get2()); return null; } catch (IllegalArgumentException iae) { throw new GridException("Failed to set sampling state for GGFS: " + arg.get1(), iae); } }
/** * Resolve GGFS profiler logs directory. * * @param ggfs GGFS instance to resolve logs dir for. * @return {@link Path} to log dir or {@code null} if not found. * @throws GridException if failed to resolve. */ public static Path resolveGgfsProfilerLogsDir(GridGgfs ggfs) throws GridException { String logsDir; if (ggfs instanceof GridGgfsEx) logsDir = ((GridGgfsEx) ggfs).clientLogDirectory(); else if (ggfs == null) throw new GridException("Failed to get profiler log folder (GGFS instance not found)"); else throw new GridException("Failed to get profiler log folder (unexpected GGFS instance type)"); URL logsDirUrl = U.resolveGridGainUrl(logsDir != null ? logsDir : DFLT_GGFS_LOG_DIR); return logsDirUrl != null ? new File(logsDirUrl.getPath()).toPath() : null; } }
/** * Processes handshake request. * * @param req Handshake request. * @return Response message. * @throws GridException In case of handshake failure. */ private GridGgfsMessage processHandshakeRequest(GridGgfsHandshakeRequest req) throws GridException { if (!F.eq(ctx.gridName(), req.gridName())) throw new GridException("Failed to perform handshake because actual Grid name differs from expected " + "[expected=" + req.gridName() + ", actual=" + ctx.gridName() + ']'); if (!F.eq(ggfs.name(), req.ggfsName())) throw new GridException("Failed to perform handshake because actual GGFS name differs from expected " + "[expected=" + req.ggfsName() + ", actual=" + ggfs.name() + ']'); GridGgfsControlResponse res = new GridGgfsControlResponse(); ggfs.clientLogDirectory(req.logDirectory()); GridGgfsHandshakeResponse handshake = new GridGgfsHandshakeResponse(ggfs.name(), ggfs.proxyPaths(), ggfs.groupBlockSize(), ggfs.globalSampling()); res.handshake(handshake); return res; }
if (dataCachePrj.ggfsDataSpaceUsed() >= dataCachePrj.ggfsDataSpaceMax()) { try { ggfs.awaitDeletesAsync().get(trashPurgeTimeout);
GridUuid.randomUuid(), ggfsCtx.ggfs().evictExclude(path, false), status.properties());
/** * Processes status request. * * @return Status response. */ private GridGgfsMessage processStatusRequest() throws GridException { GridGgfsStatus status = ggfs.globalSpace(); GridGgfsControlResponse res = new GridGgfsControlResponse(); res.status(status); return res; }
if (dataCachePrj.ggfsDataSpaceUsed() >= dataCachePrj.ggfsDataSpaceMax()) { try { ggfs.awaitDeletesAsync().get(trashPurgeTimeout);
GridUuid.randomUuid(), ggfsCtx.ggfs().evictExclude(path, false), status.properties());