001    package org.kuali.ole.docstore.utility;
002    
003    import 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     */
012    public 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    
030    
031        static{
032            mertixHeading = "\"Batch Start Time\" \t" + "\"Time To Convert String To ReqObj\" \t"
033                       + "\"Time To Create Nodes In Jcr\"\t" + "\"Time To Save Jcr Session\"\t" + "\"ingesting Time\"\t"
034                       + "\"Time To Convert Xml To Pojo\"\t" + "\"Time To Convert To Solr InputDocs\"\t"
035                       + "\"Time To Index Solr InputDocs\"\t" + "\"Time To Solr Commit\"\t" + "\"Indexing Time\"\t"
036                       + "\"Ingest N Index TotalTime\"\t" + "\"Batch Time\"\t" + "\"Batch End Time\" \t"
037                       + "\"Solr Optimize Time\"";
038        }
039        public long getTimeToConvertStringToReqObj() {
040            return timeToConvertStringToReqObj;
041        }
042    
043        public void setTimeToConvertStringToReqObj(long timeToConvertStringToReqObj) {
044            this.timeToConvertStringToReqObj = timeToConvertStringToReqObj;
045        }
046    
047        public long getTimeToCreateNodesInJcr() {
048            return timeToCreateNodesInJcr;
049        }
050    
051        public void setTimeToCreateNodesInJcr(long timeToCreateNodesInJcr) {
052            this.timeToCreateNodesInJcr = timeToCreateNodesInJcr;
053        }
054    
055        public long getTimeToSaveJcrSession() {
056            return timeToSaveJcrSession;
057        }
058    
059        public void setTimeToSaveJcrSession(long timeToSaveJcrSession) {
060            this.timeToSaveJcrSession = timeToSaveJcrSession;
061        }
062    
063        public long getIngestingTime() {
064            return ingestingTime;
065        }
066    
067        public void setIngestingTime(long ingestingTime) {
068            this.ingestingTime = ingestingTime;
069        }
070    
071        public long getTimeToConvertXmlToPojo() {
072            return timeToConvertXmlToPojo;
073        }
074    
075        public void setTimeToConvertXmlToPojo(long timeToConvertXmlToPojo) {
076            this.timeToConvertXmlToPojo = timeToConvertXmlToPojo;
077        }
078    
079        public long getTimeToConvertToSolrInputDocs() {
080            return timeToConvertToSolrInputDocs;
081        }
082    
083        public void setTimeToConvertToSolrInputDocs(long timeToConvertToSolrInputDocs) {
084            this.timeToConvertToSolrInputDocs = timeToConvertToSolrInputDocs;
085        }
086    
087        public long getTimeToIndexSolrInputDocs() {
088            return timeToIndexSolrInputDocs;
089        }
090    
091        public void setTimeToIndexSolrInputDocs(long timeToIndexSolrInputDocs) {
092            this.timeToIndexSolrInputDocs = timeToIndexSolrInputDocs;
093        }
094    
095        public long getTimeToSolrCommit() {
096            return timeToSolrCommit;
097        }
098    
099        public void setTimeToSolrCommit(long timeToSolrCommit) {
100            this.timeToSolrCommit = timeToSolrCommit;
101        }
102    
103        public long getTimeToSolrOptimize() {
104            return timeToSolrOptimize;
105        }
106    
107        public void setTimeToSolrOptimize(long timeToSolrOptimize) {
108            this.timeToSolrOptimize = timeToSolrOptimize;
109        }
110    
111        public long getIndexingTime() {
112            return indexingTime;
113        }
114    
115        public void setIndexingTime(long indexingTime) {
116            this.indexingTime = indexingTime;
117        }
118    
119        public long getIngestNIndexTotalTime() {
120            return ingestNIndexTotalTime;
121        }
122    
123        public void setIngestNIndexTotalTime(long ingestNIndexTotalTime) {
124            this.ingestNIndexTotalTime = ingestNIndexTotalTime;
125        }
126    
127        public long getBatchTime() {
128            return batchTime;
129        }
130    
131        public void setBatchTime(long batchTime) {
132            this.batchTime = batchTime;
133        }
134    
135        public String getBatchStartTime() {
136            return batchStartTime;
137        }
138    
139        public void setBatchStartTime(String batchStartTime) {
140            this.batchStartTime = batchStartTime;
141        }
142    
143        public String getBatchEndTime() {
144            return batchEndTime;
145        }
146    
147        public void setBatchEndTime(String batchEndTime) {
148            this.batchEndTime = batchEndTime;
149        }
150    
151        @Override
152         public String toString() {
153             StringBuilder sb = new StringBuilder();
154             sb.append(mertixHeading);
155             BatchIngestStatistics bS = BulkIngestStatistics.getInstance().getCurrentBatch();
156             buildBatchMetric(sb, bS);
157    
158             return sb.toString();
159         }
160    
161        public void buildBatchMetric(StringBuilder sb, BatchIngestStatistics bS) {
162            sb.append("\n");
163            sb.append(bS.getBatchStartTime());
164            sb.append("\t");
165            sb.append(DateTimeUtil.formatTime(bS.getTimeToConvertStringToReqObj()));
166            sb.append("\t");
167            sb.append(DateTimeUtil.formatTime(bS.getTimeToCreateNodesInJcr()));
168            sb.append("\t");
169            sb.append(DateTimeUtil.formatTime(bS.getTimeToSaveJcrSession()));
170            sb.append("\t");
171            sb.append(DateTimeUtil.formatTime(bS.getIngestingTime()));
172            sb.append("\t");
173            sb.append(DateTimeUtil.formatTime(bS.getTimeToConvertXmlToPojo()));
174            sb.append("\t");
175            sb.append(DateTimeUtil.formatTime(bS.getTimeToConvertToSolrInputDocs()));
176            sb.append("\t");
177            sb.append(DateTimeUtil.formatTime(bS.getTimeToIndexSolrInputDocs()));
178            sb.append("\t");
179            sb.append(DateTimeUtil.formatTime(bS.getTimeToSolrCommit()));
180            sb.append("\t");
181            sb.append(DateTimeUtil.formatTime(bS.getIndexingTime()));
182            sb.append("\t");
183            sb.append(DateTimeUtil.formatTime(bS.getIngestNIndexTotalTime()));
184            sb.append("\t");
185            sb.append(DateTimeUtil.formatTime(bS.getBatchTime()));
186            sb.append("\t");
187            sb.append(bS.getBatchEndTime());
188            sb.append("\t");
189            sb.append(DateTimeUtil.formatTime(bS.getTimeToSolrOptimize()));
190            sb.append("\t");
191        }
192    
193    
194    }