public void run() { long errors = 0; if (removeBrokenLinks) errors += removeBrokenLinks(); message("\nRepair database complete (" + errors + " errors)"); }
@Override public ODatabaseImport setOptions(String iOptions) { super.setOptions(iOptions); return this; }
@Override public void run() { compare(); }
@ConsoleCommand(description = "Export a database schema") public void exportSchema(@ConsoleParameter(name = "output-file", description = "Output file path") final String iOutputFilePath) throws IOException { checkForDatabase(); message("\nExporting current database to: " + iOutputFilePath + "..."); try { ODatabaseExport exporter = new ODatabaseExport(currentDatabase, iOutputFilePath, this); exporter.setIncludeRecords(false); exporter.exportDatabase().close(); } catch (ODatabaseExportException e) { printError(e); } }
@Override public void importGraph(String importFile) throws IOException { ODatabaseDocumentTx db = factory.getDatabase(); try { OCommandOutputListener listener = new OCommandOutputListener() { @Override public void onMessage(String iText) { System.out.println(iText); } }; ODatabaseImport databaseImport = new ODatabaseImport(db, importFile, listener); databaseImport.importDatabase(); databaseImport.close(); } finally { db.close(); } } }
private void import_(final ODatabaseDocumentTx db, final InputStream input) throws IOException { checkNotNull(db); checkNotNull(input); log.debug("Starting import"); ODatabaseImport importer = new ODatabaseImport(db, input, new LoggingCommandOutputListener("IMPORT")); importer.importDatabase(); log.debug("Completed import"); }
@Override public void run() { importDatabase(); }
@Override public void run() { exportDatabase(); }
public void repair(final ODatabaseSession graph, final OCommandOutputListener outputListener, final Map<String, List<String>> options) { message(outputListener, "Repair of graph '" + graph.getURL() + "' is started ...\n"); final long beginTime = System.currentTimeMillis(); final ORepairStats stats = new ORepairStats(); // SCAN AND CLEAN ALL THE EDGES FIRST (IF ANY) repairEdges(graph, stats, outputListener, options, false); // SCAN ALL THE VERTICES repairVertices(graph, stats, outputListener, options, false); message(outputListener, "Repair of graph '" + graph.getURL() + "' completed in " + ((System.currentTimeMillis() - beginTime) / 1000) + " secs\n"); message(outputListener, " scannedEdges.....: " + stats.scannedEdges + "\n"); message(outputListener, " removedEdges.....: " + stats.removedEdges + "\n"); message(outputListener, " scannedVertices..: " + stats.scannedVertices + "\n"); message(outputListener, " scannedLinks.....: " + stats.scannedLinks + "\n"); message(outputListener, " removedLinks.....: " + stats.removedLinks + "\n"); message(outputListener, " repairedVertices.: " + stats.repairedVertices + "\n"); }
@Override public void run() { for (OIndex index : database.getMetadata().getIndexManager().getIndexes()) { if (!canCheck(index)) { continue; } checkIndex(index); } message("Total errors found on indexes: " + getTotalErrors()); }
@Override public void check(final ODatabaseIdentifier databaseIdentifier) { final ODatabaseDocument db = (ODatabaseDocument) getDocumentDatabase(databaseIdentifier, OStorageRemote.CONNECTION_STRATEGY.STICKY); final ODatabaseTool repair = new ODatabaseRepair().setDatabase(db); repair.run(); } }
@Override protected void configureODatabaseExport(ODatabaseExport dbExport) { dbExport.setOptions("-excludeAll=true -includeSchema=true"); }
@Override protected void parseSetting(final String option, final List<String> items) { if (option.equalsIgnoreCase("-compressionLevel")) compressionLevel = Integer.parseInt(items.get(0)); else if (option.equalsIgnoreCase("-compressionBuffer")) compressionBuffer = Integer.parseInt(items.get(0)); else super.parseSetting(option, items); }
public void setOption(final String option, String value) { parseSetting("-" + option, Arrays.asList(value)); }
void printProgress(String clusterName, int clusterId, int step, int totSteps) { StringBuilder msg = new StringBuilder(); msg.append("\rcluster " + clusterName + " (" + clusterId + ") |"); for (int i = 0; i < totSteps; i++) { if (i < step) { msg.append("*"); } else { msg.append(" "); } } msg.append("| "); msg.append(step * 100 / totSteps); msg.append("%%"); message(msg.toString()); }
protected void rewriteLinksInDocument(ODocument document, Set<ORID> brokenRids) { rewriteLinksInDocument(document, exportImportHashTable, brokenRids); document.save(); }
private void processBrokenRids() throws IOException, ParseException { Set<ORID> brokenRids = new HashSet<>(); processBrokenRids(brokenRids); jsonReader.readNext(OJSONReader.COMMA_SEPARATOR); }
public void check(final ODatabaseSession graph, final OCommandOutputListener outputListener, final Map<String, List<String>> options) { message(outputListener, "Check of graph '" + graph.getURL() + "' is started...\n"); final long beginTime = System.currentTimeMillis(); final ORepairStats stats = new ORepairStats(); // SCAN AND CLEAN ALL THE EDGES FIRST (IF ANY) repairEdges(graph, stats, outputListener, options, true); // SCAN ALL THE VERTICES repairVertices(graph, stats, outputListener, options, true); message(outputListener, "Check of graph '" + graph.getURL() + "' completed in " + ((System.currentTimeMillis() - beginTime) / 1000) + " secs\n"); message(outputListener, " scannedEdges.....: " + stats.scannedEdges + "\n"); message(outputListener, " edgesToRemove....: " + stats.removedEdges + "\n"); message(outputListener, " scannedVertices..: " + stats.scannedVertices + "\n"); message(outputListener, " scannedLinks.....: " + stats.scannedLinks + "\n"); message(outputListener, " linksToRemove....: " + stats.removedLinks + "\n"); message(outputListener, " verticesToRepair.: " + stats.repairedVertices + "\n"); }
@Override public ODatabaseExport setOptions(final String s) { super.setOptions(s); return this; }
@Override protected void parseSetting(final String option, final List<String> items) { if (option.equalsIgnoreCase("-deleteRIDMapping")) deleteRIDMapping = Boolean.parseBoolean(items.get(0)); else if (option.equalsIgnoreCase("-preserveClusterIDs")) preserveClusterIDs = Boolean.parseBoolean(items.get(0)); else if (option.equalsIgnoreCase("-merge")) merge = Boolean.parseBoolean(items.get(0)); else if (option.equalsIgnoreCase("-migrateLinks")) migrateLinks = Boolean.parseBoolean(items.get(0)); else if (option.equalsIgnoreCase("-rebuildIndexes")) rebuildIndexes = Boolean.parseBoolean(items.get(0)); else super.parseSetting(option, items); }