use of org.erlide.runtime.rpc.RpcTimeoutException in project erlide_eclipse by erlang.
the class DialyzerUtils method doDialyze.
public static void doDialyze(final IProgressMonitor monitor, final Set<IErlModule> modules, final Set<IErlProject> projects, final IBackend backend) throws InvocationTargetException, DialyzerErrorException {
if (backend == null) {
ErlLogger.warn("Trying to dialyze with null backend");
return;
}
try {
for (final IErlModule module : modules) {
DialyzerMarkerUtils.removeDialyzerMarkersFor(module.getResource());
}
// TODO handle preferences from multiple projects
final DialyzerPreferences prefs = DialyzerPreferences.get(null);
final Collection<String> pltPaths = prefs.getPltPaths();
// prefs.getFromSource();
final boolean fromSource = false;
// prefs.getNoCheckPLT();
final boolean noCheckPLT = true;
final List<String> files = Lists.newArrayList();
final List<IPath> includeDirs = Lists.newArrayList();
final List<String> names = Lists.newArrayList();
DialyzerUtils.collectFilesAndIncludeDirs(modules, projects, files, names, includeDirs, fromSource);
if (names.isEmpty()) {
return;
}
final String fileNames = names.size() + " modules [" + DialyzerUtils.getFileNames(names) + "]";
monitor.subTask(fileNames);
ErlLogger.trace("dialyzer", "run %s", fileNames);
final IOtpRpc b = backend.getOtpRpc();
final RpcFuture future = ErlideDialyze.dialyze(b, files, pltPaths, includeDirs, fromSource, noCheckPLT);
while (!future.isDone()) {
// check cancellation
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
// check backend down
if (!backend.isRunning()) {
throw new BackendException("Dialyzer: backend " + backend.getName() + " is down");
}
OtpErlangObject r = null;
try {
r = future.checkedGet(500, TimeUnit.MILLISECONDS);
} catch (final TimeoutException e) {
} catch (final RpcTimeoutException e) {
}
if (r != null) {
DialyzerUtils.processResult(b, r);
}
}
} catch (final RpcException e) {
throw new InvocationTargetException(e);
} catch (final BackendException e) {
throw new InvocationTargetException(e);
}
}
use of org.erlide.runtime.rpc.RpcTimeoutException in project erlide_eclipse by erlang.
the class OtpRpc method getRpcResult.
/**
* Retrieve the result of a RPC.
*
* @param mbox
* @param timeout
* @param env
* @return
* @throws RpcException
*/
@Override
public OtpErlangObject getRpcResult(final OtpMbox mbox, final long timeout, final String env) throws RpcException {
assert mbox != null;
OtpErlangObject res = null;
try {
try {
if (timeout == OtpRpc.INFINITY) {
res = mbox.receive();
} else {
res = mbox.receive(timeout);
}
if (OtpRpc.CHECK_RPC) {
ErlLogger.debug("RPC " + mbox.hashCode() + "<= " + res);
}
} finally {
if (res != null) {
mbox.close();
}
}
if (res == null) {
final String msg = env != null ? env : "??";
throw new RpcTimeoutException(msg);
}
if (!(res instanceof OtpErlangTuple)) {
throw new RpcException(res.toString());
}
final OtpErlangTuple t = (OtpErlangTuple) res;
if (t.arity() != 2) {
throw new RpcException(res.toString());
}
res = t.elementAt(1);
} catch (final OtpErlangExit e) {
throw new RpcException(e);
} catch (final OtpErlangDecodeException e) {
throw new RpcException(e);
}
return res;
}
use of org.erlide.runtime.rpc.RpcTimeoutException in project erlide_eclipse by erlang.
the class OtpRpc method call.
@Override
public OtpErlangObject call(final long timeout, final OtpErlangObject gleader, final String module, final String fun, final String signature, final Object... args0) throws RpcException {
checkConnected();
OtpErlangObject result = null;
try {
final RpcFuture future = sendRpcCall(localNode, nodeName, false, gleader, module, fun, signature, args0);
result = future.checkedGet(timeout, TimeUnit.MILLISECONDS);
if (OtpRpc.CHECK_RPC) {
ErlLogger.debug("RPC result:: " + result);
}
if (isBadRpc(result)) {
throw new RpcException("Bad RPC: " + result);
}
} catch (final SignatureException e) {
throw new RpcException(e);
} catch (final TimeoutException e) {
throw new RpcTimeoutException(e.getMessage());
}
return result;
}
Aggregations