<commit_before>package org.slc.sli.ingestion.model;


import java.util.Date;

import org.slc.sli.ingestion.util.BatchJobUtils;

/**
 * Model for metrics of an ingestion job with resolution into its stage and resource
 *
 * @author dduran
 *
 */
public class Metrics {

    private String resourceId;

    private String sourceIp;

    private String hostname;

    private Date startTimestamp;

    private Date stopTimestamp;

    private long recordCount;

    private long errorCount;

    // mongoTemplate requires this constructor.
    public Metrics() {
    }

    public Metrics(String resourceId, String sourceIp, String hostname) {
        this(resourceId, sourceIp, hostname, null, null, 0, 0);
    }

    public Metrics(String resourceId, String sourceIp, String hostname, Date startTimestamp, Date stopTimestamp,
            long recordCount, long errorCount) {
        super();
        this.resourceId = resourceId;
        this.sourceIp = sourceIp;
        this.hostname = hostname;
        this.startTimestamp = startTimestamp;
        this.stopTimestamp = stopTimestamp;
        this.recordCount = recordCount;
        this.errorCount = errorCount;
    }

    public static Metrics createAndStart(String resourceId) {
        Metrics metrics = new Metrics(resourceId, BatchJobUtils.getHostAddress(), BatchJobUtils.getHostName());
        metrics.setRecordCount(0);
        metrics.setErrorCount(0);
        metrics.startMetric();
        return metrics;
    }

    public String getResourceId() {
        return resourceId;
    }

    public void setResourceId(String resourceId) {
        this.resourceId = resourceId;
    }

    public String getSourceIp() {
        return sourceIp;
    }

    public void setSourceIp(String sourceIp) {
        this.sourceIp = sourceIp;
    }

    public String getHostname() {
        return hostname;
    }

    public void setHostname(String hostname) {
        this.hostname = hostname;
    }

    public Date getStartTimestamp() {
        return startTimestamp;
    }

    public void setStartTimestamp(Date startTimestamp) {
        this.startTimestamp = startTimestamp;
    }

    public Date getStopTimestamp() {
        return stopTimestamp;
    }

    public void setStopTimestamp(Date stopTimestamp) {
        this.stopTimestamp = stopTimestamp;
    }

    public long getRecordCount() {
        return recordCount;
    }

    public void setRecordCount(long recordCount) {
        this.recordCount = recordCount;
    }

    public long getErrorCount() {
        return errorCount;
    }

    public void setErrorCount(long errorCount) {
        this.errorCount = errorCount;
    }

    public void update(String resourceId, String sourceIp, String hostname, Date startTimestamp,
            Date stopTimestamp, long recordCount, long errorCount) {
        if (resourceId != null) {
            this.resourceId = resourceId;
        }
        if (sourceIp != null) {
            this.sourceIp = sourceIp;
        }
        if (hostname != null) {
            this.hostname = hostname;
        }
        if (startTimestamp != null) {
            this.startTimestamp = startTimestamp;
        }
        if (stopTimestamp != null) {
            this.stopTimestamp = stopTimestamp;
        }
        this.recordCount = recordCount;
        this.errorCount = errorCount;
    }

    public void startMetric() {
        this.setStartTimestamp(BatchJobUtils.getCurrentTimeStamp());
    }

    public void stopMetric() {
        this.setStopTimestamp(BatchJobUtils.getCurrentTimeStamp());
    }
}<commit_msg>Added elapsed time to Metrics<commit_after>package org.slc.sli.ingestion.model;

import java.util.Date;

import org.slc.sli.ingestion.util.BatchJobUtils;

/**
 * Model for metrics of an ingestion job with resolution into its stage and resource
 *
 * @author dduran
 *
 */
public class Metrics {

    private String resourceId;

    private String sourceIp;

    private String hostname;

    private Date startTimestamp;

    private Date stopTimestamp;

    private long recordCount;

    private long errorCount;

    /** The elapsed time, in miliseconds. */
    private long elapsedTime;

    // mongoTemplate requires this constructor.
    public Metrics() {
    }

    public Metrics(String resourceId, String sourceIp, String hostname) {
        this(resourceId, sourceIp, hostname, null, null, 0, 0);
    }

    public Metrics(String resourceId, String sourceIp, String hostname, Date startTimestamp, Date stopTimestamp,
            long recordCount, long errorCount) {
        super();
        this.resourceId = resourceId;
        this.sourceIp = sourceIp;
        this.hostname = hostname;
        this.startTimestamp = startTimestamp;
        this.stopTimestamp = stopTimestamp;
        this.recordCount = recordCount;
        this.errorCount = errorCount;
        calcElapsedTime();
    }

    public static Metrics createAndStart(String resourceId) {
        Metrics metrics = new Metrics(resourceId, BatchJobUtils.getHostAddress(), BatchJobUtils.getHostName());
        metrics.setRecordCount(0);
        metrics.setErrorCount(0);
        metrics.startMetric();
        return metrics;
    }

    public String getResourceId() {
        return resourceId;
    }

    public void setResourceId(String resourceId) {
        this.resourceId = resourceId;
    }

    public String getSourceIp() {
        return sourceIp;
    }

    public void setSourceIp(String sourceIp) {
        this.sourceIp = sourceIp;
    }

    public String getHostname() {
        return hostname;
    }

    public void setHostname(String hostname) {
        this.hostname = hostname;
    }

    public Date getStartTimestamp() {
        return startTimestamp;
    }

    public void setStartTimestamp(Date startTimestamp) {
        this.startTimestamp = startTimestamp;
    }

    public Date getStopTimestamp() {
        return stopTimestamp;
    }

    public void setStopTimestamp(Date stopTimestamp) {
        this.stopTimestamp = stopTimestamp;
    }

    public long getRecordCount() {
        return recordCount;
    }

    public void setRecordCount(long recordCount) {
        this.recordCount = recordCount;
    }

    public long getErrorCount() {
        return errorCount;
    }

    public void setErrorCount(long errorCount) {
        this.errorCount = errorCount;
    }

    public void update(String resourceId, String sourceIp, String hostname, Date startTimestamp, Date stopTimestamp,
            long recordCount, long errorCount) {
        if (resourceId != null) {
            this.resourceId = resourceId;
        }
        if (sourceIp != null) {
            this.sourceIp = sourceIp;
        }
        if (hostname != null) {
            this.hostname = hostname;
        }
        if (startTimestamp != null) {
            this.startTimestamp = startTimestamp;
        }
        if (stopTimestamp != null) {
            this.stopTimestamp = stopTimestamp;
        }
        this.recordCount = recordCount;
        this.errorCount = errorCount;
        calcElapsedTime();
    }

    public void startMetric() {
        this.setStartTimestamp(BatchJobUtils.getCurrentTimeStamp());
    }

    public void stopMetric() {
        this.setStopTimestamp(BatchJobUtils.getCurrentTimeStamp());
        calcElapsedTime();
    }

    public long getElapsedTime() {
        return elapsedTime;
    }

    private void calcElapsedTime() {
        elapsedTime = stopTimestamp.getTime() - startTimestamp.getTime();
    }
}
{'fraction_non_alphanumeric': 0.08161902217472615, 'fraction_numerical': 0.0010686615014694097, 'mean_word_length': 2.4486411791801013, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4559155', 'n_tokens_mistral': 2041, 'n_tokens_neox': 1969, 'n_words': 510}