Example #1
0
 /**
  * Returns true if the StatusManager associated with the context passed as parameter has one or
  * more StatusListener instances registered. Returns false otherwise.
  *
  * @param context
  * @return true if one or more StatusListeners registered, false otherwise
  * @since 1.0.8
  */
 public static boolean contextHasStatusListener(Context context) {
   StatusManager sm = context.getStatusManager();
   if (sm == null) return false;
   List<StatusListener> listeners = sm.getCopyOfStatusListenerList();
   if (listeners == null || listeners.size() == 0) return false;
   else return true;
 }
Example #2
0
 public static void addStatus(Context context, Status status) {
   if (context == null) {
     return;
   }
   StatusManager sm = context.getStatusManager();
   if (sm != null) {
     sm.add(status);
   }
 }
 /** Print status messages retrospectively */
 private void retrospectivePrint() {
   if (context == null) return;
   long now = System.currentTimeMillis();
   StatusManager sm = context.getStatusManager();
   List<Status> statusList = sm.getCopyOfStatusList();
   for (Status status : statusList) {
     long timestamp = status.getDate();
     if (now - timestamp < retrospective) {
       print(status);
     }
   }
 }
Example #4
0
  @Test
  public void testCheckup() throws IOException {
    MockClock clk = new MockClock(0);
    Clock.setClock(clk);
    StatusManager stats = new StatusManager();

    // foo is in state HELLO and has configuration numbered 0
    long prev = Clock.unixTime();
    boolean needsRefresh =
        stats.updateHeartbeatStatus(NetUtils.localhost(), "physnode", "foo", NodeState.HELLO, 0);
    LOG.info(stats.getNodeStatuses());
    assertTrue(needsRefresh);

    // move forward in time, but not far enough to trigger being lost
    clk.forward(FlumeConfiguration.get().getConfigHeartbeatPeriod() * 5);
    stats.checkup();
    StatusManager.NodeStatus ns = stats.getNodeStatuses().get("foo");
    assertEquals(0, ns.version);
    assertTrue(prev <= ns.lastseen);
    assertEquals(NodeState.HELLO, ns.state);
    prev = ns.lastseen;

    clk.forward(FlumeConfiguration.get().getConfigHeartbeatPeriod() * 20);
    stats.checkup();
    ns = stats.getNodeStatuses().get("foo");
    assertEquals(0, ns.version);
    assertTrue(prev <= ns.lastseen);
    assertEquals(NodeState.LOST, ns.state);
    prev = ns.lastseen;

    LOG.info(ns.toString());
    LOG.info(stats.getStatus("foo").toString());
  }
Example #5
0
  /** Opens the given editor on the selected file revision. */
  protected void openEditor(IEditorDescriptor editorDescriptor, boolean openUsingDescriptor) {
    IFileRevision fileRevision = getFileRevision();
    if (fileRevision == null) {
      return;
    }
    try {
      IProgressMonitor monitor = new NullProgressMonitor();
      IStorage storage = fileRevision.getStorage(monitor);
      boolean isFile = storage instanceof IFile;

      if (openUsingDescriptor) {
        // discouraged access to open system editors
        ((WorkbenchPage) (page.getSite().getPage()))
            .openEditorFromDescriptor(
                isFile
                    ? new FileEditorInput((IFile) storage)
                    : (IEditorInput)
                        FileRevisionEditorInput.createEditorInputFor(fileRevision, monitor),
                editorDescriptor,
                true,
                null);
      } else {
        String editorId =
            editorDescriptor == null
                ? IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID
                : editorDescriptor.getId();
        page.getSite()
            .getPage()
            .openEditor(
                isFile
                    ? new FileEditorInput((IFile) storage)
                    : (IEditorInput)
                        FileRevisionEditorInput.createEditorInputFor(fileRevision, monitor),
                editorId,
                true,
                MATCH_BOTH);
      }
    } catch (PartInitException e) {
      StatusAdapter statusAdapter = new StatusAdapter(e.getStatus());
      statusAdapter.setProperty(
          IStatusAdapterConstants.TITLE_PROPERTY, TeamUIMessages.LocalHistoryPage_OpenEditorError);
      StatusManager.getManager().handle(statusAdapter, StatusManager.SHOW);
    } catch (CoreException e) {
      StatusAdapter statusAdapter = new StatusAdapter(e.getStatus());
      statusAdapter.setProperty(
          IStatusAdapterConstants.TITLE_PROPERTY, TeamUIMessages.LocalHistoryPage_OpenEditorError);
      StatusManager.getManager().handle(statusAdapter, StatusManager.LOG);
    }
  }
