/** * Uploads the data from the given input stream to the BLOB server in a content-addressable manner. * * @param inputStream * the input stream to read the data from * @return the computed BLOB key identifying the BLOB on the server * @throws IOException * thrown if an I/O error occurs while reading the data from the input stream or uploading the data to the * BLOB server */ public BlobKey put(InputStream inputStream) throws IOException { return putInputStream(null, null, inputStream); }
/** * Uploads data from the given input stream to the BLOB server and stores it under the given job ID and key. * * @param jobId * the job ID to identify the uploaded data * @param key * the key to identify the uploaded data * @param inputStream * the input stream to read the data from * @throws IOException * thrown if an I/O error occurs while reading the data from the input stream or uploading the data to the * BLOB server */ public void put(JobID jobId, String key, InputStream inputStream) throws IOException { if (key.length() > MAX_KEY_LENGTH) { throw new IllegalArgumentException("Keys must not be longer than " + MAX_KEY_LENGTH); } putInputStream(jobId, key, inputStream); }
@Override public TransientBlobKey putTransient(InputStream inputStream) throws IOException { try (BlobClient bc = createClient()) { return (TransientBlobKey) bc.putInputStream(null, inputStream, TRANSIENT_BLOB); } }
@Override public TransientBlobKey putTransient(InputStream inputStream) throws IOException { try (BlobClient bc = createClient()) { return (TransientBlobKey) bc.putInputStream(null, inputStream, TRANSIENT_BLOB); } }
@Override public TransientBlobKey putTransient(InputStream inputStream) throws IOException { try (BlobClient bc = createClient()) { return (TransientBlobKey) bc.putInputStream(null, inputStream, TRANSIENT_BLOB); } }
@Override public TransientBlobKey putTransient(JobID jobId, InputStream inputStream) throws IOException { checkNotNull(jobId); try (BlobClient bc = createClient()) { return (TransientBlobKey) bc.putInputStream(jobId, inputStream, TRANSIENT_BLOB); } }
@Override public TransientBlobKey putTransient(JobID jobId, InputStream inputStream) throws IOException { checkNotNull(jobId); try (BlobClient bc = createClient()) { return (TransientBlobKey) bc.putInputStream(jobId, inputStream, TRANSIENT_BLOB); } }
@Override public TransientBlobKey putTransient(JobID jobId, InputStream inputStream) throws IOException { checkNotNull(jobId); try (BlobClient bc = createClient()) { return (TransientBlobKey) bc.putInputStream(jobId, inputStream, TRANSIENT_BLOB); } }
/** * Uploads a single file to the {@link PermanentBlobService} of the given {@link BlobServer}. * * @param jobId * ID of the job this blob belongs to (or <tt>null</tt> if job-unrelated) * @param file * file to upload * * @throws IOException * if the upload fails */ public PermanentBlobKey uploadFile(JobID jobId, Path file) throws IOException { final FileSystem fs = file.getFileSystem(); try (InputStream is = fs.open(file)) { return (PermanentBlobKey) putInputStream(jobId, is, PERMANENT_BLOB); } } }
/** * Uploads a single file to the {@link PermanentBlobService} of the given {@link BlobServer}. * * @param jobId * ID of the job this blob belongs to (or <tt>null</tt> if job-unrelated) * @param file * file to upload * * @throws IOException * if the upload fails */ public PermanentBlobKey uploadFile(JobID jobId, Path file) throws IOException { final FileSystem fs = file.getFileSystem(); try (InputStream is = fs.open(file)) { return (PermanentBlobKey) putInputStream(jobId, is, PERMANENT_BLOB); } } }
/** * Uploads a single file to the {@link PermanentBlobService} of the given {@link BlobServer}. * * @param jobId * ID of the job this blob belongs to (or <tt>null</tt> if job-unrelated) * @param file * file to upload * * @throws IOException * if the upload fails */ public PermanentBlobKey uploadFile(JobID jobId, Path file) throws IOException { final FileSystem fs = file.getFileSystem(); if (fs.getFileStatus(file).isDir()) { return uploadDirectory(jobId, file, fs); } else { try (InputStream is = fs.open(file)) { return (PermanentBlobKey) putInputStream(jobId, is, PERMANENT_BLOB); } } }