@Override public String getName() { return AzureUtilities.getName(archiveDirectory); }
@Override public String getName() { return AzureUtilities.getName(archiveDirectory); }
@Override public String getName() { return AzureUtilities.getName(archiveDirectory); }
@Override public String getName() { return AzureUtilities.getName(archiveDirectory); }
private int parseCurrentSuffix() { String name = AzureUtilities.getName(currentBlob); Pattern pattern = Pattern.compile(Pattern.quote(journalNamePrefix) + "\\.(\\d+)" ); Matcher matcher = pattern.matcher(name); int parsedSuffix; if (matcher.find()) { String suffix = matcher.group(1); try { parsedSuffix = Integer.parseInt(suffix); } catch (NumberFormatException e) { log.warn("Can't parse suffix for journal file {}", name); parsedSuffix = 0; } } else { log.warn("Can't parse journal file name {}", name); parsedSuffix = 0; } return parsedSuffix; }
private int parseCurrentSuffix() { String name = AzureUtilities.getName(currentBlob); Pattern pattern = Pattern.compile(Pattern.quote(journalNamePrefix) + "\\.(\\d+)" ); Matcher matcher = pattern.matcher(name); int parsedSuffix; if (matcher.find()) { String suffix = matcher.group(1); try { parsedSuffix = Integer.parseInt(suffix); } catch (NumberFormatException e) { log.warn("Can't parse suffix for journal file {}", name); parsedSuffix = 0; } } else { log.warn("Can't parse journal file name {}", name); parsedSuffix = 0; } return parsedSuffix; }
@Override public List<String> listArchives() throws IOException { try { return StreamSupport.stream(cloudBlobDirectory .listBlobs(null, false, EnumSet.noneOf(BlobListingDetails.class), null, null) .spliterator(), false) .filter(i -> i instanceof CloudBlobDirectory) .map(i -> (CloudBlobDirectory) i) .filter(i -> getName(i).endsWith(".tar")) .map(CloudBlobDirectory::getPrefix) .map(Paths::get) .map(Path::getFileName) .map(Path::toString) .collect(Collectors.toList()); } catch (URISyntaxException | StorageException e) { throw new IOException(e); } }
@Override public List<String> listArchives() throws IOException { try { return StreamSupport.stream(cloudBlobDirectory .listBlobs(null, false, EnumSet.noneOf(BlobListingDetails.class), null, null) .spliterator(), false) .filter(i -> i instanceof CloudBlobDirectory) .map(i -> (CloudBlobDirectory) i) .filter(i -> getName(i).endsWith(".tar")) .map(CloudBlobDirectory::getPrefix) .map(Paths::get) .map(Path::getFileName) .map(Path::toString) .collect(Collectors.toList()); } catch (URISyntaxException | StorageException e) { throw new IOException(e); } }
String name = getName(b); Matcher m = pattern.matcher(name); if (!m.matches()) {
String name = getName(b); Matcher m = pattern.matcher(name); if (!m.matches()) {
private void copyBlob(CloudBlob blob, CloudBlobDirectory newParent) throws IOException { checkArgument(blob instanceof CloudBlockBlob, "Only page blobs are supported for the rename"); try { String blobName = getName(blob); CloudBlockBlob newBlob = newParent.getBlockBlobReference(blobName); newBlob.startCopy(blob.getUri()); boolean isStatusPending = true; while (isStatusPending) { newBlob.downloadAttributes(); if (newBlob.getCopyState().getStatus() == CopyStatus.PENDING) { Thread.sleep(100); } else { isStatusPending = false; } } CopyStatus finalStatus = newBlob.getCopyState().getStatus(); if (newBlob.getCopyState().getStatus() != CopyStatus.SUCCESS) { throw new IOException("Invalid copy status for " + blob.getUri().getPath() + ": " + finalStatus); } } catch (StorageException | InterruptedException | URISyntaxException e) { throw new IOException(e); } }
private void copyBlob(CloudBlob blob, CloudBlobDirectory newParent) throws IOException { checkArgument(blob instanceof CloudBlockBlob, "Only page blobs are supported for the rename"); try { String blobName = getName(blob); CloudBlockBlob newBlob = newParent.getBlockBlobReference(blobName); newBlob.startCopy(blob.getUri()); boolean isStatusPending = true; while (isStatusPending) { newBlob.downloadAttributes(); if (newBlob.getCopyState().getStatus() == CopyStatus.PENDING) { Thread.sleep(100); } else { isStatusPending = false; } } CopyStatus finalStatus = newBlob.getCopyState().getStatus(); if (newBlob.getCopyState().getStatus() != CopyStatus.SUCCESS) { throw new IOException("Invalid copy status for " + blob.getUri().getPath() + ": " + finalStatus); } } catch (StorageException | InterruptedException | URISyntaxException e) { throw new IOException(e); } }