Skip to content

Commit

Permalink
Support environmental properties to set protocol properties #374
Browse files Browse the repository at this point in the history
Review properties that can be exposed as managed properties and disallow writing to properties that don't support it #386
  • Loading branch information
rhusar committed Oct 30, 2024
1 parent 1d4385f commit fbdc25d
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 32 deletions.
64 changes: 56 additions & 8 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,62 @@ This library implements a JGroups discovery protocol which replaces protocols li
The `aws.S3_PING` automatically registers itself to JGroups with the magic number `789`.
You can overwrite this by setting the system property `s3ping.magic_number` to different number, e.g. `-Ds3ping.magic_number=123`.

=== Possible Configurations

// TODO change this to table format
* *region_name*: like "eu-west-1", "us-east-1", etc.
* *bucket_name*: the S3 bucket to store the files in
* *bucket_prefix* (optional): if you don't want the plugin to pollute your S3 bucket, you can configure a prefix like "jgroups/"
* *endpoint* (optional): you can override the S3 endpoint if you know what you are doing
* *kms_key_id* (optional): you can set this to a kms key id to enable KMS-SSE encryption when writing data to S3 (see https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html)
=== Configurations Properties

//[align="left",width="90%",cols="3,3,3,10",options="header"]
// //cols="1,1,10"
[align="left",cols="3,1,10",options="header"]
|===
| Attribute Name +
System Property
| Default
| Description

| `region_name` +
System property: `jgroups.aws.s3.region_name`
| *required*
| The S3 region to use.

| `bucket_name` +
System property: `jgroups.aws.s3.bucket_name`
|
| The S3 bucket to use.

| `bucket_prefix` +
System property: `jgroups.aws.s3.bucket_prefix`
|
| The S3 bucket prefix to use (optional e.g. 'jgroups/').


| `check_if_bucket_exists` +
System property: `jgroups.aws.s3.check_if_bucket_exists`
| `true`
| Checks if the bucket exists in S3 and creates a new one if missing

| `endpoint` +
System property: `jgroups.aws.s3.endpoint`
|
| The S3 endpoint to use (optional).

| `path_style_access_enabled` +
System property: `jgroups.aws.s3.path_style_access_enabled`
| `false`
| The S3 path-style enable (optional).

| `kms_key_id` +
System property: `jgroups.aws.s3.kms_key_id`
|
| Use kms encryption with s3 with the given kms key (optionally - enables KMS Server side encryption (SSE-KMS) using the given kms key)

| `acl_grant_bucket_owner_full_control` +
System property: `jgroups.aws.s3.acl_grant_bucket_owner_full_control`
| `false`
| Flag indicating whether or not to grant the bucket owner full control over the bucket on each update. This is useful in multi-region deployments where each region exists in its own AWS account.

|===

NOTE: System properties are supported since JGroups AWS release version 3.0.1.Final.
To use properties in the previous version, the property must be explicitly defined in the configuration.

=== Example Stack

Expand Down
63 changes: 39 additions & 24 deletions src/main/java/org/jgroups/protocols/aws/S3_PING.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,45 @@ public class S3_PING extends FILE_PING {
protected static final String SERIALIZED_CONTENT_TYPE="text/plain";
protected static final String MAGIC_NUMBER_SYSTEM_PROPERTY="s3ping.magic_number";

@Property(description="The S3 path-style enable (optional).", exposeAsManagedAttribute=false)
protected boolean path_style_access_enabled=false;

@Property(description="The S3 endpoint to use (optional).", exposeAsManagedAttribute=false)
protected String endpoint;

@Property(description="The S3 region to use.", exposeAsManagedAttribute=false)
protected String region_name;

@Property(description="The S3 bucket to use.", exposeAsManagedAttribute=false)
protected String bucket_name;

@Property(description="The S3 bucket prefix to use (optional e.g. 'jgroups/').", exposeAsManagedAttribute=false)
protected String bucket_prefix;

@Property(description="Checks if the bucket exists in S3 and creates a new one if missing")
protected boolean check_if_bucket_exists=true;

@Property(description = "Flag indicating whether or not to grant the bucket owner full control over the bucket " +
"on each update. This is useful in multi-region deployments where each region exists in its own AWS account.")
protected boolean acl_grant_bucket_owner_full_control = false;

@Property(description="KMS key to use for enabling KMS server-side encryption (SSE-KMS) for S3 (optional).", exposeAsManagedAttribute=false)
protected String kms_key_id;
@Property(description = "The S3 path-style enable (optional).",
systemProperty = "jgroups.aws.s3.path_style_access_enabled",
writable = false)
protected boolean path_style_access_enabled;

@Property(description = "The S3 endpoint to use (optional).",
systemProperty = "jgroups.aws.s3.endpoint",
writable = false)
protected String endpoint;

@Property(description = "The S3 region to use.",
systemProperty = "jgroups.aws.s3.region_name",
writable = false)
protected String region_name;

@Property(description = "The S3 bucket to use.",
systemProperty = "jgroups.aws.s3.bucket_name",
writable = false)
protected String bucket_name;

@Property(description = "The S3 bucket prefix to use (optional e.g. 'jgroups/').",
systemProperty = "jgroups.aws.s3.bucket_prefix",
writable = false)
protected String bucket_prefix;

@Property(description = "Checks if the bucket exists in S3 and creates a new one if missing",
systemProperty = "jgroups.aws.s3.check_if_bucket_exists",
writable = false)
protected boolean check_if_bucket_exists = true;

@Property(description = "Flag indicating whether or not to grant the bucket owner full control over the bucket on each update. This is useful in multi-region deployments where each region exists in its own AWS account.",
systemProperty = "jgroups.aws.s3.acl_grant_bucket_owner_full_control",
writable = false)
protected boolean acl_grant_bucket_owner_full_control;

@Property(description = "KMS key to use for enabling KMS server-side encryption (SSE-KMS) for S3 (optional).",
systemProperty = "jgroups.aws.s3.kms_key_id",
exposeAsManagedAttribute = false)
protected String kms_key_id;

protected S3Client s3Client;

Expand Down

0 comments on commit fbdc25d

Please sign in to comment.