Example #6
0
 public int getHighestLevel(long threshold) {
   List<Status> filteredList =
       filterStatusListByTimeThreshold(sm.getCopyOfStatusList(), threshold);
   int maxLevel = Status.INFO;
   for (Status s : filteredList) {
     if (s.getLevel() > maxLevel) maxLevel = s.getLevel();
   }
   return maxLevel;
 }
Example #7
0
 public boolean containsMatch(String regex) {
   Pattern p = Pattern.compile(regex);
   for (Status status : sm.getCopyOfStatusList()) {
     String msg = status.getMessage();
     Matcher matcher = p.matcher(msg);
     if (matcher.lookingAt()) {
       return true;
     }
   }
   return false;
 }
Example #8
0
 public boolean containsException(Class exceptionType) {
   Iterator stati = sm.getCopyOfStatusList().iterator();
   while (stati.hasNext()) {
     Status status = (Status) stati.next();
     Throwable t = status.getThrowable();
     if (t != null && t.getClass().getName().equals(exceptionType.getName())) {
       return true;
     }
   }
   return false;
 }
Example #9
0
 public int matchCount(String regex) {
   int count = 0;
   Pattern p = Pattern.compile(regex);
   for (Status status : sm.getCopyOfStatusList()) {
     String msg = status.getMessage();
     Matcher matcher = p.matcher(msg);
     if (matcher.lookingAt()) {
       count++;
     }
   }
   return count;
 }
Example #10
0
 public void b(Boolean boolean1) {
   if (b == null) {
     return;
   }
   StatusManager.j().a(c);
   if (c != null) {
     b.a(c);
     return;
   } else {
     b.b(null);
     return;
   }
 }
Example #11
0
  /**
   * Return the time of last reset. -1 if last reset time could not be found
   *
   * @return time of last reset or -1
   */
  public long timeOfLastReset() {
    List<Status> statusList = sm.getCopyOfStatusList();
    if (statusList == null) return -1;

    int len = statusList.size();
    for (int i = len - 1; i >= 0; i--) {
      Status s = statusList.get(i);
      if (CoreConstants.RESET_MSG_PREFIX.equals(s.getMessage())) {
        return s.getDate();
      }
    }
    return -1;
  }
Example #12
0
  public boolean containsMatch(long threshold, int level, String regex) {
    List<Status> filteredList =
        filterStatusListByTimeThreshold(sm.getCopyOfStatusList(), threshold);
    Pattern p = Pattern.compile(regex);

    for (Status status : filteredList) {
      if (level != status.getLevel()) {
        continue;
      }
      String msg = status.getMessage();
      Matcher matcher = p.matcher(msg);
      if (matcher.lookingAt()) {
        return true;
      }
    }
    return false;
  }
