forked from orientechnologies/orientdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
90 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 0 additions & 173 deletions
173
...src/test/java/com/orientechnologies/orient/server/distributed/asynch/TestReplication.java
This file was deleted.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
...technologies/orient/server/distributed/asynch/TestReplicationVersionIncrementedByOne.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.orientechnologies.orient.server.distributed.asynch; | ||
|
||
import com.orientechnologies.common.log.OLogManager; | ||
import com.orientechnologies.orient.core.Orient; | ||
import com.tinkerpop.blueprints.Vertex; | ||
import com.tinkerpop.blueprints.impls.orient.OrientBaseGraph; | ||
import com.tinkerpop.blueprints.impls.orient.OrientGraph; | ||
import com.tinkerpop.blueprints.impls.orient.OrientVertex; | ||
import junit.framework.TestCase; | ||
|
||
import java.io.File; | ||
|
||
public class TestReplicationVersionIncrementedByOne extends TestCase { | ||
|
||
private static final String CONFIG_DIR = "src/test/resources"; | ||
private static final String DB1_DIR = "target/db1"; | ||
private static final String SERVER_ORIENT_URL_MAIN = "plocal:" + DB1_DIR + "/databases/testDB"; | ||
|
||
private volatile Throwable exceptionInThread; | ||
|
||
public void testReplication2() throws Throwable { | ||
Orient.setRegisterDatabaseByPath(true); | ||
|
||
// Start the first DB server. | ||
Thread dbServer1 = new Thread() { | ||
@Override | ||
public void run() { | ||
dbServer(DB1_DIR, SERVER_ORIENT_URL_MAIN, "asynch-dserver-config-0.xml"); | ||
} | ||
}; | ||
dbServer1.start(); | ||
dbServer1.join(); | ||
|
||
// Start the first DB client. | ||
Thread dbClient1 = new Thread() { | ||
@Override | ||
public void run() { | ||
dbClient1(); | ||
} | ||
}; | ||
dbClient1.start(); | ||
dbClient1.join(); | ||
|
||
if (exceptionInThread != null) { | ||
throw exceptionInThread; | ||
} | ||
} | ||
|
||
private void dbServer(String dbDirectory, String orientUrl, String dbConfigName) { | ||
BareBonesServer dbServer = new BareBonesServer(); | ||
dbServer.deleteRecursively(new File(dbDirectory)); | ||
if (orientUrl != null) { | ||
dbServer.createDB(orientUrl); | ||
} | ||
System.setProperty("ORIENTDB_HOME", dbDirectory); | ||
dbServer.start(CONFIG_DIR, dbConfigName); | ||
} | ||
|
||
private void dbClient1() { | ||
OrientBaseGraph graph = new OrientGraph(SERVER_ORIENT_URL_MAIN); | ||
try { | ||
Vertex v1 = graph.addVertex("vertextype", (String) null); | ||
graph.commit(); | ||
assertEquals(1, ((OrientVertex) v1).getRecord().getVersion()); | ||
|
||
Vertex v2 = graph.addVertex("vertextype", (String) null); | ||
graph.commit(); | ||
assertEquals(1, ((OrientVertex) v2).getRecord().getVersion()); | ||
|
||
v1.addEdge("edgetype", v2); | ||
graph.commit(); | ||
assertEquals(2, ((OrientVertex) v1).getRecord().getVersion()); | ||
assertEquals(2, ((OrientVertex) v2).getRecord().getVersion()); | ||
} catch (Throwable e) { | ||
if (exceptionInThread == null) { | ||
exceptionInThread = e; | ||
} | ||
} finally { | ||
OLogManager.instance().info(this, "Shutting down"); | ||
graph.shutdown(); | ||
} | ||
} | ||
|
||
} |