/**
   * If CloseGuard is enabled, logs a warning if the caller did not properly cleanup by calling an
   * explicit close method before finalization. If CloseGuard is disable, no action is performed.
   */
  public void warnIfOpen() {
    if (allocationSite == null || !ENABLED) {
      return;
    }

    String message =
        ("A resource was acquired at attached stack trace but never released. "
            + "See java.io.Closeable for information on avoiding resource leaks.");

    REPORTER.report(message, allocationSite);
  }
Exemple #2
0
  public static void main(String[] args) {

    InputSignal s1 = new InputSignal();
    Reporter rep = new LineReporter();
    Reporter rep2 = new LineReporter();
    rep.init();
    rep2.init();

    Neuron n1 = new Neuron();
    Neuron n2 = new Neuron();
    Neuron n3 = new Neuron();
    Neuron n4 = new Neuron();

    n3.attachReporter(rep2);
    n4.attachReporter(rep);

    Link l1 = new Link(s1, n1, 1.0);
    Link l2 = new Link(s1, n2, 1.0);
    Link l3 = new Link(n2, n3, 1.0);
    Link l4 = new Link(n1, n4, 1.0);
    Link l5 = new Link(n3, n4, -1.0);

    Sequence s = new Sequence();

    s.addElement(n4);
    s.addElement(l5);
    s.addElement(l4);
    s.addElement(n3);
    s.addElement(l3);
    s.addElement(n2);
    s.addElement(n1);
    s.addElement(l2);
    s.addElement(l1);
    s.addElement(s1);

    for (int i = 0; i < 100; i++) {
      s.cycle();
    }
    rep.report();
    rep2.report();
  }
  public void report() {
    SortedMap<String, Counter> counterMap = metricRegistry.getCounters();
    SortedMap<String, Histogram> histogramMap = metricRegistry.getHistograms();
    SortedMap<String, Execution> executionMap = metricRegistry.getExecutions();

    Map<String, CounterMetric> counterMetricMap = new LinkedHashMap<String, CounterMetric>();
    for (Entry<String, Counter> entry : counterMap.entrySet()) {
      counterMetricMap.put(entry.getKey(), entry.getValue().calculateMetric());
    }

    Map<String, HistogramMetric> histogramMetricMap = new LinkedHashMap<String, HistogramMetric>();
    for (Entry<String, Histogram> entry : histogramMap.entrySet()) {
      histogramMetricMap.put(entry.getKey(), entry.getValue().calculateMetric());
    }

    Map<String, ExecutionMetric> executionMetricMap = new LinkedHashMap<String, ExecutionMetric>();
    for (Entry<String, Execution> entry : executionMap.entrySet()) {
      executionMetricMap.put(entry.getKey(), entry.getValue().calculateMetric());
    }

    for (Reporter reporter : reporters) {
      reporter.report(counterMetricMap, histogramMetricMap, executionMetricMap);
    }
  }
 public void broadcastElectionsNews() {
   for (Reporter reporter : reporters) {
     reporter.report();
   }
 }
Exemple #5
0
 // use only with Contexts created directly by other Contexts
 // (no intervening Job);
 // caller should call reporter.checkAgentClass() or
 // reporter.checkAgentSetClass() beforehand
 public Object evaluateReporter(Agent agent, Reporter reporter) {
   this.agent = agent;
   return reporter.report(this);
 }