Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added one more index for async - remote - 3 nodes
- Loading branch information
Showing
4 changed files
with
271 additions
and
2 deletions.
There are no files selected for viewing
108 changes: 108 additions & 0 deletions
108
...est/java/com/orientechnologies/orient/server/distributed/asynch/AsyncIndexRemoteTest.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,108 @@ | ||
package com.orientechnologies.orient.server.distributed.asynch; | ||
|
||
import junit.framework.Assert; | ||
|
||
import com.orientechnologies.common.log.OLogManager; | ||
import com.orientechnologies.orient.core.sql.OCommandSQL; | ||
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; | ||
import com.orientechnologies.orient.core.storage.ORecordDuplicatedException; | ||
import com.tinkerpop.blueprints.impls.orient.OrientBaseGraph; | ||
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx; | ||
import com.tinkerpop.blueprints.impls.orient.OrientVertex; | ||
|
||
public class AsyncIndexRemoteTest extends BareBoneBase3ServerTest { | ||
|
||
@Override | ||
protected String getDatabaseName() { | ||
return "AsyncIndexTest"; | ||
} | ||
|
||
protected void dbClient1() { | ||
OrientBaseGraph graph = new OrientGraphNoTx(getRemoteURL()); | ||
try { | ||
graph.command(new OCommandSQL("create class SMS")).execute(); | ||
graph.command(new OCommandSQL("create property SMS.type string")).execute(); | ||
graph.command(new OCommandSQL("create property SMS.lang string")).execute(); | ||
graph.command(new OCommandSQL("create property SMS.source integer")).execute(); | ||
graph.command(new OCommandSQL("create property SMS.content string")).execute(); | ||
graph.command(new OCommandSQL("alter property SMS.lang min 2")).execute(); | ||
graph.command(new OCommandSQL("alter property SMS.lang max 2")).execute(); | ||
graph.command(new OCommandSQL("create index sms_keys ON SMS (type, lang) unique")).execute(); | ||
|
||
graph.command(new OCommandSQL("insert into sms (type, lang, source, content) values ( 'notify', 'en', 1, 'This is a test')")) | ||
.execute(); | ||
try { | ||
graph | ||
.command(new OCommandSQL("insert into sms (type, lang, source, content) values ( 'notify', 'en', 1, 'This is a test')")) | ||
.execute(); | ||
Assert.fail("violated unique index was not raised"); | ||
} catch (ORecordDuplicatedException e) { | ||
} | ||
|
||
final Iterable<OrientVertex> result = graph.command(new OSQLSynchQuery<OrientVertex>("select count(*) from SMS")).execute(); | ||
|
||
Assert.assertEquals(1, ((Number) result.iterator().next().getProperty("count")).intValue()); | ||
|
||
} catch (Throwable e) { | ||
if (exceptionInThread == null) { | ||
exceptionInThread = e; | ||
} | ||
} finally { | ||
OLogManager.instance().info(this, "Shutting down db1"); | ||
graph.shutdown(); | ||
} | ||
|
||
// CHECK ON THE 2ND NODE | ||
OrientBaseGraph graph2 = new OrientGraphNoTx(getRemoteURL2()); | ||
try { | ||
try { | ||
graph2 | ||
.command(new OCommandSQL("insert into sms (type, lang, source, content) values ( 'notify', 'en', 1, 'This is a test')")) | ||
.execute(); | ||
Assert.fail("violated unique index was not raised"); | ||
} catch (ORecordDuplicatedException e) { | ||
} | ||
|
||
final Iterable<OrientVertex> result = graph2.command(new OSQLSynchQuery<OrientVertex>("select count(*) from SMS")).execute(); | ||
|
||
Assert.assertEquals(1, ((Number) result.iterator().next().getProperty("count")).intValue()); | ||
|
||
} catch (Throwable e) { | ||
if (exceptionInThread == null) { | ||
exceptionInThread = e; | ||
} | ||
} finally { | ||
OLogManager.instance().info(this, "Shutting down db2"); | ||
graph2.shutdown(); | ||
} | ||
|
||
// CHECK ON THE 2ND NODE | ||
OrientBaseGraph graph3 = new OrientGraphNoTx(getRemoteURL3()); | ||
try { | ||
try { | ||
graph3 | ||
.command(new OCommandSQL("insert into sms (type, lang, source, content) values ( 'notify', 'en', 1, 'This is a test')")) | ||
.execute(); | ||
Assert.fail("violated unique index was not raised"); | ||
} catch (ORecordDuplicatedException e) { | ||
} | ||
|
||
final Iterable<OrientVertex> result = graph3.command(new OSQLSynchQuery<OrientVertex>("select count(*) from SMS")).execute(); | ||
|
||
Assert.assertEquals(1, ((Number) result.iterator().next().getProperty("count")).intValue()); | ||
|
||
} catch (Throwable e) { | ||
if (exceptionInThread == null) { | ||
exceptionInThread = e; | ||
} | ||
} finally { | ||
OLogManager.instance().info(this, "Shutting down db3"); | ||
graph3.shutdown(); | ||
} | ||
} | ||
|
||
@Override | ||
protected void dbClient2() { | ||
|
||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
.../java/com/orientechnologies/orient/server/distributed/asynch/BareBoneBase3ServerTest.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,90 @@ | ||
package com.orientechnologies.orient.server.distributed.asynch; | ||
|
||
import com.orientechnologies.common.io.OFileUtils; | ||
import com.orientechnologies.orient.core.Orient; | ||
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; | ||
|
||
import java.io.File; | ||
|
||
public abstract class BareBoneBase3ServerTest extends BareBoneBase2ServerTest { | ||
|
||
protected static final String DB3_DIR = "target/db3"; | ||
|
||
protected String getLocalURL3() { | ||
return "plocal:" + DB3_DIR + "/databases/" + getDatabaseName(); | ||
} | ||
|
||
protected String getRemoteURL3() { | ||
return "remote:localhost:2426/" + getDatabaseName(); | ||
} | ||
|
||
public void setUp() { | ||
System.out.println("SETUP TEST"); | ||
super.setUp(); | ||
OFileUtils.deleteRecursively(new File(DB3_DIR)); | ||
} | ||
|
||
@Override | ||
protected void tearDown() throws Exception { | ||
System.out.println("TEAR DOWN"); | ||
|
||
super.tearDown(); | ||
|
||
new ODatabaseDocumentTx(getLocalURL3()).open("admin", "admin").drop(); | ||
OFileUtils.deleteRecursively(new File(DB3_DIR)); | ||
} | ||
|
||
public void testReplication() throws Throwable { | ||
Orient.setRegisterDatabaseByPath(true); | ||
|
||
final BareBonesServer[] servers = new BareBonesServer[3]; | ||
Thread dbServer1 = new Thread() { | ||
@Override | ||
public void run() { | ||
servers[0] = dbServer(DB1_DIR, getLocalURL(), "asynch-dserver-config-0.xml"); | ||
} | ||
}; | ||
dbServer1.start(); | ||
dbServer1.join(); | ||
|
||
Thread dbServer2 = new Thread() { | ||
@Override | ||
public void run() { | ||
servers[1] = dbServer(DB2_DIR, getLocalURL2(), "asynch-dserver-config-1.xml"); | ||
} | ||
}; | ||
dbServer2.start(); | ||
dbServer2.join(); | ||
|
||
Thread dbServer3 = new Thread() { | ||
@Override | ||
public void run() { | ||
servers[2] = dbServer(DB3_DIR, getLocalURL3(), "asynch-dserver-config-2.xml"); | ||
} | ||
}; | ||
dbServer3.start(); | ||
dbServer3.join(); | ||
|
||
Thread dbClient1 = new Thread() { | ||
@Override | ||
public void run() { | ||
dbClient1(); | ||
} | ||
}; | ||
dbClient1.start(); | ||
|
||
Thread dbClient2 = new Thread() { | ||
@Override | ||
public void run() { | ||
dbClient2(); | ||
} | ||
}; | ||
dbClient2.start(); | ||
|
||
dbClient1.join(); | ||
dbClient2.join(); | ||
|
||
endTest(servers); | ||
} | ||
|
||
} |
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
69 changes: 69 additions & 0 deletions
69
distributed/src/test/resources/asynch-dserver-config-2.xml
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,69 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<orient-server> | ||
<handlers> | ||
<handler class="com.orientechnologies.orient.graph.handler.OGraphServerHandler"> | ||
<parameters/> | ||
</handler> | ||
<handler class="com.orientechnologies.orient.server.handler.OJMXPlugin"> | ||
<parameters> | ||
<parameter value="false" name="enabled"/> | ||
<parameter value="true" name="profilerManaged"/> | ||
</parameters> | ||
</handler> | ||
<handler class="com.orientechnologies.orient.server.handler.OAutomaticBackup"> | ||
<parameters> | ||
<parameter value="false" name="enabled"/> | ||
<parameter value="4h" name="delay"/> | ||
<parameter value="backup" name="target.directory"/> | ||
<parameter value="${DBNAME}-${DATE:yyyyMMddHHmmss}.json" name="target.fileName"/> | ||
<parameter value="" name="db.include"/> | ||
<parameter value="" name="db.exclude"/> | ||
</parameters> | ||
</handler> | ||
<handler class="com.orientechnologies.orient.server.handler.OServerSideScriptInterpreter"> | ||
<parameters> | ||
<parameter value="false" name="enabled"/> | ||
</parameters> | ||
</handler> | ||
<handler class="com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin"> | ||
<parameters> | ||
<parameter value="true" name="enabled"/> | ||
<parameter value="src/test/resources/asynch-distributed-db-config.json" name="configuration.db.default"/> | ||
<parameter value="src/test/resources/hazelcast-2.xml" name="configuration.hazelcast"/> | ||
<parameter value="com.orientechnologies.orient.server.distributed.conflict.ODefaultReplicationConflictResolver" name="conflict.resolver.impl"/> | ||
<parameter value="node3" name="nodeName"/> | ||
</parameters> | ||
</handler> | ||
</handlers> | ||
<network> | ||
<protocols> | ||
<protocol implementation="com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary" name="binary"/> | ||
<protocol implementation="com.orientechnologies.orient.server.network.protocol.http.ONetworkProtocolHttpDb" name="http"/> | ||
</protocols> | ||
<listeners> | ||
<listener protocol="binary" socket="default" port-range="2425-2430" ip-address="0.0.0.0"/> | ||
<listener protocol="http" socket="default" port-range="2481-2490" ip-address="0.0.0.0"> | ||
<commands> | ||
<command implementation="com.orientechnologies.orient.server.network.protocol.http.command.get.OServerCommandGetStaticContent" pattern="GET|www GET|studio/ GET| GET|*.htm GET|*.html GET|*.xml GET|*.jpeg GET|*.jpg GET|*.png GET|*.gif GET|*.js GET|*.css GET|*.swf GET|*.ico GET|*.txt GET|*.otf GET|*.pjs GET|*.svg" stateful="false"> | ||
<parameters> | ||
<entry value="Cache-Control: no-cache, no-store, max-age=0, must-revalidate\r\nPragma: no-cache" name="http.cache:*.htm *.html"/> | ||
<entry value="Cache-Control: max-age=120" name="http.cache:default"/> | ||
</parameters> | ||
</command> | ||
</commands> | ||
<parameters> | ||
<parameter value="utf-8" name="network.http.charset"/> | ||
</parameters> | ||
</listener> | ||
</listeners> | ||
</network> | ||
<users> | ||
<user resources="*" password="02030E9917890174FB847A47C4BFFC449A604A248E9642BB31F28CE51245EC85" name="root"/> | ||
<user resources="connect,server.listDatabases,server.dblist" password="guest" name="guest"/> | ||
<user resources="database.passthrough" password="repl" name="replicator"/> | ||
</users> | ||
<properties> | ||
<entry value="info" name="log.console.level"/> | ||
<entry value="fine" name="log.file.level"/> | ||
</properties> | ||
</orient-server> |