use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class OrientTestsManualTx method setUpGraph.
@Before
public void setUpGraph() {
graphFactory = new OrientGraphFactory(DATABASE_URL);
graphFactory.setAutoStartTx(false);
graph = graphFactory.getTx();
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class DbCreationTest method testZipCompression.
public void testZipCompression() {
if (database == null || !database.getURL().startsWith("plocal:"))
return;
OGlobalConfiguration.STORAGE_COMPRESSION_METHOD.setValue("gzip");
final String buildDirectory = System.getProperty("buildDirectory", ".");
String dburl = "plocal:" + buildDirectory + "/test-db/" + this.getClass().getSimpleName();
final OrientGraphFactory factory = new OrientGraphFactory(dburl, "admin", "admin");
if (factory.exists())
factory.drop();
factory.close();
OrientGraphNoTx db = factory.getNoTx();
db.drop();
OGlobalConfiguration.STORAGE_COMPRESSION_METHOD.setValue(OGlobalConfiguration.STORAGE_COMPRESSION_METHOD.getValue());
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class GraphTransactionConsistency method testTransactionConsistency.
public void testTransactionConsistency() throws InterruptedException {
final OrientGraphFactory factory = new OrientGraphFactory("plocal:target/GraphTransactionConsistency", false);
database = txMode ? factory.getTx() : factory.getNoTx();
System.out.println("Checking consistency of database...");
System.out.println("Records found V=" + database.countVertices() + " E=" + database.countEdges());
final Iterable<OrientVertex> vertices = database.command(new OCommandSQL("select from V")).execute();
for (OrientVertex v : vertices) {
final ODocument doc = v.getRecord();
Assert.assertNotNull(doc);
final ORidBag out = doc.field("out_");
if (out != null) {
for (Iterator<OIdentifiable> it = out.rawIterator(); it.hasNext(); ) {
final OIdentifiable edge = it.next();
Assert.assertNotNull(edge);
final ODocument rec = edge.getRecord();
Assert.assertNotNull(rec);
Assert.assertNotNull(rec.field("out"));
Assert.assertEquals(((ODocument) rec.field("out")).getIdentity(), v.getIdentity());
Assert.assertNotNull(rec.field("in"));
}
}
final ORidBag in = doc.field("in_");
if (in != null) {
for (Iterator<OIdentifiable> it = in.rawIterator(); it.hasNext(); ) {
final OIdentifiable edge = it.next();
Assert.assertNotNull(edge);
final ODocument rec = edge.getRecord();
Assert.assertNotNull(rec);
Assert.assertNotNull(rec.field("in"));
Assert.assertEquals(((ODocument) rec.field("in")).getIdentity(), v.getIdentity());
Assert.assertNotNull(rec.field("out"));
}
}
}
System.out.println("Consistency ok.");
final Thread[] threads = new Thread[THREADS];
for (int i = 0; i < THREADS; ++i) {
final int threadNum = i;
threads[i] = new Thread(new Runnable() {
@Override
public void run() {
OrientBaseGraph graph = txMode ? factory.getTx() : factory.getNoTx();
try {
System.out.println("THREAD " + threadNum + " Start transactions (" + TXNUM + ")");
for (int i = 0; i < TXNUM; ++i) {
final OrientVertex v1 = graph.addVertex(null, "v", i, "type", "Main", "lastUpdate", new Date());
for (int e = 0; e < EDGENUM; ++e) {
final OrientVertex v2 = graph.addVertex(null, "v", i, "e", e, "type", "Connected", "lastUpdate", new Date());
v1.addEdge("E", v2);
}
if (i % TXBATCH == 0) {
System.out.println("THREAD " + threadNum + " Committing batch of " + TXBATCH + " (i=" + i + ")");
System.out.flush();
graph.commit();
System.out.println("THREAD " + threadNum + " Commit ok - records found V=" + graph.countVertices() + " E=" + graph.countEdges());
System.out.flush();
}
}
} finally {
graph.shutdown();
}
}
});
Thread.sleep(1000);
threads[i].start();
}
for (int i = 0; i < THREADS; ++i) {
try {
threads[i].join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
database.shutdown();
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class BackupTest method main.
public static void main(String[] args) throws IOException {
File backupFile = new File("testbackup.zip");
OutputStream oS = new FileOutputStream(backupFile);
OrientGraphFactory factory = new OrientGraphFactory("plocal:backupTest", "admin", "admin");
OrientGraphNoTx graphNoTx = factory.getNoTx();
graphNoTx.getRawGraph().backup(oS, null, null, null, 1, 1024);
ZipFile zipFile = new ZipFile(backupFile);
Enumeration enumeration = zipFile.entries();
System.out.format("ZipFile : %s%n", zipFile);
while (enumeration.hasMoreElements()) {
Object entry = enumeration.nextElement();
System.out.format(" Entry : %s%n", entry);
}
factory.close();
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraphFactory in project orientdb by orientechnologies.
the class SuperNodeGraphSpeedTest method init.
@Override
@Test(enabled = false)
public void init() throws Exception {
String buildDirectory = System.getProperty("buildDirectory", ".");
if (buildDirectory == null) {
buildDirectory = ".";
}
final OrientGraphFactory factory = new OrientGraphFactory("plocal:" + buildDirectory + "/SuperNodeGraphSpeedTest", "admin", "admin");
if (factory.exists())
factory.drop();
graph = factory.getNoTx();
superNode = graph.addVertex(null);
factory.close();
}
Aggregations