本文整理汇总了Java中com.orientechnologies.orient.core.db.tool.ODatabaseExport类的典型用法代码示例。如果您正苦于以下问题:Java ODatabaseExport类的具体用法?Java ODatabaseExport怎么用?Java ODatabaseExport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODatabaseExport类属于com.orientechnologies.orient.core.db.tool包,在下文中一共展示了ODatabaseExport类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exportGraph
import com.orientechnologies.orient.core.db.tool.ODatabaseExport; //导入依赖的package包/类
@Override
public void exportGraph(String outputDirectory) throws IOException {
if (log.isDebugEnabled()) {
log.debug("Running export to {" + outputDirectory + "} directory.");
}
ODatabaseDocumentTx db = factory.getDatabase();
try {
OCommandOutputListener listener = new OCommandOutputListener() {
@Override
public void onMessage(String iText) {
System.out.println(iText);
}
};
String dateString = formatter.format(new Date());
String exportFile = "export_" + dateString;
new File(outputDirectory).mkdirs();
ODatabaseExport export = new ODatabaseExport(db, new File(outputDirectory, exportFile).getAbsolutePath(), listener);
export.exportDatabase();
export.close();
} finally {
db.close();
}
}
示例2: export
import com.orientechnologies.orient.core.db.tool.ODatabaseExport; //导入依赖的package包/类
@Override
public void export(final OutputStream output, final Set<String> excludedClassNames) throws IOException {
checkNotNull(output);
checkNotNull(excludedClassNames);
log.debug("Exporting database: {}", name);
try (ODatabaseDocumentTx db = openDb()) {
checkState(db.exists(), "Database does not exist: %s", name);
log.debug("Starting export");
ODatabaseExport exporter = new ODatabaseExport(db, output, new LoggingCommandOutputListener("EXPORT"));
if (!excludedClassNames.isEmpty()) {
// orientdb maps to classnames to uppercase
Set<String> upperCasedExcludedClassNames = excludedClassNames.stream()
.map(String::toUpperCase)
.collect(Collectors.toSet());
log.debug("excluding : {}", upperCasedExcludedClassNames);
exporter.setExcludeClasses(upperCasedExcludedClassNames);
}
exporter.exportDatabase();
log.debug("Completed export");
}
}
示例3: connect
import com.orientechnologies.orient.core.db.tool.ODatabaseExport; //导入依赖的package包/类
@Override
public OrientConnection connect() throws Exception {
final OrientGraphFactory graphFactory = new OrientGraphFactory("memory:graph", userName, password);
graphFactory.setAutoStartTx(false);
graphFactory.declareIntent(new OIntentMassiveInsert().setEnableCache(false));
return new AbstractOrientConnection(graphFactory.getNoTx()) {
@Override
public void close() throws Exception {
graph.commit();
new ODatabaseExport(graph.getRawGraph(), url.getDbName(), System.err::print).exportDatabase();
graph.getRawGraph().close();
}
};
}
示例4: backupDatabase
import com.orientechnologies.orient.core.db.tool.ODatabaseExport; //导入依赖的package包/类
private void backupDatabase (Task task) throws NdexException {
task.setStartTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));
String ndexRoot = Configuration.getInstance().getNdexRoot();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strDate = sdf.format(Calendar.getInstance().getTime());
try (ODatabaseDocumentTx db = NdexDatabase.getInstance().getAConnection()){
String exportFile = ndexRoot + "/dbbackups/db_"+ strDate + ".export";
logger.info("Backing up database to " + exportFile);
try{
OCommandOutputListener listener = new OCommandOutputListener() {
@Override
public void onMessage(String iText) {
logger.info(iText);
}
};
ODatabaseExport export = new ODatabaseExport(db, exportFile, listener);
export.setIncludeIndexDefinitions(false);
export.exportDatabase();
export.close();
task.setFinishTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));
task.setStatus(Status.COMPLETED);
task.setMessage("Db exported to " + exportFile);
logger.info("Database back up fininished succefully.");
} catch (Exception e) {
task.setMessage(e.getMessage());
task.setStatus(Status.FAILED);
logger.severe("IO exception when backing up database. " + e.getMessage());
e.printStackTrace();
}
try (TaskDAO taskdao = new TaskDAO (NdexDatabase.getInstance().getAConnection())) {
taskdao.createTask(null, task);
taskdao.commit();
taskdao.close();
}
}
}