Search in sources :

Example 1 with OGraphRepair

use of com.tinkerpop.blueprints.impls.orient.OGraphRepair in project orientdb by orientechnologies.

the class TestGraphRecovering method testRecoverPerfectGraphLW.

@Test
public void testRecoverPerfectGraphLW() {
    final OrientBaseGraph g = new OrientGraphNoTx("memory:testRecoverPerfectGraphLW");
    try {
        init(g, true);
        final TestListener eventListener = new TestListener();
        new OGraphRepair().setEventListener(eventListener).repair(g, null, null);
        Assert.assertEquals(eventListener.scannedEdges, 0);
        Assert.assertEquals(eventListener.removedEdges, 0);
        Assert.assertEquals(eventListener.scannedVertices, 3);
        Assert.assertEquals(eventListener.scannedLinks, 6);
        Assert.assertEquals(eventListener.removedLinks, 0);
        Assert.assertEquals(eventListener.repairedVertices, 0);
    } finally {
        g.shutdown();
    }
}
Also used : OGraphRepair(com.tinkerpop.blueprints.impls.orient.OGraphRepair) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph) Test(org.junit.Test)

Example 2 with OGraphRepair

use of com.tinkerpop.blueprints.impls.orient.OGraphRepair in project orientdb by orientechnologies.

the class OGremlinConsole method repairDatabase.

@Override
@ConsoleCommand(description = "Repair database structure", splitInWords = false)
public void repairDatabase(@ConsoleParameter(name = "options", description = "Options: [--fix-graph] [--fix-links] [-v]] [--fix-ridbags] [--fix-bonsai]", optional = true) String iOptions) throws IOException {
    checkForDatabase();
    final boolean fix_graph = iOptions == null || iOptions.contains("--fix-graph");
    if (fix_graph) {
        // REPAIR GRAPH
        final Map<String, List<String>> options = parseOptions(iOptions);
        new OGraphRepair().repair(OrientGraphFactory.getNoTxGraphImplFactory().getGraph(currentDatabase), this, options);
    }
    final boolean fix_links = iOptions == null || iOptions.contains("--fix-links");
    if (fix_links) {
        // REPAIR DATABASE AT LOW LEVEL
        super.repairDatabase(iOptions);
    }
    if (!currentDatabase.getURL().startsWith("plocal")) {
        message("\n fix-bonsai can be run only on plocal connection \n");
        return;
    }
    final boolean fix_ridbags = iOptions == null || iOptions.contains("--fix-ridbags");
    if (fix_ridbags) {
        OBonsaiTreeRepair repairer = new OBonsaiTreeRepair();
        repairer.repairDatabaseRidbags(currentDatabase, this);
    }
    final boolean fix_bonsai = iOptions == null || iOptions.contains("--fix-bonsai");
    if (fix_bonsai) {
        OBonsaiTreeRepair repairer = new OBonsaiTreeRepair();
        repairer.repairDatabaseRidbags(currentDatabase, this);
    }
}
Also used : OGraphRepair(com.tinkerpop.blueprints.impls.orient.OGraphRepair) List(java.util.List) OBonsaiTreeRepair(com.tinkerpop.blueprints.impls.orient.OBonsaiTreeRepair) ConsoleCommand(com.orientechnologies.common.console.annotation.ConsoleCommand)

Example 3 with OGraphRepair

use of com.tinkerpop.blueprints.impls.orient.OGraphRepair in project orientdb by orientechnologies.

the class TestGraphRecovering method testRecoverPerfectGraphNonLW.

@Test
public void testRecoverPerfectGraphNonLW() {
    final OrientBaseGraph g = new OrientGraphNoTx("memory:testRecoverPerfectGraphNonLW");
    try {
        init(g, false);
        final TestListener eventListener = new TestListener();
        new OGraphRepair().setEventListener(eventListener).repair(g, null, null);
        Assert.assertEquals(eventListener.scannedEdges, 3);
        Assert.assertEquals(eventListener.removedEdges, 0);
        Assert.assertEquals(eventListener.scannedVertices, 3);
        Assert.assertEquals(eventListener.scannedLinks, 6);
        Assert.assertEquals(eventListener.removedLinks, 0);
        Assert.assertEquals(eventListener.repairedVertices, 0);
    } finally {
        g.shutdown();
    }
}
Also used : OGraphRepair(com.tinkerpop.blueprints.impls.orient.OGraphRepair) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph) Test(org.junit.Test)

