Menu
Amazon DynamoDB
Developer Guide (API Version 2012-08-10)

Installing and Running the DynamoDB Storage Backend for Titan

The DynamoDB Storage Backend for Titan is available as an Apache Maven project on GitHub, and will run on Windows, Mac, or Linux computers. The DynamoDB Storage Backend for Titan requires Java 1.7 (or later) and Apache Maven. To get Java, go to http://java.com/download/. To get Apache Maven, go to http://maven.apache.org/. Follow the steps below to install the DynamoDB Storage Backend for Titan in your local Maven repository and test the installation.

Important

This documentation is for DynamoDB Storage Backend for Titan version 1.0. For information about previous versions, see the README.md file for Titan 0.4.4 and the README.md file for Titan 0.5.4.

The first example uses the Marvel Universe Social Graph. This graph has comic book characters as vertices, with edges to each comic book they appear in. For more information about the Marvel Universe Social Graph, go to the Marvel Universe Social Graph dataset webpage.

To load a subset of the Marvel Universe Social Graph

  1. In the folder where you want to set up the Git project, run the following command to clone the Git project.

    git clone https://github.com/awslabs/dynamodb-titan-storage-backend.git

    Note

    This git command is for Titan Version 1.0.0. For the Titan 0.4.4 git command, see the README.md file for Titan 0.4.4. For the Titan 0.5.4 git command, see the README.md file for Titan 0.5.4.

  2. Change into the dynamodb-titan-storage-backend folder, and then type the following command to install the package using Maven.

    mvn install

    When you install Maven, it downloads the additional dependencies from the Maven repository, including the Titan package.

  3. Open another command-prompt window, and then type the following command to start DynamoDB on your computer (for testing the graph database).

    mvn test -Pstart-dynamodb-local
  4. In the previous command-prompt window, type the following command to clean up old Elasticsearch indexes .

    rm -rf /tmp/searchindex
  5. Type the following command to install Gremlin Server with the DynamoDB Storage Backend for Titan.

    src/test/resources/install-gremlin-server.sh
  6. Type the following command to change directories to the Gremlin Server home directory.

    cd server/dynamodb-titan100-storage-backend-1.0.0-hadoop1

  7. Type the following command to start Gremlin Server configured to use the DynamoDB on your local machine.

    bin/gremlin-server.sh ${PWD}/conf/gremlin-server/gremlin-server-local.yaml

  8. In another command-prompt window, change directories to the Gremlin Server home.

    Then, type the following to start a Gremlin shell.

    bin/gremlin.sh
  9. In the Gremlin shell, type the following to connect to the Gremlin Server.

    :remote connect tinkerpop.server conf/remote.yaml

    Note

    The colon (:) is a required part of the command.

  10. Type the following command to load the first 100 lines of the Marvel Universe Social Graph.

    :> com.amazon.titan.example.MarvelGraphFactory.load(graph, 100, false)

    Important

    The :> characters at the beginning of the command are required. They indicate to the shell that these commands be run on the Gremlin Server that you connected to in the previous command.

    The remaining steps all use this same syntax.

    To increase the number of test lines and create a larger graph, raise the value of the second argument to the MarvelGraphFactory.load() method.

  11. Type the following to print the characters and the comic-books they appeared in where the characters had a weapon that was a shield or claws.

    :> g.V().as('character').has('weapon', within('shield','claws')).out('appeared').as('comic-book').select('character','comic-book')
  12. Type the following to print the characters and the comic-books they appeared in where the characters had a weapon that was not a shield or claws.

    :> g.V().as('character').has('weapon', without('shield','claws')).out('appeared').as('comic-book').select('character','comic-book')
  13. Type the following to print a sorted list of the characters that appear in comic-book AVF 4.

    :> g.V().has('comic-book', 'AVF 4').in('appeared').values('character').order()
  14. Print a sorted list of the characters that appear in comic-book AVF 4 that have a weapon that is not a shield or claws.

    :> g.V().has('comic-book', 'AVF 4').in('appeared').has('weapon', without('shield','claws')).values('character').order()

To load the Graph of the Gods

The Graph of the Gods is an example graph that is built into Titan and used in the Titan documentation. This procedure shows you how to load the Graph of the Gods with the DynamoDB Storage Backend for Titan, so you can follow the tutorial in the Titan Getting Started documentation.

  1. Follow steps 1 through 9 of the Marvel graph section.

  2. Type the following to load the Graph of the Gods.

     :> com.thinkaurelius.titan.example.GraphOfTheGodsFactory.load(graph)
  3. Go to the Titan Getting Started documentation and then follow the rest of the setup process, starting from the Global Graph Indices section.

    Important

    You need to prepend each command with :> to remotely execute the commands on the Gremlin Server endpoint.

    Also, you must prepend local variables definitions in the same line as traversals that include local variables.

    For example, to run the traversal g.V(hercules).out('father', 'mother').values('name') remotely, you would need to prepend it with the definition for Hercules:

    :> hercules = g.V(saturn).repeat(__.in('father')).times(2).next(); g.V(hercules).out('father', 'mother').values('name')

    However, since saturn is also a local variable, you must define it as well:

    :> saturn = g.V().has('name', 'saturn').next(); hercules = g.V(saturn).repeat(__.in('father')).times(2).next(); g.V(hercules).out('father', 'mother').values('name')

The reason these need to be prepended is that local variable state is not carried over for each remote script execution, except for the variables defined in the scripts that run when Gremlin server is turned on. See the scriptEngines/gremlin-groovy/scripts list element in the Gremlin Server YAML file for more information.