Reputation: 311
I should use OrientDB in embedded mode in a Java-Groovy application. At the same time, I have to distribute this java-groovy application in several machines.
The question is: is it possible to access the same database from all the machines? In other words: is it possible to have a distributed database in embedded mode in OrientDB?
Thank you
Upvotes: 13
Views: 5604
Reputation: 3622
I created a small example project which demonstrates how to setup an embedded orientdb cluster.
The example consists of two tests which are located in two different projects. Each test starts a new orientdb server. One of the tests writes data and the second test reads the data which has been written.
I'm still trying to figure out some quirks but so far it is able to illustrate the basic principal.
https://github.com/Jotschi/orientdb-cluster-test
Upvotes: 0
Reputation: 508
I know I am answering this question a little late, but I hope this will help someone else googling for the same issue:
I am able to run OrientDB in Embedded mode with Clustering (Distribution) on. Below is the complete code
System.setProperty("ORIENTDB_HOME","/your path to OrientDB/orientdb-community-1.7-rc1");
OServer server = OServerMain.create();
server.startup(
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
"<orient-server>\n" +
" <handlers>\n" +
" <!-- CLUSTER PLUGIN, TO TURN ON SET THE 'ENABLED' PARAMETER TO 'true' -->\n" +
" <handler class=\"com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin\">\n" +
" <parameters>\n" +
" <!-- <parameter name=\"nodeName\" value=\"europe1\" /> -->\n" +
" <parameter name=\"enabled\" value=\"true\" />\n" +
" <parameter name=\"configuration.db.default\" value=\"${ORIENTDB_HOME}/config/default-distributed-db-config.json\" />\n" +
" <parameter name=\"configuration.hazelcast\" value=\"${ORIENTDB_HOME}/config/hazelcast.xml\" />\n" +
" <parameter name=\"conflict.resolver.impl\" value=\"com.orientechnologies.orient.server.distributed.conflict.ODefaultReplicationConflictResolver\" />\n" +
" \n" +
" <!-- PARTITIONING STRATEGIES -->\n" +
" <parameter name=\"sharding.strategy.round-robin\" value=\"com.orientechnologies.orient.server.hazelcast.sharding.strategy.ORoundRobinPartitioninStrategy\" />\n" +
" </parameters>\n" +
" </handler>\n" +
" <!-- AUTOMATIC BACKUP, TO TURN ON SET THE 'ENABLED' PARAMETER TO 'true' -->\n" +
" <handler class=\"com.orientechnologies.orient.server.handler.OAutomaticBackup\">\n" +
" <parameters>\n" +
" <parameter name=\"enabled\" value=\"false\" />\n" +
" <parameter name=\"delay\" value=\"4h\" />\n" +
" <parameter name=\"target.directory\" value=\"backup\" />\n" +
" <parameter name=\"target.fileName\" value=\"${DBNAME}-${DATE:yyyyMMddHHmmss}.json\" /><!-- ${DBNAME} AND ${DATE:} VARIABLES ARE SUPPORTED -->\n" +
" <parameter name=\"db.include\" value=\"\" /><!-- DEFAULT: NO ONE, THAT MEANS ALL DATABASES. USE COMMA TO SEPARATE MULTIPLE DATABASE NAMES -->\n" +
" <parameter name=\"db.exclude\" value=\"\" /><!-- USE COMMA TO SEPARATE MULTIPLE DATABASE NAMES -->\n" +
" </parameters>\n" +
" </handler>\n" +
" <!-- MAIL, TO TURN ON SET THE 'ENABLED' PARAMETER TO 'true' -->\n" +
" <handler class=\"com.orientechnologies.orient.server.plugin.mail.OMailPlugin\">\n" +
" <parameters>\n" +
" <parameter name=\"enabled\" value=\"true\" />\n" +
" <!-- CREATE MULTIPLE PROFILES WITH profile.<name>... -->\n" +
" <parameter name=\"profile.default.mail.smtp.host\" value=\"localhost\" />\n" +
" <parameter name=\"profile.default.mail.smtp.port\" value=\"25\" />\n" +
" <parameter name=\"profile.default.mail.smtp.auth\" value=\"true\" />\n" +
" <parameter name=\"profile.default.mail.smtp.starttls.enable\" value=\"true\" />\n" +
" <parameter name=\"profile.default.mail.smtp.user\" value=\"\" />\n" +
" <parameter name=\"profile.default.mail.smtp.password\" value=\"\" />\n" +
" <parameter name=\"profile.default.mail.date.format\" value=\"yyyy-MM-dd HH:mm:ss\" />\n" +
" </parameters>\n" +
" </handler>\n" +
" <!-- SERVER SIDE SCRIPT INTERPRETER. WARNING! THIS CAN BE A SECURITY HOLE: ENABLE IT ONLY IF CLIENTS ARE TRUCT, TO TURN ON SET THE 'ENABLED' PARAMETER \n" +
" TO 'true' -->\n" +
" <handler class=\"com.orientechnologies.orient.server.handler.OServerSideScriptInterpreter\">\n" +
" <parameters>\n" +
" <parameter name=\"enabled\" value=\"false\" />\n" +
" </parameters>\n" +
" </handler>\n" +
" </handlers>\n" +
" <network>\n" +
" <protocols>\n" +
" <!-- Default registered protocol. It reads commands using the HTTP protocol and write data locally -->\n" +
" <protocol name=\"binary\" implementation=\"com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary\" />\n" +
" <protocol name=\"http\" implementation=\"com.orientechnologies.orient.server.network.protocol.http.ONetworkProtocolHttpDb\" />\n" +
" </protocols>\n" +
" <listeners>\n" +
" <listener protocol=\"binary\" ip-address=\"0.0.0.0\" port-range=\"2424-2430\" />\n" +
" <listener protocol=\"http\" ip-address=\"0.0.0.0\" port-range=\"2480-2490\">\n" +
" <parameters>\n" +
" <!-- Connection's custom parameters. If not specified the global configuration will be taken -->\n" +
" <parameter name=\"network.http.charset\" value=\"utf-8\" />\n" +
" <!-- Define additional HTTP headers to always send as response -->\n" +
" <!-- Allow cross-site scripting -->\n" +
" <!-- parameter name=\"network.http.additionalResponseHeaders\" value=\"Access-Control-Allow-Origin: *;Access-Control-Allow-Credentials: true\" /-->\n" +
" </parameters>\n" +
" <commands>\n" +
" <command\n" +
" 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\"\n" +
" implementation=\"com.orientechnologies.orient.server.network.protocol.http.command.get.OServerCommandGetStaticContent\">\n" +
" <parameters>\n" +
" <!-- Don't cache html resources in development mode -->\n" +
" <entry name=\"http.cache:*.htm *.html\" value=\"Cache-Control: no-cache, no-store, max-age=0, must-revalidate\\r\\nPragma: no-cache\" />\n" +
" <!-- Default caching -->\n" +
" <entry name=\"http.cache:default\" value=\"Cache-Control: max-age=120\" />\n" +
" </parameters>\n" +
" </command>\n" +
" </commands>\n" +
" </listener>\n" +
" </listeners>\n" +
" <cluster>\n" +
" </cluster>\n" +
" </network>\n" +
" <storages>\n" +
" </storages>\n" +
" <users>\n" +
" </users>\n" +
" <properties>\n" +
" <!-- Uses the Hazelcast's distributed cache as 2nd level cache -->\n" +
" <!-- <entry name=\"cache.level2.impl\" value=\"com.orientechnologies.orient.server.hazelcast.OHazelcastCache\" /> -->\n" +
"\n" +
" <!-- DATABASE POOL: size min/max -->\n" +
" <entry name=\"db.pool.min\" value=\"1\" />\n" +
" <entry name=\"db.pool.max\" value=\"20\" />\n" +
" \n" +
" <!-- LEVEL1 AND 2 CACHE: enable/disable and set the size as number of entries -->\n" +
" <entry name=\"cache.level1.enabled\" value=\"false\" />\n" +
" <entry name=\"cache.level1.size\" value=\"1000\" />\n" +
" <entry name=\"cache.level2.enabled\" value=\"true\" />\n" +
" <entry name=\"cache.level2.size\" value=\"1000\" />\n" +
" \n" +
" <!-- PROFILER: configures the profiler as <seconds-for-snapshot>,<archive-snapshot-size>,<summary-size> -->\n" +
" <entry name=\"profiler.enabled\" value=\"true\" />\n" +
" <!-- <entry name=\"profiler.config\" value=\"30,10,10\" /> --> \n" +
"\n" +
" <!-- LOG: enable/Disable logging. Levels are: finer, fine, finest, info, warning -->\n" +
" <entry name=\"log.console.level\" value=\"info\" />\n" +
" <entry name=\"log.file.level\" value=\"fine\" />\n" +
" </properties>\n" +
"</orient-server>");
server.activate();
We need to add the following jars
concurrentlinkedhashmap-lru-1.3.1.jar
hazelcast-3.1.jar
javassist-3.16.1-GA.jar
orient-commons-1.7-rc1.jar
orientdb-client-1.7-rc1.jar
orientdb-core-1.7-rc1.jar
orientdb-distributed-1.7-rc1.jar
orientdb-enterprise-1.7-rc1.jar
orientdb-object-1.7-rc1.jar
orientdb-server-1.7-rc1.jar
Upvotes: 12
Reputation: 9060
Yes, take a look at: https://github.com/orientechnologies/orientdb/wiki/Embedded-Server. With the distributed configuration multiple embedded servers can be synchronized across the network.
Upvotes: 3