Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
DynamoDB Cookbook

You're reading from   DynamoDB Cookbook Over 90 hands-on recipes to design Internet scalable web and mobile applications with Amazon DynamoDB

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher
ISBN-13 9781784393755
Length 266 pages
Edition 1st Edition
Concepts
Arrow right icon
Author (1):
Arrow left icon
Tanmay Deshpande Tanmay Deshpande
Author Profile Icon Tanmay Deshpande
Tanmay Deshpande
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Taking Your First Steps with DynamoDB FREE CHAPTER 2. Operating with DynamoDB Tables 3. Manipulating DynamoDB Items 4. Managing DynamoDB Indexes 5. Exploring Higher Level Programming Interfaces for DynamoDB 6. Securing DynamoDB 7. DynamoDB Best Practices 8. Integrating DynamoDB with other AWS Services 9. Developing Web Applications using DynamoDB 10. Developing Mobile Applications using DynamoDB Index

Downloading and setting up DynamoDB Local

A call to any cloud resource may cost money to you, even if you are just doing development and not talking about any hosting in the production cluster. During development, we may need to try many things, and all those trials would cost us. The development best practices demand us to follow a test-driven development. For continuous integration and builds, it's good to run unit tests and integration tests to make sure that the build is intact. If we keep running unit tests and integration tests on the actual DynamoDB, we may end up paying a lot. To cater to this issue, we have something called as DynamoDB Local.

DynamoDB Local is a small client-side database and server that mimics the actual DynamoDB. It enables you to develop and test your code in the local environment, without modifying anything on the actual DynamoDB. It is compatible with the actual DynamoDB API, so there is no need to worry about duplicating your efforts.

Getting ready

DynamoDB Local is a Java Archive (JAR) file, which will run on the Windows, Mac, or Linux machines. To execute these APIs, you should have Java Runtime Engine (JRE) 6.0+ installed on your machine. You can refer to following docs to install JRE on your machine:

For Windows 64-bit machine: http://www.oracle.com/technetwork/java/javase/install-windows-64-142952.html.

For Windows 32-bit machine: http://www.oracle.com/technetwork/java/javase/install-windows-141940.html.

For Mac: http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jre.html.

How to do it…

You can download DynamoDB Local from the following locations:

Now, let's perform the following steps to install DynamoDB Local:

  1. Once done, just unzip the .jar file, and save it in a folder.
  2. Now use Command Prompt, go to the folder where you have unzipped the .jar file, and execute the following command:
    java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar
    

    You will see the jetty server getting started at http://localhost:8000:

    How to do it…
  3. Now you can use this as an endpoint for your development. For example, if we want to use it in the Java SDK, we can use this as follows:
    client = new AmazonDynamoDBClient(credentials);
    client.setEndpoint("http://localhost:8000");

    We will see more of its uses in the following chapters.

How it works…

DynamoDB Local is a simple .jar file that runs on your local machine and mimics the actual DynamoDB. You can do your development using DynamoDB, test your code, and simply redirect to the actual DynamoDB whenever it is ready for production deployment. Even though DynamoDB Local mimics most of the DynamoDB features, it does not support some important ones, which are as follows:

  • It does not consider the provisioned throughput settings while making any calls.
  • It does not throttle the read or write activity. The CreateTable, UpdateTable, and DeleteTable operations occur immediately. The table state is always ACTIVE.
  • It does not keep track of the consumed capacity units. So, it always returns null instead of the actual capacity units.
  • Read operations in DynamoDB are eventually consistent, but due to the speed of DynamoDB Local, it appears to be strongly consistent.

There's more…

The DynamoDB Local .jar gives you various other options in addition in order to manage DynamoDB Local smoothly. Here are some more options:

The -help function will list all the options available with DynamoDB Local JAR, as shown in the following command:

java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar – help

The output is shown in the following command:

There's more…
You have been reading a chapter from
DynamoDB Cookbook
Published in: Sep 2015
Publisher:
ISBN-13: 9781784393755
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image