├── .gitignore ├── .travis.yml ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── buildspec.yml ├── checkstyle.xml ├── dynamodb-janusgraph-storage-backend-cfn.yaml ├── dynamodb-janusgraph-tables-multiple.yaml ├── dynamodb-janusgraph-tables-single.yaml ├── pom.xml └── src ├── main ├── java │ └── com │ │ ├── amazon │ │ └── janusgraph │ │ │ ├── diskstorage │ │ │ └── dynamodb │ │ │ │ ├── AbstractDynamoDbStore.java │ │ │ │ ├── AwsStore.java │ │ │ │ ├── BackendDataModel.java │ │ │ │ ├── BackendNotFoundException.java │ │ │ │ ├── BackendRuntimeException.java │ │ │ │ ├── Client.java │ │ │ │ ├── Constants.java │ │ │ │ ├── DynamoDBStoreManager.java │ │ │ │ ├── DynamoDbDelegate.java │ │ │ │ ├── DynamoDbSingleRowStore.java │ │ │ │ ├── DynamoDbStore.java │ │ │ │ ├── DynamoDbStoreFactory.java │ │ │ │ ├── DynamoDbStoreTransaction.java │ │ │ │ ├── ExponentialBackoff.java │ │ │ │ ├── Expression.java │ │ │ │ ├── GetItemResultWrapper.java │ │ │ │ ├── GetItemWorker.java │ │ │ │ ├── JanusGraphConfigUtil.java │ │ │ │ ├── ListTablesWorker.java │ │ │ │ ├── MetricStore.java │ │ │ │ ├── PaginatingTask.java │ │ │ │ ├── QueryResultWrapper.java │ │ │ │ ├── QueryWithLimitWorker.java │ │ │ │ ├── QueryWorker.java │ │ │ │ ├── TableNameDynamoDbStoreFactory.java │ │ │ │ ├── builder │ │ │ │ ├── AbstractBuilder.java │ │ │ │ ├── ConditionExpressionBuilder.java │ │ │ │ ├── EntryBuilder.java │ │ │ │ ├── FilterExpressionBuilder.java │ │ │ │ ├── ItemBuilder.java │ │ │ │ ├── KeyBuilder.java │ │ │ │ ├── MultiUpdateExpressionBuilder.java │ │ │ │ ├── SingleExpectedAttributeValueBuilder.java │ │ │ │ └── SingleUpdateBuilder.java │ │ │ │ ├── iterator │ │ │ │ ├── MultiRecordIterator.java │ │ │ │ ├── MultiRowParallelScanInterpreter.java │ │ │ │ ├── MultiRowSequentialScanInterpreter.java │ │ │ │ ├── ParallelScanner.java │ │ │ │ ├── ScanBackedKeyIterator.java │ │ │ │ ├── ScanContext.java │ │ │ │ ├── ScanContextInterpreter.java │ │ │ │ ├── ScanSegmentWorker.java │ │ │ │ ├── Scanner.java │ │ │ │ ├── SequentialScanner.java │ │ │ │ ├── SingleKeyRecordIterator.java │ │ │ │ ├── SingleRowScanInterpreter.java │ │ │ │ └── StaticRecordIterator.java │ │ │ │ └── mutation │ │ │ │ ├── DeleteItemWorker.java │ │ │ │ ├── MutateWorker.java │ │ │ │ ├── SingleUpdateWithCleanupWorker.java │ │ │ │ └── UpdateItemWorker.java │ │ │ └── example │ │ │ └── MarvelGraphFactory.java │ │ └── google │ │ └── common │ │ └── util │ │ └── concurrent │ │ └── RateLimiterCreator.java └── resources │ └── META-INF │ └── marvel.csv └── test ├── java └── com │ ├── amazon │ └── janusgraph │ │ ├── ClientTest.java │ │ ├── DynamoDbStoreTransactionTest.java │ │ ├── GraphOfTheGodsTest.java │ │ ├── MarvelTest.java │ │ ├── ScenarioTests.java │ │ ├── TestCiHeartbeat.java │ │ ├── TestGraphUtil.java │ │ ├── diskstorage │ │ └── dynamodb │ │ │ ├── AbstractDynamoDBIDAuthorityTest.java │ │ │ ├── AbstractDynamoDBLogTest.java │ │ │ ├── AbstractDynamoDBMultiWriteStoreTest.java │ │ │ ├── AbstractDynamoDbStoreTest.java │ │ │ ├── DynamoDBLockStoreTest.java │ │ │ ├── DynamoDbDelegateTest.java │ │ │ ├── MultiDynamoDBIDAuthorityTest.java │ │ │ ├── MultiDynamoDBLogTest.java │ │ │ ├── MultiDynamoDBMultiWriteStoreTest.java │ │ │ ├── MultiDynamoDBStoreTest.java │ │ │ ├── SingleDynamoDBIDAuthorityTest.java │ │ │ ├── SingleDynamoDBLogTest.java │ │ │ ├── SingleDynamoDBMultiWriteStoreTest.java │ │ │ └── SingleDynamoDBStoreTest.java │ │ ├── graphdb │ │ └── dynamodb │ │ │ ├── AbstractDynamoDBEventualGraphTest.java │ │ │ ├── AbstractDynamoDBGraphConcurrentTest.java │ │ │ ├── AbstractDynamoDBGraphIterativeTest.java │ │ │ ├── AbstractDynamoDBGraphPerformanceMemoryTest.java │ │ │ ├── AbstractDynamoDBGraphSpeedTest.java │ │ │ ├── AbstractDynamoDBGraphTest.java │ │ │ ├── AbstractDynamoDBOLAPTest.java │ │ │ ├── AbstractDynamoDBOperationCountingTest.java │ │ │ ├── AbstractDynamoDBPartitionGraphTest.java │ │ │ ├── MultiDynamoDBEventualGraphTest.java │ │ │ ├── MultiDynamoDBGraphConcurrentTest.java │ │ │ ├── MultiDynamoDBGraphPerformanceMemoryTest.java │ │ │ ├── MultiDynamoDBGraphSpeedTest.java │ │ │ ├── MultiDynamoDBGraphTest.java │ │ │ ├── MultiDynamoDBOLAPTest.java │ │ │ ├── MultiDynamoDBOperationCountingTest.java │ │ │ ├── MultiDynamoDBPartitionGraphTest.java │ │ │ ├── SingleDynamoDBEventualGraphTest.java │ │ │ ├── SingleDynamoDBGraphConcurrentTest.java │ │ │ ├── SingleDynamoDBGraphPerformanceMemoryTest.java │ │ │ ├── SingleDynamoDBGraphSpeedTest.java │ │ │ ├── SingleDynamoDBGraphTest.java │ │ │ ├── SingleDynamoDBOLAPTest.java │ │ │ ├── SingleDynamoDBOperationCountingTest.java │ │ │ ├── SingleDynamoDBPartitionGraphTest.java │ │ │ └── TestCombination.java │ │ ├── testcategory │ │ ├── GraphSimpleLogTestCategory.java │ │ ├── IsolateMultiConcurrentGetSlice.java │ │ ├── IsolateMultiConcurrentGetSliceAndMutate.java │ │ ├── IsolateMultiEdgesExceedCacheSize.java │ │ ├── IsolateMultiLargeJointIndexRetrieval.java │ │ ├── IsolateMultiVertexCentricQuery.java │ │ ├── IsolateRemainingTestsCategory.java │ │ ├── IsolateSingleConcurrentGetSlice.java │ │ ├── IsolateSingleConcurrentGetSliceAndMutate.java │ │ ├── MultiDynamoDBGraphTestCategory.java │ │ ├── MultiDynamoDBMultiWriteStoreTestCategory.java │ │ ├── MultiDynamoDBOLAPTestCategory.java │ │ ├── MultiDynamoDBStoreTestCategory.java │ │ ├── MultiIdAuthorityLogStoreCategory.java │ │ ├── MultipleItemTestCategory.java │ │ ├── SingleDynamoDBGraphTestCategory.java │ │ ├── SingleDynamoDBMultiWriteStoreTestCategory.java │ │ ├── SingleDynamoDBOLAPTestCategory.java │ │ ├── SingleDynamoDBStoreTestCategory.java │ │ ├── SingleIdAuthorityLogStoreCategory.java │ │ └── SingleItemTestCategory.java │ │ └── testutils │ │ ├── CiHeartbeat.java │ │ └── HeartbeatTimerTask.java │ └── google │ └── common │ └── util │ └── concurrent │ └── RateLimiterCreatorTest.java └── resources ├── META-INF └── HotelTriples.txt ├── current-gen-instance-types ├── docker-compose.yml ├── dynamodb-janusgraph-docker └── Dockerfile ├── dynamodb-local-docker.properties ├── dynamodb-local-docker └── Dockerfile ├── dynamodb-local.properties ├── dynamodb.properties ├── get-recent-al-amis.sh ├── gremlin-server-local-docker.yaml ├── gremlin-server-local.yaml ├── gremlin-server-service.sh ├── gremlin-server.yaml ├── install-gremlin-server.sh ├── install-reqs.sh ├── janusgraph-0.2.0-hadoop2.zip.asc ├── log4j.properties ├── remote.yaml ├── titan-upgrade.properties └── type-to-arch.sh /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /pom.xml.tag 3 | /pom.xml.releaseBackup 4 | /pom.xml.versionsBackup 5 | /pom.xml.next 6 | /release.properties 7 | /dependency-reduced-pom.xml 8 | /buildNumber.properties 9 | /.mvn/timing.properties 10 | /server 11 | /elasticsearch 12 | /*.iml 13 | /.idea 14 | /.project 15 | /.classpath 16 | /.settings 17 | .DS_Store 18 | *~ 19 | /src/test/resources/dynamodb-janusgraph-docker/*.zip 20 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | sudo: required 3 | dist: trusty 4 | jdk: 5 | - oraclejdk8 6 | cache: 7 | directories: 8 | - "${HOME}/.m2" 9 | env: 10 | matrix: 11 | #32 minutes 12 | - MODULE="MultiStoreTest" CATEGORY="MultiDynamoDBStoreTestCategory" 13 | #22 minutes 14 | - MODULE="MultiVertexCentricQuery" CATEGORY="IsolateMultiVertexCentricQuery" 15 | #17.5 minutes 16 | - MODULE="SingleGraphTest" CATEGORY="SingleDynamoDBGraphTestCategory" 17 | #17.3 minutes 18 | - MODULE="SingleStoreTest" CATEGORY="SingleDynamoDBStoreTestCategory" 19 | #16.5 minutes 20 | - MODULE="MultiLargeJointIndexRetrieval" CATEGORY="IsolateMultiLargeJointIndexRetrieval" 21 | #15.7 minutes 22 | - MODULE="MultiOLAPTest" CATEGORY="MultiDynamoDBOLAPTestCategory" 23 | #13.5 minutes 24 | - MODULE="MultiGraphTest" CATEGORY="MultiDynamoDBGraphTestCategory" 25 | #11.8 minutes 26 | - MODULE="MultiEdgesExceedCacheSize" CATEGORY="IsolateMultiEdgesExceedCacheSize" 27 | #12 minutes 28 | - MODULE="SingleIdAuthorityLogStore" CATEGORY="SingleIdAuthorityLogStoreCategory" 29 | #11 minutes 30 | - MODULE="MultiIdAuthorityLogStore" CATEGORY="MultiIdAuthorityLogStoreCategory" 31 | #9 minutes 32 | - MODULE="SingleOLAPTest" CATEGORY="SingleDynamoDBOLAPTestCategory" 33 | #8.7 minutes 34 | - MODULE="MultiConcurrentGetSliceAndMutate" CATEGORY="IsolateMultiConcurrentGetSliceAndMutate" 35 | #8.5 minutes 36 | - MODULE="RemainingTestsCategory" CATEGORY="IsolateRemainingTestsCategory" 37 | #6.5 minutes 38 | - MODULE="MultiConcurrentGetSlice" CATEGORY="IsolateMultiConcurrentGetSlice" 39 | #6.4 minutes 40 | - MODULE="SingleConcurrentGetSliceAndMutate" CATEGORY="IsolateSingleConcurrentGetSliceAndMutate" 41 | #4.8 minutes 42 | - MODULE="SingleConcurrentGetSlice" CATEGORY="IsolateSingleConcurrentGetSlice" 43 | #3.2 44 | - MODULE="SingleMultiWriteStoreTestCategory" CATEGORY="SingleDynamoDBMultiWriteStoreTestCategory" 45 | #2.8 minutes 46 | - MODULE="MultiMultiWriteStoreTestCategory" CATEGORY="MultiDynamoDBMultiWriteStoreTestCategory" 47 | #To be added 48 | - MODULE="GraphSimpleLogTest" CATEGORY="GraphSimpleLogTestCategory" 49 | addons: 50 | apt: 51 | packages: 52 | - oracle-java8-installer 53 | branches: 54 | only: 55 | - 1.0.0 56 | - master 57 | - janusgraph 58 | script: 59 | #build the matrix item 60 | - mvn install -P integration-tests -Dgroups="com.amazon.janusgraph.testcategory.${CATEGORY}" -Dinclude.category="**/*.java" 61 | #validating cloudformation templates requires credentials. This will be a manual step, unfortunately. 62 | #- aws cloudformation validate-template --region us-west-2 --template-body `pwd | sed -e 's/\//\/\//g' -e 's/^/file:\//' -e 's/$/\/\/dynamodb-janusgraph-storage-backend-cfn\.yaml/'` 63 | #- aws cloudformation validate-template --region us-west-2 --template-body `pwd | sed -e 's/\//\/\//g' -e 's/^/file:\//' -e 's/$/\/\/dynamodb-janusgraph-tables-single\.yaml/'` 64 | #- aws cloudformation validate-template --region us-west-2 --template-body `pwd | sed -e 's/\//\/\//g' -e 's/^/file:\//' -e 's/$/\/\/dynamodb-janusgraph-tables-multiple\.yaml/'` 65 | notifications: 66 | email: 67 | - amcp@amazon.co.jp 68 | - johanjcbs@gmail.com 69 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Amazon DynamoDB Storage Backend for Titan 2 | Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | 4 | This product includes software developed at 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). 8 | 9 | ********************** 10 | THIRD PARTY COMPONENTS 11 | ********************** 12 | This software includes third party software subject to the following copyrights: 13 | - 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. 15 | - Guava: Google Core Libraries for Java - Copyright 2010 and onwards Google, Inc. Apache License 2.0. 16 | - rexster-service.sh - Copyright (c) 2009-Infinity, TinkerPop [http://tinkerpop.com]. BSD License. 17 | 18 | The licenses for these third party components are included in LICENSE.txt. 19 | -------------------------------------------------------------------------------- /buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.1 2 | 3 | phases: 4 | build: 5 | commands: 6 | - echo Build started on `date` 7 | - mvn install 8 | # From README.md, use: MultipleItemTestCategory, SingleItemTestCategory, IsolateGraphFailingTestCategory for CATEGORY 9 | - mvn verify -Pintegration-tests -Dgroups="com.amazon.janusgraph.testcategory.${CATEGORY}" -Dinclude.category="**/*.java" 10 | - aws cloudformation validate-template --template-body `pwd | sed -e 's/\//\/\//g' -e 's/^/file:\//' -e 's/$/\/\/dynamodb-janusgraph-storage-backend-cfn\.yaml/'` 11 | - src/test/resources/install-gremlin-server.sh 12 | post_build: 13 | commands: 14 | - echo Build completed on `date` 15 | artifacts: 16 | files: 17 | - target/**/* 18 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/AwsStore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import java.util.Collection; 18 | import java.util.Map; 19 | 20 | import org.janusgraph.diskstorage.BackendException; 21 | import org.janusgraph.diskstorage.StaticBuffer; 22 | import org.janusgraph.diskstorage.keycolumnvalue.KCVMutation; 23 | import org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStore; 24 | 25 | import com.amazon.janusgraph.diskstorage.dynamodb.mutation.MutateWorker; 26 | 27 | /** 28 | * Responsible for communicating with a single AWS backing store table. 29 | * 30 | * @author Matthew Sowders 31 | * @author Alexander Patrikalakis 32 | * 33 | */ 34 | public interface AwsStore extends KeyColumnValueStore { 35 | 36 | /** 37 | * Creates the KCV store and underlying DynamoDB tables. 38 | * @throws BackendException if unable to ensure the underlying store 39 | */ 40 | void ensureStore() throws BackendException; 41 | 42 | /** 43 | * Deletes the KCV store and underlying DynamoDB tables. 44 | * @throws BackendException 45 | */ 46 | void deleteStore() throws BackendException; 47 | 48 | /** 49 | * Titan relies on static store names to be used, but we want the ability to 50 | * have multiple graphs in a single region, so prepend a configurable prefix to the 51 | * underlying table names of each graph and get the DynamoDB table name with this method 52 | * 53 | * @return the table name corresponding to the KCVStore 54 | */ 55 | String getTableName(); 56 | 57 | /** 58 | * Creates workers whose job it is to commit the actual mutations in the given mutation map. 59 | * @param mutationMap 60 | * @param txh 61 | * @return a collection of MutateWorker objects that when executed will commit all changes specified by mutationMap 62 | */ 63 | Collection createMutationWorkers(Map mutationMap, 64 | DynamoDbStoreTransaction txh); 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/BackendDataModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import lombok.Getter; 18 | import lombok.RequiredArgsConstructor; 19 | 20 | /** 21 | * Creates a store backend based on configuration. 22 | * 23 | * @author Matthew Sowders 24 | * 25 | */ 26 | @RequiredArgsConstructor 27 | public enum BackendDataModel { 28 | SINGLE("Single") { 29 | @Override 30 | public AwsStore createStoreBackend(final DynamoDBStoreManager manager, final String prefix, final String name) { 31 | return new DynamoDbSingleRowStore(manager, prefix, name); 32 | } 33 | }, 34 | MULTI("Multiple") { 35 | @Override 36 | public AwsStore createStoreBackend(final DynamoDBStoreManager manager, final String prefix, final String name) { 37 | return new DynamoDbStore(manager, prefix, name); 38 | } 39 | }; 40 | 41 | @Getter 42 | private final String camelCaseName; 43 | 44 | public abstract AwsStore createStoreBackend(DynamoDBStoreManager manager, String prefix, String name); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/BackendNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | 18 | import org.janusgraph.diskstorage.PermanentBackendException; 19 | 20 | /** 21 | * Interpretation of DynamoDB ResourceNotFoundException 22 | * @author Alexander Patrikalakis 23 | * 24 | */ 25 | public class BackendNotFoundException extends PermanentBackendException { 26 | 27 | private static final long serialVersionUID = 5595152932709453493L; 28 | 29 | public BackendNotFoundException(final String msg, final Throwable cause) { 30 | super(msg, cause); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/BackendRuntimeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | 18 | import org.janusgraph.diskstorage.BackendException; 19 | 20 | /** 21 | * This class wraps around StorageExceptions in the Amazon DynamoDB Storage Backend for Titan, 22 | * a checked exception 23 | * @author Alexander Patrikalakis 24 | * 25 | */ 26 | public class BackendRuntimeException extends RuntimeException { 27 | BackendRuntimeException(final String str) { 28 | super(str); 29 | } 30 | public BackendRuntimeException(final BackendException e) { 31 | super(e); 32 | } 33 | 34 | public BackendException getBackendException() { 35 | final Throwable throwable = super.getCause(); 36 | if (throwable instanceof BackendException) { 37 | return (BackendException) throwable; 38 | } 39 | return null; 40 | } 41 | 42 | private static final long serialVersionUID = 6184087040805925812L; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/DynamoDbStoreFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import org.janusgraph.diskstorage.BackendException; 18 | 19 | /** 20 | * Creates a backend store for a given table name. 21 | * 22 | * @author Matthew Sowders 23 | * 24 | */ 25 | public interface DynamoDbStoreFactory { 26 | /** 27 | * Creates a backend store for a given table name. 28 | * 29 | * @param prefix the prefix of the table name. For example if prefix was foo and name was bar, 30 | * the full table name would be foo_bar. The prefix is shared by all stores created by a factory. 31 | * @param name the name of the KCVStore, without the prefix. 32 | * @return a KCVStore with the given name and table prefix 33 | * @throws BackendException 34 | */ 35 | AwsStore create(DynamoDBStoreManager manager, String prefix, String name) throws BackendException; 36 | 37 | /** 38 | * Gets all stores created by this factory. 39 | * 40 | * @return an Iterable of all the stores interned in this factory 41 | */ 42 | Iterable getAllStores(); 43 | 44 | /** 45 | * Gets backend store for store name. 46 | * 47 | * @param store the name of the store to get 48 | * @return the KCVStore that corresponds to the store name provided 49 | */ 50 | AwsStore getStore(String store); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/Expression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import java.util.Map; 18 | 19 | import com.amazonaws.services.dynamodbv2.model.AttributeValue; 20 | 21 | import lombok.Getter; 22 | import lombok.RequiredArgsConstructor; 23 | 24 | /** 25 | * Structure of update and condition expressions required for a DynamoDB conditional update. 26 | * 27 | * The expressions share an attribute value and name map. 28 | * @author Alexander Patrikalakis 29 | * @author Michael Rodaitis 30 | */ 31 | @RequiredArgsConstructor 32 | public class Expression { 33 | 34 | @Getter 35 | private final String updateExpression; 36 | @Getter 37 | private final String conditionExpression; 38 | private final Map attributeValues; 39 | 40 | public Map getAttributeValues() { 41 | // DynamoDB expects null expression maps when they are empty. 42 | if (attributeValues == null || attributeValues.isEmpty()) { 43 | return null; 44 | } 45 | return attributeValues; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/GetItemResultWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import org.janusgraph.diskstorage.StaticBuffer; 18 | 19 | import com.amazonaws.services.dynamodbv2.model.GetItemResult; 20 | 21 | import lombok.Getter; 22 | import lombok.RequiredArgsConstructor; 23 | 24 | /** 25 | * Titan's interface for multiqueries requires us to map GetItem results to a StaticBuffer. 26 | * This class is used to simplify that process by holding both relevant pieces of data in a POJO. 27 | */ 28 | @RequiredArgsConstructor 29 | @Getter 30 | public class GetItemResultWrapper { 31 | 32 | private final StaticBuffer janusGraphKey; 33 | private final GetItemResult dynamoDBResult; 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/GetItemWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import java.util.concurrent.Callable; 18 | 19 | import org.janusgraph.diskstorage.StaticBuffer; 20 | 21 | import com.amazonaws.services.dynamodbv2.model.GetItemRequest; 22 | import com.amazonaws.services.dynamodbv2.model.GetItemResult; 23 | 24 | /** 25 | * Worker class used to execute a GetItem request as a callable. 26 | * Used to allow multiqueries against SINGLE stores to execute across many threads. 27 | */ 28 | public class GetItemWorker implements Callable { 29 | 30 | private final GetItemRequest request; 31 | private final DynamoDbDelegate dynamoDbDelegate; 32 | private final StaticBuffer hashKey; 33 | 34 | public GetItemWorker(final StaticBuffer hashKey, final GetItemRequest request, final DynamoDbDelegate dynamoDbDelegate) { 35 | this.hashKey = hashKey; 36 | this.request = request; 37 | this.dynamoDbDelegate = dynamoDbDelegate; 38 | } 39 | 40 | @Override 41 | public GetItemResultWrapper call() throws Exception { 42 | final GetItemResult result = new ExponentialBackoff.GetItem(request, dynamoDbDelegate).runWithBackoff(); 43 | return new GetItemResultWrapper(hashKey, result); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/JanusGraphConfigUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import org.janusgraph.diskstorage.configuration.ConfigOption; 18 | import org.janusgraph.diskstorage.configuration.Configuration; 19 | 20 | final class JanusGraphConfigUtil { 21 | 22 | private JanusGraphConfigUtil() { 23 | } 24 | 25 | static T getNullableConfigValue(final Configuration config, final ConfigOption option) { 26 | if (config.has(option)) { 27 | return config.get(option); 28 | } 29 | return null; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/ListTablesWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | import org.janusgraph.diskstorage.BackendException; 21 | 22 | import com.amazonaws.services.dynamodbv2.model.ListTablesRequest; 23 | import com.amazonaws.services.dynamodbv2.model.ListTablesResult; 24 | 25 | import lombok.Getter; 26 | 27 | /** 28 | * This class merges multiple pages of table names into one ListTablesResult. 29 | * 30 | * @author Alexander Patrikalakis 31 | */ 32 | public class ListTablesWorker extends PaginatingTask { 33 | @Getter 34 | private final ListTablesRequest request = new ListTablesRequest(); 35 | private final List tableNames = new ArrayList<>(); 36 | 37 | ListTablesWorker(final DynamoDbDelegate delegate) { 38 | super(delegate, delegate.getListTablesApiName(), null /*tableName*/); 39 | } 40 | 41 | @Override 42 | public ListTablesResult next() throws BackendException { 43 | final ListTablesResult result = delegate.listTables(request); 44 | if (result.getLastEvaluatedTableName() != null && !result.getLastEvaluatedTableName().isEmpty()) { 45 | request.setExclusiveStartTableName(result.getLastEvaluatedTableName()); 46 | } else { //done 47 | markComplete(); 48 | } 49 | 50 | // c add scanned items 51 | tableNames.addAll(result.getTableNames()); 52 | return result; 53 | } 54 | 55 | @Override 56 | protected ListTablesResult getMergedPages() { 57 | return new ListTablesResult().withTableNames(tableNames); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/MetricStore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import java.util.Collection; 18 | import java.util.Map; 19 | 20 | import org.janusgraph.diskstorage.BackendException; 21 | import org.janusgraph.diskstorage.StaticBuffer; 22 | import org.janusgraph.diskstorage.keycolumnvalue.KCVMutation; 23 | import org.janusgraph.diskstorage.util.MetricInstrumentedStore; 24 | 25 | import com.amazon.janusgraph.diskstorage.dynamodb.mutation.MutateWorker; 26 | 27 | /** 28 | * Proxies another store to centralize metrics gathering. 29 | * 30 | * @author Matthew Sowders 31 | * 32 | */ 33 | public class MetricStore extends MetricInstrumentedStore implements AwsStore { 34 | private final AwsStore delegate; 35 | 36 | MetricStore(final AwsStore delegate) { 37 | super(delegate, delegate.getTableName()); 38 | this.delegate = delegate; 39 | } 40 | 41 | @Override 42 | public void deleteStore() throws BackendException { 43 | delegate.deleteStore(); 44 | } 45 | 46 | @Override 47 | public void ensureStore() throws BackendException { 48 | delegate.ensureStore(); 49 | } 50 | 51 | @Override 52 | public String getTableName() { 53 | return delegate.getTableName(); 54 | } 55 | 56 | @Override 57 | public Collection createMutationWorkers(final Map mutationMap, final DynamoDbStoreTransaction txh) { 58 | return delegate.createMutationWorkers(mutationMap, txh); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/PaginatingTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import java.util.concurrent.Callable; 18 | 19 | import org.janusgraph.diskstorage.BackendException; 20 | 21 | import lombok.Getter; 22 | import lombok.RequiredArgsConstructor; 23 | import lombok.experimental.Accessors; 24 | 25 | /** 26 | * Paginator base class for scan and query workers. 27 | * @param the result type of a page of data. 28 | * 29 | * @author Alexander Patrikalakis 30 | * 31 | */ 32 | @RequiredArgsConstructor 33 | public abstract class PaginatingTask implements Callable { 34 | protected final DynamoDbDelegate delegate; 35 | @Getter 36 | @Accessors(fluent = true) 37 | protected boolean hasNext = true; 38 | 39 | private int pagesProcessed = 0; 40 | private final String apiName; 41 | private final String tableName; 42 | 43 | /** 44 | * Paginates through pages of an entity. 45 | * @return an encapsulation of the pages of an entity 46 | * @throws BackendException if there was any trouble paginating 47 | */ 48 | public R call() throws BackendException { 49 | while (hasNext) { 50 | pagesProcessed++; 51 | next(); 52 | } 53 | delegate.updatePagesHistogram(apiName, tableName, pagesProcessed); 54 | return getMergedPages(); 55 | } 56 | 57 | /** 58 | * Merges all the pages iterated through in this instance and returns them. 59 | * @return a merged view of all the paged results of this iterator 60 | */ 61 | protected abstract R getMergedPages(); 62 | 63 | /** 64 | * Moves the iterator to the next page in preparation for another hasNext/processPage call. 65 | * @return the next page 66 | * @throws BackendException if there was an exception thrown by the backend. 67 | */ 68 | public abstract R next() throws BackendException; 69 | 70 | protected void markComplete() { 71 | hasNext = false; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/QueryResultWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import org.janusgraph.diskstorage.StaticBuffer; 18 | 19 | import com.amazonaws.services.dynamodbv2.model.QueryResult; 20 | 21 | import lombok.AccessLevel; 22 | import lombok.Getter; 23 | import lombok.RequiredArgsConstructor; 24 | 25 | /** 26 | * The QueryResultWrapper class associates the JanusGraph key that was used to create the QueryRequest 27 | * resulting in the enclosed QueryResult. 28 | * 29 | * @author Alexander Patrikalakis 30 | */ 31 | @RequiredArgsConstructor 32 | public class QueryResultWrapper { 33 | 34 | @Getter(AccessLevel.PACKAGE) 35 | private final StaticBuffer titanKey; 36 | @Getter 37 | private final QueryResult dynamoDBResult; 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/QueryWithLimitWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | import org.janusgraph.diskstorage.BackendException; 21 | import org.janusgraph.diskstorage.StaticBuffer; 22 | 23 | import com.amazonaws.services.dynamodbv2.model.AttributeValue; 24 | import com.amazonaws.services.dynamodbv2.model.QueryRequest; 25 | import com.google.common.base.Preconditions; 26 | import com.google.common.collect.Iterables; 27 | import com.google.common.collect.Lists; 28 | 29 | /** 30 | * QueryWorker that also enforces a limit on the total number of results it gathers before stopping. The number of items returned by this worker 31 | * will always be less than or equal to the given limit. 32 | */ 33 | public class QueryWithLimitWorker extends QueryWorker { 34 | 35 | private final int limit; 36 | 37 | QueryWithLimitWorker(final DynamoDbDelegate delegate, final QueryRequest request, final StaticBuffer titanKey, final int limit) { 38 | super(delegate, request, titanKey); 39 | this.limit = limit; 40 | request.setLimit(limit); 41 | } 42 | 43 | @Override 44 | public QueryResultWrapper next() throws BackendException { 45 | final QueryResultWrapper wrapper = super.next(); 46 | 47 | final int returnedCount = getReturnedCount(); 48 | // If we already have reached the limit for this query, we can stop making new requests 49 | if (returnedCount >= limit) { 50 | markComplete(); 51 | } else { 52 | // Make sure we don't ask DynamoDB for more results than we care about 53 | final int maxRemainingRecords = limit - returnedCount; 54 | Preconditions.checkState(maxRemainingRecords > 0); 55 | getRequest().setLimit(maxRemainingRecords); 56 | } 57 | return wrapper; 58 | } 59 | 60 | @Override 61 | protected List> getFinalItemList() { 62 | final Iterable> limitedIter = Iterables.limit(super.getFinalItemList(), limit); 63 | return Lists.newArrayList(limitedIter); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/TableNameDynamoDbStoreFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import java.util.concurrent.ConcurrentHashMap; 18 | import java.util.concurrent.ConcurrentMap; 19 | 20 | import org.janusgraph.diskstorage.BackendException; 21 | import org.janusgraph.diskstorage.PermanentBackendException; 22 | 23 | import lombok.extern.slf4j.Slf4j; 24 | 25 | /** 26 | * Creates backend store based on table name. 27 | * 28 | * @author Matthew Sowders 29 | * @author Alexander Patrikalakis 30 | * 31 | */ 32 | @Slf4j 33 | public class TableNameDynamoDbStoreFactory implements DynamoDbStoreFactory { 34 | private final ConcurrentMap stores = new ConcurrentHashMap<>(); 35 | 36 | @Override 37 | public AwsStore create(final DynamoDBStoreManager manager, final String prefix, final String name) throws BackendException { 38 | log.debug("Entering TableNameDynamoDbStoreFactory.create prefix:{} name:{}", prefix, name); 39 | // ensure there is only one instance used per table name. 40 | 41 | final Client client = manager.getClient(); 42 | final BackendDataModel model = client.dataModel(name); 43 | if (model == null) { 44 | throw new PermanentBackendException(String.format("Store name %s unknown. Set up user log / lock store in properties", name)); 45 | } 46 | final AwsStore storeBackend = model.createStoreBackend(manager, prefix, name); 47 | final AwsStore create = new MetricStore(storeBackend); 48 | final AwsStore previous = stores.putIfAbsent(name, create); 49 | if (null == previous) { 50 | try { 51 | create.ensureStore(); 52 | } catch (BackendException e) { 53 | client.getDelegate().shutdown(); 54 | throw e; 55 | } 56 | } 57 | final AwsStore store = stores.get(name); 58 | log.debug("Exiting TableNameDynamoDbStoreFactory.create prefix:{} name:{} returning:{}", prefix, name, store); 59 | return store; 60 | } 61 | 62 | @Override 63 | public Iterable getAllStores() { 64 | return stores.values(); 65 | } 66 | 67 | @Override 68 | public AwsStore getStore(final String store) { 69 | return stores.get(store); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/builder/AbstractBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.builder; 16 | 17 | import java.nio.ByteBuffer; 18 | import java.util.Arrays; 19 | import java.util.Map; 20 | 21 | import org.apache.commons.codec.DecoderException; 22 | import org.apache.commons.codec.binary.Hex; 23 | import org.janusgraph.diskstorage.StaticBuffer; 24 | import org.janusgraph.diskstorage.util.BufferUtil; 25 | import org.janusgraph.diskstorage.util.StaticArrayBuffer; 26 | 27 | import com.amazon.janusgraph.diskstorage.dynamodb.Constants; 28 | import com.amazonaws.services.dynamodbv2.model.AttributeValue; 29 | 30 | /** 31 | * AbstractBuilder is responsible for some of the StaticBuffer to String and 32 | * visa-versa required for working with the database. 33 | * 34 | * @author Matthew Sowders 35 | * @author Alexander Patrikalakis 36 | * 37 | */ 38 | public abstract class AbstractBuilder { 39 | 40 | protected AttributeValue encodeKeyAsAttributeValue(final StaticBuffer input) { 41 | return new AttributeValue().withS(encodeKeyBuffer(input)); 42 | } 43 | 44 | public static String encodeKeyBuffer(final StaticBuffer input) { 45 | if (input == null || input.length() == 0) { 46 | return null; 47 | } 48 | final ByteBuffer buf = input.asByteBuffer(); 49 | final byte[] bytes = Arrays.copyOf(buf.array(), buf.limit()); 50 | return Hex.encodeHexString(bytes); 51 | } 52 | 53 | protected AttributeValue encodeValue(final StaticBuffer value) { 54 | // Dynamo does not allow empty binary values, so we use a placeholder 55 | // for empty values 56 | if (value.length() <= 0) { 57 | return new AttributeValue().withS(Constants.EMPTY_BUFFER_PLACEHOLDER); 58 | } 59 | return new AttributeValue().withB(value.asByteBuffer()); 60 | } 61 | 62 | protected StaticBuffer decodeValue(final AttributeValue val) { 63 | if (null == val) { 64 | return null; 65 | } 66 | // Dynamo does not allow empty binary values, so we use a placeholder 67 | // for empty values 68 | if (Constants.EMPTY_BUFFER_PLACEHOLDER.equals(val.getS())) { 69 | return BufferUtil.emptyBuffer(); 70 | } 71 | return StaticArrayBuffer.of(val.getB()); 72 | } 73 | 74 | protected StaticBuffer decodeKey(final Map key, final String name) { 75 | if (null == key || !key.containsKey(name)) { 76 | return null; 77 | } 78 | final AttributeValue attributeValue = key.get(name); 79 | final String value = attributeValue.getS(); 80 | return decodeKey(value); 81 | } 82 | 83 | public static StaticBuffer decodeKey(final String name) { 84 | try { 85 | return new StaticArrayBuffer(Hex.decodeHex(name.toCharArray())); 86 | } catch (DecoderException e) { 87 | throw new RuntimeException(e); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/builder/FilterExpressionBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.builder; 16 | 17 | import java.util.HashMap; 18 | import java.util.Map; 19 | 20 | import org.janusgraph.diskstorage.StaticBuffer; 21 | import org.janusgraph.diskstorage.keycolumnvalue.SliceQuery; 22 | 23 | import com.amazon.janusgraph.diskstorage.dynamodb.Constants; 24 | import com.amazon.janusgraph.diskstorage.dynamodb.Expression; 25 | import com.amazonaws.services.dynamodbv2.model.AttributeValue; 26 | 27 | import lombok.Setter; 28 | import lombok.experimental.Accessors; 29 | 30 | /** 31 | * Builds filter expressions using the encoding of Titan data model 32 | * @author Michael Rodaitis 33 | * 34 | */ 35 | public class FilterExpressionBuilder extends AbstractBuilder { 36 | 37 | private final Map expressionAttributeValues = new HashMap<>(); 38 | @Setter 39 | @Accessors(fluent = true) 40 | private String label; 41 | private StaticBuffer startValue; 42 | private StaticBuffer endValue; 43 | 44 | public FilterExpressionBuilder rangeKey() { 45 | return label(Constants.JANUSGRAPH_RANGE_KEY); 46 | } 47 | 48 | public FilterExpressionBuilder range(final StaticBuffer start, final StaticBuffer end) { 49 | this.startValue = start; 50 | this.endValue = end; 51 | return this; 52 | } 53 | 54 | public FilterExpressionBuilder range(final SliceQuery slice) { 55 | this.startValue = slice.getSliceStart(); 56 | this.endValue = slice.getSliceEnd(); 57 | return this; 58 | } 59 | 60 | public Expression build() { 61 | 62 | final StringBuilder sb = new StringBuilder(); 63 | sb.append(label).append(" BETWEEN "); 64 | 65 | final String startVar = String.format(":s%s", label); 66 | final String endVar = String.format(":e%s", label); 67 | sb.append(startVar).append(" AND ").append(endVar); 68 | expressionAttributeValues.put(startVar, encodeKeyAsAttributeValue(startValue)); 69 | expressionAttributeValues.put(endVar, encodeKeyAsAttributeValue(endValue)); 70 | 71 | return new Expression(null /*updateExpression*/, sb.toString(), 72 | expressionAttributeValues); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/builder/ItemBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.builder; 16 | 17 | import java.util.Collections; 18 | import java.util.HashMap; 19 | import java.util.Map; 20 | 21 | import org.janusgraph.diskstorage.StaticBuffer; 22 | 23 | import com.amazon.janusgraph.diskstorage.dynamodb.Constants; 24 | import com.amazonaws.services.dynamodbv2.model.AttributeValue; 25 | 26 | /** 27 | * ItemBuilder is responsible for translating from StaticBuffers to DynamoDB 28 | * item maps. 29 | * 30 | * @author Matthew Sowders 31 | * 32 | */ 33 | public class ItemBuilder extends AbstractBuilder { 34 | 35 | private final Map item = new HashMap<>(); 36 | 37 | public ItemBuilder hashKey(final StaticBuffer key) { 38 | item.put(Constants.JANUSGRAPH_HASH_KEY, encodeKeyAsAttributeValue(key)); 39 | return this; 40 | } 41 | 42 | public ItemBuilder rangeKey(final StaticBuffer key) { 43 | item.put(Constants.JANUSGRAPH_RANGE_KEY, encodeKeyAsAttributeValue(key)); 44 | return this; 45 | } 46 | 47 | public ItemBuilder value(final StaticBuffer value) { 48 | item.put(Constants.JANUSGRAPH_VALUE, encodeValue(value)); 49 | return this; 50 | } 51 | 52 | public Map build() { 53 | return Collections.unmodifiableMap(item); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/builder/KeyBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.builder; 16 | 17 | import java.util.Map; 18 | 19 | import org.janusgraph.diskstorage.StaticBuffer; 20 | 21 | import com.amazonaws.services.dynamodbv2.model.AttributeValue; 22 | 23 | /** 24 | * KeyBuilder is responsible for extracting constant string attribute names from 25 | * DynamoDB item maps. 26 | * 27 | * @author Matthew Sowders 28 | * 29 | */ 30 | public class KeyBuilder extends AbstractBuilder { 31 | 32 | private final Map item; 33 | 34 | public KeyBuilder(final Map item) { 35 | this.item = item; 36 | } 37 | 38 | public StaticBuffer build(final String name) { 39 | return decodeKey(item, name); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/builder/MultiUpdateExpressionBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.builder; 16 | 17 | import java.util.Map; 18 | 19 | import org.janusgraph.diskstorage.StaticBuffer; 20 | 21 | import com.amazon.janusgraph.diskstorage.dynamodb.Constants; 22 | import com.amazon.janusgraph.diskstorage.dynamodb.DynamoDbStore; 23 | import com.amazon.janusgraph.diskstorage.dynamodb.DynamoDbStoreTransaction; 24 | import com.amazon.janusgraph.diskstorage.dynamodb.Expression; 25 | import com.amazonaws.services.dynamodbv2.model.AttributeValue; 26 | import com.google.common.collect.Maps; 27 | 28 | import lombok.AccessLevel; 29 | import lombok.NonNull; 30 | import lombok.RequiredArgsConstructor; 31 | import lombok.Setter; 32 | import lombok.experimental.Accessors; 33 | 34 | /** 35 | * Builder for update expressions for updating multi data model entries 36 | * @author Michael Rodaitis 37 | * 38 | */ 39 | @Setter(AccessLevel.PUBLIC) 40 | @Accessors(fluent = true) 41 | @RequiredArgsConstructor 42 | public class MultiUpdateExpressionBuilder extends AbstractBuilder { 43 | 44 | private static final String VALUE_LABEL = ":v"; 45 | private static final String EXPECTED_VALUE_LABEL = ":e"; 46 | private static final String MISSING_VALUE_EXPR = String.format("attribute_not_exists(%s)", Constants.JANUSGRAPH_VALUE); 47 | private static final String EXPECTED_VALUE_EXPR = String.format("%s = %s", Constants.JANUSGRAPH_VALUE, EXPECTED_VALUE_LABEL); 48 | private static final String SET_VALUE_EXPR = String.format("SET %s = %s", Constants.JANUSGRAPH_VALUE, VALUE_LABEL); 49 | 50 | @NonNull 51 | private final DynamoDbStore store; 52 | @NonNull 53 | private final DynamoDbStoreTransaction transaction; 54 | @Setter 55 | private StaticBuffer hashKey; 56 | @Setter 57 | private StaticBuffer rangeKey; 58 | @Setter 59 | private StaticBuffer value; 60 | 61 | /** 62 | * 63 | * @return 64 | */ 65 | public Expression build() { 66 | final Map attributeValues = Maps.newHashMap(); 67 | 68 | // This might be used for a DeleteItem, in which case the update expression should be null 69 | String updateExpression = null; 70 | if (value != null) { 71 | updateExpression = SET_VALUE_EXPR; 72 | final AttributeValue updateValue = encodeValue(value); 73 | attributeValues.put(VALUE_LABEL, updateValue); 74 | } 75 | 76 | // Condition expression and attribute value 77 | String conditionExpression = null; 78 | if (transaction.contains(store, hashKey, rangeKey)) { 79 | final StaticBuffer expectedValue = transaction.get(store, hashKey, rangeKey); 80 | if (expectedValue == null) { 81 | conditionExpression = MISSING_VALUE_EXPR; 82 | } else { 83 | final AttributeValue expectedAttributeValue = encodeValue(expectedValue); 84 | conditionExpression = EXPECTED_VALUE_EXPR; 85 | attributeValues.put(EXPECTED_VALUE_LABEL, expectedAttributeValue); 86 | } 87 | } 88 | 89 | // We aren't using any Titan column names in the expressions for MULTI records, so we don't need to label any argument names. 90 | return new Expression(updateExpression, conditionExpression, attributeValues); 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/builder/SingleExpectedAttributeValueBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.builder; 16 | 17 | import java.util.Map; 18 | 19 | import lombok.NonNull; 20 | import org.janusgraph.diskstorage.Entry; 21 | import org.janusgraph.diskstorage.StaticBuffer; 22 | import org.janusgraph.diskstorage.keycolumnvalue.KCVMutation; 23 | 24 | import com.amazon.janusgraph.diskstorage.dynamodb.DynamoDbSingleRowStore; 25 | import com.amazon.janusgraph.diskstorage.dynamodb.DynamoDbStoreTransaction; 26 | import com.amazonaws.services.dynamodbv2.model.AttributeValue; 27 | import com.amazonaws.services.dynamodbv2.model.ComparisonOperator; 28 | import com.amazonaws.services.dynamodbv2.model.ExpectedAttributeValue; 29 | import com.google.common.collect.Maps; 30 | 31 | import lombok.RequiredArgsConstructor; 32 | 33 | 34 | /** 35 | * Builder for ExpectedAttributeValue maps for updates to SINGLE records. 36 | * We avoid the use of expressions here 37 | * because we can exceed the max expression size for very large updates. 38 | * @author Michael Rodaitis 39 | * @author Alexander Patrikalakis 40 | */ 41 | @RequiredArgsConstructor 42 | public class SingleExpectedAttributeValueBuilder extends AbstractBuilder { 43 | 44 | @NonNull 45 | private final DynamoDbSingleRowStore store; 46 | @NonNull 47 | private final DynamoDbStoreTransaction transaction; 48 | @NonNull 49 | private final StaticBuffer key; 50 | 51 | public Map build(final KCVMutation mutation) { 52 | final Map expected = Maps.newHashMapWithExpectedSize(mutation.getTotalMutations()); 53 | 54 | for (Entry addedColumn : mutation.getAdditions()) { 55 | final StaticBuffer columnKey = addedColumn.getColumn(); 56 | addExpectedValueIfPresent(columnKey, expected); 57 | } 58 | 59 | for (StaticBuffer deletedKey : mutation.getDeletions()) { 60 | addExpectedValueIfPresent(deletedKey, expected); 61 | } 62 | 63 | return expected; 64 | } 65 | 66 | private void addExpectedValueIfPresent(final StaticBuffer column, final Map expectedValueMap) { 67 | final String dynamoDbColumn = encodeKeyBuffer(column); 68 | 69 | if (expectedValueMap.containsKey(dynamoDbColumn)) { 70 | return; 71 | } 72 | 73 | if (transaction.contains(store, key, column)) { 74 | final StaticBuffer expectedValue = transaction.get(store, key, column); 75 | final ExpectedAttributeValue expectedAttributeValue; 76 | if (expectedValue == null) { 77 | expectedAttributeValue = new ExpectedAttributeValue().withExists(false); 78 | } else { 79 | final AttributeValue attributeValue = encodeValue(expectedValue); 80 | expectedAttributeValue = new ExpectedAttributeValue().withValue(attributeValue) 81 | .withComparisonOperator(ComparisonOperator.EQ); 82 | } 83 | expectedValueMap.put(dynamoDbColumn, expectedAttributeValue); 84 | } 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/builder/SingleUpdateBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.builder; 16 | 17 | import java.util.HashMap; 18 | import java.util.List; 19 | import java.util.Map; 20 | 21 | import org.janusgraph.diskstorage.Entry; 22 | import org.janusgraph.diskstorage.StaticBuffer; 23 | 24 | import com.amazonaws.services.dynamodbv2.model.AttributeAction; 25 | import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; 26 | 27 | /** 28 | * UpdateBuilder is responsible for building AttributeValueUpdate maps to update 29 | * items in DynamoDB in the SINGLE data model. 30 | * 31 | * @author Matthew Sowders 32 | */ 33 | public class SingleUpdateBuilder extends AbstractBuilder { 34 | private final Map updates = new HashMap<>(); 35 | 36 | public SingleUpdateBuilder put(final StaticBuffer column, final StaticBuffer value) { 37 | updates.put(encodeKeyBuffer(column), 38 | new AttributeValueUpdate() 39 | .withAction(AttributeAction.PUT) 40 | .withValue(encodeValue(value))); 41 | return this; 42 | } 43 | 44 | public SingleUpdateBuilder additions(final List additions) { 45 | for (Entry addition : additions) { 46 | put(addition.getColumn(), addition.getValue()); 47 | } 48 | return this; 49 | } 50 | 51 | private SingleUpdateBuilder delete(final StaticBuffer column) { 52 | updates.put(encodeKeyBuffer(column), 53 | new AttributeValueUpdate() 54 | .withAction(AttributeAction.DELETE)); 55 | return this; 56 | } 57 | 58 | public Map build() { 59 | return new HashMap<>(updates); 60 | } 61 | 62 | public SingleUpdateBuilder deletions(final List deletions) { 63 | for (StaticBuffer deletion : deletions) { 64 | delete(deletion); 65 | } 66 | return this; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/iterator/ScanBackedKeyIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.iterator; 16 | 17 | import java.io.IOException; 18 | import java.util.Collections; 19 | import java.util.Iterator; 20 | import java.util.List; 21 | 22 | import org.janusgraph.diskstorage.Entry; 23 | import org.janusgraph.diskstorage.StaticBuffer; 24 | import org.janusgraph.diskstorage.keycolumnvalue.KeyIterator; 25 | import org.janusgraph.diskstorage.util.RecordIterator; 26 | 27 | /** 28 | * KeyIterator that is backed by a DynamoDB scan. This class is ignorant to the fact that 29 | * its backing scan might be running in parallel. The ScanContextInterpreter is expected to 30 | * be compatible with whatever scan order the scanner is using. 31 | * 32 | * @author Michael Rodaitis 33 | */ 34 | public class ScanBackedKeyIterator implements KeyIterator { 35 | 36 | private final Scanner scanner; 37 | private final ScanContextInterpreter interpreter; 38 | 39 | private SingleKeyRecordIterator current; 40 | private Iterator recordIterators = Collections.emptyIterator(); 41 | 42 | public ScanBackedKeyIterator(final Scanner scanner, final ScanContextInterpreter interpreter) { 43 | this.scanner = scanner; 44 | this.interpreter = interpreter; 45 | } 46 | 47 | @Override 48 | public RecordIterator getEntries() { 49 | return current.getRecordIterator(); 50 | } 51 | 52 | @Override 53 | public void close() throws IOException { 54 | scanner.close(); 55 | recordIterators = Collections.emptyIterator(); 56 | } 57 | 58 | @Override 59 | public boolean hasNext() { 60 | if (recordIterators.hasNext()) { 61 | return true; 62 | } 63 | 64 | while (scanner.hasNext() && !recordIterators.hasNext()) { 65 | nextScanResult(); 66 | } 67 | return recordIterators.hasNext(); 68 | } 69 | 70 | private void nextScanResult() { 71 | final ScanContext scanContext = scanner.next(); 72 | final List newIterators = interpreter.buildRecordIterators(scanContext); 73 | recordIterators = newIterators.iterator(); 74 | } 75 | 76 | @Override 77 | public StaticBuffer next() { 78 | current = recordIterators.next(); 79 | return current.getKey(); 80 | } 81 | 82 | @Override 83 | public void remove() { 84 | throw new UnsupportedOperationException("remove"); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/iterator/ScanContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.iterator; 16 | 17 | import com.amazonaws.services.dynamodbv2.model.ScanRequest; 18 | import com.amazonaws.services.dynamodbv2.model.ScanResult; 19 | 20 | import lombok.Getter; 21 | import lombok.RequiredArgsConstructor; 22 | 23 | /** 24 | * Holds the request and response for one "page" of a DynamoDB scan. 25 | * 26 | * @author Michael Rodaitis 27 | */ 28 | @Getter 29 | @RequiredArgsConstructor 30 | public class ScanContext { 31 | 32 | private final ScanRequest scanRequest; 33 | private final ScanResult scanResult; 34 | 35 | public boolean isFirstResult() { 36 | return scanRequest.getExclusiveStartKey() == null || scanRequest.getExclusiveStartKey().isEmpty(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/iterator/ScanContextInterpreter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.iterator; 16 | 17 | import java.util.List; 18 | 19 | /** 20 | * 21 | * @author Michael Rodaitis 22 | * 23 | */ 24 | public interface ScanContextInterpreter { 25 | 26 | /** 27 | * 28 | * @param scanContext 29 | * @return 30 | */ 31 | List buildRecordIterators(ScanContext scanContext); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/iterator/ScanSegmentWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.iterator; 16 | 17 | import java.util.Iterator; 18 | import java.util.concurrent.Callable; 19 | 20 | import org.janusgraph.diskstorage.BackendException; 21 | 22 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendRuntimeException; 23 | import com.amazon.janusgraph.diskstorage.dynamodb.DynamoDbDelegate; 24 | import com.amazon.janusgraph.diskstorage.dynamodb.ExponentialBackoff.Scan; 25 | import com.amazonaws.services.dynamodbv2.model.ScanRequest; 26 | import com.amazonaws.services.dynamodbv2.model.ScanResult; 27 | 28 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 29 | 30 | /** 31 | * This class executes multiple scan requests on one segment of a table in series, 32 | * as a runnable. Instances meant to be used as tasks of the worker thread pool for parallel 33 | * scans. 34 | * 35 | * @author Alexander Patrikalakis 36 | * 37 | */ 38 | public class ScanSegmentWorker implements Callable, Iterator { 39 | private final DynamoDbDelegate delegate; 40 | private final ScanRequest request; 41 | private boolean hasNext; 42 | private int lastConsumedCapacity; 43 | 44 | public ScanSegmentWorker(final DynamoDbDelegate delegate, final ScanRequest request) { 45 | this.delegate = delegate; 46 | this.request = DynamoDbDelegate.copyScanRequest(request); 47 | this.hasNext = true; 48 | this.lastConsumedCapacity = delegate.estimateCapacityUnits(DynamoDbDelegate.SCAN, request.getTableName()); 49 | } 50 | 51 | @SuppressFBWarnings(value = "IT_NO_SUCH_ELEMENT", 52 | justification = "https://github.com/awslabs/dynamodb-janusgraph-storage-backend/issues/222") 53 | @Override 54 | public ScanResult next() { 55 | final Scan backoff = new Scan(request, delegate, lastConsumedCapacity); 56 | ScanResult result = null; 57 | try { 58 | result = backoff.runWithBackoff(); //this will be non-null or runWithBackoff throws 59 | } catch (BackendException e) { 60 | throw new BackendRuntimeException(e); 61 | } 62 | 63 | if (result.getConsumedCapacity() != null) { 64 | lastConsumedCapacity = result.getConsumedCapacity().getCapacityUnits().intValue(); 65 | } 66 | 67 | if (result.getLastEvaluatedKey() != null && !result.getLastEvaluatedKey().isEmpty()) { 68 | hasNext = true; 69 | request.setExclusiveStartKey(result.getLastEvaluatedKey()); 70 | } else { 71 | hasNext = false; 72 | } 73 | 74 | return result; 75 | } 76 | 77 | @Override 78 | public boolean hasNext() { 79 | return hasNext; 80 | } 81 | 82 | @Override 83 | public ScanContext call() throws Exception { 84 | try { 85 | final ScanRequest originalRequest = DynamoDbDelegate.copyScanRequest(request); 86 | final ScanResult result = next(); 87 | return new ScanContext(originalRequest, result); 88 | } catch (BackendRuntimeException e) { 89 | throw e.getBackendException(); 90 | } 91 | } 92 | 93 | @Override 94 | public void remove() { 95 | throw new UnsupportedOperationException("deletion not supported"); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/iterator/Scanner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.iterator; 16 | 17 | import java.io.Closeable; 18 | import java.util.Iterator; 19 | 20 | /** 21 | * 22 | * @author Michael Rodaitis 23 | * 24 | */ 25 | public interface Scanner extends Iterator, Closeable { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/iterator/SingleKeyRecordIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.iterator; 16 | 17 | import org.janusgraph.diskstorage.Entry; 18 | import org.janusgraph.diskstorage.StaticBuffer; 19 | import org.janusgraph.diskstorage.util.RecordIterator; 20 | 21 | import lombok.AccessLevel; 22 | import lombok.Getter; 23 | import lombok.RequiredArgsConstructor; 24 | 25 | /** 26 | * Holds a reference to a key and a RecordIterator for entries that correspond to that key. 27 | * Used as an intermediate value holder in AbstractLazyKeyIterator. 28 | * 29 | * @author Matthew Sowders 30 | * @author Alexander Patrikalakis 31 | * @author Michael Rodaitis 32 | */ 33 | @RequiredArgsConstructor(access = AccessLevel.PACKAGE) 34 | public class SingleKeyRecordIterator { 35 | 36 | @Getter 37 | private final StaticBuffer key; 38 | @Getter(AccessLevel.PACKAGE) 39 | private final RecordIterator recordIterator; 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/iterator/StaticRecordIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.iterator; 16 | 17 | import java.io.IOException; 18 | import java.util.Iterator; 19 | 20 | import org.janusgraph.diskstorage.Entry; 21 | import org.janusgraph.diskstorage.util.RecordIterator; 22 | 23 | /** 24 | * Iterator for entries. This implementation is eagerly loaded. A further 25 | * improvement might be to add a lazily loaded implementation. 26 | * 27 | * @author Matthew Sowders 28 | * 29 | */ 30 | public class StaticRecordIterator implements RecordIterator { 31 | private Iterator delegate; 32 | 33 | public StaticRecordIterator(final Iterable entries) { 34 | this.delegate = entries.iterator(); 35 | } 36 | 37 | @Override 38 | public boolean hasNext() { 39 | if (null == delegate) { 40 | return false; 41 | } 42 | return delegate.hasNext(); 43 | } 44 | 45 | @Override 46 | public Entry next() { 47 | if (null == delegate) { 48 | throw new IllegalStateException(); 49 | } 50 | return delegate.next(); 51 | } 52 | 53 | @Override 54 | public void remove() { 55 | throw new UnsupportedOperationException(); 56 | } 57 | 58 | @Override 59 | public void close() throws IOException { 60 | delegate = null; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/mutation/DeleteItemWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.mutation; 16 | 17 | import org.janusgraph.diskstorage.BackendException; 18 | 19 | import com.amazon.janusgraph.diskstorage.dynamodb.DynamoDbDelegate; 20 | import com.amazon.janusgraph.diskstorage.dynamodb.ExponentialBackoff.DeleteItem; 21 | import com.amazonaws.services.dynamodbv2.model.DeleteItemRequest; 22 | 23 | import lombok.RequiredArgsConstructor; 24 | 25 | /** 26 | * 27 | * @author Alexander Patrikalakis 28 | * 29 | */ 30 | @RequiredArgsConstructor 31 | public class DeleteItemWorker implements MutateWorker { 32 | 33 | private final DeleteItemRequest deleteItemRequest; 34 | private final DynamoDbDelegate dynamoDbDelegate; 35 | 36 | @Override 37 | public Void call() throws BackendException { 38 | new DeleteItem(deleteItemRequest, dynamoDbDelegate).runWithBackoff(); 39 | 40 | // void 41 | return null; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/mutation/MutateWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.mutation; 16 | 17 | import java.util.concurrent.Callable; 18 | 19 | /** 20 | * 21 | * @author Alexander Patrikalakis 22 | * @author Michael Rodaitis 23 | * 24 | */ 25 | public interface MutateWorker extends Callable { 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/mutation/SingleUpdateWithCleanupWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.mutation; 16 | 17 | import java.util.Map; 18 | 19 | import org.janusgraph.diskstorage.BackendException; 20 | 21 | import com.amazon.janusgraph.diskstorage.dynamodb.Constants; 22 | import com.amazon.janusgraph.diskstorage.dynamodb.DynamoDbDelegate; 23 | import com.amazon.janusgraph.diskstorage.dynamodb.ExponentialBackoff.DeleteItem; 24 | import com.amazon.janusgraph.diskstorage.dynamodb.ExponentialBackoff.UpdateItem; 25 | import com.amazonaws.services.dynamodbv2.model.AttributeValue; 26 | import com.amazonaws.services.dynamodbv2.model.DeleteItemRequest; 27 | import com.amazonaws.services.dynamodbv2.model.UpdateItemRequest; 28 | import com.amazonaws.services.dynamodbv2.model.UpdateItemResult; 29 | 30 | import lombok.RequiredArgsConstructor; 31 | 32 | /** 33 | * 34 | * @author Alexander Patrikalakis 35 | * @author Michael Rodaitis 36 | * 37 | */ 38 | @RequiredArgsConstructor 39 | public class SingleUpdateWithCleanupWorker implements MutateWorker { 40 | 41 | private static final int ATTRIBUTES_IN_EMPTY_SINGLE_ITEM = 1; 42 | 43 | private final UpdateItemRequest updateItemRequest; 44 | private final DynamoDbDelegate dynamoDbDelegate; 45 | 46 | @Override 47 | public Void call() throws BackendException { 48 | 49 | final UpdateItem updateBackoff = new UpdateItem(updateItemRequest, dynamoDbDelegate); 50 | final UpdateItemResult result = updateBackoff.runWithBackoff(); 51 | 52 | 53 | final Map item = result.getAttributes(); 54 | 55 | if (item == null) { 56 | // bail 57 | return null; 58 | } 59 | 60 | // If the record has no Titan columns left after deletions occur, then just delete the record 61 | if (item.containsKey(Constants.JANUSGRAPH_HASH_KEY) && item.size() == ATTRIBUTES_IN_EMPTY_SINGLE_ITEM) { 62 | final DeleteItem deleteBackoff = new DeleteItem(new DeleteItemRequest().withTableName(updateItemRequest.getTableName()) 63 | .withKey(updateItemRequest.getKey()), dynamoDbDelegate); 64 | deleteBackoff.runWithBackoff(); 65 | } 66 | 67 | // void 68 | return null; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/amazon/janusgraph/diskstorage/dynamodb/mutation/UpdateItemWorker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb.mutation; 16 | 17 | import org.janusgraph.diskstorage.BackendException; 18 | 19 | import com.amazon.janusgraph.diskstorage.dynamodb.DynamoDbDelegate; 20 | import com.amazon.janusgraph.diskstorage.dynamodb.ExponentialBackoff.UpdateItem; 21 | import com.amazonaws.services.dynamodbv2.model.UpdateItemRequest; 22 | 23 | import lombok.RequiredArgsConstructor; 24 | 25 | /** 26 | * 27 | * @author Alexander Patrikalakis 28 | * 29 | */ 30 | @RequiredArgsConstructor 31 | public class UpdateItemWorker implements MutateWorker { 32 | 33 | private final UpdateItemRequest updateItemRequest; 34 | private final DynamoDbDelegate dynamoDbDelegate; 35 | 36 | @Override 37 | public Void call() throws BackendException { 38 | final UpdateItem updateBackoff = new UpdateItem(updateItemRequest, dynamoDbDelegate); 39 | updateBackoff.runWithBackoff(); 40 | 41 | // void 42 | return null; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/google/common/util/concurrent/RateLimiterCreator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Portions copyright 2010 Google, Inc. 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 | package com.google.common.util.concurrent; 17 | 18 | /** 19 | * Special RateLimiter constructors and factories are package private in Google Guava. 20 | * Need to set up the bursting bucket on DynamoDB tables. 21 | * @author Alexander Patrikalakis 22 | * 23 | */ 24 | public final class RateLimiterCreator { 25 | private RateLimiterCreator() { 26 | } 27 | /** 28 | * This method creates a bursting rate limiter with a configurable burst bucket of tokens. 29 | * @param rate permits per second 30 | * @param burstBucketSizeInSeconds size of burst bucket expressed in seconds. 31 | * @return a new rate limiter with the desired burst bucket size. 32 | */ 33 | //BEGIN copied code 34 | //https://github.com/google/guava/blob/v18.0/guava/src/com/google/common/util/concurrent/RateLimiter.java#L137 35 | public static RateLimiter createBurstingLimiter(final double rate, final double burstBucketSizeInSeconds) { 36 | final RateLimiter rateLimiter = new SmoothRateLimiter.SmoothBursty(RateLimiter.SleepingStopwatch.createFromSystemTimer(), 37 | burstBucketSizeInSeconds /* maxBurstSeconds */); 38 | rateLimiter.setRate(rate); 39 | return rateLimiter; 40 | } 41 | //END copied code 42 | //https://github.com/google/guava/blob/v18.0/guava/src/com/google/common/util/concurrent/RateLimiter.java#L140 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/ClientTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph; 16 | 17 | import org.junit.AfterClass; 18 | import org.junit.Test; 19 | 20 | import com.amazon.janusgraph.diskstorage.dynamodb.Client; 21 | 22 | /** 23 | * 24 | * @author Matthew Sowders 25 | * @author Alexander Patrikalakis 26 | */ 27 | public class ClientTest { 28 | 29 | @Test 30 | public void shutdown() throws Exception { 31 | final Client client = TestGraphUtil.instance.createClient(); 32 | client.getDelegate().shutdown(); 33 | } 34 | 35 | @AfterClass 36 | public static void cleanUpTables() throws Exception { 37 | TestGraphUtil.instance.cleanUpTables(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/DynamoDbStoreTransactionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph; 16 | 17 | import static org.junit.Assert.assertFalse; 18 | import static org.junit.Assert.assertTrue; 19 | 20 | import org.janusgraph.diskstorage.BaseTransactionConfig; 21 | import org.janusgraph.diskstorage.util.StandardBaseTransactionConfig; 22 | import org.janusgraph.diskstorage.util.StandardBaseTransactionConfig.Builder; 23 | import org.janusgraph.diskstorage.util.time.TimestampProviders; 24 | import org.junit.Before; 25 | import org.junit.Test; 26 | import org.junit.experimental.categories.Category; 27 | 28 | import com.amazon.janusgraph.diskstorage.dynamodb.DynamoDbStoreTransaction; 29 | import com.amazon.janusgraph.testcategory.IsolateRemainingTestsCategory; 30 | 31 | /** 32 | * 33 | * @author Matthew Sowders 34 | * @author Alexander Patrikalakis 35 | */ 36 | @Category({IsolateRemainingTestsCategory.class}) 37 | public class DynamoDbStoreTransactionTest { 38 | private DynamoDbStoreTransaction instance; 39 | private BaseTransactionConfig config; 40 | 41 | @Before 42 | public void setup() { 43 | final Builder txBuilder = new StandardBaseTransactionConfig.Builder().timestampProvider(TimestampProviders.NANO); 44 | config = txBuilder.build(); 45 | instance = new DynamoDbStoreTransaction(config); 46 | } 47 | 48 | @Test 49 | public void testEquals() { 50 | assertFalse(instance.equals(null)); 51 | assertTrue(instance.equals(instance)); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/GraphOfTheGodsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | import static org.junit.Assert.assertNotNull; 19 | import static org.junit.Assert.assertTrue; 20 | 21 | import java.util.Collection; 22 | import java.util.Iterator; 23 | 24 | import org.apache.tinkerpop.gremlin.structure.Vertex; 25 | import org.janusgraph.core.JanusGraph; 26 | import org.janusgraph.diskstorage.BackendException; 27 | import org.janusgraph.example.GraphOfTheGodsFactory; 28 | import org.junit.After; 29 | import org.junit.Test; 30 | import org.junit.experimental.categories.Category; 31 | import org.junit.runner.RunWith; 32 | import org.junit.runners.Parameterized; 33 | 34 | import com.amazon.janusgraph.graphdb.dynamodb.TestCombination; 35 | import com.amazon.janusgraph.testcategory.IsolateRemainingTestsCategory; 36 | 37 | /** 38 | * 39 | * @author Matthew Sowders 40 | * @author Alexander Patrikalakis 41 | * 42 | */ 43 | @Category({IsolateRemainingTestsCategory.class}) 44 | @RunWith(Parameterized.class) 45 | public class GraphOfTheGodsTest { 46 | private static final long EDGES = 17; 47 | private static final long VERTICES = 12; 48 | 49 | private final JanusGraph graph; 50 | 51 | //TODO 52 | @Parameterized.Parameters//(name = "{0}") 53 | public static Collection data() { 54 | return TestCombination.NATIVE_LOCKING_CROSS_MODELS; 55 | } 56 | public GraphOfTheGodsTest(final TestCombination combination) { 57 | graph = TestGraphUtil.instance.openGraph(combination.getDataModel()); 58 | GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true); 59 | } 60 | 61 | @After 62 | public void tearDownGraph() throws BackendException { 63 | TestGraphUtil.instance.tearDownGraph(graph); 64 | } 65 | 66 | @Test 67 | public void testQueryByName() throws Exception { 68 | final Iterator results = graph.traversal().V().has("name", "jupiter"); 69 | assertTrue("Query should return a result", results.hasNext()); 70 | final Vertex jupiter = results.next(); 71 | assertNotNull("Query result should be non null", jupiter); 72 | } 73 | 74 | @Test 75 | public void testQueryAllVertices() throws Exception { 76 | assertEquals("Expected the correct number of VERTICES", 77 | VERTICES, graph.traversal().V().count().tryNext().get().longValue()); 78 | } 79 | 80 | @Test 81 | public void testQueryAllEdges() throws Exception { 82 | assertEquals("Expected the correct number of EDGES", 83 | EDGES, graph.traversal().E().count().tryNext().get().longValue()); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/TestCiHeartbeat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.janusgraph; 17 | 18 | import static org.mockito.Mockito.times; 19 | import static org.mockito.Mockito.verify; 20 | 21 | import org.apache.log4j.Appender; 22 | import org.apache.log4j.Level; 23 | import org.apache.log4j.Logger; 24 | import org.apache.log4j.spi.LoggingEvent; 25 | import org.junit.Assert; 26 | import org.junit.Before; 27 | import org.junit.Rule; 28 | import org.junit.Test; 29 | import org.junit.rules.TestName; 30 | import org.junit.runner.RunWith; 31 | import org.mockito.ArgumentCaptor; 32 | import org.mockito.Captor; 33 | import org.mockito.Mock; 34 | import org.mockito.runners.MockitoJUnitRunner; 35 | 36 | import com.amazon.janusgraph.testutils.CiHeartbeat; 37 | 38 | /** 39 | * 40 | * @author Johan Jacobs 41 | * 42 | */ 43 | @RunWith(MockitoJUnitRunner.class) 44 | public class TestCiHeartbeat { 45 | 46 | @Rule 47 | public final TestName testName = new TestName(); 48 | 49 | @Mock 50 | private Appender mockAppender; 51 | @Captor 52 | private ArgumentCaptor captorLoggingEvent; 53 | 54 | @Before 55 | public void setup() { 56 | 57 | final Logger root = Logger.getRootLogger(); 58 | root.addAppender(mockAppender); 59 | root.setLevel(Level.WARN); 60 | } 61 | 62 | @Test 63 | public void testHeartbeatConsoleOutput() throws InterruptedException { 64 | 65 | final CiHeartbeat ciHeartbeat = new CiHeartbeat(500, 3); 66 | 67 | ciHeartbeat.startHeartbeat(testName.getMethodName()); 68 | 69 | Thread.sleep(2000); 70 | 71 | ciHeartbeat.stopHeartbeat(); 72 | 73 | verify(mockAppender, times(6)).doAppend(captorLoggingEvent.capture()); 74 | 75 | final LoggingEvent unitTestStartEvent = captorLoggingEvent.getAllValues().get(0); 76 | Assert.assertEquals("Heartbeat - [started] - testHeartbeatConsoleOutput - 0ms", unitTestStartEvent.getMessage()); 77 | 78 | final LoggingEvent heartbeatOneEvent = captorLoggingEvent.getAllValues().get(1); 79 | Assert.assertTrue(heartbeatOneEvent.getMessage().toString().contains("Heartbeat - [1] - testHeartbeatConsoleOutput - ")); 80 | 81 | final LoggingEvent heartbeatTwoEvent = captorLoggingEvent.getAllValues().get(2); 82 | Assert.assertTrue(heartbeatTwoEvent.getMessage().toString().contains("Heartbeat - [2] - testHeartbeatConsoleOutput - ")); 83 | 84 | final LoggingEvent heartbeatThreeEvent = captorLoggingEvent.getAllValues().get(3); 85 | Assert.assertTrue(heartbeatThreeEvent.getMessage().toString().contains("Heartbeat - [3] - testHeartbeatConsoleOutput - ")); 86 | 87 | final LoggingEvent heartbeatfourEvent = captorLoggingEvent.getAllValues().get(4); 88 | Assert.assertTrue(heartbeatfourEvent.getMessage().toString().contains("Heartbeat - [4] - testHeartbeatConsoleOutput - ")); 89 | 90 | final LoggingEvent unitTestEndEvent = captorLoggingEvent.getAllValues().get(5); 91 | Assert.assertTrue(unitTestEndEvent.getMessage().toString().contains("Heartbeat - [finished] - testHeartbeatConsoleOutput - ")); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/diskstorage/dynamodb/AbstractDynamoDBIDAuthorityTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import java.util.Collections; 18 | 19 | import org.janusgraph.diskstorage.BackendException; 20 | import org.janusgraph.diskstorage.IDAuthorityTest; 21 | import org.janusgraph.diskstorage.configuration.BasicConfiguration; 22 | import org.janusgraph.diskstorage.configuration.WriteConfiguration; 23 | import org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager; 24 | import org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration; 25 | import org.junit.After; 26 | import org.junit.Before; 27 | import org.junit.Rule; 28 | import org.junit.rules.TestName; 29 | 30 | import com.amazon.janusgraph.TestGraphUtil; 31 | import com.amazon.janusgraph.testutils.CiHeartbeat; 32 | 33 | /** 34 | * 35 | * @author Alexander Patrikalakis 36 | * @author Johan Jacobs 37 | * 38 | */ 39 | public abstract class AbstractDynamoDBIDAuthorityTest extends IDAuthorityTest { 40 | 41 | @Rule 42 | public final TestName testName = new TestName(); 43 | 44 | private final CiHeartbeat ciHeartbeat; 45 | 46 | protected final BackendDataModel model; 47 | protected AbstractDynamoDBIDAuthorityTest(final WriteConfiguration baseConfig, 48 | final BackendDataModel model) { 49 | super(TestGraphUtil.instance.appendStoreConfig(model, baseConfig.copy(), Collections.singletonList("ids"))); 50 | this.model = model; 51 | this.ciHeartbeat = new CiHeartbeat(); 52 | } 53 | 54 | @Override 55 | public KeyColumnValueStoreManager openStorageManager() throws BackendException { 56 | final BasicConfiguration config = new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, super.baseStoreConfiguration, 57 | BasicConfiguration.Restriction.NONE); 58 | return new DynamoDBStoreManager(config); 59 | } 60 | 61 | @Before 62 | public void setUpTest() throws Exception { 63 | this.ciHeartbeat.startHeartbeat(this.testName.getMethodName()); 64 | } 65 | 66 | @After 67 | public void tearDownTest() throws Exception { 68 | TestGraphUtil.instance.cleanUpTables(); 69 | this.ciHeartbeat.stopHeartbeat(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/diskstorage/dynamodb/AbstractDynamoDBLogTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | import org.janusgraph.diskstorage.BackendException; 21 | import org.janusgraph.diskstorage.configuration.BasicConfiguration; 22 | import org.janusgraph.diskstorage.configuration.WriteConfiguration; 23 | import org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager; 24 | import org.janusgraph.diskstorage.log.KCVSLogTest; 25 | import org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration; 26 | import org.junit.AfterClass; 27 | 28 | import com.amazon.janusgraph.TestGraphUtil; 29 | 30 | /** 31 | * 32 | * @author Alexander Patrikalakis 33 | * @author Johan Jacobs 34 | */ 35 | public abstract class AbstractDynamoDBLogTest extends KCVSLogTest { 36 | 37 | protected final BackendDataModel model; 38 | protected AbstractDynamoDBLogTest(final BackendDataModel model) { 39 | this.model = model; 40 | } 41 | 42 | public KeyColumnValueStoreManager openStorageManager() throws BackendException { 43 | final List logNames = new ArrayList<>(12); 44 | logNames.add("test1"); 45 | logNames.add("durable"); 46 | logNames.add("ml0"); 47 | logNames.add("ml1"); 48 | logNames.add("ml2"); 49 | logNames.add("loner0"); 50 | logNames.add("loner1"); 51 | logNames.add("loner2"); 52 | logNames.add("loner3"); 53 | logNames.add("loner4"); 54 | logNames.add("fuzz"); 55 | logNames.add("testx"); 56 | final WriteConfiguration wc = TestGraphUtil.instance.getStoreConfig(model, logNames); 57 | final BasicConfiguration config = new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, wc, 58 | BasicConfiguration.Restriction.NONE); 59 | 60 | return new DynamoDBStoreManager(config); 61 | } 62 | 63 | @AfterClass 64 | public static void cleanUpTables() throws Exception { 65 | TestGraphUtil.instance.cleanUpTables(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/diskstorage/dynamodb/AbstractDynamoDBMultiWriteStoreTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | import org.janusgraph.diskstorage.BackendException; 21 | import org.janusgraph.diskstorage.MultiWriteKeyColumnValueStoreTest; 22 | import org.janusgraph.diskstorage.configuration.BasicConfiguration; 23 | import org.janusgraph.diskstorage.configuration.WriteConfiguration; 24 | import org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager; 25 | import org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration; 26 | import org.junit.After; 27 | import org.junit.AfterClass; 28 | import org.junit.Before; 29 | import org.junit.Rule; 30 | import org.junit.Test; 31 | import org.junit.rules.TestName; 32 | 33 | import com.amazon.janusgraph.TestGraphUtil; 34 | import com.amazon.janusgraph.testutils.CiHeartbeat; 35 | 36 | /** 37 | * 38 | * @author Alexander Patrikalakis 39 | * @author Johan Jacobs 40 | * 41 | */ 42 | public abstract class AbstractDynamoDBMultiWriteStoreTest extends MultiWriteKeyColumnValueStoreTest { 43 | 44 | @Rule 45 | public final TestName testName = new TestName(); 46 | 47 | private final CiHeartbeat ciHeartbeat; 48 | protected final BackendDataModel model; 49 | protected AbstractDynamoDBMultiWriteStoreTest(final BackendDataModel model) { 50 | this.model = model; 51 | this.ciHeartbeat = new CiHeartbeat(); 52 | } 53 | 54 | public KeyColumnValueStoreManager openStorageManager() throws BackendException { 55 | final List storeNames = new ArrayList<>(2); 56 | storeNames.add(storeName1); 57 | storeNames.add(storeName2); 58 | final WriteConfiguration wc = TestGraphUtil.instance.getStoreConfig(model, storeNames); 59 | final BasicConfiguration config = new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, wc, 60 | BasicConfiguration.Restriction.NONE); 61 | 62 | return new DynamoDBStoreManager(config); 63 | } 64 | 65 | @AfterClass 66 | public static void cleanUpTables() throws Exception { 67 | TestGraphUtil.instance.cleanUpTables(); 68 | } 69 | 70 | @Before 71 | public void setUp() throws Exception { 72 | super.setUp(); 73 | this.ciHeartbeat.startHeartbeat(this.testName.getMethodName()); 74 | } 75 | 76 | @After 77 | public void tearDown() throws Exception { 78 | this.ciHeartbeat.stopHeartbeat(); 79 | super.tearDown(); 80 | } 81 | 82 | @Override 83 | @Test 84 | public void mutateManyStressTest() throws BackendException { 85 | this.mutateManyStressTestWithVariableRounds(1); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/diskstorage/dynamodb/AbstractDynamoDbStoreTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import java.util.Collections; 18 | import java.util.List; 19 | import java.util.concurrent.ExecutionException; 20 | 21 | import org.janusgraph.diskstorage.BackendException; 22 | import org.janusgraph.diskstorage.KeyColumnValueStoreTest; 23 | import org.janusgraph.diskstorage.configuration.BasicConfiguration; 24 | import org.janusgraph.diskstorage.configuration.WriteConfiguration; 25 | import org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager; 26 | import org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration; 27 | import org.junit.After; 28 | import org.junit.Before; 29 | import org.junit.Rule; 30 | import org.junit.rules.TestName; 31 | 32 | import com.amazon.janusgraph.TestGraphUtil; 33 | import com.amazon.janusgraph.testutils.CiHeartbeat; 34 | 35 | /** 36 | * 37 | * @author Alexander Patrikalakis 38 | * @author Johan Jacobs 39 | * 40 | */ 41 | public abstract class AbstractDynamoDbStoreTest extends KeyColumnValueStoreTest 42 | { 43 | @Rule 44 | public final TestName testName = new TestName(); 45 | 46 | private final int NUM_COLUMNS = 50; 47 | private final CiHeartbeat ciHeartbeat; 48 | protected final BackendDataModel model; 49 | protected AbstractDynamoDbStoreTest(final BackendDataModel model) { 50 | this.model = model; 51 | this.ciHeartbeat = new CiHeartbeat(); 52 | } 53 | @Override 54 | public KeyColumnValueStoreManager openStorageManager() throws BackendException 55 | { 56 | final List storeNames = Collections.singletonList("testStore1"); 57 | final WriteConfiguration wc = TestGraphUtil.instance.getStoreConfig(model, storeNames); 58 | 59 | if (name.getMethodName().equals("parallelScanTest")) { 60 | wc.set("storage.dynamodb." + Constants.DYNAMODB_ENABLE_PARALLEL_SCAN.getName(), "true"); 61 | } 62 | final BasicConfiguration config = new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, wc, 63 | BasicConfiguration.Restriction.NONE); 64 | 65 | return new DynamoDBStoreManager(config); 66 | } 67 | 68 | @Override 69 | public void testConcurrentGetSliceAndMutate() throws ExecutionException, InterruptedException, BackendException { 70 | testConcurrentStoreOps(true, NUM_COLUMNS); 71 | } 72 | 73 | @Override 74 | public void testConcurrentGetSlice() throws ExecutionException, InterruptedException, BackendException { 75 | testConcurrentStoreOps(false, NUM_COLUMNS); 76 | } 77 | @Before 78 | public void setUp() throws Exception { 79 | super.setUp(); 80 | this.ciHeartbeat.startHeartbeat(this.testName.getMethodName()); 81 | } 82 | 83 | @After 84 | public void tearDown() throws Exception { 85 | TestGraphUtil.instance.cleanUpTables(); 86 | this.ciHeartbeat.stopHeartbeat(); 87 | super.tearDown(); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/diskstorage/dynamodb/MultiDynamoDBIDAuthorityTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import org.janusgraph.diskstorage.configuration.WriteConfiguration; 18 | import org.junit.experimental.categories.Category; 19 | 20 | import com.amazon.janusgraph.testcategory.MultiIdAuthorityLogStoreCategory; 21 | import com.amazon.janusgraph.testcategory.MultipleItemTestCategory; 22 | 23 | /** 24 | * 25 | * @author Alexander Patrikalakis 26 | * 27 | */ 28 | @Category({ MultiIdAuthorityLogStoreCategory.class, MultipleItemTestCategory.class }) 29 | public class MultiDynamoDBIDAuthorityTest extends AbstractDynamoDBIDAuthorityTest { 30 | 31 | /*this test is Parametrized so the ctor takes an argument*/ 32 | public MultiDynamoDBIDAuthorityTest(final WriteConfiguration baseConfig) { 33 | super(baseConfig, BackendDataModel.MULTI); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/diskstorage/dynamodb/MultiDynamoDBLogTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | 18 | import org.junit.Test; 19 | import org.junit.experimental.categories.Category; 20 | 21 | import com.amazon.janusgraph.testcategory.MultiIdAuthorityLogStoreCategory; 22 | import com.amazon.janusgraph.testcategory.MultipleItemTestCategory; 23 | 24 | /** 25 | * 26 | * @author Alexander Patrikalakis 27 | * @author Johan Jacobs 28 | * 29 | */ 30 | @Category({ MultiIdAuthorityLogStoreCategory.class, MultipleItemTestCategory.class }) 31 | public class MultiDynamoDBLogTest extends AbstractDynamoDBLogTest { 32 | public MultiDynamoDBLogTest() throws Exception { 33 | super(BackendDataModel.MULTI); 34 | } 35 | 36 | static private final long LONGER_TIMEOUT_MS = 120000; 37 | 38 | @Override 39 | @Test 40 | public void mediumSendReceiveSerial() throws Exception { 41 | simpleSendReceive(2000,50, LONGER_TIMEOUT_MS); 42 | } 43 | @Override 44 | @Test 45 | public void testMultipleReadersOnSingleLog() throws Exception { 46 | sendReceive(4, 2000, 50, false, LONGER_TIMEOUT_MS); 47 | } 48 | @Override 49 | @Test 50 | public void testMultipleReadersOnSingleLogSerial() throws Exception { 51 | sendReceive(4, 2000, 50, true, LONGER_TIMEOUT_MS); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/diskstorage/dynamodb/MultiDynamoDBMultiWriteStoreTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import org.junit.experimental.categories.Category; 18 | 19 | import com.amazon.janusgraph.testcategory.MultiDynamoDBMultiWriteStoreTestCategory; 20 | import com.amazon.janusgraph.testcategory.MultipleItemTestCategory; 21 | 22 | 23 | /** 24 | * 25 | * @author Alexander Patrikalakis 26 | * 27 | */ 28 | @Category({ MultiDynamoDBMultiWriteStoreTestCategory.class, MultipleItemTestCategory.class }) 29 | public class MultiDynamoDBMultiWriteStoreTest extends AbstractDynamoDBMultiWriteStoreTest { 30 | 31 | public MultiDynamoDBMultiWriteStoreTest() { 32 | super(BackendDataModel.MULTI); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/diskstorage/dynamodb/SingleDynamoDBIDAuthorityTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import org.janusgraph.diskstorage.configuration.WriteConfiguration; 18 | import org.junit.experimental.categories.Category; 19 | 20 | import com.amazon.janusgraph.testcategory.SingleIdAuthorityLogStoreCategory; 21 | import com.amazon.janusgraph.testcategory.SingleItemTestCategory; 22 | 23 | /** 24 | * 25 | * @author Alexander Patrikalakis 26 | * 27 | */ 28 | @Category({ SingleIdAuthorityLogStoreCategory.class, SingleItemTestCategory.class }) 29 | public class SingleDynamoDBIDAuthorityTest extends AbstractDynamoDBIDAuthorityTest { 30 | 31 | /*this test is Parametrized so the ctor takes an argument*/ 32 | public SingleDynamoDBIDAuthorityTest(final WriteConfiguration baseConfig) { 33 | super(baseConfig, BackendDataModel.SINGLE); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/diskstorage/dynamodb/SingleDynamoDBLogTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import org.junit.experimental.categories.Category; 18 | 19 | import com.amazon.janusgraph.testcategory.SingleIdAuthorityLogStoreCategory; 20 | import com.amazon.janusgraph.testcategory.SingleItemTestCategory; 21 | 22 | /** 23 | * 24 | * @author Alexander Patrikalakis 25 | * 26 | */ 27 | @Category({ SingleIdAuthorityLogStoreCategory.class, SingleItemTestCategory.class }) 28 | public class SingleDynamoDBLogTest extends AbstractDynamoDBLogTest { 29 | 30 | public SingleDynamoDBLogTest() { 31 | super(BackendDataModel.SINGLE); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/diskstorage/dynamodb/SingleDynamoDBMultiWriteStoreTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.diskstorage.dynamodb; 16 | 17 | import org.junit.experimental.categories.Category; 18 | 19 | import com.amazon.janusgraph.testcategory.SingleDynamoDBMultiWriteStoreTestCategory; 20 | import com.amazon.janusgraph.testcategory.SingleItemTestCategory; 21 | 22 | /** 23 | * 24 | * @author Alexander Patrikalakis 25 | * 26 | */ 27 | @Category({ SingleDynamoDBMultiWriteStoreTestCategory.class, SingleItemTestCategory.class }) 28 | public class SingleDynamoDBMultiWriteStoreTest extends AbstractDynamoDBMultiWriteStoreTest { 29 | 30 | public SingleDynamoDBMultiWriteStoreTest() { 31 | super(BackendDataModel.SINGLE); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/AbstractDynamoDBEventualGraphTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.janusgraph.diskstorage.BackendException; 18 | import org.janusgraph.diskstorage.configuration.WriteConfiguration; 19 | import org.janusgraph.graphdb.JanusGraphEventualGraphTest; 20 | import org.junit.After; 21 | import org.junit.AfterClass; 22 | import org.junit.Before; 23 | import org.junit.Rule; 24 | import org.junit.rules.TestName; 25 | 26 | import com.amazon.janusgraph.TestGraphUtil; 27 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 28 | import com.amazon.janusgraph.testutils.CiHeartbeat; 29 | 30 | /** 31 | * 32 | * @author Alexander Patrikalakis 33 | * @author Johan Jacobs 34 | * 35 | */ 36 | public abstract class AbstractDynamoDBEventualGraphTest extends JanusGraphEventualGraphTest { 37 | 38 | @Rule 39 | public final TestName testName = new TestName(); 40 | 41 | private final CiHeartbeat ciHeartbeat; 42 | protected final BackendDataModel model; 43 | protected AbstractDynamoDBEventualGraphTest(final BackendDataModel model) { 44 | this.model = model; 45 | this.ciHeartbeat = new CiHeartbeat(); 46 | } 47 | 48 | @Override 49 | public WriteConfiguration getConfiguration() 50 | { 51 | return TestGraphUtil.instance.graphConfig(model); 52 | } 53 | 54 | @AfterClass 55 | public static void deleteTables() throws BackendException { 56 | TestGraphUtil.instance.cleanUpTables(); 57 | } 58 | 59 | @Before 60 | public void setUpTest() throws Exception { 61 | this.ciHeartbeat.startHeartbeat(this.testName.getMethodName()); 62 | } 63 | 64 | @After 65 | public void tearDownTest() throws Exception { 66 | this.ciHeartbeat.stopHeartbeat(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/AbstractDynamoDBGraphConcurrentTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import java.util.concurrent.ExecutionException; 18 | 19 | import org.janusgraph.diskstorage.BackendException; 20 | import org.janusgraph.diskstorage.configuration.WriteConfiguration; 21 | import org.janusgraph.graphdb.JanusGraphConcurrentTest; 22 | import org.junit.After; 23 | import org.junit.AfterClass; 24 | import org.junit.Before; 25 | import org.junit.Rule; 26 | import org.junit.Test; 27 | import org.junit.rules.TestName; 28 | 29 | import com.amazon.janusgraph.TestGraphUtil; 30 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 31 | import com.amazon.janusgraph.testutils.CiHeartbeat; 32 | 33 | /** 34 | * 35 | * @author Alexander Patrikalakis 36 | * @author Johan Jacobs 37 | * 38 | */ 39 | public abstract class AbstractDynamoDBGraphConcurrentTest extends JanusGraphConcurrentTest 40 | { 41 | @Rule 42 | public final TestName testName = new TestName(); 43 | 44 | private final CiHeartbeat ciHeartbeat; 45 | protected final BackendDataModel model; 46 | protected AbstractDynamoDBGraphConcurrentTest(final BackendDataModel model) { 47 | this.model = model; 48 | this.ciHeartbeat = new CiHeartbeat(); 49 | } 50 | 51 | @Override 52 | public WriteConfiguration getConfiguration() 53 | { 54 | return TestGraphUtil.instance.graphConfig(model); 55 | } 56 | 57 | @AfterClass 58 | public static void deleteTables() throws BackendException { 59 | TestGraphUtil.instance.cleanUpTables(); 60 | } 61 | 62 | @Before 63 | public void setUpTest() throws Exception { 64 | this.ciHeartbeat.startHeartbeat(this.testName.getMethodName()); 65 | } 66 | 67 | @After 68 | public void tearDownTest() throws Exception { 69 | this.ciHeartbeat.stopHeartbeat(); 70 | } 71 | 72 | //begin janusgraph-test code - modified because test takes too long, kept number of runnables 73 | //the same 74 | //https://github.com/thinkaurelius/titan/blob/0.9.0-M2/titan-test/src/main/java/com/thinkaurelius/titan/graphdb/TitanGraphConcurrentTest.java#L291 75 | @Test 76 | @Override 77 | public void testStandardIndexVertexPropertyReads() throws InterruptedException, ExecutionException { 78 | //this test takes too long so reduce the number of threads 79 | testStandardIndexVertexPropertyReadsLogic(4 /*numThreads*/); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/AbstractDynamoDBGraphIterativeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.janusgraph.diskstorage.BackendException; 18 | import org.janusgraph.diskstorage.configuration.BasicConfiguration; 19 | import org.janusgraph.diskstorage.configuration.WriteConfiguration; 20 | import org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStoreManager; 21 | import org.janusgraph.graphdb.JanusGraphIterativeBenchmark; 22 | import org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration; 23 | import org.junit.After; 24 | import org.junit.AfterClass; 25 | import org.junit.Before; 26 | import org.junit.Rule; 27 | import org.junit.rules.TestName; 28 | 29 | import com.amazon.janusgraph.TestGraphUtil; 30 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 31 | import com.amazon.janusgraph.diskstorage.dynamodb.DynamoDBStoreManager; 32 | import com.amazon.janusgraph.testutils.CiHeartbeat; 33 | import com.google.common.annotations.VisibleForTesting; 34 | 35 | /** 36 | * 37 | * @author Alexander Patrikalakis 38 | * @author Johan Jacobs 39 | */ 40 | public abstract class AbstractDynamoDBGraphIterativeTest extends JanusGraphIterativeBenchmark { 41 | 42 | @Rule 43 | public final TestName testName = new TestName(); 44 | 45 | private final CiHeartbeat ciHeartbeat; 46 | protected final BackendDataModel model; 47 | @VisibleForTesting 48 | protected AbstractDynamoDBGraphIterativeTest(final BackendDataModel model) { 49 | this.model = model; 50 | this.ciHeartbeat = new CiHeartbeat(); 51 | } 52 | 53 | @Override 54 | public KeyColumnValueStoreManager openStorageManager() throws BackendException { 55 | final WriteConfiguration wc = TestGraphUtil.instance.graphConfig(model); 56 | final BasicConfiguration config = new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, wc, 57 | BasicConfiguration.Restriction.NONE); 58 | 59 | return new DynamoDBStoreManager(config); 60 | } 61 | 62 | @Override 63 | public WriteConfiguration getConfiguration() 64 | { 65 | return TestGraphUtil.instance.graphConfig(model); 66 | } 67 | 68 | @AfterClass 69 | public static void deleteTables() throws BackendException { 70 | TestGraphUtil.instance.cleanUpTables(); 71 | } 72 | 73 | @Before 74 | public void setUpTest() throws Exception { 75 | this.ciHeartbeat.startHeartbeat(this.testName.getMethodName()); 76 | } 77 | 78 | @After 79 | public void tearDownTest() throws Exception { 80 | this.ciHeartbeat.stopHeartbeat(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/AbstractDynamoDBGraphPerformanceMemoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.janusgraph.diskstorage.BackendException; 18 | import org.janusgraph.diskstorage.configuration.WriteConfiguration; 19 | import org.janusgraph.graphdb.JanusGraphPerformanceMemoryTest; 20 | import org.junit.After; 21 | import org.junit.AfterClass; 22 | import org.junit.Before; 23 | import org.junit.Rule; 24 | import org.junit.rules.TestName; 25 | 26 | import com.amazon.janusgraph.TestGraphUtil; 27 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 28 | import com.amazon.janusgraph.testutils.CiHeartbeat; 29 | /** 30 | * 31 | * @author Alexander Patrikalakis 32 | * @author Johan Jacobs 33 | * 34 | */ 35 | public abstract class AbstractDynamoDBGraphPerformanceMemoryTest extends JanusGraphPerformanceMemoryTest 36 | { 37 | @Rule 38 | public final TestName testName = new TestName(); 39 | 40 | private final CiHeartbeat ciHeartbeat; 41 | protected final BackendDataModel model; 42 | protected AbstractDynamoDBGraphPerformanceMemoryTest(final BackendDataModel model) { 43 | this.model = model; 44 | this.ciHeartbeat = new CiHeartbeat(); 45 | } 46 | 47 | @Override 48 | public WriteConfiguration getConfiguration() 49 | { 50 | return TestGraphUtil.instance.graphConfig(model); 51 | } 52 | 53 | @AfterClass 54 | public static void deleteTables() throws BackendException { 55 | TestGraphUtil.instance.cleanUpTables(); 56 | } 57 | 58 | @Before 59 | public void setUpTest() throws Exception { 60 | this.ciHeartbeat.startHeartbeat(this.testName.getMethodName()); 61 | } 62 | 63 | @After 64 | public void tearDownTest() throws Exception { 65 | this.ciHeartbeat.stopHeartbeat(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/AbstractDynamoDBGraphSpeedTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.janusgraph.core.JanusGraphFactory; 18 | import org.janusgraph.diskstorage.BackendException; 19 | import org.janusgraph.graphdb.JanusGraphSpeedTest; 20 | import org.janusgraph.graphdb.SpeedTestSchema; 21 | import org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration; 22 | import org.janusgraph.graphdb.database.StandardJanusGraph; 23 | import org.junit.After; 24 | import org.junit.AfterClass; 25 | import org.junit.Before; 26 | import org.junit.Rule; 27 | import org.junit.rules.TestName; 28 | 29 | import com.amazon.janusgraph.TestGraphUtil; 30 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 31 | import com.amazon.janusgraph.testutils.CiHeartbeat; 32 | 33 | /** 34 | * 35 | * @author Alexander Patrikalakis 36 | * @author Johan Jacobs 37 | * 38 | */ 39 | public abstract class AbstractDynamoDBGraphSpeedTest extends JanusGraphSpeedTest { 40 | @Rule 41 | public final TestName testName = new TestName(); 42 | 43 | private final CiHeartbeat ciHeartbeat; 44 | private static StandardJanusGraph graph; 45 | private static SpeedTestSchema schema; 46 | protected final BackendDataModel model; 47 | 48 | protected AbstractDynamoDBGraphSpeedTest(final BackendDataModel model) throws BackendException { 49 | super(TestGraphUtil.instance.graphConfig(model)); 50 | this.model = model; 51 | this.ciHeartbeat = new CiHeartbeat(); 52 | } 53 | 54 | @AfterClass 55 | public static void deleteTables() throws BackendException { 56 | TestGraphUtil.instance.cleanUpTables(); 57 | } 58 | 59 | @Override 60 | protected StandardJanusGraph getGraph() throws BackendException { 61 | if (null == graph) { 62 | final GraphDatabaseConfiguration graphconfig = new GraphDatabaseConfiguration(conf); 63 | graphconfig.getBackend().clearStorage(); 64 | graph = (StandardJanusGraph) JanusGraphFactory.open(conf); 65 | initializeGraph(graph); 66 | } 67 | return graph; 68 | } 69 | 70 | @Override 71 | protected SpeedTestSchema getSchema() { 72 | if (null == schema) { 73 | schema = SpeedTestSchema.get(); 74 | } 75 | return schema; 76 | } 77 | 78 | @Before 79 | public void setUpTest() throws Exception { 80 | this.ciHeartbeat.startHeartbeat(this.testName.getMethodName()); 81 | } 82 | 83 | @After 84 | public void tearDownTest() throws Exception { 85 | this.ciHeartbeat.stopHeartbeat(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/AbstractDynamoDBGraphTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import java.util.Collections; 18 | import java.util.List; 19 | 20 | import org.janusgraph.diskstorage.BackendException; 21 | import org.janusgraph.diskstorage.configuration.WriteConfiguration; 22 | import org.janusgraph.graphdb.JanusGraphTest; 23 | import org.junit.After; 24 | import org.junit.AfterClass; 25 | import org.junit.Before; 26 | import org.junit.Rule; 27 | import org.junit.rules.TestName; 28 | 29 | import com.amazon.janusgraph.TestGraphUtil; 30 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 31 | import com.amazon.janusgraph.testutils.CiHeartbeat; 32 | 33 | /** 34 | * 35 | * FunctionalTitanGraphTest contains the specializations of the Titan functional tests required for 36 | * the DynamoDB storage backend. 37 | * 38 | * @author Alexander Patrikalakis 39 | * @author Johan Jacobs 40 | * 41 | */ 42 | public abstract class AbstractDynamoDBGraphTest extends JanusGraphTest { 43 | private final CiHeartbeat ciHeartbeat; 44 | 45 | @Rule 46 | public final TestName testName = new TestName(); 47 | 48 | protected final BackendDataModel model; 49 | protected AbstractDynamoDBGraphTest(final BackendDataModel model) { 50 | this.model = model; 51 | this.ciHeartbeat = new CiHeartbeat(); 52 | } 53 | 54 | @Override 55 | public WriteConfiguration getConfiguration() { 56 | final String methodName = testName.getMethodName(); 57 | final List extraStoreNames = methodName.contains("simpleLogTest") ? Collections.singletonList("ulog_test") : Collections.emptyList(); 58 | return TestGraphUtil.instance.graphConfigWithClusterPartitionsAndExtraStores(model, extraStoreNames, 1 /*janusGraphClusterPartitions*/); 59 | } 60 | 61 | @AfterClass 62 | public static void deleteTables() throws BackendException { 63 | TestGraphUtil.instance.cleanUpTables(); 64 | } 65 | 66 | @Before 67 | public void setUpTest() throws Exception { 68 | this.ciHeartbeat.startHeartbeat(this.testName.getMethodName()); 69 | } 70 | 71 | @After 72 | public void tearDownTest() throws Exception { 73 | this.ciHeartbeat.stopHeartbeat(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/AbstractDynamoDBOLAPTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.janusgraph.diskstorage.BackendException; 18 | import org.janusgraph.diskstorage.configuration.WriteConfiguration; 19 | import org.janusgraph.olap.OLAPTest; 20 | import org.junit.After; 21 | import org.junit.AfterClass; 22 | import org.junit.Before; 23 | import org.junit.Rule; 24 | import org.junit.rules.TestName; 25 | 26 | import com.amazon.janusgraph.TestGraphUtil; 27 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 28 | import com.amazon.janusgraph.testutils.CiHeartbeat; 29 | 30 | /** 31 | * 32 | * @author Alexander Patrikalakis 33 | * @author Johan Jacobs 34 | * 35 | */ 36 | public abstract class AbstractDynamoDBOLAPTest extends OLAPTest { 37 | 38 | @Rule 39 | public final TestName testName = new TestName(); 40 | 41 | private final CiHeartbeat ciHeartbeat; 42 | protected final BackendDataModel model; 43 | protected AbstractDynamoDBOLAPTest(final BackendDataModel model) { 44 | this.model = model; 45 | this.ciHeartbeat = new CiHeartbeat(); 46 | } 47 | 48 | @Override 49 | public WriteConfiguration getConfiguration() 50 | { 51 | return TestGraphUtil.instance.graphConfig(model); 52 | } 53 | 54 | @AfterClass 55 | public static void deleteTables() throws BackendException { 56 | TestGraphUtil.instance.cleanUpTables(); 57 | } 58 | 59 | @Before 60 | public void setUpTest() throws Exception { 61 | this.ciHeartbeat.startHeartbeat(this.testName.getMethodName()); 62 | } 63 | 64 | @After 65 | public void tearDownTest() throws Exception { 66 | this.ciHeartbeat.stopHeartbeat(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/AbstractDynamoDBOperationCountingTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.janusgraph.diskstorage.BackendException; 18 | import org.janusgraph.diskstorage.configuration.WriteConfiguration; 19 | import org.janusgraph.graphdb.JanusGraphOperationCountingTest; 20 | import org.junit.After; 21 | import org.junit.AfterClass; 22 | import org.junit.Before; 23 | import org.junit.Rule; 24 | import org.junit.rules.TestName; 25 | 26 | import com.amazon.janusgraph.TestGraphUtil; 27 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 28 | import com.amazon.janusgraph.testutils.CiHeartbeat; 29 | 30 | /** 31 | * 32 | * @author Alexander Patrikalakis 33 | * @author Johan Jacobs 34 | * 35 | */ 36 | public abstract class AbstractDynamoDBOperationCountingTest extends JanusGraphOperationCountingTest { 37 | 38 | @Rule 39 | public final TestName testName = new TestName(); 40 | 41 | private final CiHeartbeat ciHeartbeat; 42 | protected final BackendDataModel model; 43 | protected AbstractDynamoDBOperationCountingTest(final BackendDataModel model) { 44 | this.model = model; 45 | this.ciHeartbeat = new CiHeartbeat(); 46 | } 47 | 48 | @Override 49 | public WriteConfiguration getBaseConfiguration() 50 | { 51 | return TestGraphUtil.instance.graphConfig(model); 52 | } 53 | 54 | @AfterClass 55 | public static void deleteTables() throws BackendException { 56 | TestGraphUtil.instance.cleanUpTables(); 57 | } 58 | 59 | @Before 60 | public void setUpTest() throws Exception { 61 | this.ciHeartbeat.startHeartbeat(this.testName.getMethodName()); 62 | } 63 | 64 | @After 65 | public void tearDownTest() throws Exception { 66 | this.ciHeartbeat.stopHeartbeat(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/AbstractDynamoDBPartitionGraphTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import java.util.Collections; 18 | 19 | import org.janusgraph.diskstorage.BackendException; 20 | import org.janusgraph.diskstorage.configuration.WriteConfiguration; 21 | import org.janusgraph.graphdb.JanusGraphPartitionGraphTest; 22 | import org.junit.After; 23 | import org.junit.AfterClass; 24 | import org.junit.Before; 25 | import org.junit.Rule; 26 | import org.junit.rules.TestName; 27 | 28 | import com.amazon.janusgraph.TestGraphUtil; 29 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 30 | import com.amazon.janusgraph.testutils.CiHeartbeat; 31 | 32 | /** 33 | * 34 | * @author Alexander Patrikalakis 35 | * @author Johan Jacobs 36 | * 37 | */ 38 | public abstract class AbstractDynamoDBPartitionGraphTest extends JanusGraphPartitionGraphTest 39 | { 40 | 41 | @Rule 42 | public final TestName testName = new TestName(); 43 | 44 | private final CiHeartbeat ciHeartbeat; 45 | protected final BackendDataModel model; 46 | protected AbstractDynamoDBPartitionGraphTest(final BackendDataModel model) { 47 | this.model = model; 48 | this.ciHeartbeat = new CiHeartbeat(); 49 | } 50 | 51 | @Override 52 | public WriteConfiguration getBaseConfiguration() 53 | { 54 | return TestGraphUtil.instance.graphConfigWithClusterPartitionsAndExtraStores(model, 55 | Collections.emptyList(), 8 /*janusGraphClusterPartitions*/); 56 | } 57 | 58 | @AfterClass 59 | public static void deleteTables() throws BackendException { 60 | TestGraphUtil.instance.cleanUpTables(); 61 | } 62 | 63 | @Before 64 | public void setUpTest() throws Exception { 65 | this.ciHeartbeat.startHeartbeat(this.testName.getMethodName()); 66 | } 67 | 68 | @After 69 | public void tearDownTest() throws Exception { 70 | this.ciHeartbeat.stopHeartbeat(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/MultiDynamoDBEventualGraphTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.junit.experimental.categories.Category; 18 | 19 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 20 | import com.amazon.janusgraph.testcategory.MultipleItemTestCategory; 21 | 22 | /** 23 | * 24 | * @author Alexander Patrikalakis 25 | * 26 | */ 27 | @Category({ MultipleItemTestCategory.class }) 28 | public class MultiDynamoDBEventualGraphTest extends AbstractDynamoDBEventualGraphTest { 29 | public MultiDynamoDBEventualGraphTest() 30 | { 31 | super(BackendDataModel.MULTI); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/MultiDynamoDBGraphConcurrentTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.junit.experimental.categories.Category; 18 | 19 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 20 | import com.amazon.janusgraph.testcategory.MultipleItemTestCategory; 21 | 22 | /** 23 | * 24 | * @author Alexander Patrikalakis 25 | * 26 | */ 27 | @Category({ MultipleItemTestCategory.class }) 28 | public class MultiDynamoDBGraphConcurrentTest extends AbstractDynamoDBGraphConcurrentTest 29 | { 30 | public MultiDynamoDBGraphConcurrentTest() 31 | { 32 | super(BackendDataModel.MULTI); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/MultiDynamoDBGraphPerformanceMemoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.junit.experimental.categories.Category; 18 | 19 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 20 | import com.amazon.janusgraph.testcategory.MultipleItemTestCategory; 21 | 22 | /** 23 | * 24 | * @author Alexander Patrikalakis 25 | * 26 | */ 27 | @Category({ MultipleItemTestCategory.class }) 28 | public class MultiDynamoDBGraphPerformanceMemoryTest extends AbstractDynamoDBGraphPerformanceMemoryTest 29 | { 30 | public MultiDynamoDBGraphPerformanceMemoryTest() 31 | { 32 | super(BackendDataModel.MULTI); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/MultiDynamoDBGraphSpeedTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.janusgraph.diskstorage.BackendException; 18 | import org.junit.experimental.categories.Category; 19 | 20 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 21 | import com.amazon.janusgraph.testcategory.MultipleItemTestCategory; 22 | 23 | /** 24 | * 25 | * @author Alexander Patrikalakis 26 | * 27 | */ 28 | @Category({ MultipleItemTestCategory.class }) 29 | public class MultiDynamoDBGraphSpeedTest extends AbstractDynamoDBGraphSpeedTest { 30 | 31 | public MultiDynamoDBGraphSpeedTest() throws BackendException { 32 | super(BackendDataModel.MULTI); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/MultiDynamoDBOLAPTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.janusgraph.diskstorage.BackendException; 18 | import org.junit.Ignore; 19 | import org.junit.experimental.categories.Category; 20 | 21 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 22 | import com.amazon.janusgraph.testcategory.MultiDynamoDBOLAPTestCategory; 23 | import com.amazon.janusgraph.testcategory.MultipleItemTestCategory; 24 | 25 | /** 26 | * 27 | * @author Alexander Patrikalakis 28 | * 29 | */ 30 | @Category({ MultiDynamoDBOLAPTestCategory.class, MultipleItemTestCategory.class }) 31 | public class MultiDynamoDBOLAPTest extends AbstractDynamoDBOLAPTest { 32 | 33 | public MultiDynamoDBOLAPTest() throws BackendException { 34 | super(BackendDataModel.MULTI); 35 | } 36 | 37 | @Override @Ignore 38 | public void testPageRank() { 39 | } 40 | 41 | @Override @Ignore 42 | public void testShortestDistance() { 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/MultiDynamoDBOperationCountingTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.junit.experimental.categories.Category; 18 | 19 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 20 | import com.amazon.janusgraph.testcategory.MultipleItemTestCategory; 21 | 22 | /** 23 | * 24 | * @author Alexander Patrikalakis 25 | * 26 | */ 27 | @Category({ MultipleItemTestCategory.class }) 28 | public class MultiDynamoDBOperationCountingTest extends AbstractDynamoDBOperationCountingTest { 29 | 30 | public MultiDynamoDBOperationCountingTest() { 31 | super(BackendDataModel.MULTI); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/MultiDynamoDBPartitionGraphTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.junit.experimental.categories.Category; 18 | 19 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 20 | import com.amazon.janusgraph.testcategory.MultipleItemTestCategory; 21 | 22 | /** 23 | * 24 | * @author Alexander Patrikalakis 25 | * 26 | */ 27 | @Category({ MultipleItemTestCategory.class }) 28 | public class MultiDynamoDBPartitionGraphTest extends AbstractDynamoDBPartitionGraphTest 29 | { 30 | public MultiDynamoDBPartitionGraphTest() 31 | { 32 | super(BackendDataModel.MULTI); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/SingleDynamoDBEventualGraphTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.junit.experimental.categories.Category; 18 | 19 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 20 | import com.amazon.janusgraph.testcategory.SingleItemTestCategory; 21 | 22 | /** 23 | * 24 | * @author Alexander Patrikalakis 25 | * 26 | */ 27 | @Category({ SingleItemTestCategory.class }) 28 | public class SingleDynamoDBEventualGraphTest extends AbstractDynamoDBEventualGraphTest { 29 | public SingleDynamoDBEventualGraphTest() 30 | { 31 | super(BackendDataModel.SINGLE); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/SingleDynamoDBGraphConcurrentTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.junit.experimental.categories.Category; 18 | 19 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 20 | import com.amazon.janusgraph.testcategory.SingleItemTestCategory; 21 | 22 | /** 23 | * 24 | * @author Alexander Patrikalakis 25 | * 26 | */ 27 | @Category({ SingleItemTestCategory.class }) 28 | public class SingleDynamoDBGraphConcurrentTest extends AbstractDynamoDBGraphConcurrentTest 29 | { 30 | public SingleDynamoDBGraphConcurrentTest() 31 | { 32 | super(BackendDataModel.SINGLE); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/SingleDynamoDBGraphPerformanceMemoryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.junit.experimental.categories.Category; 18 | 19 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 20 | import com.amazon.janusgraph.testcategory.SingleItemTestCategory; 21 | 22 | /** 23 | * 24 | * @author Alexander Patrikalakis 25 | * 26 | */ 27 | @Category({ SingleItemTestCategory.class }) 28 | public class SingleDynamoDBGraphPerformanceMemoryTest extends AbstractDynamoDBGraphPerformanceMemoryTest 29 | { 30 | public SingleDynamoDBGraphPerformanceMemoryTest() 31 | { 32 | super(BackendDataModel.SINGLE); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/SingleDynamoDBGraphSpeedTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.janusgraph.diskstorage.BackendException; 18 | import org.junit.experimental.categories.Category; 19 | 20 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 21 | import com.amazon.janusgraph.testcategory.SingleItemTestCategory; 22 | 23 | /** 24 | * 25 | * @author Alexander Patrikalakis 26 | * 27 | */ 28 | @Category({ SingleItemTestCategory.class }) 29 | public class SingleDynamoDBGraphSpeedTest extends AbstractDynamoDBGraphSpeedTest { 30 | 31 | public SingleDynamoDBGraphSpeedTest() throws BackendException { 32 | super(BackendDataModel.SINGLE); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/SingleDynamoDBOLAPTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.janusgraph.diskstorage.BackendException; 18 | import org.junit.experimental.categories.Category; 19 | 20 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 21 | import com.amazon.janusgraph.testcategory.SingleDynamoDBOLAPTestCategory; 22 | import com.amazon.janusgraph.testcategory.SingleItemTestCategory; 23 | 24 | /** 25 | * 26 | * @author Alexander Patrikalakis 27 | * 28 | */ 29 | @Category({ SingleDynamoDBOLAPTestCategory.class, SingleItemTestCategory.class}) 30 | public class SingleDynamoDBOLAPTest extends AbstractDynamoDBOLAPTest { 31 | 32 | public SingleDynamoDBOLAPTest() throws BackendException { 33 | super(BackendDataModel.SINGLE); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/SingleDynamoDBOperationCountingTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.junit.experimental.categories.Category; 18 | 19 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 20 | import com.amazon.janusgraph.testcategory.SingleItemTestCategory; 21 | 22 | /** 23 | * 24 | * @author Alexander Patrikalakis 25 | * 26 | */ 27 | @Category({ SingleItemTestCategory.class }) 28 | public class SingleDynamoDBOperationCountingTest extends AbstractDynamoDBOperationCountingTest { 29 | 30 | public SingleDynamoDBOperationCountingTest() { 31 | super(BackendDataModel.SINGLE); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/SingleDynamoDBPartitionGraphTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import org.junit.experimental.categories.Category; 18 | 19 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 20 | import com.amazon.janusgraph.testcategory.SingleItemTestCategory; 21 | 22 | /** 23 | * 24 | * @author Alexander Patrikalakis 25 | * 26 | */ 27 | @Category({ SingleItemTestCategory.class }) 28 | public class SingleDynamoDBPartitionGraphTest extends AbstractDynamoDBPartitionGraphTest 29 | { 30 | public SingleDynamoDBPartitionGraphTest() 31 | { 32 | super(BackendDataModel.SINGLE); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/graphdb/dynamodb/TestCombination.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.graphdb.dynamodb; 16 | 17 | import static com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel.MULTI; 18 | import static com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel.SINGLE; 19 | 20 | import com.amazon.janusgraph.diskstorage.dynamodb.BackendDataModel; 21 | import com.google.common.collect.Lists; 22 | import lombok.Getter; 23 | import lombok.RequiredArgsConstructor; 24 | 25 | import java.util.Collection; 26 | import java.util.Collections; 27 | import java.util.List; 28 | import java.util.stream.Collectors; 29 | 30 | /** 31 | * Test combinations for Lock store tests 32 | * 33 | * @author Alexander Patrikalakis 34 | * 35 | */ 36 | @RequiredArgsConstructor 37 | public enum TestCombination { 38 | SINGLE_ITEM_DYNAMODB_LOCKING(SINGLE, true), 39 | SINGLE_ITEM_JANUSGRAPH_LOCKING(SINGLE, false), 40 | MULTIPLE_ITEM_DYNAMODB_LOCKING(MULTI, true), 41 | MULTIPLE_ITEM_JANUSGRAPH_LOCKING(MULTI, false); 42 | 43 | @Getter 44 | private final BackendDataModel dataModel; 45 | @Getter 46 | private final Boolean useNativeLocking; 47 | 48 | public static final Collection LOCKING_CROSS_MODELS = 49 | Lists.newArrayList( 50 | SINGLE_ITEM_DYNAMODB_LOCKING, SINGLE_ITEM_JANUSGRAPH_LOCKING, 51 | MULTIPLE_ITEM_DYNAMODB_LOCKING, MULTIPLE_ITEM_JANUSGRAPH_LOCKING).stream() 52 | .map(Collections::singletonList) 53 | .map(List::toArray) 54 | .collect(Collectors.toList()); 55 | 56 | public static final Collection NATIVE_LOCKING_CROSS_MODELS = 57 | Lists.newArrayList( 58 | SINGLE_ITEM_DYNAMODB_LOCKING, 59 | MULTIPLE_ITEM_DYNAMODB_LOCKING).stream() 60 | .map(Collections::singletonList) 61 | .map(List::toArray) 62 | .collect(Collectors.toList()); 63 | 64 | 65 | 66 | public String toString() { 67 | return dataModel.getCamelCaseName() + (useNativeLocking ? "DynamoDB" : "JanusGraph") + "Locking"; 68 | } 69 | } -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/GraphSimpleLogTestCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * 19 | * @author Alexander Patrikalakis 20 | * 21 | */ 22 | public interface GraphSimpleLogTestCategory { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/IsolateMultiConcurrentGetSlice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * 19 | * @author Alexander Patrikalakis 20 | * 21 | */ 22 | public interface IsolateMultiConcurrentGetSlice { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/IsolateMultiConcurrentGetSliceAndMutate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * 19 | * @author Alexander Patrikalakis 20 | * 21 | */ 22 | public interface IsolateMultiConcurrentGetSliceAndMutate { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/IsolateMultiEdgesExceedCacheSize.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * 19 | * @author Alexander Patrikalakis 20 | * 21 | */ 22 | public interface IsolateMultiEdgesExceedCacheSize { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/IsolateMultiLargeJointIndexRetrieval.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * 19 | * @author Alexander Patrikalakis 20 | * 21 | */ 22 | public interface IsolateMultiLargeJointIndexRetrieval { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/IsolateMultiVertexCentricQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * 19 | * @author Alexander Patrikalakis 20 | * 21 | */ 22 | public interface IsolateMultiVertexCentricQuery { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/IsolateRemainingTestsCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * 19 | * @author Alexander Patrikalakis 20 | * 21 | */ 22 | public interface IsolateRemainingTestsCategory { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/IsolateSingleConcurrentGetSlice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * 19 | * @author Alexander Patrikalakis 20 | * 21 | */ 22 | public interface IsolateSingleConcurrentGetSlice { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/IsolateSingleConcurrentGetSliceAndMutate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * 19 | * @author Alexander Patrikalakis 20 | * 21 | */ 22 | public interface IsolateSingleConcurrentGetSliceAndMutate { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/MultiDynamoDBGraphTestCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * 19 | * @author Alexander Patrikalakis 20 | */ 21 | public interface MultiDynamoDBGraphTestCategory { 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/MultiDynamoDBMultiWriteStoreTestCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.janusgraph.testcategory; 17 | 18 | /** 19 | * This is a category for all multi write store tests of the multiple item data model 20 | * @author Johan Jacobs 21 | */ 22 | public interface MultiDynamoDBMultiWriteStoreTestCategory { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/MultiDynamoDBOLAPTestCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.janusgraph.testcategory; 17 | 18 | /** 19 | * This is a category for all OLAP tests of the multiple item data model 20 | * @author Johan Jacobs 21 | */ 22 | public interface MultiDynamoDBOLAPTestCategory { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/MultiDynamoDBStoreTestCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.janusgraph.testcategory; 17 | 18 | /** 19 | * This is a category for all store tests of the multiple item data model 20 | * @author Johan Jacobs 21 | */ 22 | public interface MultiDynamoDBStoreTestCategory { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/MultiIdAuthorityLogStoreCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * This is a category for all tests of the single item data model 19 | * @author Alexander Patrikalakis 20 | * 21 | */ 22 | public interface MultiIdAuthorityLogStoreCategory { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/MultipleItemTestCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * 19 | * @author Alexander Patrikalakis 20 | * 21 | */ 22 | public interface MultipleItemTestCategory { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/SingleDynamoDBGraphTestCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * This is a category for all graph tests of the single item data model 19 | * @author Johan Jacobs 20 | */ 21 | public interface SingleDynamoDBGraphTestCategory { 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/SingleDynamoDBMultiWriteStoreTestCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * This is a category for all multi store write tests of the single item data model 19 | * @author Johan Jacobs 20 | */ 21 | public interface SingleDynamoDBMultiWriteStoreTestCategory { 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/SingleDynamoDBOLAPTestCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * This is a category for all OLAP tests of the single item data model 19 | * @author Johan Jacobs 20 | */ 21 | public interface SingleDynamoDBOLAPTestCategory { 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/SingleDynamoDBStoreTestCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * This is a category for all store tests of the single item data model 19 | * @author Johan Jacobs 20 | */ 21 | public interface SingleDynamoDBStoreTestCategory { 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/SingleIdAuthorityLogStoreCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * This is a category for all tests of the single item data model 19 | * @author Alexander Patrikalakis 20 | * 21 | */ 22 | public interface SingleIdAuthorityLogStoreCategory { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testcategory/SingleItemTestCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.amazon.janusgraph.testcategory; 16 | 17 | /** 18 | * 19 | * @author Alexander Patrikalakis 20 | * 21 | */ 22 | public interface SingleItemTestCategory { 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testutils/CiHeartbeat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.janusgraph.testutils; 17 | 18 | import java.util.Timer; 19 | 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | 23 | /** 24 | * This heartbeat timer will print to the console every x configured milliseconds. This is to prevent Travis CI from 25 | * terminating the build if there is no console output in a 10min time frame. The heartbeat will only run for up to x 26 | * configured intervals, this is needed for tests which are really in a hung state and Travis CI can then fail the build. 27 | * 28 | * The heartbeat is started and stopped before and after each test case. The current running unit test and the current 29 | * execution time of the test is included in the heartbeat for better visibility in to any long running tests. 30 | * 31 | * @author Johan Jacobs 32 | * 33 | */ 34 | public class CiHeartbeat { 35 | 36 | private static final Logger LOG = LoggerFactory.getLogger(CiHeartbeat.class); 37 | 38 | private static final long DEFAULT_HEARTBEAT_INTERVAL = 300000; 39 | private static final int DEFAULT_MAXIMUM_INTERVALS = 8; 40 | 41 | private Timer heartbeatTimer; 42 | private boolean timerStarted; 43 | private final long configuredHeartbeatInterval; 44 | private final int configuredMaximumIntervals; 45 | private String configuredUnitTestName; 46 | private final long heartbeatStartTime; 47 | 48 | public CiHeartbeat() { 49 | this(DEFAULT_HEARTBEAT_INTERVAL, DEFAULT_MAXIMUM_INTERVALS); 50 | } 51 | 52 | public CiHeartbeat(final long heartbeatInterval, final int maximumIntervals) { 53 | 54 | this.configuredHeartbeatInterval = heartbeatInterval; 55 | this.configuredMaximumIntervals = maximumIntervals; 56 | this.heartbeatStartTime = System.currentTimeMillis(); 57 | } 58 | 59 | public void startHeartbeat(final String unitTestName) { 60 | 61 | if(this.timerStarted) { 62 | LOG.warn(String.format("Travis CI heartbeat timer is already running for unit test with name: %s.", this.configuredUnitTestName)); 63 | return; 64 | } 65 | 66 | this.configuredUnitTestName = unitTestName; 67 | this.heartbeatTimer = new Timer("Unit test heartbeat timer"); 68 | 69 | final HeartbeatTimerTask heartbeatTimerTask = new HeartbeatTimerTask(this.configuredMaximumIntervals, this.heartbeatStartTime, this.configuredUnitTestName); 70 | this.heartbeatTimer.schedule(heartbeatTimerTask, this.configuredHeartbeatInterval, this.configuredHeartbeatInterval); 71 | 72 | this.timerStarted = true; 73 | 74 | LOG.info(String.format("Heartbeat - [started] - %s - 0ms", 75 | this.configuredUnitTestName)); 76 | } 77 | 78 | public void stopHeartbeat() { 79 | 80 | if (this.heartbeatTimer != null && this.timerStarted) { 81 | this.heartbeatTimer.cancel(); 82 | this.heartbeatTimer = null; 83 | this.timerStarted = false; 84 | 85 | final long currentRunTimeMilliseconds = System.currentTimeMillis() - heartbeatStartTime; 86 | 87 | LOG.info(String.format("Heartbeat - [finished] - %s - %dms", 88 | configuredUnitTestName, 89 | currentRunTimeMilliseconds)); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/test/java/com/amazon/janusgraph/testutils/HeartbeatTimerTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | package com.amazon.janusgraph.testutils; 17 | 18 | import java.util.TimerTask; 19 | 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | 23 | /** 24 | * 25 | * @author Johan Jacobs 26 | * 27 | */ 28 | public class HeartbeatTimerTask extends TimerTask { 29 | 30 | private static final Logger LOG = LoggerFactory.getLogger(HeartbeatTimerTask.class); 31 | 32 | private int intervals; 33 | private final int configuredMaximumIntervals; 34 | private final long heartbeatStartTime; 35 | private final String configuredUnitTestName; 36 | 37 | public HeartbeatTimerTask(final int configuredMaximumIntervals, final long heartbeatStartTime, final String configuredUnitTestName) { 38 | this.configuredMaximumIntervals = configuredMaximumIntervals; 39 | this.heartbeatStartTime = heartbeatStartTime; 40 | this.configuredUnitTestName = configuredUnitTestName; 41 | } 42 | 43 | @Override 44 | public void run() { 45 | 46 | intervals++; 47 | final long currentRunTimeMilliseconds = System.currentTimeMillis() - heartbeatStartTime; 48 | 49 | if (intervals == configuredMaximumIntervals) { 50 | LOG.warn(String.format("Heartbeat - [%d] - %s - %dms.", 51 | intervals, 52 | configuredUnitTestName, 53 | currentRunTimeMilliseconds)); 54 | return; 55 | } 56 | 57 | LOG.info(String.format("Heartbeat - [%d] - %s - %dms", 58 | intervals, 59 | configuredUnitTestName, 60 | currentRunTimeMilliseconds)); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/test/java/com/google/common/util/concurrent/RateLimiterCreatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://aws.amazon.com/apache2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | package com.google.common.util.concurrent; 16 | 17 | import static org.junit.Assert.assertEquals; 18 | 19 | import java.util.concurrent.TimeUnit; 20 | 21 | import org.junit.Test; 22 | 23 | /** 24 | * 25 | * @author Alexander Patrikalakis 26 | */ 27 | public class RateLimiterCreatorTest { 28 | 29 | static final double DELTA = 0.1; 30 | 31 | @Test 32 | public void testTrickleBurst() { 33 | final RateLimiter l = RateLimiterCreator.createBurstingLimiter(1 /*rate*/,1 /*burstBucketSize*/); 34 | double waited = l.acquire(1); 35 | assertEquals(0.0, waited, DELTA); 36 | waited = l.acquire(1); 37 | assertEquals(1.0, waited, DELTA); 38 | Uninterruptibles.sleepUninterruptibly(5, TimeUnit.SECONDS); 39 | waited = l.acquire(5); 40 | assertEquals(0.0, waited, DELTA); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/resources/current-gen-instance-types: -------------------------------------------------------------------------------- 1 | t2.nano 2 | t2.micro 3 | t2.small 4 | t2.medium 5 | t2.large 6 | t2.xlarge 7 | t2.2xlarge 8 | m4.large 9 | m4.xlarge 10 | m4.2xlarge 11 | m4.4xlarge 12 | m4.10xlarge 13 | m4.16xlarge 14 | m5.large 15 | m5.xlarge 16 | m5.2xlarge 17 | m5.4xlarge 18 | m5.12xlarge 19 | m5.24xlarge 20 | m5d.large 21 | m5d.xlarge 22 | m5d.2xlarge 23 | m5d.4xlarge 24 | m5d.12xlarge 25 | m5d.24xlarge 26 | c4.large 27 | c4.xlarge 28 | c4.2xlarge 29 | c4.4xlarge 30 | c4.8xlarge 31 | c5.large 32 | c5.xlarge 33 | c5.2xlarge 34 | c5.4xlarge 35 | c5.9xlarge 36 | c5.18xlarge 37 | c5d.xlarge 38 | c5d.2xlarge 39 | c5d.4xlarge 40 | c5d.9xlarge 41 | c5d.18xlarge 42 | r4.large 43 | r4.xlarge 44 | r4.2xlarge 45 | r4.4xlarge 46 | r4.8xlarge 47 | r4.16xlarge 48 | x1.16xlarge 49 | x1.32xlarge 50 | x1e.xlarge 51 | x1e.2xlarge 52 | x1e.4xlarge 53 | x1e.8xlarge 54 | x1e.16xlarge 55 | x1e.32xlarge 56 | d2.xlarge 57 | d2.2xlarge 58 | d2.4xlarge 59 | d2.8xlarge 60 | h1.2xlarge 61 | h1.4xlarge 62 | h1.8xlarge 63 | h1.16xlarge 64 | i3.large 65 | i3.xlarge 66 | i3.2xlarge 67 | i3.4xlarge 68 | i3.8xlarge 69 | i3.16xlarge 70 | i3.metal 71 | f1.2xlarge 72 | f1.16xlarge 73 | g3.4xlarge 74 | g3.8xlarge 75 | g3.16xlarge 76 | p2.xlarge 77 | p2.8xlarge 78 | p2.16xlarge 79 | p3.2xlarge 80 | p3.8xlarge 81 | p3.16xlarge 82 | -------------------------------------------------------------------------------- /src/test/resources/docker-compose.yml: -------------------------------------------------------------------------------- 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" 42 | -------------------------------------------------------------------------------- /src/test/resources/dynamodb-janusgraph-docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2017-2018 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 amazonlinux 17 | RUN yum update -y -q -e 0 && yum upgrade -y -q -e 0 && yum install -y -q java-1.8.0-openjdk unzip 18 | 19 | ARG server_zip 20 | ADD ${server_zip} /var 21 | 22 | RUN server_base=`basename ${server_zip} .zip` && \ 23 | unzip -q /var/${server_base}.zip -d /var && \ 24 | mv /var/${server_base} /var/jg 25 | 26 | WORKDIR /var/jg 27 | -------------------------------------------------------------------------------- /src/test/resources/dynamodb-local-docker.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). 5 | # You may not use this file except in compliance with the License. 6 | # A copy of the License is located at 7 | # 8 | # http://aws.amazon.com/apache2.0 9 | # 10 | # or in the "license" file accompanying this file. This file is distributed 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | # express or implied. See the License for the specific language governing 13 | # permissions and limitations under the License. 14 | # 15 | 16 | gremlin.graph=org.janusgraph.core.JanusGraphFactory 17 | #metrics.enabled=true 18 | #metrics.prefix=j 19 | #metrics.csv.interval=1000 20 | #metrics.csv.directory=metrics 21 | 22 | # Turn off JanusGraph retries as we batch and have our own exponential backoff strategy. 23 | storage.write-time=1 ms 24 | storage.read-time=1 ms 25 | 26 | storage.backend=com.amazon.janusgraph.diskstorage.dynamodb.DynamoDBStoreManager 27 | storage.dynamodb.client.credentials.class-name=com.amazonaws.auth.BasicAWSCredentials 28 | storage.dynamodb.client.credentials.constructor-args=access,secret 29 | storage.dynamodb.client.signing-region=us-east-1 30 | 31 | storage.dynamodb.client.endpoint=http://dynamodb-local:8000 32 | 33 | storage.dynamodb.stores.edgestore.initial-capacity-read=12 34 | storage.dynamodb.stores.edgestore.initial-capacity-write=12 35 | storage.dynamodb.stores.edgestore.read-rate=1000 36 | storage.dynamodb.stores.edgestore.write-rate=1000 37 | 38 | storage.dynamodb.stores.graphindex.initial-capacity-read=9 39 | storage.dynamodb.stores.graphindex.initial-capacity-write=9 40 | storage.dynamodb.stores.graphindex.read-rate=1000 41 | storage.dynamodb.stores.graphindex.write-rate=1000 42 | 43 | storage.dynamodb.stores.systemlog.initial-capacity-read=1 44 | storage.dynamodb.stores.systemlog.initial-capacity-write=1 45 | storage.dynamodb.stores.systemlog.read-rate=1 46 | storage.dynamodb.stores.systemlog.write-rate=1 47 | 48 | storage.dynamodb.stores.janusgraph_ids.initial-capacity-read=1 49 | storage.dynamodb.stores.janusgraph_ids.initial-capacity-write=1 50 | storage.dynamodb.stores.janusgraph_ids.read-rate=1 51 | storage.dynamodb.stores.janusgraph_ids.write-rate=1 52 | 53 | storage.dynamodb.stores.system_properties.initial-capacity-read=1 54 | storage.dynamodb.stores.system_properties.initial-capacity-write=1 55 | storage.dynamodb.stores.system_properties.read-rate=1 56 | storage.dynamodb.stores.system_properties.write-rate=1 57 | 58 | storage.dynamodb.stores.txlog.initial-capacity-read=1 59 | storage.dynamodb.stores.txlog.initial-capacity-write=1 60 | storage.dynamodb.stores.txlog.read-rate=1 61 | storage.dynamodb.stores.txlog.write-rate=1 62 | -------------------------------------------------------------------------------- /src/test/resources/dynamodb-local-docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2017-2018 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 amazonlinux 17 | 18 | RUN yum update -y -q -e 0 && yum upgrade -y -q -e 0 \ 19 | && yum install -y -q java-1.8.0-openjdk sqlite3 libsqlite3-dev wget tar gzip \ 20 | && mkdir -p /var/dynamodblocal 21 | WORKDIR /var/dynamodblocal 22 | RUN wget https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz -q -O - | tar -xz 23 | EXPOSE 8000 24 | ENTRYPOINT ["java", "-jar", "DynamoDBLocal.jar", "-inMemory"] 25 | -------------------------------------------------------------------------------- /src/test/resources/dynamodb-local.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). 5 | # You may not use this file except in compliance with the License. 6 | # A copy of the License is located at 7 | # 8 | # http://aws.amazon.com/apache2.0 9 | # 10 | # or in the "license" file accompanying this file. This file is distributed 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | # express or implied. See the License for the specific language governing 13 | # permissions and limitations under the License. 14 | # 15 | 16 | gremlin.graph=org.janusgraph.core.JanusGraphFactory 17 | #metrics.enabled=true 18 | #metrics.prefix=j 19 | #metrics.csv.interval=1000 20 | #metrics.csv.directory=metrics 21 | 22 | # Turn off JanusGraph retries as we batch and have our own exponential backoff strategy. 23 | storage.write-time=1 ms 24 | storage.read-time=1 ms 25 | 26 | storage.backend=com.amazon.janusgraph.diskstorage.dynamodb.DynamoDBStoreManager 27 | storage.dynamodb.client.credentials.class-name=com.amazonaws.auth.BasicAWSCredentials 28 | storage.dynamodb.client.credentials.constructor-args=access,secret 29 | storage.dynamodb.client.signing-region=us-east-1 30 | 31 | storage.dynamodb.client.endpoint=http://localhost:4567 32 | 33 | storage.dynamodb.stores.edgestore.initial-capacity-read=12 34 | storage.dynamodb.stores.edgestore.initial-capacity-write=12 35 | storage.dynamodb.stores.edgestore.read-rate=1000 36 | storage.dynamodb.stores.edgestore.write-rate=1000 37 | 38 | storage.dynamodb.stores.graphindex.initial-capacity-read=9 39 | storage.dynamodb.stores.graphindex.initial-capacity-write=9 40 | storage.dynamodb.stores.graphindex.read-rate=1000 41 | storage.dynamodb.stores.graphindex.write-rate=1000 42 | 43 | storage.dynamodb.stores.systemlog.initial-capacity-read=1 44 | storage.dynamodb.stores.systemlog.initial-capacity-write=1 45 | storage.dynamodb.stores.systemlog.read-rate=1 46 | storage.dynamodb.stores.systemlog.write-rate=1 47 | 48 | storage.dynamodb.stores.janusgraph_ids.initial-capacity-read=1 49 | storage.dynamodb.stores.janusgraph_ids.initial-capacity-write=1 50 | storage.dynamodb.stores.janusgraph_ids.read-rate=1 51 | storage.dynamodb.stores.janusgraph_ids.write-rate=1 52 | 53 | storage.dynamodb.stores.system_properties.initial-capacity-read=1 54 | storage.dynamodb.stores.system_properties.initial-capacity-write=1 55 | storage.dynamodb.stores.system_properties.read-rate=1 56 | storage.dynamodb.stores.system_properties.write-rate=1 57 | 58 | storage.dynamodb.stores.txlog.initial-capacity-read=1 59 | storage.dynamodb.stores.txlog.initial-capacity-write=1 60 | storage.dynamodb.stores.txlog.read-rate=1 61 | storage.dynamodb.stores.txlog.write-rate=1 62 | -------------------------------------------------------------------------------- /src/test/resources/dynamodb.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). 5 | # You may not use this file except in compliance with the License. 6 | # A copy of the License is located at 7 | # 8 | # http://aws.amazon.com/apache2.0 9 | # 10 | # or in the "license" file accompanying this file. This file is distributed 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | # express or implied. See the License for the specific language governing 13 | # permissions and limitations under the License. 14 | # 15 | 16 | gremlin.graph=org.janusgraph.core.JanusGraphFactory 17 | #metrics.enabled=true 18 | #metrics.prefix=j 19 | #metrics.csv.interval=1000 20 | #metrics.csv.directory=metrics 21 | 22 | # Turn off JanusGraph retries as we batch and have our own exponential backoff strategy. 23 | storage.write-time=1 ms 24 | storage.read-time=1 ms 25 | 26 | storage.backend=com.amazon.janusgraph.diskstorage.dynamodb.DynamoDBStoreManager 27 | storage.dynamodb.client.credentials.class-name=com.amazonaws.auth.DefaultAWSCredentialsProviderChain 28 | storage.dynamodb.client.credentials.constructor-args= 29 | storage.dynamodb.client.signing-region=us-west-2 30 | 31 | 32 | 33 | storage.dynamodb.stores.edgestore.initial-capacity-read=12 34 | storage.dynamodb.stores.edgestore.initial-capacity-write=12 35 | storage.dynamodb.stores.edgestore.read-rate=12 36 | storage.dynamodb.stores.edgestore.write-rate=12 37 | 38 | storage.dynamodb.stores.graphindex.initial-capacity-read=9 39 | storage.dynamodb.stores.graphindex.initial-capacity-write=9 40 | storage.dynamodb.stores.graphindex.read-rate=9 41 | storage.dynamodb.stores.graphindex.write-rate=9 42 | 43 | storage.dynamodb.stores.systemlog.initial-capacity-read=1 44 | storage.dynamodb.stores.systemlog.initial-capacity-write=1 45 | storage.dynamodb.stores.systemlog.read-rate=1 46 | storage.dynamodb.stores.systemlog.write-rate=1 47 | 48 | storage.dynamodb.stores.janusgraph_ids.initial-capacity-read=1 49 | storage.dynamodb.stores.janusgraph_ids.initial-capacity-write=1 50 | storage.dynamodb.stores.janusgraph_ids.read-rate=1 51 | storage.dynamodb.stores.janusgraph_ids.write-rate=1 52 | 53 | storage.dynamodb.stores.system_properties.initial-capacity-read=1 54 | storage.dynamodb.stores.system_properties.initial-capacity-write=1 55 | storage.dynamodb.stores.system_properties.read-rate=1 56 | storage.dynamodb.stores.system_properties.write-rate=1 57 | 58 | storage.dynamodb.stores.txlog.initial-capacity-read=1 59 | storage.dynamodb.stores.txlog.initial-capacity-write=1 60 | storage.dynamodb.stores.txlog.read-rate=1 61 | storage.dynamodb.stores.txlog.write-rate=1 62 | -------------------------------------------------------------------------------- /src/test/resources/get-recent-al-amis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 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 | 17 | 18 | LATER_THAN_DATE=$1 19 | 20 | aws ec2 describe-regions --query 'Regions[*].[RegionName]' | sed -e '/\[/d' -e '/\]/d' -e "s/^[ \t]*//" | sed 's/\"//g' | sort | while read region; do 21 | echo " ${region}:" 22 | aws ec2 describe-images \ 23 | --region ${region} \ 24 | --owners amazon \ 25 | --filters "Name=root-device-type,Values=ebs" "Name=name,Values=amzn-ami-*" \ 26 | --query 'Images[? CreationDate > `'${LATER_THAN_DATE}'` && !contains(Name, `minimal`) && !contains(Name, `nat`)].[ImageId, ImageLocation]' |\ 27 | grep "\"" |\ 28 | sed -e 's/^[ ]*\(.*\)[ ]*$/\1/' -e '/\"$/s/$/%/' |\ 29 | tr "\n" "@" |\ 30 | tr "%" "\n" |\ 31 | sed -e 's/[ ]*@//g' \ 32 | -e "/^[ \t]*$/d" \ 33 | -e 's/\"//g' \ 34 | -e 's/\(.*\),\(.*\)/\2,\1/' \ 35 | -e '/pv/s/\(.*\),\(.*\)/PV64:\ \2/' \ 36 | -e '/x86_64-gp2/s/\(.*\),\(.*\)/HVMG2:\ \2/' \ 37 | -e '/x86_64-ebs/s/\(.*\),\(.*\)/HVM64:\ \2/' \ 38 | -e 's/^/\ \ \ \ \ \ /' | sort 39 | done 40 | -------------------------------------------------------------------------------- /src/test/resources/gremlin-server-local-docker.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # Portions copyright Titan: Distributed Graph Database - Copyright 2012 and onwards Aurelius. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). 5 | # You may not use this file except in compliance with the License. 6 | # A copy of the License is located at 7 | # 8 | # http://aws.amazon.com/apache2.0 9 | # 10 | # or in the "license" file accompanying this file. This file is distributed 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | # express or implied. See the License for the specific language governing 13 | # permissions and limitations under the License. 14 | # 15 | # This file was adapted from the following file: 16 | # https://github.com/thinkaurelius/titan/blob/1.0.0/titan-dist/src/assembly/static/conf/gremlin-server/gremlin-server.yaml 17 | # 18 | host: 0.0.0.0 19 | port: 8182 20 | threadPoolWorker: 1 21 | gremlinPool: 8 22 | scriptEvaluationTimeout: 30000 23 | serializedResponseTimeout: 30000 24 | channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer 25 | graphs: { 26 | graph: conf/gremlin-server/dynamodb-local-docker.properties} 27 | plugins: 28 | - janusgraph.imports 29 | scriptEngines: { 30 | gremlin-groovy: { 31 | imports: [java.lang.Math], 32 | staticImports: [java.lang.Math.PI], 33 | scripts: [scripts/empty-sample.groovy]}} 34 | serializers: 35 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 36 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: {ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 37 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }} 38 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 39 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 40 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 41 | processors: 42 | - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }} 43 | - { className: org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor, config: { cacheExpirationTime: 600000, cacheMaxSize: 1000 }} 44 | metrics: { 45 | consoleReporter: {enabled: true, interval: 180000}, 46 | csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv}, 47 | jmxReporter: {enabled: true}, 48 | slf4jReporter: {enabled: true, interval: 180000}, 49 | gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST}, 50 | graphiteReporter: {enabled: false, interval: 180000}} 51 | maxInitialLineLength: 4096 52 | maxHeaderSize: 8192 53 | maxChunkSize: 8192 54 | maxContentLength: 65536 55 | maxAccumulationBufferComponents: 1024 56 | resultIterationBatchSize: 64 57 | writeBufferLowWaterMark: 32768 58 | writeBufferHighWaterMark: 65536 59 | ssl: { 60 | enabled: false} 61 | -------------------------------------------------------------------------------- /src/test/resources/gremlin-server-local.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # Portions copyright Titan: Distributed Graph Database - Copyright 2012 and onwards Aurelius. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). 5 | # You may not use this file except in compliance with the License. 6 | # A copy of the License is located at 7 | # 8 | # http://aws.amazon.com/apache2.0 9 | # 10 | # or in the "license" file accompanying this file. This file is distributed 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | # express or implied. See the License for the specific language governing 13 | # permissions and limitations under the License. 14 | # 15 | # This file was adapted from the following file: 16 | # https://github.com/thinkaurelius/titan/blob/1.0.0/titan-dist/src/assembly/static/conf/gremlin-server/gremlin-server.yaml 17 | # 18 | host: 0.0.0.0 19 | port: 8182 20 | threadPoolWorker: 1 21 | gremlinPool: 8 22 | scriptEvaluationTimeout: 30000 23 | serializedResponseTimeout: 30000 24 | channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer 25 | graphs: { 26 | graph: conf/gremlin-server/dynamodb-local.properties} 27 | plugins: 28 | - janusgraph.imports 29 | scriptEngines: { 30 | gremlin-groovy: { 31 | imports: [java.lang.Math], 32 | staticImports: [java.lang.Math.PI], 33 | scripts: [scripts/empty-sample.groovy]}} 34 | serializers: 35 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 36 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: {ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 37 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }} 38 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 39 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 40 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 41 | processors: 42 | - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }} 43 | - { className: org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor, config: { cacheExpirationTime: 600000, cacheMaxSize: 1000 }} 44 | metrics: { 45 | consoleReporter: {enabled: true, interval: 180000}, 46 | csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv}, 47 | jmxReporter: {enabled: true}, 48 | slf4jReporter: {enabled: true, interval: 180000}, 49 | gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST}, 50 | graphiteReporter: {enabled: false, interval: 180000}} 51 | maxInitialLineLength: 4096 52 | maxHeaderSize: 8192 53 | maxChunkSize: 8192 54 | maxContentLength: 65536 55 | maxAccumulationBufferComponents: 1024 56 | resultIterationBatchSize: 64 57 | writeBufferLowWaterMark: 32768 58 | writeBufferHighWaterMark: 65536 59 | ssl: { 60 | enabled: false} 61 | -------------------------------------------------------------------------------- /src/test/resources/gremlin-server.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # Portions copyright Titan: Distributed Graph Database - Copyright 2012 and onwards Aurelius. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). 5 | # You may not use this file except in compliance with the License. 6 | # A copy of the License is located at 7 | # 8 | # http://aws.amazon.com/apache2.0 9 | # 10 | # or in the "license" file accompanying this file. This file is distributed 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | # express or implied. See the License for the specific language governing 13 | # permissions and limitations under the License. 14 | # 15 | # This file was adapted from the following file: 16 | # https://github.com/thinkaurelius/titan/blob/1.0.0/titan-dist/src/assembly/static/conf/gremlin-server/gremlin-server.yaml 17 | # 18 | host: 0.0.0.0 19 | port: 8182 20 | threadPoolWorker: 1 21 | gremlinPool: 8 22 | scriptEvaluationTimeout: 30000 23 | serializedResponseTimeout: 30000 24 | channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer 25 | graphs: { 26 | graph: conf/gremlin-server/dynamodb.properties} 27 | plugins: 28 | - janusgraph.imports 29 | scriptEngines: { 30 | gremlin-groovy: { 31 | imports: [java.lang.Math], 32 | staticImports: [java.lang.Math.PI], 33 | scripts: [scripts/empty-sample.groovy]}} 34 | serializers: 35 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 36 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: {ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 37 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }} 38 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 39 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 40 | - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 41 | processors: 42 | - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }} 43 | - { className: org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor, config: { cacheExpirationTime: 600000, cacheMaxSize: 1000 }} 44 | metrics: { 45 | consoleReporter: {enabled: true, interval: 180000}, 46 | csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv}, 47 | jmxReporter: {enabled: true}, 48 | slf4jReporter: {enabled: true, interval: 180000}, 49 | gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST}, 50 | graphiteReporter: {enabled: false, interval: 180000}} 51 | maxInitialLineLength: 4096 52 | maxHeaderSize: 8192 53 | maxChunkSize: 8192 54 | maxContentLength: 65536 55 | maxAccumulationBufferComponents: 1024 56 | resultIterationBatchSize: 64 57 | writeBufferLowWaterMark: 32768 58 | writeBufferHighWaterMark: 65536 59 | ssl: { 60 | enabled: false} 61 | -------------------------------------------------------------------------------- /src/test/resources/install-reqs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"). 7 | # You may not use this file except in compliance with the License. 8 | # A copy of the License is located at 9 | # 10 | # http://aws.amazon.com/apache2.0 11 | # 12 | # or in the "license" file accompanying this file. This file is distributed 13 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 14 | # express or implied. See the License for the specific language governing 15 | # permissions and limitations under the License. 16 | # 17 | 18 | sudo -i 19 | wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo \ 20 | -O /etc/yum.repos.d/epel-apache-maven.repo 21 | sed -i s/\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo 22 | yum update -y && sudo yum upgrade -y 23 | yum install -y apache-maven sqlite-devel git java-1.8.0-openjdk-devel docker 24 | service docker start 25 | usermod -a -G docker ec2-user 26 | alternatives --set java /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java 27 | alternatives --set javac /usr/lib/jvm/java-1.8.0-openjdk.x86_64/bin/javac 28 | curl -L "https://github.com/docker/compose/releases/download/1.11.2/docker-compose-$(uname -s)-$(uname -m)" \ 29 | -o /usr/local/bin/docker-compose 30 | chmod +x /usr/local/bin/docker-compose 31 | exit 32 | -------------------------------------------------------------------------------- /src/test/resources/janusgraph-0.2.0-hadoop2.zip.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1 3 | 4 | iQIcBAABCgAGBQJZ3oovAAoJEGa4X/FBgCuoZrEP/15iXGPfGB8N26aTnaTEcOUR 5 | 7Qksk6FnnGy/gRUu0BrAaTcoHGYZJ7kTGlBIas3HAWt7kOfdTtgoJxaGyjNir/oo 6 | zoqhwC369XysXem3UGiJh4sbOpmqh6TQTsg6hgPTIsF/FJCgtZntV5ozVr+lxPtV 7 | pFobG1bVKdeiC89Y0nqQ+6NcdkwEMqHyWUKh2AfNrIG82omp/yWVJJe+Hl5VA7nZ 8 | WUdz0A87f07+VFbBkHBx0z5iCymd7Tps59ohWsf6RrVxZtNaXApvqz5MN3WhvukP 9 | S3rJgfWpI7KgDceg96SGcs4Ep/gCx9PiK0EUbQt4kj0vpKS28YzCyJ+xG8/vSy4V 10 | 0x+GWWXXWDxkaxdnWCg86Uq5tPZKTWFD9x53W0LfHZhKXuaF+VAm8czLRPXvwI1z 11 | KKJdIQFZ8iQWk6e2s+OangM0m4HlADS8W669NRO582oimG3fIdtUxlKm9l4dM6/p 12 | GGGggFALaeT3tcduFsS5/9BDIamEFdAVUR/J5oRdTKyX9qQUp/sY6PFUSg1Qw7Sc 13 | Bcr1Qs8F/GNpGxKRa+DVU3WluFUqiqt3Kv8A/aBtIjqKKBIo6FpHMe3zrtn99qvz 14 | fLYKlmgDgoeHgHYW87ua0vRq9YTqvIMsKuFQIWs1lScupUaO4Qifq9ohMffaVA21 15 | jUB5sikK//jKosQ39fG7 16 | =4zSE 17 | -----END PGP SIGNATURE----- 18 | -------------------------------------------------------------------------------- /src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). 5 | # You may not use this file except in compliance with the License. 6 | # A copy of the License is located at 7 | # 8 | # http://aws.amazon.com/apache2.0 9 | # 10 | # or in the "license" file accompanying this file. This file is distributed 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | # express or implied. See the License for the specific language governing 13 | # permissions and limitations under the License. 14 | # 15 | 16 | log4j.rootLogger=info, stdout 17 | #log4j.logger.com.amazon.janusgraph=trace 18 | log4j.logger.com.amazon.janusgraph.testutils=INFO 19 | log4j.logger.org.janusgraph=ERROR 20 | log4j.category.org.elasticsearch=ERROR 21 | log4j.logger.com.amazonaws=ERROR 22 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 23 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 24 | 25 | # Pattern to output the caller's file name and line number. 26 | log4j.appender.stdout.layout.ConversionPattern=%d (%t) [%5p] (%F:%L) - %m%n 27 | -------------------------------------------------------------------------------- /src/test/resources/remote.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | # Portions copyright Titan: Distributed Graph Database - Copyright 2012 and onwards Aurelius. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). 5 | # You may not use this file except in compliance with the License. 6 | # A copy of the License is located at 7 | # 8 | # http://aws.amazon.com/apache2.0 9 | # 10 | # or in the "license" file accompanying this file. This file is distributed 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | # express or implied. See the License for the specific language governing 13 | # permissions and limitations under the License. 14 | # 15 | # This file was adapted from the following file: 16 | # https://github.com/thinkaurelius/titan/blob/1.0.0/titan-dist/src/assembly/static/conf/gremlin-server/remote.yaml 17 | # 18 | hosts: [localhost] 19 | port: 8182 20 | serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }} -------------------------------------------------------------------------------- /src/test/resources/titan-upgrade.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"). 5 | # You may not use this file except in compliance with the License. 6 | # A copy of the License is located at 7 | # 8 | # http://aws.amazon.com/apache2.0 9 | # 10 | # or in the "license" file accompanying this file. This file is distributed 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | # express or implied. See the License for the specific language governing 13 | # permissions and limitations under the License. 14 | # 15 | gremlin.graph=org.janusgraph.core.JanusGraphFactory 16 | storage.write-time=1 ms 17 | storage.read-time=1 ms 18 | storage.backend=com.amazon.janusgraph.diskstorage.dynamodb.DynamoDbStoreManager 19 | storage.dynamodb.prefix=v100 20 | ids.store-name=titan_ids 21 | storage.dynamodb.client.credentials.class-name=com.amazonaws.auth.DefaultAWSCredentialsProviderChain 22 | storage.dynamodb.client.credentials.constructor-args= 23 | storage.dynamodb.client.endpoint=https://dynamodb.us-east-1.amazonaws.com 24 | storage.dynamodb.client.signing-region=us-east-1 25 | -------------------------------------------------------------------------------- /src/test/resources/type-to-arch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 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 | 17 | cat $1 | while read instance_type; do 18 | echo " ${instance_type}:" 19 | if [[ $instance_type == "g2"* ]]; then 20 | echo " Arch: HVMG2" 21 | else 22 | echo " Arch: HVM64" 23 | fi 24 | done 25 | --------------------------------------------------------------------------------