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