Skip to content

Instantly share code, notes, and snippets.

@enesakar
Created March 8, 2012 07:35
Show Gist options
  • Save enesakar/1999418 to your computer and use it in GitHub Desktop.
Save enesakar/1999418 to your computer and use it in GitHub Desktop.
Hazelcast MapStore Implementation
public class MyMapStore implements MapStore<String, Contact> {
private AmazonSimpleDB sdb;
private void init() {
try {
sdb = new AmazonSimpleDBClient(new PropertiesCredentials(getClass().getClassLoader().getResourceAsStream("AwsCredentials.properties")));
createDomainIfNotExists("Contact");
} catch (IOException e) {
e.printStackTrace();
}
}
private void createDomainIfNotExists(String domainName) {
if (!sdb.listDomains().getDomainNames().contains(domainName))
sdb.createDomain(new CreateDomainRequest(domainName));
}
public void store(String key, Contact contact) {
List<ReplaceableAttribute> attrList = new ArrayList<ReplaceableAttribute>();
attrList.add(new ReplaceableAttribute("Phone", contact.getPhone(), true));
attrList.add(new ReplaceableAttribute("Name", contact.getName(), true));
sdb.putAttributes(new PutAttributesRequest("Contact", contact.getName(), attrList));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment