Skip to content

Commit

Permalink
fixed simpleDb again
Browse files Browse the repository at this point in the history
  • Loading branch information
akamel001 committed Apr 8, 2012
1 parent ff9e267 commit 81a3d00
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions server/SimpleDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import util.Configuration;

import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.dynamodb.model.ConditionalCheckFailedException;
import com.amazonaws.services.simpledb.AmazonSimpleDBClient;
import com.amazonaws.services.simpledb.model.CreateDomainRequest;
import com.amazonaws.services.simpledb.model.DeleteDomainRequest;
Expand Down Expand Up @@ -51,23 +52,24 @@ public synchronized void createDomain(String domain){
sdbc.createDomain(new CreateDomainRequest(domain));

ArrayList<ReplaceableAttribute> newAttributes = new ArrayList<ReplaceableAttribute>();
newAttributes.add(new ReplaceableAttribute(AttrName, " ", false));
newAttributes.add(new ReplaceableAttribute(AttrName, " ", true));
PutAttributesRequest newRequest = new PutAttributesRequest();

// UpdateCondition expected = new UpdateCondition();
// expected.setName(AttrName);
// expected.setExists(false);
UpdateCondition expected = new UpdateCondition();
expected.setName(AttrName);
expected.setExists(false);

newRequest.setDomainName(MEMBER_LIST_DOMAIN);
newRequest.setItemName(AttrName);

//newRequest.setExpected(expected);
newRequest.setExpected(expected);
newRequest.setAttributes(newAttributes);

try {
sdbc.putAttributes(newRequest);
} catch(Exception e){
e.printStackTrace();
} catch(ConditionalCheckFailedException e){
//e.printStackTrace();
System.out.println("Conditional Check failed, the attribute probably already exists.");
}
}

Expand Down Expand Up @@ -223,7 +225,7 @@ public void run() {
double probOfRefresh = 1.0/localMbrList.size();
double rand = generator.nextDouble();

if(rand <= probOfRefresh)
//if(rand <= probOfRefresh)
memberRefresh();
} catch (InterruptedException e) {
e.printStackTrace();
Expand Down

0 comments on commit 81a3d00

Please sign in to comment.