anchor.diff:  %% API calls. The time is returned in seconds, and in most cases it has one
   %% second accuracy.
   %% Cache key is used to allow different caches for different remote servers.
  +%% Any errors should be logged inside the RemoteTimestampFun fun and 'error'
  +%% should be returned.
   %% @end
   %%--------------------------------------------------------------------
   -spec remote_timestamp(CacheKey :: atom(), RemoteTimestampFun :: fun()) ->
  
positive.code:         {ok, {Bias, CacheExpiration}} when Now < CacheExpiration ->
              Now + Bias;
          _ ->
              RemoteTimestamp = RemoteTimestampFun(),
              After = system_time_milli_seconds(),
              % Request to the remote server can take some time, so we need to
              % slightly adjust the result. Estimate local time when measurement
              % on the remote server was done - roughly in about the middle of the
              % time taken by the request. Given that the request should take less
              % then a second in total, we get 1 second accuracy.
              EstimatedMeasurementTime = (Now + After) div 2,
              Bias = RemoteTimestamp - EstimatedMeasurementTime,
              % Cache measured bias if the latency was not too big.
              case After - Now > ?MAX_LATENCY_TO_CACHE_REMOTE_TIMESTAMP of
                  true ->
                      ok;
                  false ->
                      application:set_env(
                          ctool, CacheKey,
                          {Bias, After + ?REMOTE_TIMESTAMP_CACHE_TTL}
                      )
              end,
              After + Bias
      end.
  
  
  
negative.code: -spec cluster_time_milli_seconds() -> non_neg_integer().
  cluster_time_milli_seconds() ->
      remote_timestamp(cluster_time_bias, fun() ->
          try
              {ok, gen_server2:call({global, ?CLUSTER_MANAGER}, get_current_time)}
          catch
              exit:{Reason, _} ->
                  ?warning("Cannot get cluster time due to: ~p", [Reason]),
                  error
          end
      end).
  
  
  