NIFI-11408 enable user to disable gzip compression with PutGCSObject

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #7139.
This commit is contained in:
Joe Witt 2023-04-07 15:47:37 -07:00 committed by Pierre Villard
parent 21e4c665dc
commit 4414793f2a
No known key found for this signature in database
GPG Key ID: F92A93B30C07C6D5
2 changed files with 16 additions and 1 deletions

View File

@ -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<String, String> userMetadata = new HashMap<>();
for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) {
if (entry.getKey().isDynamic()) {

View File

@ -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(),