View Javadoc

1   /*
2    * SymmetricDS is an open source database synchronization solution.
3    *   
4    * Copyright (C) Chris Henson <chenson42@users.sourceforge.net>,
5    *               Eric Long <erilong@users.sourceforge.net>
6    *
7    * This library is free software; you can redistribute it and/or
8    * modify it under the terms of the GNU Lesser General Public
9    * License as published by the Free Software Foundation; either
10   * version 3 of the License, or (at your option) any later version.
11   *
12   * This library is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this library; if not, see
19   * <http://www.gnu.org/licenses/>.
20   */
21  
22  package org.jumpmind.symmetric.model;
23  
24  import java.io.Serializable;
25  import java.util.Date;
26  
27  import org.jumpmind.symmetric.load.IDataLoaderContext;
28  import org.jumpmind.symmetric.load.IDataLoaderStatistics;
29  import org.jumpmind.symmetric.util.AppUtils;
30  
31  public class IncomingBatchHistory implements Serializable {
32  
33      private static final long serialVersionUID = 1L;
34  
35      private static String thisHostName;
36  
37      public enum Status {
38          OK, ER, SK;
39      }
40  
41      private long batchId;
42  
43      private String nodeId;
44  
45      private Status status;
46  
47      private String hostName;
48  
49      private long byteCount;
50  
51      private long networkMillis;
52  
53      private long filterMillis;
54  
55      private long databaseMillis;
56  
57      private long statementCount;
58  
59      private long fallbackInsertCount;
60  
61      private long fallbackUpdateCount;
62  
63      private long missingDeleteCount;
64  
65      private long failedRowNumber;
66  
67      private Date startTime;
68  
69      private Date endTime;
70  
71      private String sqlState;
72  
73      private int sqlCode;
74  
75      private String sqlMessage;
76  
77      static {
78          thisHostName = AppUtils.getServerId();
79      }
80  
81      public IncomingBatchHistory() {
82          this.hostName = thisHostName;
83      }
84  
85      public IncomingBatchHistory(IDataLoaderContext context) {
86          batchId = context.getBatchId();
87          nodeId = context.getNodeId();
88          status = Status.OK;
89          startTime = new Date();
90          this.hostName = thisHostName;
91      }
92  
93      public void setValues(IDataLoaderStatistics statistics, boolean isSuccess) {
94          byteCount = statistics.getByteCount();
95          networkMillis = statistics.getNetworkMillis();
96          filterMillis = statistics.getFilterMillis();
97          databaseMillis = statistics.getDatabaseMillis();
98          statementCount = statistics.getStatementCount();
99          fallbackInsertCount = statistics.getFallbackInsertCount();
100         fallbackUpdateCount = statistics.getFallbackUpdateCount();
101         missingDeleteCount = statistics.getMissingDeleteCount();
102         endTime = new Date();
103         if (!isSuccess) {
104             status = Status.ER;
105             failedRowNumber = statistics.getStatementCount();
106         }
107     }
108 
109     public String getNodeBatchId() {
110         return nodeId + "-" + batchId;
111     }
112 
113     public long getBatchId() {
114         return batchId;
115     }
116 
117     public void setBatchId(long batchId) {
118         this.batchId = batchId;
119     }
120 
121     public Date getEndTime() {
122         return endTime;
123     }
124 
125     public void setEndTime(Date endTime) {
126         this.endTime = endTime;
127     }
128 
129     public Status getStatus() {
130         return status;
131     }
132 
133     public void setStatus(Status status) {
134         this.status = status;
135     }
136 
137     public long getFailedRowNumber() {
138         return failedRowNumber;
139     }
140 
141     public void setFailedRowNumber(long failedRowNumber) {
142         this.failedRowNumber = failedRowNumber;
143     }
144 
145     public long getFallbackInsertCount() {
146         return fallbackInsertCount;
147     }
148 
149     public void setFallbackInsertCount(long fallbackInsertCount) {
150         this.fallbackInsertCount = fallbackInsertCount;
151     }
152 
153     public long getFallbackUpdateCount() {
154         return fallbackUpdateCount;
155     }
156 
157     public void setFallbackUpdateCount(long fallbackUpdateCount) {
158         this.fallbackUpdateCount = fallbackUpdateCount;
159     }
160 
161     public String getHostName() {
162         return hostName;
163     }
164 
165     public void setHostName(String hostName) {
166         this.hostName = hostName;
167     }
168 
169     public String getNodeId() {
170         return nodeId;
171     }
172 
173     public void setNodeId(String nodeId) {
174         this.nodeId = nodeId;
175     }
176 
177     public Date getStartTime() {
178         return startTime;
179     }
180 
181     public void setStartTime(Date startTime) {
182         this.startTime = startTime;
183     }
184 
185     public long getStatementCount() {
186         return statementCount;
187     }
188 
189     public void setStatementCount(long statementCount) {
190         this.statementCount = statementCount;
191     }
192 
193     public long getMissingDeleteCount() {
194         return missingDeleteCount;
195     }
196 
197     public void setMissingDeleteCount(long missingDeleteCount) {
198         this.missingDeleteCount = missingDeleteCount;
199     }
200 
201     public long getByteCount() {
202         return byteCount;
203     }
204 
205     public void setByteCount(long byteCount) {
206         this.byteCount = byteCount;
207     }
208 
209     public long getDatabaseMillis() {
210         return databaseMillis;
211     }
212 
213     public void setDatabaseMillis(long databaseMillis) {
214         this.databaseMillis = databaseMillis;
215     }
216 
217     public long getFilterMillis() {
218         return filterMillis;
219     }
220 
221     public void setFilterMillis(long filterMillis) {
222         this.filterMillis = filterMillis;
223     }
224 
225     public long getNetworkMillis() {
226         return networkMillis;
227     }
228 
229     public void setNetworkMillis(long networkMillis) {
230         this.networkMillis = networkMillis;
231     }
232 
233     public int getSqlCode() {
234         return sqlCode;
235     }
236 
237     public void setSqlCode(int sqlCode) {
238         this.sqlCode = sqlCode;
239     }
240 
241     public String getSqlMessage() {
242         return sqlMessage;
243     }
244 
245     public void setSqlMessage(String sqlMessage) {
246         this.sqlMessage = sqlMessage;
247     }
248 
249     public String getSqlState() {
250         return sqlState;
251     }
252 
253     public void setSqlState(String sqlState) {
254         this.sqlState = sqlState;
255     }
256 
257 }