package com.orientechnologies.orient.server.distributed.asynch;

import com.tinkerpop.blueprints.impls.orient.OrientBaseGraph;
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;

import java.util.concurrent.CountDownLatch;

public class TestAsyncReplMode2ServersOverflow extends BareBoneBase2ServerTest {

  private static final int TOTAL   = 10000;
  CountDownLatch           counter = new CountDownLatch(2);

  @Override
  protected String getDatabaseName() {
    return "TestAsyncReplMode2ServersOverflow";
  }

  protected void dbClient1() {
//    OGlobalConfiguration.LOG_CONSOLE_LEVEL.setValue("FINEST");
    exec("client1");
  }

  protected void dbClient2() {
    exec("client2");
  }

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

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

    OrientBaseGraph graph = new OrientGraphNoTx(getLocalURL());

    try {
      int i = 0;
      for (; i < TOTAL; ++i) {
        graph.addVertex(null);
      }

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

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

@@ -181,16 +181,106 @@
 aphNoTx;
+%0Aimport com.tinkerpop.blueprints.impls.orient.OrientVertex;%0Aimport junit.framework.Assert;
 %0A%0Aimport
@@ -1101,28 +1101,110 @@
     
-graph.addVertex(null
+final OrientVertex v = graph.addVertex(null);%0A        Assert.assertTrue(v.getIdentity().isPersistent()
 );%0A 

Test case for issue #5218