@Override public String restoreBlock(long id, byte[] hash) throws IOException { if (id == -1) { SDFSLogger.getLog().warn("Hash not found for " + StringUtils.getHexString(hash) + " id " + id); return null; } String haName = this.restoreRequests.get(new Long(id)); if (haName == null) haName = EncyptUtils.encHashArchiveName(id, Main.chunkStoreEncryptionEnabled); else { return haName; } try { CloudBlockBlob blob = container.getBlockBlobReference("blocks/" + haName); blob.downloadAttributes(); if (blob.getProperties().getStandardBlobTier().equals(StandardBlobTier.ARCHIVE)) { blob.uploadStandardBlobTier(StandardBlobTier.HOT); bio.removeBlobDataTracker(id, EncyptUtils.encHashArchiveName(Main.DSEID, Main.chunkStoreEncryptionEnabled)); this.restoreRequests.put(new Long(id), haName); return haName; } else { this.restoreRequests.put(new Long(id), null); return null; } } catch (Exception e) { SDFSLogger.getLog().error("unable to restore " + id,e); throw new IOException(e); } }
if (this.tier != null && this.tier.equals(StandardBlobTier.ARCHIVE)) { blob.downloadAttributes(); if (blob.getProperties().getStandardBlobTier().equals(StandardBlobTier.ARCHIVE)) { this.restoreBlock(id, new byte [16]); throw new DataArchivedException(id, null);
public static void main(String[] args) { String storageConnectionString = "DefaultEndpointsProtocol=http;" + "AccountName=" + args[0] + ";" + "AccountKey=" + args[1]; try { // Retrieve storage account from connection-string. CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString); // Create the blob client. CloudBlobClient blobClient = storageAccount.createCloudBlobClient(); // Get a reference to a container. // The container name must be lower case CloudBlobContainer container = blobClient.getContainerReference(args[2]); CloudBlockBlob kblob = container.getBlockBlobReference("blocks/MTEwMjE4ODc4MjM0MzY3NzM="); kblob.downloadAttributes(); System.out.println(kblob.getProperties().getStandardBlobTier()); System.out.println(kblob.getProperties().getRehydrationStatus()); } catch (Exception e) { // Output the stack trace. e.printStackTrace(); } }
CloudBlockBlob blob = container.getBlockBlobReference("blocks/" + hashString); blob.downloadAttributes(); if (!blob.getProperties().getStandardBlobTier().equals(tier)) { blob.uploadStandardBlobTier(this.tier); SDFSLogger.getLog().info("Moved blocks/" + hashString + " to " + blob.getProperties().getStandardBlobTier());
@Override public boolean blockRestored(String id) { try { CloudBlockBlob blob = container.getBlockBlobReference("blocks/" + id); if(!blob.exists()) return true; blob.downloadAttributes(); if (blob.getProperties().getStandardBlobTier().equals(StandardBlobTier.HOT)) { return true; } else { if (blob.getProperties().getRehydrationStatus() == null || blob.getProperties().getRehydrationStatus().equals(RehydrationStatus.UNKNOWN)) { SDFSLogger.getLog().warn("rehydration status unknow for " + id + " will attempt to rehydrate"); blob.uploadStandardBlobTier(StandardBlobTier.HOT); } return false; } } catch (Exception e) { SDFSLogger.getLog().warn("error while checking block [" + id + "] restored", e); return false; } }
properties.setBlobTierInferred(Boolean.parseBoolean(tierInferredString)); else if (properties.getPremiumPageBlobTier() != null || properties.getStandardBlobTier() != null) { properties.setBlobTierInferred(false);
@Test @Category({ DevFabricTests.class, DevStoreTests.class }) public void testCloudBlockBlobUploadStandardTier() throws StorageException, IOException, URISyntaxException { for (StandardBlobTier standardBlobTier : StandardBlobTier.values()) { if (standardBlobTier == StandardBlobTier.UNKNOWN) { continue; } final String blobName = BlobTestHelper.generateRandomBlobNameWithPrefix("testBlob"); final CloudBlockBlob blob = this.container.getBlockBlobReference(blobName); blob.uploadText("text"); blob.uploadStandardBlobTier(standardBlobTier); assertEquals(standardBlobTier, blob.getProperties().getStandardBlobTier()); assertNull(blob.getProperties().getPremiumPageBlobTier()); assertNull(blob.getProperties().getRehydrationStatus()); CloudBlockBlob blob2 = this.container.getBlockBlobReference(blobName); blob2.downloadAttributes(); assertEquals(standardBlobTier, blob2.getProperties().getStandardBlobTier()); assertNull(blob2.getProperties().getPremiumPageBlobTier()); assertNull(blob2.getProperties().getRehydrationStatus()); CloudBlockBlob blob3 = (CloudBlockBlob)this.container.listBlobs().iterator().next(); assertEquals(standardBlobTier, blob3.getProperties().getStandardBlobTier()); assertNull(blob3.getProperties().getPremiumPageBlobTier()); assertNull(blob3.getProperties().getRehydrationStatus()); blob.deleteIfExists(); } }
blobRef1.uploadStandardBlobTier(StandardBlobTier.COOL); assertNull(blobRef1.getProperties().getRehydrationStatus()); assertEquals(StandardBlobTier.ARCHIVE, blobRef1.getProperties().getStandardBlobTier()); assertNull(blobRef1.getProperties().getPremiumPageBlobTier()); assertEquals(StandardBlobTier.ARCHIVE, blob.getProperties().getStandardBlobTier()); assertNull(blob.getProperties().getPremiumPageBlobTier()); blobRef2.uploadStandardBlobTier(StandardBlobTier.HOT); assertNull(blobRef2.getProperties().getRehydrationStatus()); assertEquals(StandardBlobTier.ARCHIVE, blobRef2.getProperties().getStandardBlobTier()); assertNull(blobRef2.getProperties().getPremiumPageBlobTier()); assertEquals(StandardBlobTier.ARCHIVE, blob2.getProperties().getStandardBlobTier()); assertNull(blob2.getProperties().getPremiumPageBlobTier()); CloudBlockBlob listBlob = (CloudBlockBlob)it.next(); assertEquals(RehydrationStatus.PENDING_TO_COOL, listBlob.getProperties().getRehydrationStatus()); assertEquals(StandardBlobTier.ARCHIVE, listBlob.getProperties().getStandardBlobTier()); assertNull(listBlob.getProperties().getPremiumPageBlobTier()); assertEquals(StandardBlobTier.ARCHIVE, listBlob2.getProperties().getStandardBlobTier()); assertNull(listBlob2.getProperties().getPremiumPageBlobTier());
assertEquals(PremiumPageBlobTier.P4, blob.getProperties().getPremiumPageBlobTier()); assertFalse(blob.getProperties().isBlobTierInferred()); assertNull(blob.getProperties().getStandardBlobTier()); assertNull(blob.getProperties().getRehydrationStatus()); assertEquals(PremiumPageBlobTier.P4, blob2.getProperties().getPremiumPageBlobTier()); assertNull(blob2.getProperties().isBlobTierInferred()); assertNull(blob2.getProperties().getStandardBlobTier()); assertNull(blob2.getProperties().getRehydrationStatus()); assertEquals(PremiumPageBlobTier.P6, blob3.getProperties().getPremiumPageBlobTier()); assertFalse(blob3.getProperties().isBlobTierInferred()); assertNull(blob3.getProperties().getStandardBlobTier()); assertNull(blob3.getProperties().getRehydrationStatus()); assertEquals(PremiumPageBlobTier.P10, blob4.getProperties().getPremiumPageBlobTier()); assertFalse(blob4.getProperties().isBlobTierInferred()); assertNull(blob4.getProperties().getStandardBlobTier()); assertNull(blob4.getProperties().getRehydrationStatus()); assertEquals(PremiumPageBlobTier.P20, blob5.getProperties().getPremiumPageBlobTier()); assertFalse(blob5.getProperties().isBlobTierInferred()); assertNull(blob5.getProperties().getStandardBlobTier()); assertNull(blob5.getProperties().getRehydrationStatus());
assertFalse(source.getProperties().isBlobTierInferred()); assertFalse(copy.getProperties().isBlobTierInferred()); assertNull(source.getProperties().getStandardBlobTier()); assertNull(source.getProperties().getRehydrationStatus()); assertNull(copy.getProperties().getStandardBlobTier()); assertNull(copy.getProperties().getRehydrationStatus()); BlobTestHelper.waitForCopy(copy); assertNull(source2.getProperties().isBlobTierInferred()); assertFalse(copy3.getProperties().isBlobTierInferred()); assertNull(source2.getProperties().getStandardBlobTier()); assertNull(source2.getProperties().getRehydrationStatus()); assertNull(copy3.getProperties().getStandardBlobTier()); assertNull(copy3.getProperties().getRehydrationStatus());
assertEquals(PremiumPageBlobTier.P40, blob.properties.getPremiumPageBlobTier()); assertFalse(blob.getProperties().isBlobTierInferred()); assertNull(blob.getProperties().getStandardBlobTier()); assertNull(blob.getProperties().getRehydrationStatus()); assertNull(blob3.getProperties().getStandardBlobTier()); assertNull(blob3.getProperties().getRehydrationStatus()); pageBlobWithTierFound = true;