Example 4 with OGraphRepair

use of com.tinkerpop.blueprints.impls.orient.OGraphRepair in project orientdb by orientechnologies.

the class TestGraphRecovering method testRecoverBrokenGraphAllEdges.

@Test
public void testRecoverBrokenGraphAllEdges() {
    final OrientBaseGraph g = new OrientGraphNoTx("memory:testRecoverBrokenGraphAllEdges");
    try {
        init(g, false);
        for (Edge e : g.getEdges()) {
            ((OrientEdge) e).getRecord().removeField("out");
            ((OrientEdge) e).getRecord().save();
        }
        final TestListener eventListener = new TestListener();
        new OGraphRepair().setEventListener(eventListener).repair(g, null, null);
        Assert.assertEquals(eventListener.scannedEdges, 3);
        Assert.assertEquals(eventListener.removedEdges, 3);
        Assert.assertEquals(eventListener.scannedVertices, 3);
        Assert.assertEquals(eventListener.scannedLinks, 6);
        Assert.assertEquals(eventListener.removedLinks, 6);
        Assert.assertEquals(eventListener.repairedVertices, 3);
    } finally {
        g.shutdown();
    }
}
Also used : OGraphRepair(com.tinkerpop.blueprints.impls.orient.OGraphRepair) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph) Edge(com.tinkerpop.blueprints.Edge) OrientEdge(com.tinkerpop.blueprints.impls.orient.OrientEdge) Test(org.junit.Test)

Example 5 with OGraphRepair

use of com.tinkerpop.blueprints.impls.orient.OGraphRepair in project orientdb by orientechnologies.

the class TestGraphRecovering method testRecoverBrokenGraphLinksInVerticesNonLW.

@Test
public void testRecoverBrokenGraphLinksInVerticesNonLW() {
    final OrientBaseGraph g = new OrientGraphNoTx("memory:testRecoverBrokenGraphLinksInVerticesNonLW");
    try {
        init(g, false);
        for (Vertex v : g.getVertices()) {
            for (String f : ((OrientVertex) v).getRecord().fieldNames()) {
                if (f.startsWith("out_"))
                    ((OrientVertex) v).getRecord().removeField(f);
            }
        }
        final TestListener eventListener = new TestListener();
        new OGraphRepair().setEventListener(eventListener).repair(g, null, null);
        Assert.assertEquals(eventListener.scannedEdges, 3);
        Assert.assertEquals(eventListener.removedEdges, 3);
        Assert.assertEquals(eventListener.scannedVertices, 3);
        Assert.assertEquals(eventListener.scannedLinks, 3);
        Assert.assertEquals(eventListener.removedLinks, 3);
        Assert.assertEquals(eventListener.repairedVertices, 3);
    } finally {
        g.shutdown();
    }
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) OGraphRepair(com.tinkerpop.blueprints.impls.orient.OGraphRepair) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph) Test(org.junit.Test)

Aggregations

OGraphRepair (com.tinkerpop.blueprints.impls.orient.OGraphRepair)6 OrientBaseGraph (com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)5 OrientGraphNoTx (com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)5 Test (org.junit.Test)5 Vertex (com.tinkerpop.blueprints.Vertex)2 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)2 ConsoleCommand (com.orientechnologies.common.console.annotation.ConsoleCommand)1 ORecordId (com.orientechnologies.orient.core.id.ORecordId)1 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1 Edge (com.tinkerpop.blueprints.Edge)1 OBonsaiTreeRepair (com.tinkerpop.blueprints.impls.orient.OBonsaiTreeRepair)1 OrientEdge (com.tinkerpop.blueprints.impls.orient.OrientEdge)1 List (java.util.List)1