1 |
41977
|
sandro.lab
|
package eu.dnetlib.index.feed;
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* FeedResult helps verifying feeding operations
|
5 |
|
|
*
|
6 |
|
|
* @author claudio
|
7 |
|
|
*/
|
8 |
|
|
public class FeedResult {
|
9 |
|
|
|
10 |
|
|
/**
|
11 |
|
|
* counter of added documents.
|
12 |
|
|
*/
|
13 |
|
|
private Integer added = null;
|
14 |
|
|
|
15 |
|
|
/**
|
16 |
|
|
* counter of skipped documents
|
17 |
|
|
*/
|
18 |
|
|
private Integer skipped = null;
|
19 |
|
|
|
20 |
|
|
/**
|
21 |
|
|
* counter of marked-for-deletion documents.
|
22 |
|
|
*/
|
23 |
|
|
private Integer marked = null;
|
24 |
|
|
|
25 |
|
|
/**
|
26 |
|
|
* marks the start of feed process.
|
27 |
|
|
*/
|
28 |
|
|
private long timeStart;
|
29 |
|
|
|
30 |
|
|
/**
|
31 |
|
|
* time elapsed to complete the feeding.
|
32 |
|
|
*/
|
33 |
|
|
private long timeElapsed;
|
34 |
|
|
|
35 |
|
|
/**
|
36 |
|
|
* builds a new FeedResult
|
37 |
|
|
*
|
38 |
|
|
* @param timeStart the start time of feed process.
|
39 |
|
|
*/
|
40 |
|
|
public FeedResult(final long timeStart) {
|
41 |
|
|
this.added = 0;
|
42 |
|
|
this.skipped = 0;
|
43 |
|
|
this.marked = 0;
|
44 |
|
|
this.timeStart = timeElapsed = timeStart;
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
/**
|
48 |
|
|
* increments added counter.
|
49 |
|
|
*/
|
50 |
|
|
public void add() {
|
51 |
|
|
added++;
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
/**
|
55 |
|
|
* increments marked counter.
|
56 |
|
|
*/
|
57 |
|
|
public void mark() {
|
58 |
|
|
marked++;
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
/**
|
62 |
|
|
* increments skipped counter.
|
63 |
|
|
*/
|
64 |
|
|
public void skip() {
|
65 |
|
|
skipped++;
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
public int getAdded() {
|
69 |
|
|
return added;
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
public int getSkipped() {
|
73 |
|
|
return skipped;
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
public int getMarked() {
|
77 |
|
|
return marked;
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
/**
|
81 |
|
|
* method calculates the time elapsed since the feed process has started.
|
82 |
|
|
*
|
83 |
|
|
* @return the time elapsed since the feed process has started.
|
84 |
|
|
*/
|
85 |
|
|
public long getTime() {
|
86 |
|
|
if (timeElapsed > 0) return timeElapsed - timeStart;
|
87 |
|
|
return System.currentTimeMillis() - timeStart;
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
public FeedResult setTimeElapsed(final long timeElapsed) {
|
91 |
|
|
this.timeElapsed = timeElapsed;
|
92 |
|
|
return this;
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
@Override
|
96 |
|
|
public String toString() {
|
97 |
|
|
return "[added: " + getAdded() + " skipped: " + getSkipped() + " marked: " + getMarked() + " time: " + (getTime() / 1000) + " sec]";
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
}
|