本文整理汇总了Java中com.tinkerpop.blueprints.Graph.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Java Graph.shutdown方法的具体用法?Java Graph.shutdown怎么用?Java Graph.shutdown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.tinkerpop.blueprints.Graph
的用法示例。
在下文中一共展示了Graph.shutdown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUserIdByEmail
import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
public String getUserIdByEmail( String email ) {
Graph graph = (Graph) connection.get();
logger.debug("getUserIdByEmail: " + email );
try {
Iterable<Vertex> iterable = graph.getVertices( GremlinDAOSpec.USER_PROPERTY_EMAIL, email );
Iterator<Vertex> it = iterable.iterator();
if( it.hasNext() ) {
return it.next().getId().toString();
}
else {
throw new UserNotFoundException( email );
}
}
finally {
graph.shutdown();
}
}
示例2: getUser
import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
public User getUser( String id ) {
Graph graph = (Graph) connection.get();
logger.debug("getUser: " + id );
try {
Vertex v = graph.getVertex( id );
if( v == null ) {
throw new UserNotFoundException( id );
}
User user = new User( v.getId().toString(),
v.getProperty( GremlinDAOSpec.USER_PROPERTY_EMAIL ),
v.getProperty( GremlinDAOSpec.USER_PROPERTY_FIRST_NAME ).toString(),
v.getProperty( GremlinDAOSpec.USER_PROPERTY_LAST_NAME ).toString()
);
return user;
}
finally {
graph.shutdown();
}
}
示例3: getAllUsers
import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Override
public List<User> getAllUsers() {
List<User> users = new ArrayList<User>();
Graph graph = (Graph) connection.get();
logger.debug("getAllUsers" );
try {
Iterable<Vertex> iterable = graph.getVertices( GremlinDAOSpec.UNIVERSAL_PROPERTY_TYPE, GremlinDAOSpec.USER_CLASS );
Iterator<Vertex> it = iterable.iterator();
while( it.hasNext() ) {
Vertex v = it.next();
User user = new User( v.getId().toString(),
v.getProperty( GremlinDAOSpec.USER_PROPERTY_EMAIL ),
v.getProperty( GremlinDAOSpec.USER_PROPERTY_FIRST_NAME ).toString(),
v.getProperty( GremlinDAOSpec.USER_PROPERTY_LAST_NAME ).toString()
);
users.add(user);
}
return users;
}
finally {
graph.shutdown();
}
}
示例4: updateUser
import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
public boolean updateUser( User user ) {
Graph graph = (Graph) connection.get();
logger.debug("updateUser: " + user.getId() );
try{
Vertex v = graph.getVertex( user.getId() );
if( v== null ) throw new UserNotFoundException( user.getEmail() );
if( user.getEmail() != null )
v.setProperty( GremlinDAOSpec.USER_PROPERTY_EMAIL, user.getEmail() );
if( user.getFirstname() != null )
v.setProperty( GremlinDAOSpec.USER_PROPERTY_FIRST_NAME, user.getFirstname() );
if( user.getLastname() != null )
v.setProperty( GremlinDAOSpec.USER_PROPERTY_LAST_NAME, user.getLastname() );
return true;
}
finally {
graph.shutdown();
}
}
示例5: deleteUser
import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
public boolean deleteUser( String id ) {
Graph graph = (Graph) connection.get();
logger.debug("deleteUser: " + id );
try {
Vertex v = graph.getVertex( id );
if( v== null ) throw new UserNotFoundException( id );
v.remove();
return true;
}
finally {
graph.shutdown();
}
}
示例6: testVertexEdgesWithNonVisibleVertexOnOtherEnd
import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
public void testVertexEdgesWithNonVisibleVertexOnOtherEnd() {
Graph graph = graphTest.generateGraph();
if (!(graph instanceof VertexiumBlueprintsGraph)) {
throw new RuntimeException("Invalid graph");
}
org.vertexium.Graph vertexiumGraph = ((VertexiumBlueprintsGraph) graph).getGraph();
Authorizations aAuthorizations = vertexiumGraph.createAuthorizations("a");
org.vertexium.Vertex v1 = vertexiumGraph.addVertex("v1", new Visibility(""), aAuthorizations);
org.vertexium.Vertex v2 = vertexiumGraph.addVertex("v2", new Visibility("a"), aAuthorizations);
org.vertexium.Vertex v3 = vertexiumGraph.addVertex("v3", new Visibility(""), aAuthorizations);
vertexiumGraph.addEdge("e1to2", v1, v2, "label", new Visibility(""), aAuthorizations);
vertexiumGraph.addEdge("e1to3", v1, v3, "label", new Visibility(""), aAuthorizations);
vertexiumGraph.flush();
Vertex blueV1 = graph.getVertex("v1");
assertEquals(1, count(blueV1.getEdges(Direction.BOTH, "label")));
assertEquals(1, count(blueV1.getVertices(Direction.BOTH, "label")));
assertEquals(1, count((Iterable) blueV1.query().direction(Direction.BOTH).vertexIds()));
graph.shutdown();
}
示例7: testPreloadAllProperties
import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Test
public void testPreloadAllProperties() {
AccumuloGraphConfiguration cfg =
AccumuloGraphTestUtils.generateGraphConfig("preloadAllProperties");
cfg.setPropertyCacheTimeout(null, TIMEOUT);
cfg.setPreloadAllProperties(true);
Graph graph = open(cfg);
AccumuloVertex v = (AccumuloVertex) graph.addVertex("V");
v.setProperty(NON_CACHED, true);
v.setProperty(CACHED, true);
v = (AccumuloVertex) graph.getVertex("V");
assertEquals(true, v.getPropertyInMemory(NON_CACHED));
assertEquals(true, v.getPropertyInMemory(CACHED));
graph.shutdown();
}
示例8: testPreloadSomeProperties
import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Test
public void testPreloadSomeProperties() {
AccumuloGraphConfiguration cfg =
AccumuloGraphTestUtils.generateGraphConfig("preloadSomeProperties");
cfg.setPropertyCacheTimeout(null, TIMEOUT);
cfg.setPreloadedProperties(new String[]{CACHED});
Graph graph = open(cfg);
AccumuloVertex v = (AccumuloVertex) graph.addVertex("V");
v.setProperty(NON_CACHED, true);
v.setProperty(CACHED, true);
v = (AccumuloVertex) graph.getVertex("V");
assertEquals(null, v.getPropertyInMemory(NON_CACHED));
assertEquals(true, v.getPropertyInMemory(CACHED));
graph.shutdown();
}
示例9: testVertexInputMap
import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Test
public void testVertexInputMap() throws Exception {
final String INSTANCE_NAME = "_mapreduce_instance";
final String TEST_TABLE_NAME = "_mapreduce_table_vertexInputMap";
if (!System.getProperty("os.name").startsWith("Windows")) {
Graph g = GraphFactory.open(new AccumuloGraphConfiguration().setInstanceName(INSTANCE_NAME)
.setUser("root").setPassword("".getBytes())
.setGraphName(TEST_TABLE_NAME).setInstanceType(InstanceType.Mock)
.setCreate(true).getConfiguration());
for (int i = 0; i < 100; i++) {
g.addVertex(i + "");
}
assertEquals(0, MRTester.main(new String[]{"root", "",
TEST_TABLE_NAME, INSTANCE_NAME, "false"}));
assertNull(e1);
assertNull(e2);
g.shutdown();
}
}
示例10: testEdgeInputMap
import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Test
public void testEdgeInputMap() throws Exception {
final String INSTANCE_NAME = "_mapreduce_instance";
final String TEST_TABLE_NAME = "_mapreduce_table_edgeInputMap";
if (!System.getProperty("os.name").startsWith("Windows")) {
Graph g = GraphFactory.open(new AccumuloGraphConfiguration().setInstanceName(INSTANCE_NAME)
.setUser("root").setPassword("".getBytes())
.setGraphName(TEST_TABLE_NAME).setInstanceType(InstanceType.Mock)
.setAutoFlush(true).setCreate(true).getConfiguration());
for (int i = 0; i < 100; i++) {
Vertex v1 = g.addVertex(i+"");
Vertex v2 = g.addVertex(i+"a");
g.addEdge(null, v1, v2, "knows");
}
assertEquals(0, MRTester.main(new String[]{"root", "",
TEST_TABLE_NAME, INSTANCE_NAME, "true"}));
assertNull(e1);
assertNull(e2);
g.shutdown();
}
}
示例11: testElementCacheSize
import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Test
public void testElementCacheSize() throws Exception {
AccumuloGraphConfiguration cfg = AccumuloGraphTestUtils
.generateGraphConfig("elementCacheSize");
Graph graph = GraphFactory.open(cfg.getConfiguration());
Vertex[] verts = new Vertex[10];
for (int i = 0; i < verts.length; i++) {
verts[i] = graph.addVertex(i);
}
Edge[] edges = new Edge[9];
for (int i = 0; i < edges.length; i++) {
edges[i] = graph.addEdge(null,
verts[0], verts[i+1], "edge");
}
sizeTests(verts);
sizeTests(edges);
graph.shutdown();
}
示例12: createUser
import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
public boolean createUser( UserSecurity user ) {
Graph graph = (Graph) connection.get();
logger.debug("createUser: " + user.getEmail() );
try {
// check if user already registered
try {
if( getUserIdByEmail( user.getEmail() ) != null ) {
throw new UserExistingException( user.getEmail() );
}
}
// continue if no user found
catch( UserNotFoundException e) {}
// create user vertex
Vertex v = graph.addVertex(null);
// type user
v.setProperty( GremlinDAOSpec.UNIVERSAL_PROPERTY_TYPE, GremlinDAOSpec.USER_CLASS );
v.setProperty( GremlinDAOSpec.USER_PROPERTY_FIRST_NAME, user.getFirstname() );
v.setProperty( GremlinDAOSpec.USER_PROPERTY_LAST_NAME, user.getLastname() );
v.setProperty( GremlinDAOSpec.USER_PROPERTY_EMAIL, user.getEmail() );
v.setProperty( GremlinDAOSpec.USER_PROPERTY_PASSWORD, user.getPassword() );
v.setProperty( GremlinDAOSpec.USER_PROPERTY_ROLE, user.getRole() );
return true;
}
finally {
graph.shutdown();
}
}
示例13: getUserAuthentication
import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Override
public UserSecurity getUserAuthentication( String id ) throws UserNotFoundException {
Graph graph = (Graph) connection.get();
logger.debug("getUserAuthentication: " + id );
try {
Vertex v = graph.getVertex( id );
if( v == null ) throw new UserNotFoundException( id );
Object oEmail = v.getProperty( GremlinDAOSpec.USER_PROPERTY_EMAIL );
Object oPassword = v.getProperty( GremlinDAOSpec.USER_PROPERTY_PASSWORD );
Object oToken = v.getProperty( GremlinDAOSpec.USER_PROPERTY_TOKEN );
Object oRole = v.getProperty( GremlinDAOSpec.USER_PROPERTY_ROLE );
String email = null;
String password = null;
String token = null;
String role = null;
if( oEmail != null )
email = oEmail.toString();
if( oPassword != null )
password = oPassword.toString();
if( oToken != null )
token = oToken.toString();
if( oRole != null )
role = oRole.toString();
UserSecurity user = new UserSecurity( email, password, token, role );
return user;
}
finally {
graph.shutdown();
}
}
示例14: setUserAuthentication
import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Override
public boolean setUserAuthentication( UserSecurity user ) throws UserNotFoundException {
Graph graph = (Graph) connection.get();
logger.debug("setUserAuthentication: " + user.getId() );
try {
Vertex v = graph.getVertex( user.getId() );
if( v == null ) throw new UserNotFoundException( user.getId() );
if( user.getPassword() != null ) {
v.setProperty( GremlinDAOSpec.USER_PROPERTY_PASSWORD, user.getPassword() );
}
if( user.getToken() != null ) {
v.setProperty(GremlinDAOSpec.USER_PROPERTY_TOKEN, user.getToken() );
}
if( user.getRole() != null ) {
v.setProperty(GremlinDAOSpec.USER_PROPERTY_ROLE, user.getRole() );
}
return true;
}
finally {
graph.shutdown();
}
}
示例15: testNonStringIds
import com.tinkerpop.blueprints.Graph; //导入方法依赖的package包/类
@Test
public void testNonStringIds() throws Exception {
Graph graph = AccumuloGraphTestUtils.makeGraph("nonStringIds");
Object[] ids = new Object[] {
10, 20, 30L, 40L,
50.0f, 60.0f, 70.0d, 80.0d,
(byte) 'a', (byte) 'b', 'c', 'd',
"str1", "str2",
new GenericObject("str3"), new GenericObject("str4"),
};
Object[] edgeIds = new Object[] {
100, 200, 300L, 400L,
500.0f, 600.0f, 700.0d, 800.0d,
(byte) 'e', (byte) 'f', 'g', 'h',
"str5", "str6",
new GenericObject("str7"), new GenericObject("str8"),
};
for (int i = 0; i < ids.length; i++) {
assertNull(graph.getVertex(ids[i]));
Vertex v = graph.addVertex(ids[i]);
assertNotNull(v);
assertNotNull(graph.getVertex(ids[i]));
}
assertEquals(ids.length, count(graph.getVertices()));
for (int i = 1; i < edgeIds.length; i++) {
assertNull(graph.getEdge(edgeIds[i-1]));
Edge e = graph.addEdge(edgeIds[i-1],
graph.getVertex(ids[i-1]),
graph.getVertex(ids[i]), "label");
assertNotNull(e);
assertNotNull(graph.getEdge(edgeIds[i-1]));
}
assertEquals(edgeIds.length-1, count(graph.getEdges()));
graph.shutdown();
}