private void releaseLease() throws IOException { try { blob.releaseLease(AccessCondition.generateLeaseCondition(leaseId)); blob.delete(); log.info("Released lease {}", leaseId); leaseId = null; } catch (StorageException e) { throw new IOException(e); } } }
private void releaseLease() throws IOException { try { blob.releaseLease(AccessCondition.generateLeaseCondition(leaseId)); blob.delete(); log.info("Released lease {}", leaseId); leaseId = null; } catch (StorageException e) { throw new IOException(e); } } }
@Override public void deleteFile(String nm, String pp) throws IOException { while (nm.startsWith(File.separator)) nm = nm.substring(1); String haName = EncyptUtils.encString(nm, Main.chunkStoreEncryptionEnabled); try { CloudBlockBlob blob = container.getBlockBlobReference(pp + "/" + haName); if (blob.exists()) { if (this.isClustered()) { String blb = "claims/" + haName + "/" + EncyptUtils.encHashArchiveName(Main.DSEID, Main.chunkStoreEncryptionEnabled); blob = container.getBlockBlobReference(blb); blob.delete(); if (!container.listBlobs("claims/" + haName).iterator().hasNext()) { blob = container.getBlockBlobReference(pp + "/" + haName); blob.delete(); } } else { blob.delete(); } } } catch (Exception e) { throw new IOException(e); } }
@NotNull public static String deleteBlob(@NotNull final StorageInputs inputs) throws Exception { final CloudBlobClient blobClient = getCloudBlobClient(inputs); final CloudBlobContainer container = blobClient.getContainerReference(inputs.getContainerName()); final CloudBlockBlob blob = container.getBlockBlobReference(inputs.getBlobName()); blob.delete(); return inputs.getBlobName(); }
@Override public void deleteChunk(byte[] hash, long start, int len) throws IOException { String hashString = this.getHashName(hash, Main.chunkStoreEncryptionEnabled); CloudBlobContainer container = null; try { container = pool.borrowObject(); this.chunks.invalidate(hashString); CloudBlockBlob blob = container.getBlockBlobReference(hashString); if (blob.exists()) blob.delete(); } catch (Exception e) { SDFSLogger.getLog() .warn("Unable to delete object " + hashString, e); } finally { pool.returnObject(container); } }
cblob.delete(); try { bio.removeBlobDataTracker(id, kblob.delete(); kblob = container.getBlockBlobReference("blocks/" + haName); kblob.delete(); kblob = container.getBlockBlobReference("keys/" + haName); kblob.delete(); SDFSLogger.getLog().info("deleted block " + id + " name=blocks/" + haName); kblob.delete(); kblob = container.getBlockBlobReference("blocks/" + haName); kblob.delete();
@Override public void renameFile(String from, String to, String pp) throws IOException { while (from.startsWith(File.separator)) from = from.substring(1); while (to.startsWith(File.separator)) to = to.substring(1); String fn = EncyptUtils.encString(from, Main.chunkStoreEncryptionEnabled); String tn = EncyptUtils.encString(to, Main.chunkStoreEncryptionEnabled); try { CloudBlockBlob sblob = container.getBlockBlobReference(pp + "/" + fn); CloudBlockBlob tblob = container.getBlockBlobReference(pp + "/" + tn); tblob.startCopy(sblob); while (tblob.getCopyState().getStatus() == CopyStatus.PENDING) { Thread.sleep(10); } if (tblob.getCopyState().getStatus() == CopyStatus.SUCCESS) { sblob.delete(); } else { throw new IOException( "unable to rename file " + fn + " because " + tblob.getCopyState().getStatus().name() + " : " + tblob.getCopyState().getStatusDescription()); } } catch (Exception e) { throw new IOException(e); } }
public void cleanup() throws Exception { if (fs != null) { fs.close(); fs = null; } if (!skipContainerDelete && container != null) { container.deleteIfExists(); container = null; } if (blob != null) { // The blob member variable is set for blobs under root containers. // Delete blob objects created for root container tests when cleaning // up the test account. blob.delete(); blob = null; } }
public void cleanup() throws Exception { if (fs != null) { fs.close(); fs = null; } if (container != null) { container.deleteIfExists(); container = null; } if (blob != null) { // The blob member variable is set for blobs under root containers. // Delete blob objects created for root container tests when cleaning // up the test account. blob.delete(); blob = null; } }
@Test public void testRecovery() throws StorageException, URISyntaxException, IOException { SegmentArchiveManager manager = new AzurePersistence(container.getDirectoryReference("oak")).createArchiveManager(false, false, new IOMonitorAdapter(), new FileStoreMonitorAdapter()); SegmentArchiveWriter writer = manager.create("data00000a.tar"); List<UUID> uuids = new ArrayList<>(); for (int i = 0; i < 10; i++) { UUID u = UUID.randomUUID(); writer.writeSegment(u.getMostSignificantBits(), u.getLeastSignificantBits(), new byte[10], 0, 10, 0, 0, false); uuids.add(u); } writer.flush(); writer.close(); container.getBlockBlobReference("oak/data00000a.tar/0005." + uuids.get(5).toString()).delete(); LinkedHashMap<UUID, byte[]> recovered = new LinkedHashMap<>(); manager.recoverEntries("data00000a.tar", recovered); assertEquals(uuids.subList(0, 5), newArrayList(recovered.keySet())); }
@Override public void eventOccurred(SendingRequestEvent eventArg) { if (((HttpURLConnection) eventArg.getConnectionObject()).getRequestMethod().equals("DELETE")) { try { blob1.delete(); assertFalse(blob1.exists()); } catch (StorageException e) { fail("Delete should succeed."); } } } });
final BlobRequestOptions options = new BlobRequestOptions(); session.getClient().getContainerReference(containerService.getContainer(file).getName()) .getBlockBlobReference(containerService.getKey(file)).delete( DeleteSnapshotsOption.INCLUDE_SNAPSHOTS, AccessCondition.generateEmptyCondition(), options, context);
@Test public void testUncleanStop() throws URISyntaxException, IOException, InvalidFileStoreVersionException, CommitFailedException, StorageException { AzurePersistence p = new AzurePersistence(container.getDirectoryReference("oak")); FileStore fs = FileStoreBuilder.fileStoreBuilder(new File("target")).withCustomPersistence(p).build(); SegmentNodeStore segmentNodeStore = SegmentNodeStoreBuilders.builder(fs).build(); NodeBuilder builder = segmentNodeStore.getRoot().builder(); builder.setProperty("foo", "bar"); segmentNodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); fs.close(); container.getBlockBlobReference("oak/data00000a.tar/closed").delete(); container.getBlockBlobReference("oak/data00000a.tar/data00000a.tar.brf").delete(); container.getBlockBlobReference("oak/data00000a.tar/data00000a.tar.gph").delete(); fs = FileStoreBuilder.fileStoreBuilder(new File("target")).withCustomPersistence(p).build(); segmentNodeStore = SegmentNodeStoreBuilders.builder(fs).build(); assertEquals("bar", segmentNodeStore.getRoot().getString("foo")); fs.close(); } }
blobRef.delete();
assertFalse(copy.getMetadata().containsKey("Test")); copy.delete();
/** * Delete a block blob. * * @throws StorageException * @throws URISyntaxException * @throws IOException */ @Test @Category({ DevFabricTests.class, DevStoreTests.class }) public void testBlockBlobDelete() throws StorageException, URISyntaxException, IOException { final CloudBlockBlob blob = this.container.getBlockBlobReference(BlobTestHelper .generateRandomBlobNameWithPrefix("testBlob")); assertFalse(blob.exists()); // create blob.uploadText("text"); assertTrue(blob.exists()); // delete blob.delete(); assertFalse(blob.exists()); // delete again, should fail as it doesn't exist try { blob.delete(); fail("Delete should fail as blob does not exist."); } catch (StorageException ex) { assertEquals(HttpURLConnection.HTTP_NOT_FOUND, ex.getHttpStatusCode()); assertEquals("The specified blob does not exist.", ex.getMessage()); assertEquals("BlobNotFound", ex.getErrorCode()); } }