public boolean updateTaskStatus()

in amazon-ecs-java-starter-kit-task/src/main/java/software/aws/ecs/java/starterkit/util/DDBUtil.java [72:105]


	public boolean updateTaskStatus(DynamoDbClient ddbClient, String tableName, String hashKey, String rangeKey,
			long workflowId, String ecsTaskId, String status, String time, long execTimeinSeconds) {
		boolean operationSuccess = false;
		// populate Hash Key and Range Key
		Map<String, AttributeValue> key = new HashMap<String, AttributeValue>();
		key.put(hashKey, AttributeValue.builder().n(Long.toString(workflowId)).build());
		key.put(rangeKey, AttributeValue.builder().s(ecsTaskId).build());

		AttributeAction action = AttributeAction.PUT;
		Map<String, AttributeValueUpdate> attributeUpdates = new HashMap<String, AttributeValueUpdate>();
		attributeUpdates.put("status", AttributeValueUpdate.builder().action(action)
				.value(AttributeValue.builder().s(status).build()).build());
		attributeUpdates.put("update_time",
				AttributeValueUpdate.builder().action(action).value(AttributeValue.builder().s(time).build()).build());
		attributeUpdates.put("exec_time_in_seconds", AttributeValueUpdate.builder().action(action)
				.value(AttributeValue.builder().n(Long.toString(execTimeinSeconds)).build()).build());

		UpdateItemRequest updateItemRequest = UpdateItemRequest.builder().tableName(tableName).key(key)
				.attributeUpdates(attributeUpdates).build();
		try {
			UpdateItemResponse updateItemResponse = ddbClient.updateItem(updateItemRequest);
			if (updateItemResponse.sdkHttpResponse().isSuccessful()) {
				operationSuccess = true;
				System.out.printf("Update item operation with hash_key: %d and range_key: %s was successful. \n",
						workflowId, ecsTaskId);
			} else
				System.out.printf("Update item operation with hash_key: %d and range_key: %s was not successful. \n",
						workflowId, ecsTaskId);
		} catch (ResourceNotFoundException e) {
			e.printStackTrace();
			System.out.println("Table not found");
		}
		return operationSuccess;
	}