@ConsoleCommand(description = "Display the current path") public void pwd() { message("\nCurrent path: " + new File("").getAbsolutePath()); }
@ConsoleCommand(description = "Return the value of a property") public void get(@ConsoleParameter(name = "property-name", description = "Name of the property") final String iPropertyName) { Object value = properties.get(iPropertyName); out.println(); if (value == null) message("\nProperty '" + iPropertyName + "' is not setted"); else out.println(iPropertyName + " = " + value); }
protected void dumpDistributedConfiguration(final boolean iForce) { if (currentDatabase == null) return; final OStorage stg = currentDatabase.getStorage(); if (stg instanceof OStorageRemote) { final ODocument distributedCfg = ((OStorageRemote) stg).getClusterConfiguration(); if (distributedCfg != null && !distributedCfg.isEmpty()) { message("\n\nDISTRIBUTED CONFIGURATION:\n" + distributedCfg.toJSON("prettyPrint")); } else if (iForce) message("\n\nDISTRIBUTED CONFIGURATION: none (OrientDB is running in standalone mode)"); } }
@ConsoleCommand(splitInWords = false, description = "Create an index against a property", onlineHelp = "SQL-Create-Index") public void createIndex(@ConsoleParameter(name = "command-text", description = "The command text to execute") String iCommandText) throws IOException { message("\n\nCreating index..."); sqlCommand("create", iCommandText, "\nCreated index successfully in %f sec(s).\n", false); updateDatabaseInfo(); message("\n\nIndex created successfully"); }
@ConsoleCommand(splitInWords = false, description = "Rebuild an index if it is automatic", onlineHelp = "SQL-Rebuild-Index") public void rebuildIndex( @ConsoleParameter(name = "command-text", description = "The command text to execute") String iCommandText) throws IOException { message("\n\nRebuilding index(es)..."); sqlCommand("rebuild", iCommandText, "\nRebuilt index(es). Found %d link(s) in %f sec(s).\n", true); updateDatabaseInfo(); message("\n\nIndex(es) rebuilt successfully"); }
@ConsoleCommand(splitInWords = false, description = "Remove an index", onlineHelp = "SQL-Drop-Index") public void dropIndex(@ConsoleParameter(name = "command-text", description = "The command text to execute") String iCommandText) throws IOException { message("\n\nRemoving index..."); sqlCommand("drop", iCommandText, "\nDropped index in %f sec(s).\n", false); updateDatabaseInfo(); message("\n\nIndex removed successfully"); }
@ConsoleCommand(description = "Load a sql script into the current database", splitInWords = true, onlineHelp = "Console-Command-Load-Script") public void loadScript(@ConsoleParameter(name = "scripPath", description = "load script scriptPath") final String scriptPath) throws IOException { checkForDatabase(); message("\nLoading script " + scriptPath + "..."); executeBatch(scriptPath); message("\nLoaded script " + scriptPath); }
@ConsoleCommand(description = "Remove the association in the dictionary", onlineHelp = "Console-Command-Dictionary-Remove") public void dictionaryRemove(@ConsoleParameter(name = "key", description = "The key to remove") final String iKey) { checkForDatabase(); boolean result = currentDatabase.getDictionary().remove(iKey); if (!result) message("\nEntry not found in dictionary."); else message("\nEntry removed from the dictionary."); }
@ConsoleCommand(description = "Execute a command against the profiler") public void profiler( @ConsoleParameter(name = "profiler command", description = "command to execute against the profiler") final String iCommandName) { if (iCommandName.equalsIgnoreCase("on")) { Orient.instance().getProfiler().startRecording(); message("\nProfiler is ON now, use 'profiler off' to turn off."); } else if (iCommandName.equalsIgnoreCase("off")) { Orient.instance().getProfiler().stopRecording(); message("\nProfiler is OFF now, use 'profiler on' to turn on."); } else if (iCommandName.equalsIgnoreCase("dump")) { out.println(Orient.instance().getProfiler().dump()); } }
/** * Should be used only by console commands */ public void loadRecordInternal(String iRecordId, String iFetchPlan) { checkForDatabase(); currentRecord = currentDatabase.load(new ORecordId(iRecordId), iFetchPlan); displayRecord(null); message("\nOK"); }
@ConsoleCommand(description = "Displays the status of the cluster nodes") public void clusterStatus() throws IOException { checkForRemoteServer(); try { message("\nCluster status:"); ODocument clusterStatus = ((OrientDBRemote) OrientDBInternal.extract(orientDB)) .getClusterStatus(currentDatabaseUserName, currentDatabaseUserPassword); out.println(clusterStatus.toJSON("attribSameRow,alwaysFetchEmbedded,fetchPlan:*:0")); } catch (Exception e) { printError(e); } }
@ConsoleCommand(description = "Insert or modify an entry in the database dictionary. The entry is comprised of key=String, value=record-id", onlineHelp = "Console-Command-Dictionary-Put") public void dictionaryPut(@ConsoleParameter(name = "key", description = "The key to bind") final String iKey, @ConsoleParameter(name = "record-id", description = "The record-id of the record to bind to the key") final String iRecordId) { checkForDatabase(); currentRecord = currentDatabase.load(new ORecordId(iRecordId)); if (currentRecord == null) message("\nError: record with id '" + iRecordId + "' was not found in database"); else { currentDatabase.getDictionary().put(iKey, currentRecord); displayRecord(null); message("\nThe entry " + iKey + "=" + iRecordId + " has been inserted in the database dictionary"); } }
/** * Should be used only by console commands */ public void reloadRecordInternal(String iRecordId, String iFetchPlan) { checkForDatabase(); currentRecord = currentDatabase .executeReadRecord(new ORecordId(iRecordId), null, -1, iFetchPlan, true, false, false, OStorage.LOCKING_STRATEGY.NONE, new SimpleRecordReader(false)); displayRecord(null); message("\nOK"); }
@ConsoleCommand(description = "Loook up a record using the dictionary. If found, set it as the current record", onlineHelp = "Console-Command-Dictionary-Get") public void dictionaryGet(@ConsoleParameter(name = "key", description = "The key to search") final String iKey) { checkForDatabase(); currentRecord = currentDatabase.getDictionary().get(iKey); if (currentRecord == null) message("\nEntry not found in dictionary."); else { currentRecord = (ORecord) currentRecord.load(); displayRecord(null); } }
@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); } }