use of com.orientechnologies.orient.core.exception.ORetryQueryException in project orientdb by orientechnologies.
the class OConsoleDatabaseApp method js.
@SuppressWarnings("unchecked")
@ConsoleCommand(splitInWords = false, description = "Execute javascript commands in the console")
public void js(@ConsoleParameter(name = "text", description = "The javascript to execute. Use 'db' to reference to a document database, 'gdb' for a graph database") final String iText) {
if (iText == null)
return;
resetResultSet();
long start = System.currentTimeMillis();
while (true) {
try {
final OCommandExecutorScript cmd = new OCommandExecutorScript();
cmd.parse(new OCommandScript("Javascript", iText));
currentResult = cmd.execute(null);
break;
} catch (ORetryQueryException e) {
continue;
}
}
float elapsedSeconds = getElapsedSecs(start);
parseResult();
if (currentResultSet != null) {
dumpResultSet(-1);
message("\nClient side script executed in %f sec(s). Returned %d records", elapsedSeconds, currentResultSet.size());
} else
message("\nClient side script executed in %f sec(s). Value returned is: %s", elapsedSeconds, currentResult);
}
use of com.orientechnologies.orient.core.exception.ORetryQueryException in project orientdb by orientechnologies.
the class OSQLCommandTask method execute.
public Object execute(ODistributedRequestId requestId, final OServer iServer, ODistributedServerManager iManager, final ODatabaseDocumentInternal database) throws Exception {
if (ODistributedServerLog.isDebugEnabled())
ODistributedServerLog.debug(this, iManager.getLocalNodeName(), getNodeSource(), DIRECTION.IN, "Execute command=%s db=%s", text.toString(), database.getName());
Object res;
while (true) {
try {
final OCommandRequest cmd = database.command(new OCommandSQL(text));
OCommandExecutor executor = OCommandManager.instance().getExecutor((OCommandRequestInternal) cmd);
executor.parse(cmd);
final OCommandExecutor exec = executor instanceof OCommandExecutorSQLDelegate ? ((OCommandExecutorSQLDelegate) executor).getDelegate() : executor;
if (exec instanceof OCommandExecutorSQLSelect && clusters.size() > 0) {
// REWRITE THE TARGET TO USE CLUSTERS
final StringBuilder buffer = new StringBuilder("cluster:[");
int i = 0;
for (String c : clusters) {
if (i++ > 0)
buffer.append(',');
buffer.append(c);
}
buffer.append("]");
((OCommandExecutorSQLSelect) exec).setParsedTarget(new OSQLTarget(buffer.toString(), exec.getContext()));
}
if (params != null)
// EXECUTE WITH PARAMETERS
res = executor.execute(params);
else
res = executor.execute(null);
break;
} catch (ORetryQueryException e) {
continue;
}
}
return res;
}
use of com.orientechnologies.orient.core.exception.ORetryQueryException in project orientdb by orientechnologies.
the class OFunction method execute.
public Object execute(final Map<Object, Object> iArgs) {
final long start = Orient.instance().getProfiler().startChrono();
Object result;
while (true) {
try {
if (callback != null)
return callback.call(iArgs);
final OCommandExecutorScript command = new OCommandExecutorScript();
command.parse(new OCommandScript(getLanguage(), getCode()));
result = command.execute(iArgs);
break;
} catch (ONeedRetryException e) {
continue;
} catch (ORetryQueryException e) {
continue;
}
}
if (Orient.instance().getProfiler().isRecording())
Orient.instance().getProfiler().stopChrono("db." + ODatabaseRecordThreadLocal.INSTANCE.get().getName() + ".function.execute", "Time to execute a function", start, "db.*.function.execute");
return result;
}
Aggregations