For the sake of the argument I followed your instructions. It still hangs 
when a NIO transaction is involved. I even released the channel file lock 
on the mappedbytebuffer.

If it is inside the constructor the createRelationship(...) 
works immediately. But this is senseless in my code.

I think I can make things work calling Neo4J on the other side of the NIO 
buffer so we don't need to keep this thread going.

As a FYI the constructor is called before any NIO classes are instantiated. 
It seems that createRelationship(...) is waiting for something that NIO 
might hold 

This is the reworked hang method:

 Label l = DynamicLabel.label("test");

 Node gn;

 Transaction t = null;

 try{

 t = graph.beginTx();

 if (!root.hasLabel(l)){

  gn = graph.createNode();

root.createRelationshipTo(gn, relationship);  

 }

 t.success();

 }

 catch(Exception e){

 e.printStackTrace();

 }

On Tuesday, January 14, 2014 10:31:55 AM UTC-7, José Cornado wrote:
>
> OS: OS X 10.6.8
> JVM 1.7
> Language: java
> Neo4J 2.0 CE
>
> I am experiencing a hang when creating a relationship. It only happens 
> when NIO MappedByteBuffer is involved. If one moves the contents of the 
> method hang inside the constructor Main the hang does not occur.
>
> Are there any restrictions on combining Neo and NIO?
>
> The db is in a different directory where the MappedByteBuffer is but they 
> share the same parent directory.
>
> Exclusion problem maybe?
>
>
> Thanks a lot!!!
>
>
> Code:
>
> package sandbox;
>
> import java.io.File;
>
> import java.io.IOException;
>
> import java.nio.MappedByteBuffer;
>
> import org.neo4j.graphdb.GraphDatabaseService;
>
> import org.neo4j.graphdb.Label;
>
> import org.neo4j.graphdb.Node;
>
> import org.neo4j.graphdb.RelationshipType;
>
> import org.neo4j.graphdb.Transaction;
>
> import org.neo4j.graphdb.factory.GraphDatabaseFactory;
>
> import org.neo4j.graphdb.DynamicLabel;
>
>
>
> class Main{
>
> private Node root;
>
> private GraphDatabaseService graph;
>
>  
>  private static enum Relationships implements RelationshipType{ CONTAINS};
>
>
>  Main() throws IOException{
>
> File location;
>
>  Transaction t = null;
>
>  try{
>
>   location = new File("location");
>
>   if (location.isFile())
>
>   location.renameTo(new File(location.getName() + '.' + 
> System.currentTimeMillis()));
>
>   if (!location.exists())
>
>   location.mkdirs();
>
>   graph = newGraphDatabaseFactory().newEmbeddedDatabase(location.getPath());
>
>   t = graph.beginTx();
>
>   root = graph.createNode();
>
> t.success();
>
>  }
>
>  catch(Exception e){
>
>   if (graph != null)
>
>   graph.shutdown(); 
>
>  throw new IOException("Could NOT start storage");
>
>  }
>
>   }
>
>  
>
>  public void shutDown(){
>
>  graph.shutdown();
>
>  }
>
>
> public void hang(MappedByteBuffer m) {
>
>  Node gn;
>
>  Transaction t = graph.beginTx();
>
>  Label l = DynamicLabel.label("test");
>
>  try{
>
>   if (!root.hasLabel(l)){
>
>   gn = graph.createNode();
>
>   root.createRelationshipTo(gn, Relationships.CONTAINS);  
>
>   }
>
>  }
>
>  finally{
>
>   t.close();
>
>  }
>
>   t.success();
>
>  }
>
>  
>
>  public static void main(String[] args){
>
>  Main m;
>
>  try {
>
>  m = new Main();
>
>   m.shutDown();
>
>  } catch (IOException e) {
>
>  e.printStackTrace();
>
>  }
>
>  }
>
> }
>

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to