public abstract class BaseSyncStatistics
extends java.lang.Object
Constructor and Description |
---|
BaseSyncStatistics()
Creates a new
BaseSyncStatistics with initial values 0 of created, updated,
failed and processed counters, an empty reportMessage and
latestBatchHumanReadableProcessingTime. |
Modifier and Type | Method and Description |
---|---|
void |
calculateProcessingTime()
Calculates the processing time taken by the subtracting the time, when the
startTimer() method of this instance was called, from the current time in
Milliseconds. |
java.util.concurrent.atomic.AtomicInteger |
getCreated()
Gets the total number of resources that were created.
|
protected java.lang.String |
getDefaultReportMessageForResource(java.lang.String resourceString)
Builds a proper summary message of the statistics report of a given
resourceString in
following format: |
java.util.concurrent.atomic.AtomicInteger |
getFailed()
Gets the total number of resources that failed to sync.
|
java.lang.String |
getLatestBatchHumanReadableProcessingTime()
Gets the human readable processing time in the following format @{code "0d, 0h, 0m, 2s,
545ms"}.
|
long |
getLatestBatchProcessingTimeInDays()
Gets the number of days it took to process.
|
long |
getLatestBatchProcessingTimeInHours()
Gets the number of hours it took to process.
|
long |
getLatestBatchProcessingTimeInMillis()
Gets the number of milliseconds it took to process.
|
long |
getLatestBatchProcessingTimeInMinutes()
Gets the number of minutes it took to process.
|
long |
getLatestBatchProcessingTimeInSeconds()
Gets the number of seconds it took to process.
|
java.util.concurrent.atomic.AtomicInteger |
getProcessed()
Gets the total number of resources that were processed/synced.
|
abstract java.lang.String |
getReportMessage()
Gets a summary message of the statistics report.
|
java.util.concurrent.atomic.AtomicInteger |
getUpdated()
Gets the total number of resources that were updated.
|
void |
incrementCreated()
Increments the total number of resource that were created.
|
void |
incrementCreated(int times)
Increments the total number of resources that were created by the supplied times.
|
void |
incrementFailed()
Increments the total number of resources that failed to sync.
|
void |
incrementFailed(int times)
Increments the total number of resources that failed to sync by the supplied times.
|
void |
incrementProcessed()
Increments the total number of resources that were processed/synced.
|
void |
incrementProcessed(int times)
Increments the total number of resources that were processed/synced by the supplied times.
|
void |
incrementUpdated()
Increments the total number of resource that were updated.
|
void |
incrementUpdated(int times)
Increments the total number of resources that were updated by the supplied times.
|
void |
startTimer()
Stores the current time of instantiation in the
latestBatchStartTime instance variable
that will be used later when calculateProcessingTime() is called to
calculate the total time of processing. |
public BaseSyncStatistics()
BaseSyncStatistics
with initial values 0
of created, updated,
failed and processed counters, an empty reportMessage and
latestBatchHumanReadableProcessingTime.public void startTimer()
latestBatchStartTime
instance variable
that will be used later when calculateProcessingTime()
is called to
calculate the total time of processing.
Note: This method isn't thread-safe and shouldn't be used in a concurrent context.
public java.util.concurrent.atomic.AtomicInteger getUpdated()
public void incrementUpdated()
public void incrementUpdated(int times)
times
- the total number of times to increment.public java.util.concurrent.atomic.AtomicInteger getCreated()
public void incrementCreated()
public void incrementCreated(int times)
times
- the total number of times to increment.public java.util.concurrent.atomic.AtomicInteger getProcessed()
public void incrementProcessed()
public void incrementProcessed(int times)
times
- the total number of times to increment.public java.util.concurrent.atomic.AtomicInteger getFailed()
public void incrementFailed()
public void incrementFailed(int times)
times
- the total number of times to increment.public void calculateProcessingTime()
startTimer()
method of this instance was called, from the current time in
Milliseconds. It also sets the processing time in all the units latestBatchProcessingTimeInDays
, latestBatchProcessingTimeInHours
, latestBatchProcessingTimeInMinutes
, latestBatchProcessingTimeInSeconds
and latestBatchProcessingTimeInMillis
. It also builds a human readable processing time, as string,
in the following format @{code "0d, 0h, 0m, 2s, 545ms"} and stores it in the publicly exposed
variable latestBatchHumanReadableProcessingTime
.
Note: This method isn't thread-safe and shouldn't be used in a concurrent context.
public java.lang.String getLatestBatchHumanReadableProcessingTime()
Note: This method isn't thread-safe and shouldn't be used in a concurrent context.
public long getLatestBatchProcessingTimeInDays()
Note: This method isn't thread-safe and shouldn't be used in a concurrent context.
public long getLatestBatchProcessingTimeInHours()
Note: This method isn't thread-safe and shouldn't be used in a concurrent context.
public long getLatestBatchProcessingTimeInMinutes()
Note: This method isn't thread-safe and shouldn't be used in a concurrent context.
public long getLatestBatchProcessingTimeInSeconds()
Note: This method isn't thread-safe and shouldn't be used in a concurrent context.
public long getLatestBatchProcessingTimeInMillis()
Note: This method isn't thread-safe and shouldn't be used in a concurrent context.
public abstract java.lang.String getReportMessage()
Note: This method isn't thread-safe and shouldn't be used in a concurrent context.
protected java.lang.String getDefaultReportMessageForResource(@Nonnull java.lang.String resourceString)
resourceString
in
following format:
"Summary: 2 resources were processed in total (2 created, 2 updated and 0 failed to sync)."
resourceString
- a string representing the resource