Skip to content

Commit

Permalink
Fixed issue #4188
Browse files Browse the repository at this point in the history
  • Loading branch information
lvca committed May 20, 2015
1 parent e126ff8 commit 7b536d8
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 175 deletions.
Expand Up @@ -1757,6 +1757,10 @@ else if (stream == null || stream.length == 0)
final boolean partialMarshalling = record instanceof ODocument final boolean partialMarshalling = record instanceof ODocument
&& OSerializationSetThreadLocal.INSTANCE.checkIfPartial((ODocument) record); && OSerializationSetThreadLocal.INSTANCE.checkIfPartial((ODocument) record);


if (partialMarshalling && !isNew)
// UPDATE + PARTIAL MARSHALLING: SKIP IT BECAUSE THE REAL UPDATE WILL BE EXECUTED BY OUTER SAVE
return (RET) record;

if (stream != null && stream.length > 0 && !partialMarshalling) { if (stream != null && stream.length > 0 && !partialMarshalling) {
if (callTriggers) { if (callTriggers) {
final ORecordHook.TYPE triggerType = wasNew ? ORecordHook.TYPE.BEFORE_CREATE : ORecordHook.TYPE.BEFORE_UPDATE; final ORecordHook.TYPE triggerType = wasNew ? ORecordHook.TYPE.BEFORE_CREATE : ORecordHook.TYPE.BEFORE_UPDATE;
Expand Down
Expand Up @@ -21,8 +21,8 @@ public void createDB(String orientUrl) {
graph.executeOutsideTx(new OCallable<Object, OrientBaseGraph>() { graph.executeOutsideTx(new OCallable<Object, OrientBaseGraph>() {
@Override @Override
public Object call(OrientBaseGraph g) { public Object call(OrientBaseGraph g) {
g.createVertexType("VertexType1"); g.createEdgeType("edgetype");
g.createEdgeType("EdgeType1"); g.createVertexType("vertextype");
return null; return null;
} }
}); });
Expand Down

This file was deleted.

@@ -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();
}
}

}

0 comments on commit 7b536d8

Please sign in to comment.