Re: [Neo4j] Multiple users on a embedded graphdb

2011-05-11 Thread Michael Hunger
No problem at all. As tx are bound to the executing thread. And the singleton 
graph-db instance is the way to go.

Good Luck with your efforts

Michael


Am 11.05.2011 um 17:04 schrieb John Doran:

 Thanks Micheal,
 Good points, I have 3 weeks to finish up(along with a mountain of other
 things to do so I can't see the server as and option, I'm really looking for
 a quick work around because of time limitations. I actually helped Rene get
 stated with combining the two, I have the two working well together. Apart
 from the problem I have now of distributions. Could a workaround be to have
 a singleton instance of the db when clients are performing queries run from
 this instance, or would there be transactional problems?
 Regards, John.
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Multiple users on a embedded graphdb

2011-05-09 Thread John Doran
Hi Jim,
Thanks for the reply, I haven't delved into the server aspect of neo4j(I'll
leave that until I finish up college). I'll have to refresh my threading
knowledge, you reckon each time users want to interact with the db to create
a thread and this would stop any exceptions relating to not being able to
connect to the database(because it's in use).
Regards,
John.
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Multiple users on a embedded graphdb

2011-05-09 Thread Marko Rodriguez
Hey,

You can have multiple threads talking to the same DB reference. You can not 
create multiple graph database services over the same directory. Thus,

final graph = new GraphDatabaseService('/tmp/test')
for(int i=0;i10;i++) {
new Thread {
public void run() {
   // do something to graph
}
  }.start()
}

But not:

graph = new GraphDatabaseSerice('/tmp/test');
graph = new GraphDatabaseService('/tmp/test');

Hope that helps,
Marko.

http://markorodriguez.com

On May 9, 2011, at 3:06 PM, John Doran wrote:

 Hi Jim,
 Thanks for the reply, I haven't delved into the server aspect of neo4j(I'll
 leave that until I finish up college). I'll have to refresh my threading
 knowledge, you reckon each time users want to interact with the db to create
 a thread and this would stop any exceptions relating to not being able to
 connect to the database(because it's in use).
 Regards,
 John.
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Multiple users on a embedded graphdb

2011-05-09 Thread Thomas Baum
hi john, 
imho the gwt is just a webapp. so i'm a bit confused why talking about threads 
in a j2ee env? 

if i understand you right you want to share one neo4j instance between 
different gwt apps(services).  i would propose creating a context-listener, on 
application startup the embedded-graph-db is placed in the servlet context.
(see the code-snippets)


a other approach would be accessing the neo4j-server direct from the gwt 
(javascript) code through the rest-api. this assumes a driver written in 
gwt-java/javascript.
@jim i hope to find the time this friday creating a lab-project this friday for 
this  :)


cheers
/thomas




// register in web.xml 
public class NeoContextListner implements ServletContextListener {
  private static final String CONTEXT_KEY = neo4j-instance;

  public static EmbeddedGraphDatabase getNeo4JInstance(ServletContext 
servletContext) {
  return (EmbeddedGraphDatabase) servletContext.getAttribute(CONTEXT_KEY);
  }

  public void contextInitialized(ServletContextEvent servletContextEvent) {
  EmbeddedGraphDatabase db = new EmbeddedGraphDatabase(/tmp/db);
  ServletContext servletContext = servletContextEvent.getServletContext();
  servletContext.setAttribute(CONTEXT_KEY, db);
  }

  public void contextDestroyed(ServletContextEvent servletContextEvent) {
  ServletContext servletContext = servletContextEvent.getServletContext();
  EmbeddedGraphDatabase db = getNeo4JInstance(servletContext);
  db.shutdown();
  }
}

usage:

public class TestServiceImpl extends RemoteServiceServlet implements 
TestService {
 public AnyResult doIt(String argument) {
  EmbeddedGraphDatabase db = 
NeoContextListner.getNeo4JInstance(getServletContext());
 use it
  }

}


Am 09.05.2011 um 23:11 schrieb Christoph K.:

 Hi John,
 
 if i unterstand Jim right, he means that you should fire up threads on the
 serverside implementation which handle client requests and deal with a
 single instance of the embeddedgraphdatabase.
 
 greetings
 Chris
 
 On Mon, May 9, 2011 at 11:06 PM, John Doran john.do...@hotmail.com wrote:
 
 Hi Jim,
 Thanks for the reply, I haven't delved into the server aspect of neo4j(I'll
 leave that until I finish up college). I'll have to refresh my threading
 knowledge, you reckon each time users want to interact with the db to
 create
 a thread and this would stop any exceptions relating to not being able to
 connect to the database(because it's in use).
 Regards,
 John.


___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user