001package org.kuali.ole.docstore.utility;
002
003import org.kuali.ole.utility.DateTimeUtil;
004
005/**
006 * Created by IntelliJ IDEA.
007 * User: Pranitha
008 * Date: 6/11/12
009 * Time: 12:24 PM
010 * To change this template use File | Settings | File Templates.
011 */
012public class BatchIngestStatistics {
013    public static String mertixHeading = null;
014
015    public long timeToConvertStringToReqObj;
016    public long timeToCreateNodesInJcr;
017    public long timeToSaveJcrSession;
018    public long ingestingTime;
019    public long timeToConvertXmlToPojo;
020    public long timeToConvertToSolrInputDocs;
021    public long timeToIndexSolrInputDocs;
022    public long timeToSolrCommit;
023    public long timeToSolrOptimize;
024    public long indexingTime;
025    public long ingestNIndexTotalTime;
026    public long batchTime;
027    public String batchStartTime;
028    public String batchEndTime;
029    public long commitSize;
030    public long recCount;
031
032
033    static {
034        mertixHeading = "\"Batch Start Time\" \t" + "\"Time To Convert String To ReqObj\" \t"
035                + "\"Time To Create Nodes In Jcr\"\t" + "\"Time To Save Jcr Session\"\t" + "\"ingesting Time\"\t"
036                + "\"Time To Convert Xml To Pojo\"\t" + "\"Time To Convert To Solr InputDocs\"\t"
037                + "\"Time To Index Solr InputDocs\"\t" + "\"Time To Solr Commit\"\t" + "\"Indexing Time\"\t"
038                + "\"Ingest N Index TotalTime\"\t" + "\"Batch Time\"\t" + "\"Batch End Time\" \t"
039                + "\"Solr Optimize Time\"";
040    }
041
042    public long getTimeToConvertStringToReqObj() {
043        return timeToConvertStringToReqObj;
044    }
045
046    public void setTimeToConvertStringToReqObj(long timeToConvertStringToReqObj) {
047        this.timeToConvertStringToReqObj = timeToConvertStringToReqObj;
048    }
049
050    public long getTimeToCreateNodesInJcr() {
051        return timeToCreateNodesInJcr;
052    }
053
054    public void setTimeToCreateNodesInJcr(long timeToCreateNodesInJcr) {
055        this.timeToCreateNodesInJcr = timeToCreateNodesInJcr;
056    }
057
058    public long getTimeToSaveJcrSession() {
059        return timeToSaveJcrSession;
060    }
061
062    public void setTimeToSaveJcrSession(long timeToSaveJcrSession) {
063        this.timeToSaveJcrSession = timeToSaveJcrSession;
064    }
065
066    public long getIngestingTime() {
067        return ingestingTime;
068    }
069
070    public void setIngestingTime(long ingestingTime) {
071        this.ingestingTime = ingestingTime;
072    }
073
074    public long getTimeToConvertXmlToPojo() {
075        return timeToConvertXmlToPojo;
076    }
077
078    public void setTimeToConvertXmlToPojo(long timeToConvertXmlToPojo) {
079        this.timeToConvertXmlToPojo = timeToConvertXmlToPojo;
080    }
081
082    public long getTimeToConvertToSolrInputDocs() {
083        return timeToConvertToSolrInputDocs;
084    }
085
086    public void setTimeToConvertToSolrInputDocs(long timeToConvertToSolrInputDocs) {
087        this.timeToConvertToSolrInputDocs = timeToConvertToSolrInputDocs;
088    }
089
090    public long getTimeToIndexSolrInputDocs() {
091        return timeToIndexSolrInputDocs;
092    }
093
094    public void setTimeToIndexSolrInputDocs(long timeToIndexSolrInputDocs) {
095        this.timeToIndexSolrInputDocs = timeToIndexSolrInputDocs;
096    }
097
098    public long getTimeToSolrCommit() {
099        return timeToSolrCommit;
100    }
101
102    public void setTimeToSolrCommit(long timeToSolrCommit) {
103        this.timeToSolrCommit = timeToSolrCommit;
104    }
105
106    public long getTimeToSolrOptimize() {
107        return timeToSolrOptimize;
108    }
109
110    public void setTimeToSolrOptimize(long timeToSolrOptimize) {
111        this.timeToSolrOptimize = timeToSolrOptimize;
112    }
113
114    public long getIndexingTime() {
115        return indexingTime;
116    }
117
118    public void setIndexingTime(long indexingTime) {
119        this.indexingTime = indexingTime;
120    }
121
122    public long getIngestNIndexTotalTime() {
123        return ingestNIndexTotalTime;
124    }
125
126    public void setIngestNIndexTotalTime(long ingestNIndexTotalTime) {
127        this.ingestNIndexTotalTime = ingestNIndexTotalTime;
128    }
129
130    public long getBatchTime() {
131        return batchTime;
132    }
133
134    public void setBatchTime(long batchTime) {
135        this.batchTime = batchTime;
136    }
137
138    public String getBatchStartTime() {
139        return batchStartTime;
140    }
141
142    public void setBatchStartTime(String batchStartTime) {
143        this.batchStartTime = batchStartTime;
144    }
145
146    public String getBatchEndTime() {
147        return batchEndTime;
148    }
149
150    public void setBatchEndTime(String batchEndTime) {
151        this.batchEndTime = batchEndTime;
152    }
153
154    public long getCommitSize() {
155        return commitSize;
156    }
157
158    public void setCommitSize(long commitSize) {
159        this.commitSize = commitSize;
160    }
161
162    public long getRecCount() {
163        return recCount;
164    }
165
166    public void setRecCount(long recCount) {
167        this.recCount = recCount;
168    }
169
170    @Override
171    public String toString() {
172        StringBuilder sb = new StringBuilder();
173        sb.append(mertixHeading);
174        BatchIngestStatistics bS = BulkIngestStatistics.getInstance().getCurrentBatch();
175        buildBatchMetric(sb, bS);
176
177        return sb.toString();
178    }
179
180    public void buildBatchMetric(StringBuilder sb, BatchIngestStatistics bS) {
181        sb.append("\n");
182        sb.append(bS.getBatchStartTime());
183        sb.append("\t");
184        sb.append(DateTimeUtil.formatTime(bS.getTimeToConvertStringToReqObj()));
185        sb.append("\t");
186        sb.append(DateTimeUtil.formatTime(bS.getTimeToCreateNodesInJcr()));
187        sb.append("\t");
188        sb.append(DateTimeUtil.formatTime(bS.getTimeToSaveJcrSession()));
189        sb.append("\t");
190        sb.append(DateTimeUtil.formatTime(bS.getIngestingTime()));
191        sb.append("\t");
192        sb.append(DateTimeUtil.formatTime(bS.getTimeToConvertXmlToPojo()));
193        sb.append("\t");
194        sb.append(DateTimeUtil.formatTime(bS.getTimeToConvertToSolrInputDocs()));
195        sb.append("\t");
196        sb.append(DateTimeUtil.formatTime(bS.getTimeToIndexSolrInputDocs()));
197        sb.append("\t");
198        sb.append(DateTimeUtil.formatTime(bS.getTimeToSolrCommit()));
199        sb.append("\t");
200        sb.append(DateTimeUtil.formatTime(bS.getIndexingTime()));
201        sb.append("\t");
202        sb.append(DateTimeUtil.formatTime(bS.getIngestNIndexTotalTime()));
203        sb.append("\t");
204        sb.append(DateTimeUtil.formatTime(bS.getBatchTime()));
205        sb.append("\t");
206        sb.append(bS.getBatchEndTime());
207        sb.append("\t");
208        sb.append(DateTimeUtil.formatTime(bS.getTimeToSolrOptimize()));
209        sb.append("\t");
210    }
211
212
213}