java - OrientDB Complete Embedded Cluster Test -


i trying create simple test that:

  1. activates full server embedded instance (embedded server , distributed configuration)
  2. creates initial test database in document mode during first run (create database)
  3. opens test database (open database)
  4. insert sample record
  5. fetch sample record
  6. add node , repeat

i can understand steps individually having difficulty piecing simple test case. example, api documentation assumes remote connection. not sure whether applicable method here, , if so, url should specify.

once have completed steps 1, 2 , 3 correctly, should able refer api documentation steps 4 , 5.

as novice user, find difficult interpret documentation in context. or clarification appreciated.

i trying run test junit test. here have far:

public class testorientdb { private static final logger log = logger.getlogger(testorientdb.class);  @test public void testfullembeddedserver() throws exception {     log.debug("connectiong database server...");     string orientdbhome = new file("src/test/resources").getabsolutepath(); //set orientdb home current directory      log.debug("the orientdb home: " + orientdbhome);     system.setproperty("orientdb_home", orientdbhome);      oserver server = oservermain.create();     url configurl = this.getclass().getresource("/orientdb-config.xml");     server.startup(configurl.openstream());     server.activate();      //how create database here?      //how open database use api this: http://orientdb.com/docs/last/document-database.html      //should pause thread keep server active?     log.debug("shutting down orientdb...");     server.shutdown(); }} 

here orientdb-config.xml:

<orient-server> <users>     <user name="root" password="password" resources="*"/> </users> <properties>     <entry value="/etc/kwcn/databases" name="server.database.path"/>     <entry name="log.console.level" value="fine"/> </properties> <handler class="com.orientechnologies.orient.server.hazelcast.ohazelcastplugin">     <parameters>         <!-- node-name. if not set auto generated first time server run -->         <!-- <parameter name="nodename" value="europe1" /> -->         <parameter name="enabled" value="true"/>         <parameter name="configuration.db.default" value="${orientdb_home}/orientdb-config.json"/>         <parameter name="configuration.hazelcast" value="${orientdb_home}/hazelcast.xml"/>     </parameters> </handler> 

here hazelcast.xml:

<hazelcast xsi:schemalocation="http://www.hazelcast.com/schema/config hazelcast-config-3.0.xsd"        xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <group>     <name>orientdb</name>     <password>orientdb</password> </group> <network>     <port auto-increment="true">2434</port>     <join>         <multicast enabled="true">             <multicast-group>235.1.1.1</multicast-group>             <multicast-port>2434</multicast-port>         </multicast>     </join> </network> <executor-service>     <pool-size>16</pool-size> </executor-service> 

here orientdb-config.json:

{ "autodeploy": true, "hotalignment": false, "executionmode": "asynchronous", "readquorum": 1, "writequorum": 2, "failureavailablenodeslessquorum": false, "readyourwrites": true, "servers": { "*": "master" }, "clusters": { "internal": { }, "index": { }, "*": { "servers": [ "<new_node>" ] } } } 

here output:

  2016-02-07 16:02:17:867 info orientdb auto-config diskcache=10,695mb (heap=3,641mb os=16,384mb disk=71,698mb) [orientechnologies] 2016-02-07 16:02:18:016 info loading configuration input stream [oserverconfigurationloaderxml] 2016-02-07 16:02:18:127    info orientdb server v2.2.0-beta starting up... [oserver] 2016-02-07 16:02:18:133 info databases directory: /etc/kwcn/databases [oserver] 2016-02-07 16:02:18:133 warni network configuration not found [oserver] 2016-02-07 16:02:18:133 warni found    orientdb_root_password variable, using value root's password [oserver] 2016-02-07 16:02:18:523 info orientdb server active v2.2.0-beta. [oserver] 2016-02-07 16:02:18:523 info orientdb server shutting down... [oserver] 2016-02-07 16:02:18:523    info shutting down plugins: [oserverpluginmanager] debug [ kwcn.testorientdb]: shutting down orientdb... 2016-02-07 16:02:18:524 info shutting down databases: [oserver] 2016-02-07 16:02:18:565 info orientdb engine shutdown complete [orient] 2016-02-07    16:02:18:566 info orientdb server shutdown complete

i suggest take @

https://github.com/orientechnologies/orientdb/blob/2.1.x/distributed/src/test/java/com/orientechnologies/orient/server/distributed/abstractserverclustertest.java

it's base class of orientdb distributed tests. class hierarchy seems quite complex, in end instantiates multiple servers , delegates subclasses test operations against them.

you can check

https://github.com/orientechnologies/orientdb/blob/2.1.x/distributed/src/test/java/com/orientechnologies/orient/server/distributed/hatest.java

that 1 of subclasses. copy or extend , implement own logic in executetest() method.

about questions:

how create database here?

as normal plocal db:

new odatabasedocumenttx("plocal:...").create() 

or

new orientgraph("plocal:...") 

//how open database use api this:

same above:

new odatabasedocumenttx("plocal:...").open("admin", "admin"); 

//should pause thread keep server active?

there no need pause thread, server creates non-daemon threads, remain active. make sure someone, @ end of tests, invokes server.shutdown() (even thread)


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -