List of usage examples for com.amazonaws.services.dynamodbv2.document DynamoDB DynamoDB
public DynamoDB(Regions regionEnum)
From source file:org.wildfly.camel.test.common.aws.DynamoDBUtils.java
License:Apache License
public static void deleteTable(AmazonDynamoDB client, String tableName) throws InterruptedException { new DynamoDB(client).getTable(tableName).delete(); }
From source file:org.xmlsh.aws.util.AWSDDBCommand.java
License:BSD License
protected DynamoDB getDynamotDB(Options opts) throws UnexpectedException, InvalidArgumentException { if (getAWSClient() == null) getDDBClient(opts);//from w w w. j a va 2s .c om assert (getAWSClient() != null); if (mDynamo == null) mDynamo = new DynamoDB(getAWSClient()); setDynamoDBOpts(opts); return mDynamo; }
From source file:oxwodwebdriver.DynamoHelper.java
public static void UploadProcessedWodDataToDynamoDB(String wod, String cardText) { System.out.println("About to upload data to DynamoDB"); BasicAWSCredentials awsCreds = new BasicAWSCredentials("", ""); AmazonDynamoDBClient client = new AmazonDynamoDBClient(awsCreds).withRegion(Regions.US_EAST_1); DynamoDB dynamoDB = new DynamoDB(client); Table table = dynamoDB.getTable("OxWod"); Map<String, String> expressionAttributeNames = new HashMap<String, String>(); expressionAttributeNames.put("#W", "Wod"); expressionAttributeNames.put("#C", "CardWod"); Map<String, Object> expressionAttributeValues = new HashMap<String, Object>(); expressionAttributeValues.put(":val1", wod); expressionAttributeValues.put(":val2", cardText); UpdateItemOutcome outcome = table.updateItem("Id", // key attribute name 1, // key attribute value "set #W = :val1, #C = :val2", // UpdateExpression expressionAttributeNames, expressionAttributeValues); System.out.println("Fnished uploading data to DynamoDB"); }
From source file:vfma.LoadSensorData.java
License:Open Source License
public ArrayList<RawSensorData> getSensorData(String lastTimestamp) throws VFMException { ArrayList<RawSensorData> rsdlist = new ArrayList<RawSensorData>(); try {/*from w w w .j av a2s .c o m*/ AmazonDynamoDBClient client = new AmazonDynamoDBClient() .withEndpoint("https://dynamodb.us-west-2.amazonaws.com"); DynamoDB dynamoDB = new DynamoDB(client); Table table = dynamoDB.getTable("sensorData"); ScanSpec scanSpec = new ScanSpec(); System.out.println("Get sensors..."); ItemCollection<ScanOutcome> items = table.scan(scanSpec); String lastTimeValue; Iterator<Item> iter = items.iterator(); while (iter.hasNext()) { Item item = iter.next(); RawSensorData rsd = new RawSensorData(); rsd.setTimestamp(item.getJSON("pass").replace("\"", "")); final JSONObject rawData = new JSONObject(item.getJSON("payload")); rsd.setSensorId(rawData.getString("sensor_id_time")); rsd.setPassing(rawData.getString("passing")); System.out.println("Read " + rsd.getSensorId()); if (rsd.getTimestamp().compareTo(lastTimestamp) > 0) rsdlist.add(rsd); lastTimeValue = rsd.getTimestamp(); } } catch (Exception e) { System.err.println("Unable to scan the table:"); System.err.println(e.getMessage()); } return rsdlist; }
From source file:ws.salient.aws.AmazonClientProvider.java
License:Apache License
public AmazonClientProvider() { Region region = Regions.getCurrentRegion(); if (region == null) { region = Region.getRegion(Regions.US_EAST_1); }//from w ww. j a v a 2 s . c om s3 = new AmazonS3Client().withRegion(region); kms = new AWSKMSClient().withRegion(region); dynamodb = new DynamoDB(new AmazonDynamoDBClient().withRegion(region)); lambda = new AWSLambdaClient().withRegion(region); }