我正在尝试执行以下流程:
用户点击 AWS Gateway (REST),
它触发 AWS Lambda,
使用 Tinkerpop/Gremlin 连接到
EC2 上的 TitanDB,它使用
云中的 AWS DynamoDB(不在 EC2 上)作为后端。
现在,我已经设法在 EC2 上创建了完全正常工作的 TitanDB 实例,该实例将数据存储在云中的 DynamoDB 中。我也可以通过 Tinkerpop/Gremlin 从 AWS Lambda 连接到 EC2,但只能通过这种方式:
Cluster.build()
.addContactPoint("10.x.x.x") // ip of EC2
.create()
.connect()
.submit("here I type my query as string and it will work");
这很有效,但是我更喜欢使用“Criteria API”(GremlinPipeline)而不是简单的 Gremlin 语言。换句话说,我需要 ORM 或类似的东西。我知道,Tinkerpop 包含它。我已经意识到,我需要的是类 Graph 的对象。这是我尝试过的:
Graph graph = TitanFactory
.build()
.set("storage.hostname", "10.x.x.x")
.set("storage.backend", "com.amazon.titan.diskstorage.dynamodb.DynamoDBStoreManager")
.set("storage.dynamodb.client.credentials.class-name", "com.amazonaws.auth.DefaultAWSCredentialsProviderChain")
.set("storage.dynamodb.client.credentials.constructor-args", "")
.set("storage.dynamodb.client.endpoint", "https://dynamodb.ap-southeast-2.amazonaws.com")
.open();
但是,它会抛出“找不到实现类:com.amazon.titan.diskstorage.dynamodb.DynamoDBStoreManager”。当然,计算机是正确的,因为 IntelliJ IDEA 也找不到它。
我的依赖:
//
// aws
compile 'com.amazonaws:aws-lambda-java-core:+'
compile 'com.amazonaws:aws-lambda-java-events:+'
compile 'com.amazonaws:aws-lambda-java-log4j:+'
compile 'com.amazonaws:aws-java-sdk-dynamodb:1.10.5.1'
compile 'com.amazonaws:aws-java-sdk-ec2:+'
//
// database
// titan 1.0.0 is compatible with gremlin 3.0.2-incubating, but not yet with 3.2.0
compile 'com.thinkaurelius.titan:titan-core:1.0.0'
compile 'org.apache.tinkerpop:gremlin-core:3.0.2-incubating'
compile 'org.apache.tinkerpop:gremlin-driver:3.0.2-incubating'
我的目标是什么:拥有完全正常工作的 Graph 对象
我的问题是什么:我没有 DynamoDBStoreManager 类,也不知道我必须添加什么依赖项。
我的另一个问题是:为什么通过 Cluster 类连接只需要 IP 并且可以工作,但 TitanFactory 需要像我在 EC2 上的 gremlin-server 上使用的那些属性?我不想创建第二个服务器,我只想作为客户端连接到它并获取 Graph 对象。
编辑:添加解析器后,它会构建,在输出中我得到多个:
13689 [TitanID(0)(4)[0]] 警告 com.thinkaurelius.titan.diskstorage.idmanagement.ConsistentKeyIDAuthority - 获取 id 块时出现临时存储异常 - 在 PT2.4S 中重试:com.thinkaurelius.titan.diskstorage.TemporaryBackendException:在 PT0.342S 中为 id 块 [1, 51) 编写声明 => 太慢,阈值为:PT0.3S
并且执行挂在 open() 方法上,因此不允许我执行任何查询。