forked from dennisk28/SmartETL
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add step stats and collecting logics
- Loading branch information
Dennis Kang
committed
Mar 15, 2015
1 parent
e01ef5c
commit 9af56c6
Showing
7 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
smartETL/src/main/java/org/f3tools/incredible/smartETL/StepStats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package org.f3tools.incredible.smartETL; | ||
|
||
/** | ||
* Capture all stats of each step | ||
* @author Dennis Kang | ||
* @since 2015/03/15 | ||
* | ||
*/ | ||
public class StepStats | ||
{ | ||
// number of lines read from previous steps | ||
private long linesRead; | ||
// number of lines written to next step(s) | ||
private long linesWritten; | ||
// number of lines read from file or database | ||
private long linesInput; | ||
// number of lines written to file or database | ||
private long linesOutput; | ||
// number of updates in a database table or file | ||
private long linesUpdated; | ||
// number of lines skipped | ||
private long linesFiltered; | ||
// number of lines errored | ||
private long linesErrored; | ||
|
||
private Step step; | ||
|
||
public StepStats(Step step) | ||
{ | ||
this.step = step; | ||
} | ||
|
||
public long getLinesRead() | ||
{ | ||
return linesRead; | ||
} | ||
|
||
public void addLinesRead() | ||
{ | ||
linesRead++; | ||
} | ||
|
||
public long getLinesWritten() | ||
{ | ||
return linesWritten; | ||
} | ||
|
||
public void addLinesWritten() | ||
{ | ||
linesWritten++; | ||
} | ||
|
||
public long getLinesInput() | ||
{ | ||
return linesInput; | ||
} | ||
|
||
public void addLinesInput() | ||
{ | ||
linesInput++; | ||
} | ||
|
||
public long getLinesOutput() | ||
{ | ||
return linesOutput; | ||
} | ||
|
||
public void addLinesOutput() | ||
{ | ||
linesOutput++; | ||
} | ||
|
||
public long getLinesUpdated() | ||
{ | ||
return linesUpdated; | ||
} | ||
|
||
public void addLinesUpdated() | ||
{ | ||
linesUpdated++; | ||
} | ||
|
||
public long getLinesFiltered() | ||
{ | ||
return linesFiltered; | ||
} | ||
|
||
public void addLinesFiltered() | ||
{ | ||
linesFiltered++; | ||
} | ||
|
||
public long getLinesErrored() | ||
{ | ||
return linesErrored; | ||
} | ||
|
||
public void addLinesErrored() | ||
{ | ||
linesErrored++; | ||
} | ||
|
||
public String toString() | ||
{ | ||
StringBuffer sb = new StringBuffer(); | ||
|
||
sb.append("Step statistics: " + step.getName() + "\n"); | ||
sb.append("Lines read: " + linesRead + "\n"); | ||
sb.append("Lines written: " + linesWritten + "\n"); | ||
sb.append("Lines inputed: " + linesInput + "\n"); | ||
sb.append("Lines outputed: " + linesOutput + "\n"); | ||
sb.append("Lines updated: " + linesUpdated + "\n"); | ||
sb.append("Lines filtered: " + linesFiltered + "\n"); | ||
sb.append("Lines with errs: " + linesErrored + "\n"); | ||
|
||
return sb.toString(); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
smartETL/src/main/java/org/f3tools/incredible/smartETL/StepStatsManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.f3tools.incredible.smartETL; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class StepStatsManager | ||
{ | ||
private static StepStatsManager instance; | ||
private Map<String, StepStats> stepStatsMap; | ||
|
||
private StepStatsManager() | ||
{ | ||
stepStatsMap = new HashMap<String, StepStats>(); | ||
} | ||
|
||
public static synchronized StepStatsManager getInstance() | ||
{ | ||
if (instance == null) instance = new StepStatsManager(); | ||
return instance; | ||
} | ||
|
||
public synchronized StepStats createStepStats(Step step) | ||
{ | ||
StepStats stepStats = new StepStats(step); | ||
stepStatsMap.put(step.getName(), stepStats); | ||
return stepStats; | ||
} | ||
|
||
public String toString() | ||
{ | ||
StringBuffer sb = new StringBuffer(); | ||
|
||
for(StepStats stats : stepStatsMap.values()) | ||
{ | ||
sb.append(stats.toString()); | ||
sb.append("\n"); | ||
} | ||
|
||
return sb.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters