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));
}
}
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));
}
}
Aggregations