org.jgroups.protocols
Class S3_PING
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.Discovery
org.jgroups.protocols.FILE_PING
org.jgroups.protocols.S3_PING
public class S3_PING
- extends FILE_PING
Discovery protocol using Amazon's S3 storage. The S3 access code reuses the example shipped by Amazon.
This protocol is unsupported and experimental !
- Author:
- Bela Ban
Fields inherited from class org.jgroups.protocols.Discovery |
break_on_coord_rsp, current_coord, force_sending_discovery_rsps, group_addr, is_coord, is_leaving, is_server, local_addr, members, num_discovery_requests, num_initial_members, num_initial_srv_members, ping_responses, return_entire_cache, stagger_timeout, timeout, timer, use_disk_cache, view |
Method Summary |
protected void |
createRootDir()
|
static java.lang.String |
generatePreSignedUrl(java.lang.String awsAccessKey,
java.lang.String awsSecretAccessKey,
java.lang.String method,
java.lang.String bucket,
java.lang.String key,
long expirationDate)
Use this helper method to generate pre-signed S3 urls for use with S3_PING. |
void |
init()
Called after instance has been created (null constructor) and before protocol is started. |
protected java.util.List<PingData> |
readAll(java.lang.String clustername)
Reads all information from the given directory under clustername |
protected void |
remove(java.lang.String clustername,
Address addr)
|
protected static java.lang.String |
sanitize(java.lang.String name)
Sanitizes bucket and folder names according to AWS guidelines |
protected boolean |
usingPreSignedUrls()
|
protected void |
validateProperties()
|
protected void |
writeToFile(PingData data,
java.lang.String clustername)
|
Methods inherited from class org.jgroups.protocols.Discovery |
deserialize, discoveryRequestReceived, findAllViews, findAllViewsAsString, findInitialMembers, findInitialMembersAsString, findMembers, getCurrentCoord, getNumberOfDiscoveryRequestsSent, getNumInitialMembers, getTimeout, getView, getViewId, handleConnect, handleDisconnect, isMergeRunning, providedUpServices, resetStats, sendDiscoveryRequest, sendDiscoveryResponse, sendMcastDiscoveryRequest, serializeWithoutView, setForceSendingDiscoveryRsps, setNumInitialMembers, setTimeout, up |
Methods inherited from class org.jgroups.stack.Protocol |
destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, printStats, providedDownServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
access_key
protected java.lang.String access_key
secret_access_key
protected java.lang.String secret_access_key
prefix
protected java.lang.String prefix
pre_signed_put_url
protected java.lang.String pre_signed_put_url
pre_signed_delete_url
protected java.lang.String pre_signed_delete_url
conn
protected org.jgroups.protocols.S3_PING.AWSAuthConnection conn
S3_PING
public S3_PING()
init
public void init()
throws java.lang.Exception
- Description copied from class:
Protocol
- Called after instance has been created (null constructor) and before protocol is started.
Properties are already set. Other protocols are not yet connected and events cannot yet be sent.
- Overrides:
init
in class FILE_PING
- Throws:
java.lang.Exception
- Thrown if protocol cannot be initialized successfully. This will cause the
ProtocolStack to fail, so the channel constructor will throw an exception
createRootDir
protected void createRootDir()
- Overrides:
createRootDir
in class FILE_PING
readAll
protected java.util.List<PingData> readAll(java.lang.String clustername)
- Description copied from class:
FILE_PING
- Reads all information from the given directory under clustername
- Overrides:
readAll
in class FILE_PING
- Returns:
writeToFile
protected void writeToFile(PingData data,
java.lang.String clustername)
- Overrides:
writeToFile
in class FILE_PING
remove
protected void remove(java.lang.String clustername,
Address addr)
- Overrides:
remove
in class FILE_PING
validateProperties
protected void validateProperties()
usingPreSignedUrls
protected boolean usingPreSignedUrls()
sanitize
protected static java.lang.String sanitize(java.lang.String name)
- Sanitizes bucket and folder names according to AWS guidelines
generatePreSignedUrl
public static java.lang.String generatePreSignedUrl(java.lang.String awsAccessKey,
java.lang.String awsSecretAccessKey,
java.lang.String method,
java.lang.String bucket,
java.lang.String key,
long expirationDate)
- Use this helper method to generate pre-signed S3 urls for use with S3_PING.
You'll need to generate urls for both the put and delete http methods.
Example:
Your AWS Access Key is "abcd".
Your AWS Secret Access Key is "efgh".
You want this node to write its information to "/S3_PING/DemoCluster/node1".
So, your bucket is "S3_PING" and your key is "DemoCluster/node1".
You want this to expire one year from now, or
(System.currentTimeMillis / 1000) + (60 * 60 * 24 * 365)
Let's assume that this equals 1316286684
Here's how to generate the value for the pre_signed_put_url property:
String putUrl = S3_PING.generatePreSignedUrl("abcd", "efgh", "put",
"S3_Ping", "DemoCluster/node1",
1316286684);
Here's how to generate the value for the pre_signed_delete_url property:
String deleteUrl = S3_PING.generatePreSignedUrl("abcd", "efgh", "delete",
"S3_Ping", "DemoCluster/node1",
1316286684);
- Parameters:
awsAccessKey
- Your AWS Access KeyawsSecretAccessKey
- Your AWS Secret Access Keymethod
- The HTTP method - use "put" or "delete" for use with S3_PINGbucket
- The S3 bucket you want to write tokey
- The key within the bucket to write toexpirationDate
- The date this pre-signed url should expire, in seconds since epoch
- Returns:
- The pre-signed url to be used in pre_signed_put_url or pre_signed_delete_url properties
Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.