Class BaseSyncStatistics

    • Constructor Summary

      Constructors 
      Constructor Description
      BaseSyncStatistics()
      Creates a new BaseSyncStatistics with initial values 0 of created, updated, failed and processed counters, an empty reportMessage and latestBatchHumanReadableProcessingTime.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BaseSyncStatistics

        public BaseSyncStatistics()
        Creates a new BaseSyncStatistics with initial values 0 of created, updated, failed and processed counters, an empty reportMessage and latestBatchHumanReadableProcessingTime.
    • Method Detail

      • startTimer

        public 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.

        Note: This method isn't thread-safe and shouldn't be used in a concurrent context.

      • getUpdated

        public java.util.concurrent.atomic.AtomicInteger getUpdated()
        Gets the total number of resources that were updated.
        Returns:
        total number of resources that were updated.
      • incrementUpdated

        public void incrementUpdated()
        Increments the total number of resource that were updated.
      • incrementUpdated

        public void incrementUpdated​(int times)
        Increments the total number of resources that were updated by the supplied times.
        Parameters:
        times - the total number of times to increment.
      • getCreated

        public java.util.concurrent.atomic.AtomicInteger getCreated()
        Gets the total number of resources that were created.
        Returns:
        total number of resources that were created.
      • incrementCreated

        public void incrementCreated()
        Increments the total number of resource that were created.
      • incrementCreated

        public void incrementCreated​(int times)
        Increments the total number of resources that were created by the supplied times.
        Parameters:
        times - the total number of times to increment.
      • getProcessed

        public java.util.concurrent.atomic.AtomicInteger getProcessed()
        Gets the total number of resources that were processed/synced.
        Returns:
        total number of resources that were processed/synced.
      • incrementProcessed

        public void incrementProcessed()
        Increments the total number of resources that were processed/synced.
      • incrementProcessed

        public void incrementProcessed​(int times)
        Increments the total number of resources that were processed/synced by the supplied times.
        Parameters:
        times - the total number of times to increment.
      • getFailed

        public java.util.concurrent.atomic.AtomicInteger getFailed()
        Gets the total number of resources that failed to sync.
        Returns:
        total number of resources that failed to sync.
      • incrementFailed

        public void incrementFailed()
        Increments the total number of resources that failed to sync.
      • incrementFailed

        public void incrementFailed​(int times)
        Increments the total number of resources that failed to sync by the supplied times.
        Parameters:
        times - the total number of times to increment.
      • calculateProcessingTime

        public 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. 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.

      • getLatestBatchHumanReadableProcessingTime

        public java.lang.String getLatestBatchHumanReadableProcessingTime()
        Gets the human readable processing time in the following format @{code "0d, 0h, 0m, 2s, 545ms"}.

        Note: This method isn't thread-safe and shouldn't be used in a concurrent context.

        Returns:
        the human readable processing time in the following format @{code "0d, 0h, 0m, 2s, 545ms"}
      • getLatestBatchProcessingTimeInDays

        public long getLatestBatchProcessingTimeInDays()
        Gets the number of days it took to process.

        Note: This method isn't thread-safe and shouldn't be used in a concurrent context.

        Returns:
        number of days taken to process.
      • getLatestBatchProcessingTimeInHours

        public long getLatestBatchProcessingTimeInHours()
        Gets the number of hours it took to process.

        Note: This method isn't thread-safe and shouldn't be used in a concurrent context.

        Returns:
        number of hours taken to process.
      • getLatestBatchProcessingTimeInMinutes

        public long getLatestBatchProcessingTimeInMinutes()
        Gets the number of minutes it took to process.

        Note: This method isn't thread-safe and shouldn't be used in a concurrent context.

        Returns:
        number of minutes taken to process.
      • getLatestBatchProcessingTimeInSeconds

        public long getLatestBatchProcessingTimeInSeconds()
        Gets the number of seconds it took to process.

        Note: This method isn't thread-safe and shouldn't be used in a concurrent context.

        Returns:
        number of seconds taken to process.
      • getLatestBatchProcessingTimeInMillis

        public long getLatestBatchProcessingTimeInMillis()
        Gets the number of milliseconds it took to process.

        Note: This method isn't thread-safe and shouldn't be used in a concurrent context.

        Returns:
        number of milliseconds taken to process.
      • getReportMessage

        public abstract java.lang.String getReportMessage()
        Gets a summary message of the statistics report.

        Note: This method isn't thread-safe and shouldn't be used in a concurrent context.

        Returns:
        a summary message of the statistics report.
      • getDefaultReportMessageForResource

        protected java.lang.String getDefaultReportMessageForResource​(@Nonnull
                                                                      java.lang.String resourceString)
        Builds a proper summary message of the statistics report of a given resourceString in following format:

        "Summary: 2 resources were processed in total (2 created, 2 updated and 0 failed to sync)."

        Parameters:
        resourceString - a string representing the resource
        Returns:
        a summary message of the statistics report