View Javadoc
1   package org.kuali.ole.docstore.common.util;
2   
3   /**
4    * Created with IntelliJ IDEA.
5    * User: sambasivam
6    * Date: 6/3/14
7    * Time: 7:51 PM
8    * To change this template use File | Settings | File Templates.
9    */
10  public class ReindexBatchStatistics extends BatchStatistics {
11  
12      private long indexTime;
13      private long buildSolrDocsTime;
14      private long recToAddInSolr;
15      private long commitTime;
16  
17      public long getIndexTime() {
18          return indexTime;
19      }
20  
21      public void addIndexTime(long indexTime) {
22          this.indexTime = this.indexTime + indexTime;
23      }
24  
25      public long getBuildSolrDocsTime() {
26          return buildSolrDocsTime;
27      }
28  
29      public void setBuildSolrDocsTime(long buildSolrDocsTime) {
30          this.buildSolrDocsTime = buildSolrDocsTime;
31      }
32  
33      public long getRecToAddInSolr() {
34          return recToAddInSolr;
35      }
36  
37      public void setRecToAddInSolr(long recToAddInSolr) {
38          this.recToAddInSolr = recToAddInSolr;
39      }
40  
41      public long getCommitTime() {
42          return commitTime;
43      }
44  
45      public void setCommitTime(long commitTime) {
46          this.commitTime = commitTime;
47      }
48  
49      public void addCommitTime(long commitTime) {
50          this.commitTime = this.commitTime + commitTime;
51      }
52  
53      public void addRecToAddInSolr(long recToAddInSolr) {
54          this.recToAddInSolr = this.recToAddInSolr + recToAddInSolr;
55      }
56  
57  
58      public void addBuildSolrDocsTime(long buildSolrDocsTime) {
59          this.buildSolrDocsTime = this.buildSolrDocsTime + buildSolrDocsTime;
60      }
61  
62  
63      @Override
64      public String toString() {
65  
66          StringBuilder stringBuilder = new StringBuilder();
67          if(super.getStartTime() != null) {
68              stringBuilder.append("Index start Time : ");
69              stringBuilder.append(super.getStartTime().toString());
70              stringBuilder.append(",");
71          }
72          stringBuilder.append("\nIndexed ");
73          stringBuilder.append(super.getBibCount());
74          stringBuilder.append(" bibs, ");
75          stringBuilder.append(super.getHoldingsCount());
76          stringBuilder.append(" holdings, ");
77          stringBuilder.append(super.getItemCount());
78          stringBuilder.append( " items, ");
79          stringBuilder.append((super.getBibCount() + super.getHoldingsCount() + super.getItemCount()));
80          stringBuilder.append(" in total.");
81          stringBuilder.append("\nbuildSolrDocsTime : ");
82          stringBuilder.append(buildSolrDocsTime);
83          stringBuilder.append(", add to solr : ");
84          stringBuilder.append(recToAddInSolr);
85          stringBuilder.append(", commit time : ");
86          stringBuilder.append(commitTime);
87          stringBuilder.append("\nTime taken - fetch : ");
88          stringBuilder.append(super.getTimeTaken());
89          stringBuilder.append(", index : ");
90          stringBuilder.append(indexTime);
91          stringBuilder.append(", Total : ");
92          stringBuilder.append((super.getTimeTaken() + this.indexTime));
93          stringBuilder.append(",\nIndex End Time : ");
94  
95  
96          if(getEndTime() != null) {
97              stringBuilder.append(super.getEndTime().toString());
98          }
99  
100         return stringBuilder.toString();
101     }
102 
103 
104     public void getBatchStatus(ReindexBatchStatistics reindexBatchStatistics) {
105 
106         setBibCount(reindexBatchStatistics.getBibCount() - getBibCount());
107         setHoldingsCount(reindexBatchStatistics.getHoldingsCount() - getHoldingsCount());
108         setItemCount(reindexBatchStatistics.getItemCount() - getItemCount());
109         setTimeTaken(reindexBatchStatistics.getTimeTaken() - getTimeTaken());
110         indexTime = reindexBatchStatistics.getIndexTime() - indexTime;
111         buildSolrDocsTime = reindexBatchStatistics.getBuildSolrDocsTime() - buildSolrDocsTime;
112         recToAddInSolr = reindexBatchStatistics.getRecToAddInSolr() - recToAddInSolr;
113         commitTime = reindexBatchStatistics.getCommitTime() - commitTime;
114     }
115 
116 
117     public void setData(ReindexBatchStatistics reindexBatchStatistics) {
118         setBibCount(reindexBatchStatistics.getBibCount());
119         setHoldingsCount(reindexBatchStatistics.getHoldingsCount());
120         setItemCount(reindexBatchStatistics.getItemCount());
121         setTimeTaken(reindexBatchStatistics.getTimeTaken());
122         indexTime = reindexBatchStatistics.getIndexTime();
123         buildSolrDocsTime = reindexBatchStatistics.getBuildSolrDocsTime();
124         recToAddInSolr = reindexBatchStatistics.getRecToAddInSolr();
125         commitTime = reindexBatchStatistics.getCommitTime();
126 
127     }
128 
129 }