protected void exec(final String iClient) {
    counter.countDown();

    try {
      counter.await();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }

    OrientBaseGraph graph = new OrientGraph(getLocalURL());

    OrientVertex vertex1 = graph.getVertex(vertex1Id);

    try {
      int i = 0;
      for (; i < TOTAL; ++i) {

        for (int retry = 0; retry < 20; ++retry) {
          try {
            OrientVertex vertex2 = graph.addVertex("vertextype", (String) null);
            vertex1.addEdge("edgetype", vertex2);
            graph.commit();

            System.out.println(
                iClient + " - successfully committed version: " + vertex1.getRecord().getVersion());
          } catch (ONeedRetryException e) {
            System.out.println(
                iClient
                    + " - caught conflict, reloading vertex. v="
                    + vertex1.getRecord().getVersion());
            vertex1.reload();
          }
        }
      }

      // STATISTICALLY HERE AT LEAST ON CONFLICT HAS BEEN RECEIVED
      vertex1.reload();

      Assert.assertTrue(vertex1.getRecord().getVersion() > TOTAL * 2 + 1);
      Assert.assertEquals(TOTAL, i);

    } catch (Throwable e) {
      if (exceptionInThread == null) exceptionInThread = e;

    } finally {
      System.out.println("Shutting down");
      graph.shutdown();

      sleep(1000);
    }
  }
Ejemplo n.º 2
0
 private Vertex getRoot(String cls) {
   try {
     List<ODocument> list =
         graph
             .getRawGraph()
             .query(
                 new OSQLSynchQuery<ODocument>(
                     "SELECT FROM "
                         + GDomConfig.global().getRootClass()
                         + " WHERE tag='"
                         + cls
                         + "'"));
     if (list == null) return null;
     if (!(list.size() > 0)) return null;
     return graph.getVertex(list.get(0).getIdentity());
   } catch (Exception ex) {
     return null;
   }
 }