/** * Uploads the container's metadata. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public void uploadMetadata() throws StorageException { this.uploadMetadata(null /* accessCondition */, null /* options */, null /* opContext */); }
/** * Uploads the container's metadata. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public void uploadMetadata() throws StorageException { this.uploadMetadata(null /* accessCondition */, null /* options */, null /* opContext */); }
@Override public void uploadMetadata(OperationContext opContext) throws StorageException { container.uploadMetadata(AccessCondition.generateEmptyCondition(), null, opContext); }
@Override public void uploadMetadata(OperationContext opContext) throws StorageException { container.uploadMetadata(AccessCondition.generateEmptyCondition(), null, opContext); }
@Override public void close() { CloudBlobContainer container = null; try { container = pool.borrowObject(); HashMap<String, String> md = container.getMetadata(); md.put("currentlength", Long.toString(this.currentLength.get())); md.put("compressedlength", Long.toString(this.compressedLength.get())); container.setMetadata(md); container.uploadMetadata(); } catch (Exception e) { SDFSLogger.getLog().error("error closing container", e); } finally { try { pool.returnObject(container); } catch (IOException e) { SDFSLogger.getLog().info("error returning object", e); } } try { pool.close(); } catch (Exception e) { } }
md.put("compressedlength", "-1"); container.setMetadata(md); container.uploadMetadata(); this.compress = Main.compress; this.encrypt = Main.chunkStoreEncryptionEnabled;
@Override public void close() { try { SDFSLogger.getLog().info("############ Closing Azure Container ##################"); // container = pool.borrowObject(); if (this.standAlone) { HashBlobArchive.close(); HashMap<String, String> md = container.getMetadata(); md.put("currentlength", Long.toString(HashBlobArchive.getLength())); md.put("compressedlength", Long.toString(HashBlobArchive.getCompressedLength())); container.setMetadata(md); container.uploadMetadata(); SDFSLogger.getLog().info("Updated container on close"); } SDFSLogger.getLog().info("############ Azure Container Closed ##################"); } catch (Exception e) { SDFSLogger.getLog().error("error closing container", e); } finally { this.closed = true; } try { // this.serviceClient. } catch (Exception e) { } }
md.put("port", Integer.toString(Main.sdfsCliPort)); container.setMetadata(md); container.uploadMetadata(); blob.uploadMetadata(); container.setMetadata(md); container.uploadMetadata(null, null, opContext); SDFSLogger.getLog().debug("set user metadata " + metaData.size());
md.put("compressedlength", Long.toString(HashBlobArchive.getCompressedLength())); container.setMetadata(md); container.uploadMetadata(null, null, opContext); } else { String lbi = "bucketinfo/"
final CloudBlobContainer container = session.getClient().getContainerReference(containerService.getContainer(file).getName()); container.setMetadata(new HashMap<String, String>(metadata)); container.uploadMetadata(AccessCondition.generateEmptyCondition(), options, context);
private static void testMetadataFailures(CloudBlobContainer container, String key, String value, boolean badKey) { container.getMetadata().put(key, value); try { container.uploadMetadata(); fail(SR.METADATA_KEY_INVALID); } catch (StorageException e) { if (badKey) { assertEquals(SR.METADATA_KEY_INVALID, e.getMessage()); } else { assertEquals(SR.METADATA_VALUE_INVALID, e.getMessage()); } } container.getMetadata().remove(key); }
@Test @Category({ DevFabricTests.class, DevStoreTests.class }) public void testCloudBlobContainerUploadMetadata() throws StorageException, URISyntaxException { this.container.create(); CloudBlobContainer container2 = this.container.getServiceClient().getContainerReference( this.container.getName()); container2.downloadAttributes(); assertEquals(0, container2.getMetadata().size()); this.container.getMetadata().put("key1", "value1"); this.container.uploadMetadata(); container2.downloadAttributes(); assertEquals(1, container2.getMetadata().size()); assertEquals("value1", container2.getMetadata().get("key1")); Iterable<CloudBlobContainer> containers = this.container.getServiceClient().listContainers( this.container.getName(), ContainerListingDetails.METADATA, null, null); for (CloudBlobContainer container3 : containers) { assertEquals(1, container3.getMetadata().size()); assertEquals("value1", container3.getMetadata().get("key1")); } this.container.getMetadata().clear(); this.container.uploadMetadata(); container2.downloadAttributes(); assertEquals(0, container2.getMetadata().size()); }
container.uploadMetadata(null, null, opContext); fail(SR.METADATA_KEY_INVALID); } catch (StorageException e) {
@Test @Category({ DevFabricTests.class, DevStoreTests.class }) public void testCloudBlobContainerInvalidMetadata() throws StorageException{ // test client-side fails correctly testMetadataFailures(this.container, null, "value1", true); testMetadataFailures(this.container, "", "value1", true); testMetadataFailures(this.container, " ", "value1", true); testMetadataFailures(this.container, "\n \t", "value1", true); testMetadataFailures(this.container, "key1", null, false); testMetadataFailures(this.container, "key1", "", false); testMetadataFailures(this.container, "key1", " ", false); testMetadataFailures(this.container, "key1", "\n \t", false); // test client can get empty metadata this.container.create(); OperationContext opContext = new OperationContext(); opContext.getSendingRequestEventHandler().addListener(new StorageEvent<SendingRequestEvent>() { // insert a metadata element with an empty value @Override public void eventOccurred(SendingRequestEvent eventArg) { HttpURLConnection request = (HttpURLConnection) eventArg.getConnectionObject(); request.setRequestProperty(Constants.HeaderConstants.PREFIX_FOR_STORAGE_METADATA + "key1", ""); } }); this.container.uploadMetadata(null, null, opContext); this.container.downloadAttributes(); assertEquals(1, this.container.getMetadata().size()); assertEquals("", this.container.getMetadata().get("key1")); }