/** * Appends a string of text to an append blob using the platform's default encoding. This API should be used * strictly in a single writer scenario because the API internally uses the append-offset conditional header to * avoid duplicate blocks which does not work in a multiple writer scenario. * <p> * If you are doing writes in a single writer scenario, please look at * {@link BlobRequestOptions#setAbsorbConditionalErrorsOnRetry(Boolean)} and see if setting this flag * to <code>true</code> is acceptable for you. * * @param content * A <code>String</code> which represents the content that will be appended to the blob. * * @throws StorageException * If a storage service error occurred. * @throws IOException * If an I/O exception occurred. */ public void appendText(final String content) throws StorageException, IOException { this.appendText(content, null /* charsetName */, null /* accessCondition */, null /* options */, null /* opContext */); }
/** * Appends a string of text to an append blob using the platform's default encoding. This API should be used * strictly in a single writer scenario because the API internally uses the append-offset conditional header to * avoid duplicate blocks which does not work in a multiple writer scenario. * <p> * If you are doing writes in a single writer scenario, please look at * {@link BlobRequestOptions#setAbsorbConditionalErrorsOnRetry(Boolean)} and see if setting this flag * to <code>true</code> is acceptable for you. * * @param content * A <code>String</code> which represents the content that will be appended to the blob. * * @throws StorageException * If a storage service error occurred. * @throws IOException * If an I/O exception occurred. */ public void appendText(final String content) throws StorageException, IOException { this.appendText(content, null /* charsetName */, null /* accessCondition */, null /* options */, null /* opContext */); }
@Override public void writeLine(String line) throws IOException { try { if (!gcJournal.exists()) { gcJournal.createOrReplace(); } gcJournal.appendText(line + "\n", Charsets.UTF_8.name(), null, null, null); } catch (StorageException e) { throw new IOException(e); } }
@Override public void writeLine(String line) throws IOException { try { if (!gcJournal.exists()) { gcJournal.createOrReplace(); } gcJournal.appendText(line + "\n", Charsets.UTF_8.name(), null, null, null); } catch (StorageException e) { throw new IOException(e); } }
@Override public void writeLine(String line) throws IOException { if (blockCount >= lineLimit) { int parsedSuffix = parseCurrentSuffix(); createNextFile(parsedSuffix); } try { currentBlob.appendText(line + "\n"); blockCount++; } catch (StorageException e) { throw new IOException(e); } }
@Override public void writeLine(String line) throws IOException { if (blockCount >= lineLimit) { int parsedSuffix = parseCurrentSuffix(); createNextFile(parsedSuffix); } try { currentBlob.appendText(line + "\n"); blockCount++; } catch (StorageException e) { throw new IOException(e); } }
private List<String> createFile(int lines, int maxLineLength) throws IOException, URISyntaxException, StorageException { Random random = new Random(); List<String> entries = new ArrayList<>(); CloudAppendBlob blob = getBlob(); for (int i = 0; i < lines; i++) { int entrySize = random.nextInt(maxLineLength) + 1; String entry = randomString(entrySize); try { blob.appendText(entry + '\n'); } catch (StorageException e) { throw new IOException(e); } entries.add(entry); } entries.add(""); Collections.reverse(entries); return entries; }
protected JournalReader createJournalReader(String s) throws IOException { try { CloudAppendBlob blob = container.getAppendBlobReference("journal/journal.log.001"); blob.createOrReplace(); blob.appendText(s); return new JournalReader(new AzureJournalFile(container.getDirectoryReference("journal"), "journal.log")); } catch (StorageException | URISyntaxException e) { throw new IOException(e); } } }