mirror of
https://github.com/JHUAPL/AccumuloGraph.git
synced 2026-01-11 13:47:54 -05:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9abbc25f4e | ||
|
|
d717030169 | ||
|
|
a2e0a9b6f9 | ||
|
|
fffc731507 | ||
|
|
1f630eb3ef |
2
pom.xml
2
pom.xml
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>edu.jhuapl.tinkerpop</groupId>
|
||||
<artifactId>blueprints-accumulo-graph</artifactId>
|
||||
<version>0.2.1</version>
|
||||
<version>0.2.2-SNAPSHOT</version>
|
||||
<name>blueprints-accumulo-graph</name>
|
||||
<description>An Accumulo-backed implementation of the Tinkerpop Blueprints graph API.</description>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -19,6 +19,8 @@ import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.attribute.FileAttribute;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -75,7 +77,7 @@ implements Serializable {
|
||||
/**
|
||||
* Temp directory used by getInstance when a Mini InstanceType is used.
|
||||
*/
|
||||
private String miniClusterTempDir;
|
||||
private File miniClusterTempDir;
|
||||
private MiniAccumuloCluster accumuloMiniCluster;
|
||||
|
||||
|
||||
@@ -254,6 +256,7 @@ implements Serializable {
|
||||
InstanceType.Mini.equals(type)) {
|
||||
setUser("root");
|
||||
setPassword("");
|
||||
setInstanceName("");
|
||||
setCreate(true);
|
||||
}
|
||||
|
||||
@@ -895,6 +898,20 @@ implements Serializable {
|
||||
if (connector == null) {
|
||||
Instance inst = null;
|
||||
switch (getInstanceType()) {
|
||||
case Mini:
|
||||
if (miniClusterTempDir == null) {
|
||||
miniClusterTempDir = Files.createTempDirectory("accumulo-mini").toFile();
|
||||
}
|
||||
accumuloMiniCluster = new MiniAccumuloCluster(miniClusterTempDir, ""); // conf.getString(PASSWORD)
|
||||
try {
|
||||
accumuloMiniCluster.start();
|
||||
} catch (Exception ex) {
|
||||
throw new AccumuloGraphException(ex);
|
||||
}
|
||||
this.setInstanceName(accumuloMiniCluster.getInstanceName());
|
||||
this.setZooKeeperHosts(accumuloMiniCluster.getZooKeepers());
|
||||
this.setPassword("");
|
||||
|
||||
case Distributed:
|
||||
if (getInstanceName() == null) {
|
||||
throw new IllegalArgumentException("Must specify instance name for distributed mode");
|
||||
@@ -904,24 +921,7 @@ implements Serializable {
|
||||
inst = new ZooKeeperInstance(getInstanceName(), getZooKeeperHosts());
|
||||
break;
|
||||
|
||||
case Mini:
|
||||
File dir = null;
|
||||
if (miniClusterTempDir == null) {
|
||||
dir = createTempDir();
|
||||
dir.deleteOnExit();
|
||||
} else {
|
||||
// already set by setMiniClusterTempDir(), It should be cleaned up outside of this class.
|
||||
dir = new File(miniClusterTempDir);
|
||||
}
|
||||
accumuloMiniCluster = new MiniAccumuloCluster(dir, ""); // conf.getString(PASSWORD)
|
||||
try {
|
||||
accumuloMiniCluster.start();
|
||||
} catch (Exception ex) {
|
||||
throw new AccumuloGraphException(ex);
|
||||
}
|
||||
inst = new ZooKeeperInstance(accumuloMiniCluster.getInstanceName(), accumuloMiniCluster.getZooKeepers());
|
||||
throw new UnsupportedOperationException("TODO");
|
||||
|
||||
|
||||
case Mock:
|
||||
inst = new MockInstance(getInstanceName());
|
||||
break;
|
||||
@@ -971,7 +971,7 @@ implements Serializable {
|
||||
* @param miniClusterTempDir
|
||||
*/
|
||||
public AccumuloGraphConfiguration setMiniClusterTempDir(String miniClusterTempDir) {
|
||||
this.miniClusterTempDir = miniClusterTempDir;
|
||||
this.miniClusterTempDir = new File(miniClusterTempDir);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1046,8 +1046,8 @@ implements Serializable {
|
||||
checkPropertyValue(Keys.PASSWORD, getPassword(), false);
|
||||
// no break intentional
|
||||
case Mini:
|
||||
checkPropertyValue(Keys.INSTANCE, getInstanceName(), false);
|
||||
checkPropertyValue(Keys.PASSWORD, getPassword(), true);
|
||||
// checkPropertyValue(Keys.INSTANCE, getInstanceName(), false);
|
||||
// checkPropertyValue(Keys.PASSWORD, getPassword(), true);
|
||||
// no break intentional
|
||||
case Mock:
|
||||
checkPropertyValue(Keys.GRAPH_NAME, getGraphName(), false);
|
||||
@@ -1089,13 +1089,6 @@ implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
private File createTempDir() throws IOException {
|
||||
File temp = File.createTempFile(AccumuloGraphConfiguration
|
||||
.class.getSimpleName(), ".mini.tmp");
|
||||
Files.delete(temp.toPath());
|
||||
Files.createDirectory(temp.toPath());
|
||||
return temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out this configuration.
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
/* Copyright 2014 The Johns Hopkins University Applied Physics Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package edu.jhuapl.tinkerpop;
|
||||
|
||||
import com.tinkerpop.blueprints.Graph;
|
||||
import com.tinkerpop.blueprints.GraphFactory;
|
||||
|
||||
import edu.jhuapl.tinkerpop.AccumuloGraphConfiguration.InstanceType;
|
||||
|
||||
public class AccumuloGraphTestUtils {
|
||||
|
||||
public static AccumuloGraphConfiguration generateGraphConfig(String graphDirectoryName) {
|
||||
return new AccumuloGraphConfiguration().setInstanceType(InstanceType.Mock)
|
||||
.setGraphName(graphDirectoryName).setCreate(true);
|
||||
}
|
||||
|
||||
public static Graph makeGraph(String name) {
|
||||
return GraphFactory.open(generateGraphConfig(name));
|
||||
}
|
||||
}
|
||||
/* Copyright 2014 The Johns Hopkins University Applied Physics Laboratory
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package edu.jhuapl.tinkerpop;
|
||||
|
||||
import com.tinkerpop.blueprints.Graph;
|
||||
import com.tinkerpop.blueprints.GraphFactory;
|
||||
|
||||
import edu.jhuapl.tinkerpop.AccumuloGraphConfiguration.InstanceType;
|
||||
|
||||
public class AccumuloGraphTestUtils {
|
||||
|
||||
public static AccumuloGraphConfiguration generateGraphConfig(String graphDirectoryName) {
|
||||
return new AccumuloGraphConfiguration().setInstanceType(InstanceType.Mini)
|
||||
.setGraphName(graphDirectoryName).setCreate(true);
|
||||
}
|
||||
|
||||
public static Graph makeGraph(String name) {
|
||||
return GraphFactory.open(generateGraphConfig(name));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user