Example #1
0
 private boolean waitForCodeServer() {
   try {
     OtpErlangObject r;
     int i = 30;
     boolean gotIt = false;
     do {
       r = call("erlang", "whereis", "a", "code_server");
       gotIt = !(r instanceof OtpErlangPid);
       if (!gotIt) {
         try {
           Thread.sleep(200);
         } catch (final InterruptedException e) {
         }
       }
       i--;
     } while (gotIt && i > 0);
     if (gotIt) {
       ErlLogger.error("code server did not start in time for %s", getNodeName());
       return false;
     }
     ErlLogger.debug("code server started");
     return true;
   } catch (final Exception e) {
     ErlLogger.error("error starting code server for %s: %s", getNodeName(), e.getMessage());
     return false;
   }
 }
Example #2
0
 private void wait_for_epmd(final String host) throws BackendException {
   // If anyone has a better solution for waiting for epmd to be up, please
   // let me know
   int tries = 50;
   boolean ok = false;
   do {
     Socket s;
     try {
       s = new Socket(host, EPMD_PORT);
       s.close();
       ok = true;
     } catch (final IOException e) {
     }
     try {
       Thread.sleep(100);
       // ErlLogger.debug("sleep............");
     } catch (final InterruptedException e1) {
     }
     tries--;
   } while (!ok && tries > 0);
   if (!ok) {
     final String msg =
         "Couldn't contact epmd - erlang backend is probably not working\n"
             + "  Possibly your host's entry in /etc/hosts is wrong ("
             + host
             + ").";
     ErlLogger.error(msg);
     throw new BackendException(msg);
   }
 }
Example #3
0
 private List<IProject> gatherProjects(final String[] projectNames) {
   final List<IProject> myProjects = Lists.newArrayList();
   for (final String s : projectNames) {
     final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(s);
     if (project == null) {
       ErlLogger.error("Launch: project not found: '%s'!", s);
       continue;
     }
     myProjects.add(project);
   }
   return myProjects;
 }
Example #4
0
  @Override
  public void connect() {
    final String label = getNodeName();
    ErlLogger.debug(label + ": waiting connection to peer...");
    try {
      wait_for_epmd();
      eventBox = createMbox("rex");

      if (waitForCodeServer()) {
        ErlLogger.debug("connected!");
      } else {
        ErlLogger.error(COULD_NOT_CONNECT_TO_BACKEND);
      }

    } catch (final BackendException e) {
      ErlLogger.error(e);
      ErlLogger.error(COULD_NOT_CONNECT_TO_BACKEND);
    } catch (final Exception e) {
      ErlLogger.error(e);
      ErlLogger.error(COULD_NOT_CONNECT_TO_BACKEND);
    }
  }
Example #5
0
 private void fillProcessesList(final TableViewer tableViewer) {
   final IProgressService ps = PlatformUI.getWorkbench().getProgressService();
   try {
     ps.busyCursorWhile(
         new IRunnableWithProgress() {
           @Override
           public void run(final IProgressMonitor pm) {
             final TracedProcess[] processesList = ProcessHelper.getProcsOnTracedNodes();
             TraceBackend.getInstance().setProcesses(processesList);
           }
         });
   } catch (final Exception e) {
     ErlLogger.error(e);
   }
 }
Example #6
0
 @Override
 public Object execute(final ExecutionEvent event) throws ExecutionException {
   // final Command command = event.getCommand();
   // final boolean oldValue = HandlerUtil.toggleCommandState(command);
   final String filterId = event.getParameter("org.erlide.ui.filterId");
   final IEclipsePreferences prefsNode = ErlangOutlinePage.getPrefsNode();
   final boolean oldValue = prefsNode.getBoolean(filterId, false);
   final boolean value = !oldValue;
   final Object activePart = HandlerUtil.getVariable(event, "activePart");
   if (activePart instanceof ContentOutline) {
     OutlineFilterUtils.addFilter(filterId, value, activePart);
   }
   prefsNode.putBoolean(filterId, value);
   try {
     prefsNode.flush();
   } catch (final BackingStoreException e) {
     ErlLogger.error(e);
   }
   return null;
 }
Example #7
0
 public void startLocalNode() {
   boolean nodeCreated = false;
   synchronized (localNodeLock) {
     int i = 0;
     do {
       try {
         i++;
         localNode = ErlRuntime.createOtpNode(data.getCookie(), data.hasLongName());
         localNode.registerStatusHandler(statusWatcher);
         nodeCreated = true;
       } catch (final IOException e) {
         ErlLogger.error("ErlRuntime could not be created (%s), retrying %d", e.getMessage(), i);
         try {
           localNodeLock.wait(300);
         } catch (final InterruptedException e1) {
         }
       }
     } while (!nodeCreated && i < 10);
   }
 }
Example #8
0
 /** Method called when stopping tracing. */
 private void doStopTracing() {
   task =
       new RunnableWithProgress("Loading trace results...") {
         @Override
         public void doAction() {
           TraceBackend.getInstance().stop();
         }
       };
   try {
     final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
     new ProgressMonitorDialog(shell).run(true, false, task);
     startStopAction.setImageDescriptor(
         DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_ACT_RUN));
     startStopAction.setToolTipText(START_LABEL);
     startStopAction.setEnabled(true);
     TracingStatusHandler.handleStatus(status);
   } catch (final Exception e) {
     ErlLogger.error(e);
   } finally {
     task = null;
   }
 }
 public static String loadPreviewContentFromFile(final Class<?> clazz, final String filename) {
   String line;
   final String separator = System.getProperty("line.separator"); // $NON-NLS-1$
   final StringBuilder buffer = new StringBuilder(512);
   BufferedReader reader = null;
   try {
     reader = new BufferedReader(new InputStreamReader(clazz.getResourceAsStream(filename)));
     while ((line = reader.readLine()) != null) {
       buffer.append(line);
       buffer.append(separator);
     }
   } catch (final IOException io) {
     ErlLogger.error(io);
   } finally {
     if (reader != null) {
       try {
         reader.close();
       } catch (final IOException e) {
       }
     }
   }
   return buffer.toString();
 }
 @Override
 public void reconcile(final IRegion partition) {
   ErlLogger.error("reconcile called");
 }
 @Override
 public void reconcile(final DirtyRegion dirtyRegion, final IRegion subRegion) {
   ErlLogger.error("reconcile called");
 }