From 4414793f2a1a458dae922864c7c53959491f8393 Mon Sep 17 00:00:00 2001 From: Joe Witt Date: Fri, 7 Apr 2023 15:47:37 -0700 Subject: [PATCH] NIFI-11408 enable user to disable gzip compression with PutGCSObject Signed-off-by: Pierre Villard This closes #7139. --- .../nifi/processors/gcp/storage/PutGCSObject.java | 15 +++++++++++++++ .../processors/gcp/storage/PutGCSObjectTest.java | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/storage/PutGCSObject.java b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/storage/PutGCSObject.java index 94efff444c..393054e435 100644 --- a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/storage/PutGCSObject.java +++ b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/storage/PutGCSObject.java @@ -194,6 +194,15 @@ public class PutGCSObject extends AbstractGCSProcessor { .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .build(); + public static final PropertyDescriptor GZIPCONTENT = new PropertyDescriptor + .Builder().name("gzip.content.enabled") + .displayName("GZIP Compression Enabled") + .description("Signals to the GCS Blob Writer whether GZIP compression during transfer is desired. " + + "False means do not gzip and can boost performance in many cases.") + .addValidator(StandardValidators.BOOLEAN_VALIDATOR) + .allowableValues(Boolean.TRUE.toString(), Boolean.FALSE.toString()) + .defaultValue(Boolean.TRUE.toString()) + .build(); public static final AllowableValue ACL_ALL_AUTHENTICATED_USERS = new AllowableValue( ALL_AUTHENTICATED_USERS.name(), "All Authenticated Users", "Gives the bucket or object owner OWNER " + "permission, and gives all authenticated Google account holders READER and WRITER permissions. " + @@ -299,6 +308,7 @@ public class PutGCSObject extends AbstractGCSProcessor { descriptors.add(ENCRYPTION_KEY); descriptors.add(OVERWRITE); descriptors.add(CONTENT_DISPOSITION_TYPE); + descriptors.add(GZIPCONTENT); return Collections.unmodifiableList(descriptors); } @@ -390,6 +400,11 @@ public class PutGCSObject extends AbstractGCSProcessor { blobWriteOptions.add(Storage.BlobWriteOption.encryptionKey(encryptionKey)); } + final boolean gzipCompress = context.getProperty(GZIPCONTENT).asBoolean(); + if (!gzipCompress){ + blobWriteOptions.add(Storage.BlobWriteOption.disableGzipContent()); + } + final HashMap userMetadata = new HashMap<>(); for (final Map.Entry entry : context.getProperties().entrySet()) { if (entry.getKey().isDynamic()) { diff --git a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/storage/PutGCSObjectTest.java b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/storage/PutGCSObjectTest.java index 8a2a74f98d..a908e91254 100644 --- a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/storage/PutGCSObjectTest.java +++ b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/storage/PutGCSObjectTest.java @@ -180,7 +180,7 @@ public class PutGCSObjectTest extends AbstractGCSTest { runner.setProperty(PutGCSObject.ENCRYPTION_KEY, ENCRYPTION_KEY); runner.setProperty(PutGCSObject.OVERWRITE, String.valueOf(OVERWRITE)); runner.setProperty(PutGCSObject.CONTENT_DISPOSITION_TYPE, CONTENT_DISPOSITION_TYPE); - + runner.setProperty(PutGCSObject.GZIPCONTENT, Boolean.FALSE.toString()); runner.assertValid(); when(storage.createFrom(blobInfoArgumentCaptor.capture(),