本文整理汇总了Java中com.orientechnologies.orient.core.db.tool.ODatabaseExport.exportDatabase方法的典型用法代码示例。如果您正苦于以下问题:Java ODatabaseExport.exportDatabase方法的具体用法?Java ODatabaseExport.exportDatabase怎么用?Java ODatabaseExport.exportDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.orientechnologies.orient.core.db.tool.ODatabaseExport
的用法示例。
在下文中一共展示了ODatabaseExport.exportDatabase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}
}
}