@GET @Path("/{taskId}/read") public MesosFileChunkObject read( @PathParam("taskId") String taskId, @QueryParam("path") String qPath, @QueryParam("offset") Optional<Long> offset, @QueryParam("length") Optional<Long> length) { final String path = getDefaultPath(taskId, qPath); final SingularityTaskHistory history = checkHistory(taskId); final String slaveHostname = history.getTask().getOffer().getHostname(); final String fullPath = new File(history.getDirectory().get(), path).toString(); try { final Optional<MesosFileChunkObject> maybeChunk = sandboxManager.read(slaveHostname, fullPath, offset, length); if (!maybeChunk.isPresent()) { throw WebExceptions.notFound("File %s does not exist for task ID %s", fullPath, taskId); } return maybeChunk.get(); } catch (SlaveNotFoundException snfe) { throw WebExceptions.notFound( "Slave @ %s was not found, it is probably offline", slaveHostname); } }
@GET @Path("/{taskId}/browse") public Collection<MesosFileObject> browse( @PathParam("taskId") String taskId, @QueryParam("path") String qPath) { final String path = getDefaultPath(taskId, qPath); final SingularityTaskHistory history = checkHistory(taskId); final String slaveHostname = history.getTask().getOffer().getHostname(); final String fullPath = new File(history.getDirectory().get(), path).toString(); try { return sandboxManager.browse(slaveHostname, fullPath); } catch (SlaveNotFoundException snfe) { throw WebExceptions.notFound( "Slave @ %s was not found, it is probably offline", slaveHostname); } }