Search in sources :

Example 1 with DataExporter

use of com.vaticle.typedb.core.migrator.data.DataExporter in project grakn by graknlabs.

the class MigratorService method exportData.

@Override
public void exportData(MigratorProto.Export.Req request, StreamObserver<MigratorProto.Export.Progress> responseObserver) {
    DataExporter exporter = new DataExporter(databaseMgr, request.getDatabase(), Paths.get(request.getFilename()), version);
    try {
        CompletableFuture<Void> migratorJob = CompletableFuture.runAsync(exporter::run);
        while (!migratorJob.isDone()) {
            Thread.sleep(1000);
            responseObserver.onNext(exporter.getProgress());
        }
        migratorJob.join();
        responseObserver.onCompleted();
    } catch (Throwable e) {
        LOG.error(e.getMessage(), e);
        responseObserver.onError(exception(e));
    }
}
Also used : DataExporter(com.vaticle.typedb.core.migrator.data.DataExporter)

Example 2 with DataExporter

use of com.vaticle.typedb.core.migrator.data.DataExporter in project grakn by graknlabs.

the class MigratorTest method test_import_export_data.

@Test
public void test_import_export_data() throws IOException {
    Util.resetDirectory(dataDir);
    try (CoreDatabaseManager databaseMgr = CoreDatabaseManager.open(options)) {
        databaseMgr.create(database);
        String schema = new String(Files.readAllBytes(schemaPath), UTF_8);
        runSchema(databaseMgr, schema);
        new DataImporter(databaseMgr, database, dataPath, Version.VERSION).run();
        new DataExporter(databaseMgr, database, exportDataPath, Version.VERSION).run();
        assertEquals(getChecksums(dataPath), getChecksums(exportDataPath));
    }
}
Also used : DataExporter(com.vaticle.typedb.core.migrator.data.DataExporter) CoreDatabaseManager(com.vaticle.typedb.core.database.CoreDatabaseManager) DataImporter(com.vaticle.typedb.core.migrator.data.DataImporter) Test(org.junit.Test)

Aggregations

DataExporter (com.vaticle.typedb.core.migrator.data.DataExporter)2 CoreDatabaseManager (com.vaticle.typedb.core.database.CoreDatabaseManager)1 DataImporter (com.vaticle.typedb.core.migrator.data.DataImporter)1 Test (org.junit.Test)1