Github user justinleet commented on a diff in the pull request:

    https://github.com/apache/metron/pull/958#discussion_r173928769
  
    --- Diff: 
metron-contrib/metron-performance/src/main/java/org/apache/metron/performance/load/monitor/writers/Writer.java
 ---
    @@ -0,0 +1,91 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.metron.performance.load.monitor.writers;
    +
    +import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
    +import org.apache.metron.performance.load.monitor.AbstractMonitor;
    +import org.apache.metron.performance.load.monitor.Results;
    +
    +import java.util.ArrayList;
    +import java.util.Date;
    +import java.util.LinkedList;
    +import java.util.List;
    +import java.util.Optional;
    +import java.util.function.Consumer;
    +
    +public class Writer {
    +
    +  private int summaryLookback;
    +  private List<LinkedList<Double>> summaries = new ArrayList<>();
    +  private List<Consumer<Writable>> writers;
    +  private List<AbstractMonitor> monitors;
    +
    +  public Writer(List<AbstractMonitor> monitors, int summaryLookback, 
List<Consumer<Writable>> writers) {
    +    this.summaryLookback = summaryLookback;
    +    this.writers = writers;
    +    this.monitors = monitors;
    +    for(AbstractMonitor m : monitors) {
    +      this.summaries.add(new LinkedList<>());
    +    }
    +  }
    +
    +  public void writeAll() {
    +    int i = 0;
    +    Date dateOf = new Date();
    +    List<Results> results = new ArrayList<>();
    +    for(AbstractMonitor m : monitors) {
    +      Long eps = m.get();
    +      if(eps != null) {
    +        if (summaryLookback > 0) {
    +          LinkedList<Double> summary = summaries.get(i);
    +          addToLookback(eps == null ? Double.NaN : eps.doubleValue(), 
summary);
    --- End diff --
    
    eps is never null here, so this can be just 
`addToLookback(eps.doubleValue(), summary);`


---

Reply via email to