Example #13
0
    public void run()
    {
        int i = 0;
        StatusManager statusmanager = a;
        statusmanager;
        JVM INSTR monitorenter ;
        aa aaa[];
        int j;
        aaa = (aa[])StatusManager.v(a).toArray(new aa[0]);
        j = aaa.length;
_L2:
        if (i >= j)
        {
            break; /* Loop/switch isn't completed */
        }
        aaa[i].a();
        i++;
        if (true) goto _L2; else goto _L1
Example #14
0
  @Test
  public void testStatusManagerHeartbeats() throws IOException {
    StatusManager stats = new StatusManager();

    FlumeConfiguration cfg = FlumeConfiguration.createTestableConfiguration();
    Clock.resetDefault();
    cfg.set(FlumeConfiguration.WEBAPPS_PATH, "build/webapps");
    cfg.set(FlumeConfiguration.MASTER_STORE, "memory");

    // avoiding gossip ack manager until it shuts down cleanly.
    ConfigStore cfgStore = FlumeMaster.createConfigStore(cfg);
    FlumeMaster fm =
        new FlumeMaster(
            new CommandManager(), new ConfigManager(cfgStore), stats, new MasterAckManager(), cfg);

    fm.getSpecMan().addLogicalNode("physnode", "foo");

    // foo is in state HELLO and has configuration numbered 0
    long prev = Clock.unixTime();
    boolean needsRefresh =
        stats.updateHeartbeatStatus(NetUtils.localhost(), "physnode", "foo", NodeState.HELLO, 0);
    LOG.info(stats.getNodeStatuses());
    assertTrue(needsRefresh);

    StatusManager.NodeStatus ns = stats.getNodeStatuses().get("foo");
    assertEquals(0, ns.version);
    assertTrue(prev <= ns.lastseen);
    assertEquals(NodeState.HELLO, ns.state);
    prev = ns.lastseen;

    needsRefresh =
        stats.updateHeartbeatStatus(NetUtils.localhost(), "physnode", "foo", NodeState.IDLE, 0);
    LOG.info(stats.getNodeStatuses());
    assertFalse(needsRefresh); // no new data flow version
    assertEquals(0, ns.version);
    assertTrue(prev <= ns.lastseen);
    assertEquals(NodeState.IDLE, ns.state);
    prev = ns.lastseen;

    needsRefresh =
        stats.updateHeartbeatStatus(NetUtils.localhost(), "physnode", "foo", NodeState.ACTIVE, 10);
    LOG.info(stats.getNodeStatuses());
    assertFalse(needsRefresh); // node has updated version number, but master
    // has not
    assertEquals(10, ns.version);
    assertTrue(prev <= ns.lastseen);
    assertEquals(NodeState.ACTIVE, ns.state);
    prev = ns.lastseen;

    // same message, no refresh
    needsRefresh =
        stats.updateHeartbeatStatus(NetUtils.localhost(), "physnode", "foo", NodeState.ACTIVE, 10);
    LOG.info(stats.getNodeStatuses());
    assertFalse(needsRefresh); // this is wierd, is this right?
    assertEquals(10, ns.version);
    assertTrue(prev <= ns.lastseen);
    assertEquals(NodeState.ACTIVE, ns.state);
    prev = ns.lastseen;

    // regress to an older version,
    needsRefresh =
        stats.updateHeartbeatStatus(NetUtils.localhost(), "physnode", "foo", NodeState.ACTIVE, 5);
    LOG.info(stats.getNodeStatuses());
    assertFalse(needsRefresh);
    assertEquals(5, ns.version);
    assertTrue(prev <= ns.lastseen);
    assertEquals(NodeState.ACTIVE, ns.state);
    prev = ns.lastseen;

    LOG.info(stats.getReport());
    LOG.info(stats.getName());
  }
Example #15
0
 /**
  * Return a list of the names of any nodes that have been seen. Used by the web interface to
  * populate choice inputs.
  */
 public Set<String> getKnownNodes() {
   return statman.getNodeStatuses().keySet();
 }
Example #16
0
 /** Generates html 1.0 data that displays the configuration status of the flume system. */
 public void reportHtml(Writer o) throws IOException {
   statman.getMetrics().toHtml(o);
   specman.getMetrics().toHtml(o);
   cmdman.getMetrics().toHtml(o);
 }