Skip to content
This repository was archived by the owner on Oct 5, 2021. It is now read-only.

Commit 27f19f7

Browse files
Alexander PatrikalakisAlexander Patrikalakis
authored andcommitted
[skip ci] Add docker scripts for use in the README tutorial.
1 parent 81d3a50 commit 27f19f7

14 files changed

+361
-64
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
/.settings
1717
.DS_Store
1818
*~
19+
/src/test/resources/dynamodb-janusgraph-docker/*.zip

NOTICE.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ Amazon DynamoDB Storage Backend for Titan
22
Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
33

44
This product includes software developed at
5-
Amazon Web Services, Inc. (http://aws.amazon.com/).
5+
Amazon Web Services, Inc. (http://aws.amazon.com/),
6+
Amazon Fulfillment Technologies (https://www.amazon.jobs/team/amazon-fulfillment-technologies-aft) and
7+
Amazon Japan (https://www.amazon.jobs/location/tokyo-area-japan).
68

79
**********************
810
THIRD PARTY COMPONENTS
911
**********************
1012
This software includes third party software subject to the following copyrights:
1113
- Titan: Distributed Graph Database - Copyright 2012 and onwards Aurelius. Apache License 2.0.
14+
- JanusGraph: Distributed Graph Database - Copyright 2017 and onwards. Apache License 2.0.
1215
- Guava: Google Core Libraries for Java - Copyright 2010 and onwards Google, Inc. Apache License 2.0.
1316
- rexster-service.sh - Copyright (c) 2009-Infinity, TinkerPop [http://tinkerpop.com]. BSD License.
1417

15-
The licenses for these third party components are included in LICENSE.txt
18+
The licenses for these third party components are included in LICENSE.txt.

README.md

Lines changed: 34 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -39,93 +39,75 @@ The graph has a vertex per comic book character with an edge to each of the
3939
comic books in which they appeared.
4040

4141
### Load a subset of the Marvel Universe Social Graph
42-
1. Install prerequisites and clone the repository in GitHub.
42+
1. Install the prerequisites (Git, JDK 1.8, Maven, Docker) of this tutorial.
43+
The command below uses a
44+
[convenience script for Amazon Linux](https://raw.githubusercontent.com/awslabs/dynamodb-janusgraph-storage-backend/master/src/test/resources/install-reqs.sh)
45+
on EC2 instances to install Git, Open JDK 1.8, Maven, and Docker. It adds the ec2-user to the docker group so that you can
46+
[execute Docker commands without using sudo](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html).
47+
Log out and back in to effect changes on ec2-user.
4348

4449
```bash
45-
sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo \
46-
-O /etc/yum.repos.d/epel-apache-maven.repo
47-
sudo sed -i s/\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo
48-
sudo yum update -y && sudo yum upgrade -y
49-
sudo yum install -y apache-maven sqlite-devel git java-1.8.0-openjdk-devel
50-
sudo alternatives --set java /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
51-
sudo alternatives --set javac /usr/lib/jvm/java-1.8.0-openjdk.x86_64/bin/javac
52-
git clone https://github.com/awslabs/dynamodb-titan-storage-backend.git
53-
cd dynamodb-titan-storage-backend
54-
```
55-
2. Run the `install` target to copy some dependencies to the target folder.
56-
57-
```bash
58-
mvn install
59-
```
60-
3. Start a new DynamoDB Local in a different shell.
61-
62-
```bash
63-
mvn test -Pstart-dynamodb-local
50+
curl https://raw.githubusercontent.com/awslabs/dynamodb-janusgraph-storage-backend/master/src/test/resources/install-reqs.sh | bash
51+
exit
6452
```
65-
4. Clean up old Elasticsearch indexes.
53+
2. Use Docker and Docker Compose to bake DynamoDB Local into a container and start Gremlin Server with the DynamoDB Storage Backend for
54+
JanusGraph installed.
6655

6756
```bash
68-
rm -rf elasticsearch
57+
docker build -t awslabs/dynamodblocal ./src/test/resources/dynamodb-local-docker \
58+
&& src/test/resources/install-gremlin-server.sh \
59+
&& cp server/dynamodb-janusgraph-storage-backend-*.zip src/test/resources/dynamodb-janusgraph-docker \
60+
&& mvn docker:build -Pdynamodb-janusgraph-docker \
61+
&& docker-compose -f src/test/resources/docker-compose.yml up -d \
62+
&& docker exec -i -t dynamodb-janusgraph /var/jg/bin/gremlin.sh
6963
```
70-
5. Install JanusGraph Server with the DynamoDB Storage Backend for JanusGraph, which
71-
includes Gremlin Server.
72-
73-
```bash
74-
src/test/resources/install-gremlin-server.sh
75-
```
76-
6. Change directories to the Gremlin Server home.
77-
78-
```bash
79-
cd server/dynamodb-janusgraph010-storage-backend-1.0.0
80-
```
81-
7. Start Gremlin Server with the DynamoDB Local configuration.
82-
83-
```bash
84-
bin/gremlin-server.sh ${PWD}/conf/gremlin-server/gremlin-server-local.yaml
85-
```
86-
8. Start a Gremlin shell with `bin/gremlin.sh` and connect to the Gremlin Server
87-
endpoint. Always execute commands on the server
64+
3. After the Gremlin shell starts, set it up to execute commands remotely.
8865

8966
```groovy
9067
:remote connect tinkerpop.server conf/remote.yaml session
9168
:remote console
9269
```
93-
9. Load the first 100 lines of the Marvel graph using the Gremlin shell.
70+
4. Load the first 100 lines of the Marvel graph using the Gremlin shell.
9471
9572
```groovy
9673
com.amazon.janusgraph.example.MarvelGraphFactory.load(graph, 100, false)
9774
```
98-
10. Print the characters and the comic-books they appeared in where the
75+
5. Print the characters and the comic-books they appeared in where the
9976
characters had a weapon that was a shield or claws.
10077
10178
```groovy
10279
g.V().has('weapon', within('shield','claws')).as('weapon', 'character', 'book').select('weapon', 'character','book').by('weapon').by('character').by(__.out('appeared').values('comic-book'))
10380
```
104-
11. Print the characters and the comic-books they appeared in where the
81+
6. Print the characters and the comic-books they appeared in where the
10582
characters had a weapon that was not a shield or claws.
10683
10784
```groovy
10885
g.V().has('weapon').has('weapon', without('shield','claws')).as('weapon', 'character', 'book').select('weapon', 'character','book').by('weapon').by('character').by(__.out('appeared').values('comic-book'))
10986
```
110-
12. Print a sorted list of the characters that appear in comic-book AVF 4.
87+
7. Print a sorted list of the characters that appear in comic-book AVF 4.
11188
11289
```groovy
11390
g.V().has('comic-book', 'AVF 4').in('appeared').values('character').order()
11491
```
115-
13. Print a sorted list of the characters that appear in comic-book AVF 4 that
92+
8. Print a sorted list of the characters that appear in comic-book AVF 4 that
11693
have a weapon that is not a shield or claws.
11794
11895
```groovy
11996
g.V().has('comic-book', 'AVF 4').in('appeared').has('weapon', without('shield','claws')).values('character').order()
12097
```
121-
14. Exit remote mode and Control-C to quit.
98+
9. Exit remote mode and Control-C to quit.
12299
123100
```groovy
124101
:remote console
125102
```
103+
10. Clean up the composed Docker containers.
104+
105+
```bash
106+
docker-compose -f src/test/resources/docker-compose.yml stop
107+
```
126108
127109
### Load the Graph of the Gods
128-
1. Repeat steps 1 through 8 of the Marvel graph section.
110+
1. Repeat steps 1 through 3 of the Marvel graph section.
129111
2. Load the Graph of the Gods.
130112
131113
```groovy
@@ -218,10 +200,9 @@ CloudFormation template that you just downloaded.
218200
6. On the Options page, click Next.
219201
7. On the Review page, select "I acknowledge that this template might cause AWS
220202
CloudFormation to create IAM resources." Then, click Create.
221-
8. Create an SSH tunnel from your localhost port 8182 to the Gremlin Server port (8182)
222-
on the EC2 host after the stack deployment is complete. The SSH tunnel command
223-
is one of the outputs of the CloudFormation script so you can just copy-paste it.
224-
9. Repeat steps 5, 6, and 8 of the Marvel graph section above.
203+
8. Start the Gremlin console on the host through SSH. You can just copy paste the `GremlinShell` output of the
204+
CloudFormation template and run it on your command line.
205+
9. Repeat step 3 of the Marvel graph section above.
225206
226207
## Data Model
227208
The Amazon DynamoDB Storage Backend for JanusGraph has a flexible data model that
@@ -412,8 +393,8 @@ credential configuration.
412393
sudo yum install -y apache-maven sqlite-devel git java-1.8.0-openjdk-devel
413394
sudo alternatives --set java /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
414395
sudo alternatives --set javac /usr/lib/jvm/java-1.8.0-openjdk.x86_64/bin/javac
415-
git clone https://github.com/awslabs/dynamodb-titan-storage-backend.git
416-
cd dynamodb-titan-storage-backend && mvn install
396+
git clone https://github.com/awslabs/dynamodb-janusgraph-storage-backend.git
397+
cd dynamodb-janusgraph-storage-backend && mvn install
417398
```
418399
2. Open a screen so that you can log out of the EC2 instance while running tests with `screen`.
419400
3. Run the single-item data model tests.

dynamodb-janusgraph-storage-backend-cfn.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ Outputs:
551551
- Fn::GetAtt:
552552
- WebServerInstance
553553
- PublicDnsName
554-
- " /usr/local/packages/dynamodb-janusgraph010-storage-backend-1.0.0/bin/gremlin.sh"
554+
- " /usr/local/packages/dynamodb-janusgraph-storage-backend-1.1.0/bin/gremlin.sh"
555555
Description: Use this remote shell to interact with the graph.
556556
GremlinServerEndpoint:
557557
Value:

pom.xml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<hadoop.version>2.2.0</hadoop.version>
3737
<mockito.version>1.9.5</mockito.version>
3838
<lombok.version>1.16.16</lombok.version>
39+
<docker.maven.version>0.4.13</docker.maven.version>
3940
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
4041
<include.category></include.category>
4142
<exclude.category></exclude.category>
@@ -256,6 +257,31 @@
256257
</plugins>
257258
</build>
258259
<profiles>
260+
<profile>
261+
<id>dynamodb-janusgraph-docker</id>
262+
<build>
263+
<pluginManagement>
264+
<plugins>
265+
<plugin>
266+
<groupId>com.spotify</groupId>
267+
<artifactId>docker-maven-plugin</artifactId>
268+
<version>${docker.maven.version}</version>
269+
<configuration>
270+
<dockerDirectory>${project.basedir}/src/test/resources/dynamodb-janusgraph-docker</dockerDirectory>
271+
<buildArgs>
272+
<server_zip>dynamodb-janusgraph-storage-backend-${project.version}.zip</server_zip>
273+
</buildArgs>
274+
<forceTags>true</forceTags>
275+
<imageName>dynamodb-janusgraph/server</imageName>
276+
<imageTags>
277+
<imageTag>${project.version}</imageTag>
278+
</imageTags>
279+
</configuration>
280+
</plugin>
281+
</plugins>
282+
</pluginManagement>
283+
</build>
284+
</profile>
259285
<profile>
260286
<id>integration-tests</id>
261287
<build>
@@ -266,7 +292,7 @@
266292
<version>${download.maven.plugin.version}</version>
267293
<executions>
268294
<execution>
269-
<id>install-dynamodb_local</id>
295+
<id>install-dynamodb-local</id>
270296
<phase>pre-integration-test</phase>
271297
<goals>
272298
<goal>wget</goal>
@@ -286,13 +312,13 @@
286312
<version>0.4</version>
287313
<executions>
288314
<execution>
289-
<id>dynamodb_local</id>
315+
<id>dynamodb-local</id>
290316
<phase>pre-integration-test</phase>
291317
<goals>
292318
<goal>start</goal>
293319
</goals>
294320
<configuration>
295-
<name>dynamodb_local</name>
321+
<name>dynamodb-local</name>
296322
<waitAfterLaunch>1</waitAfterLaunch>
297323
<arguments>
298324
<argument>java</argument>
@@ -310,7 +336,9 @@
310336
<execution>
311337
<id>stop-jar-process</id>
312338
<phase>post-integration-test</phase>
313-
<goals><goal>stop-all</goal></goals>
339+
<goals>
340+
<goal>stop-all</goal>
341+
</goals>
314342
</execution>
315343
</executions>
316344
</plugin>

src/test/resources/docker-compose.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
# Portions copyright 2017 JanusGraph authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License").
6+
# You may not use this file except in compliance with the License.
7+
# A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0
10+
#
11+
# or in the "license" file accompanying this file. This file is distributed
12+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13+
# express or implied. See the License for the specific language governing
14+
# permissions and limitations under the License.
15+
#
16+
version: '2.1'
17+
services:
18+
dynamodb-janusgraph:
19+
image: dynamodb-janusgraph/server:latest
20+
container_name: dynamodb-janusgraph
21+
healthcheck:
22+
test: ["CMD-SHELL", "curl -f http://localhost:8182; if [ $$? -eq 22 ]; then exit 0; else exit 1; fi"]
23+
interval: 1s
24+
timeout: 20s
25+
retries: 20
26+
ports:
27+
- "8182:8182"
28+
depends_on:
29+
dynamodb-local:
30+
condition: service_healthy
31+
command: ["/var/jg/bin/gremlin-server.sh", "./conf/gremlin-server/gremlin-server-local-docker.yaml"]
32+
dynamodb-local:
33+
image: awslabs/dynamodblocal:latest
34+
container_name: dynamodb_local
35+
healthcheck:
36+
test: ["CMD-SHELL", "curl -f http://localhost:8000/shell/ || exit 1"]
37+
interval: 1s
38+
timeout: 10s
39+
retries: 3
40+
ports:
41+
- "8000:8000"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
# Portions copyright 2017 JanusGraph authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License").
6+
# You may not use this file except in compliance with the License.
7+
# A copy of the License is located at
8+
#
9+
# http://aws.amazon.com/apache2.0
10+
#
11+
# or in the "license" file accompanying this file. This file is distributed
12+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13+
# express or implied. See the License for the specific language governing
14+
# permissions and limitations under the License.
15+
#
16+
FROM openjdk:8
17+
18+
ARG server_zip
19+
ADD ${server_zip} /var
20+
21+
RUN chmod a+x /usr/bin/wait-for-dynamodb-local.sh && \
22+
apt-get update -y && apt-get install -y zip && \
23+
server_base=`basename ${server_zip} .zip` && \
24+
unzip -q /var/${server_base}.zip -d /var && \
25+
mv /var/${server_base} /var/jg
26+
27+
WORKDIR /var/jg

0 commit comments

Comments
 (0)