jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julien Viet <jul...@jboss.org>
Subject Re: Problems with concurrent sessions
Date Thu, 07 Jul 2005 16:14:56 GMT
the spec does not define isolation between concurrent sessions, you can 
read chapter "Reflecting Item State" 7.1.2

it is left up to the vendor, so the question is rather : how is 
isolation implemented in jackrabbit ?

it would be good to have clarifications indeed about how isolation is 
achieved is jackrabbit and if it is configurable
somewhere.

Nicolas Belisle wrote:

> Hi,
>
> Thanks for your response.
>
> Before posting a jira issue, I would like to make a few things clear.
>
> What is the session isolation level [ref. 
> http://www.unix.org.ua/orelly/java-ent/ebeans/ch08_03.htm] by default 
> ? Is it configurable ? At least, Jackrabbit seems to prevent dirty 
> reads (determined from tests). Is there any documentation regarding 
> isolation level ? I think it is a very important topic...
>
> Example :
> A : open session
> A : read nodes "test" & "test2"
> B : open session
> A : delete nodes "test" & "test2"
> B : save session //WHAT SHOULD HAPPEN ??
> B : logout
> A : read nodes "test" & "test2" //WHAT SHOULD HAPPEN ??
> A : logout
>
> The answers differs depending on the isolation level.
>
> Also, does the test cases cover concurrent sessions ?
>
> Regards,
>
> Nicolas
>
>
> Le 05:33 2005-07-07, vous avez écrit:
>
>> hi nicolas
>>
>> On 7/6/05, Nicolas Belisle <Nicolas.Belisle@bibl.ulaval.ca> wrote:
>> > Hi,
>> >
>> > I'm a Jackrabbit newbie. I'm doing some tests with the tool and I'm 
>> having
>> > problem with concurrent sessions.
>> >
>> > I have joined my (simple) test class (JCRTest) and the exception I 
>> get from
>> > running it.
>> >
>> > Anyone had similar problems ?
>>
>> this seems to be a bug, please post a jira issue.
>>
>> thanks
>> stefan
>>
>> >
>> > Regards,
>> >
>> > Nicolas
>> >
>> >
>> > -->The exception report:
>> > java.util.NoSuchElementException: cdeab285-fdbc-4af3-918a-bf4316a29276
>> > at 
>> org.apache.jackrabbit.core.LazyItemIterator.next(LazyItemIterator.java:157) 
>>
>> > at
>> > 
>> org.apache.jackrabbit.core.LazyItemIterator.nextNode(LazyItemIterator.java:98) 
>>
>> > at app.JCRTest$ThreadDeleter.run(JCRTest.java:107)
>> >
>> > -->The class:
>> > package app;
>> >
>> > import java.util.Hashtable;
>> >
>> > import javax.jcr.Node;
>> > import javax.jcr.NodeIterator;
>> > import javax.jcr.Repository;
>> > import javax.jcr.RepositoryException;
>> > import javax.jcr.Session;
>> > import javax.jcr.SimpleCredentials;
>> > import javax.jcr.observation.Event;
>> > import javax.jcr.observation.EventIterator;
>> > import javax.jcr.observation.EventListener;
>> > import javax.naming.Context;
>> > import javax.naming.InitialContext;
>> >
>> > import org.apache.jackrabbit.core.jndi.RegistryHelper;
>> > import org.apache.jackrabbit.core.value.StringValue;
>> >
>> > public class JCRTest {
>> >
>> >          private Repository repository;
>> >
>> >          public JCRTest(Repository repository) {
>> >                  this.repository = repository;
>> >          }
>> >
>> >          public void execute() throws Exception {
>> >                  Session session = this.repository.login(new
>> > SimpleCredentials("", "".toCharArray()), null);
>> >
>> >                  Node rn = session.getRootNode();
>> >                  new ThreadObserver().start();
>> >                  Node n = rn.addNode("node" + 
>> System.currentTimeMillis(),
>> > "nt:unstructured");
>> >                  n.setProperty("testprop", new StringValue("Hello, 
>> World."));
>> >                  new ThreadDeleter().start();
>> >
>> >                  session.save();
>> >                  session.logout();
>> >          }
>> >
>> >          public static void main(String[] args) {
>> >                  try {
>> >                          String configFile = 
>> "repository/repository.xml";
>> >                          String repHomeDir = "repository";
>> >
>> >                          Hashtable env = new Hashtable();
>> >                          env.put(Context.INITIAL_CONTEXT_FACTORY,
>> > 
>> "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
>> >                          env.put(Context.PROVIDER_URL, "localhost");
>> >                          InitialContext ctx = new InitialContext(env);
>> >
>> >                          RegistryHelper.registerRepository(ctx, 
>> "repo",
>> > configFile, repHomeDir, true);
>> >                          Repository r = (Repository) 
>> ctx.lookup("repo");
>> >
>> >                          for (int i = 0; i < 20; i++) {
>> >                                  JCRTest test = new JCRTest(r);
>> >                                  test.execute();
>> >                          }
>> >
>> >                  } catch (Exception e){
>> >                          e.printStackTrace();
>> >                  }
>> >          }
>> >
>> >          public  class ThreadObserver extends Thread {
>> >                  public void run() {
>> >                          System.out.println("Observing thread 
>> started");
>> >                          try {
>> >                                  Session session = 
>> repository.login(new
>> > SimpleCredentials("", "".toCharArray()));
>> >                                  EventListener el = new 
>> EventListener() {
>> >                                          public void 
>> onEvent(EventIterator
>> > events) {
>> >                                                  while 
>> (events.hasNext()) {
>> >                                                          try {
>> >                                          Thread.sleep(100);
>> >                                      } catch (InterruptedException 
>> e) {}
>> >
>> >                                      Event e = events.nextEvent();
>> >                                                          if 
>> (e.getType() ==
>> > Event.NODE_ADDED) {
>> >                                                                  try {
>> >   System.out.println("Node
>> > added : " + e.getPath());
>> >                                                                  } 
>> catch
>> > (RepositoryException re) {
>> >   re.printStackTrace();
>> >                                                                  }
>> >                                                          }
>> >
>> >                                                  }
>> >                                          }
>> >                                  };
>> > session.getWorkspace().getObservationManager().addEventListener(el,
>> > Event.NODE_ADDED, "/", true, null, null, false);
>> >                                  session.save();
>> >                                  //Some time to listen
>> >                                  Thread.sleep(500);
>> >                                  session.logout();
>> >                          } catch (Exception e) {
>> >                                  e.printStackTrace();
>> >                          }
>> >                  }
>> >          }
>> >
>> >          public  class ThreadDeleter extends Thread {
>> >                  public void run() {
>> >                          System.out.println("Deleter thread started");
>> >                          try {
>> >                                  Session session = 
>> repository.login(new
>> > SimpleCredentials("", "".toCharArray()));
>> >
>> >                                  Node rn = session.getRootNode();
>> >                                  for (NodeIterator ni = rn.getNodes();
>> > ni.hasNext(); ) {
>> >                                          Thread.sleep(100);
>> >                                          Node currentNode = 
>> ni.nextNode();
>> >                                          if
>> > (currentNode.getName().startsWith("node")) {
>> >                                                  currentNode.remove();
>> >                                          }
>> >                                  }
>> >                                  session.save();
>> >                                  session.logout();
>> >
>> >                          } catch (Exception e) {
>> >                                  e.printStackTrace();
>> >                          }
>> >                  }
>> >          }
>> > }
>> >
>> >
>
>
>


-- 
Julien Viet
JBoss Portal Lead Developer


Mime
View raw message