anchor.diff:  -define(SYNC_MODE_PERIODIC, 'periodic').
   -define(SYNC_MODE_WRITETHROUGH, 'writethrough').
   -type(sync_mode() :: ?SYNC_MODE_NONE |
  -                     ?SYNC_MODE_PERIODIC |
  -                     ?SYNC_MODE_WRITETHROUGH).
  +?SYNC_MODE_PERIODIC |
  +?SYNC_MODE_WRITETHROUGH).
   -define(OBJ_PRV_READ_WRITE, 'read_and_write').
   -define(OBJ_PRV_READ_ONLY, 'read').
   -define(OBJ_PRV_WRITE_ONLY, 'write').
   -type(obj_privilege() :: ?OBJ_PRV_READ_WRITE |
  -                         ?OBJ_PRV_READ_ONLY |
  -                         ?OBJ_PRV_WRITE_ONLY).
  +?OBJ_PRV_READ_ONLY |
  +?OBJ_PRV_WRITE_ONLY).
   -record(obj_server_state, {
  -          id :: atom(),
  -          seq_num = 0 :: non_neg_integer(),
  -          privilege = ?OBJ_PRV_READ_WRITE :: obj_privilege(),
  -          meta_db_id :: atom(),
  -          compaction_worker_id :: atom(),
  -          diagnosis_logger_id :: atom(),
  -          root_path = [] :: string(),
  -          object_storage = #backend_info{}  :: #backend_info{},
  -          storage_stats  = #storage_stats{} :: #storage_stats{},
  -          state_filepath :: string(),
  -          sync_mode = ?SYNC_MODE_NONE :: sync_mode(),
  -          sync_interval_in_ms = ?DEF_SYNC_INTERVAL :: pos_integer(),
  -          is_strict_check = false :: boolean(),
  -          is_locked = false :: boolean(),
  -          is_del_blocked = false  :: boolean(),
  -          threshold_slow_processing = ?DEF_THRESHOLD_SLOW_PROC :: non_neg_integer(),
  -          is_able_to_write = true :: boolean()
  -         }).
  +id :: atom(),
  +seq_num = 0 :: non_neg_integer(),
  +privilege = ?OBJ_PRV_READ_WRITE :: obj_privilege(),
  +meta_db_id :: atom(),
  +compaction_worker_id :: atom(),
  +diagnosis_logger_id :: atom(),
  +root_path = [] :: string(),
  +object_storage = #backend_info{}  :: #backend_info{},
  +storage_stats  = #storage_stats{} :: #storage_stats{},
  +state_filepath :: string(),
  +sync_mode = ?SYNC_MODE_NONE :: sync_mode(),
  +sync_interval_in_ms = ?DEF_SYNC_INTERVAL :: pos_integer(),
  +is_strict_check = false :: boolean(),
  +is_locked = false :: boolean(),
  +is_del_blocked = false  :: boolean(),
  +threshold_slow_processing = ?DEF_THRESHOLD_SLOW_PROC :: non_neg_integer(),
  +is_able_to_write = true :: boolean()
  +}).
   
   %% apllication-env
   -define(env_metadata_db(),
  -        case application:get_env(?APP_NAME, metadata_storage) of
  -            {ok, EnvMetadataDB} ->
  -                EnvMetadataDB;
  -            _ ->
  -                ?DEF_METADATA_DB
  -        end).
  +case application:get_env(?APP_NAME, metadata_storage) of
  +{ok, EnvMetadataDB} ->
  +EnvMetadataDB;
  +_ ->
  +?DEF_METADATA_DB
  +end).
   
   -define(env_sync_mode(),
  -        case application:get_env(?APP_NAME, sync_mode) of
  -            {ok, SyncMode} ->
  -                SyncMode;
  -            _ ->
  -                ?SYNC_MODE_NONE
  -        end).
  +case application:get_env(?APP_NAME, sync_mode) of
  +{ok, SyncMode} ->
  +SyncMode;
  +_ ->
  +?SYNC_MODE_NONE
  +end).
   
   -define(env_sync_interval(),
  -        case application:get_env(?APP_NAME, sync_interval_in_ms) of
  -            {ok, SyncInterval} ->
  -                SyncInterval;
  -            _ ->
  -                ?DEF_SYNC_INTERVAL
  -        end).
  +case application:get_env(?APP_NAME, sync_interval_in_ms) of
  +{ok, SyncInterval} ->
  +SyncInterval;
  +_ ->
  +?DEF_SYNC_INTERVAL
  +end).
   
   -ifdef(TEST).
   -define(env_strict_check(), true).
   -else.
   -define(env_strict_check(),
  -        case application:get_env(?APP_NAME, is_strict_check) of
  -            {ok, EnvStrictCheck} ->
  -                EnvStrictCheck;
  -            _ ->
  -                false
  -        end).
  +case application:get_env(?APP_NAME, is_strict_check) of
  +{ok, EnvStrictCheck} ->
  +EnvStrictCheck;
  +_ ->
  +false
  +end).
   -endif.
   
   -define(env_enable_diagnosis_log(),
  -        case application:get_env(?APP_NAME,
  -                                 is_enable_diagnosis_log) of
  -            {ok, true} ->
  -                true;
  -            _ ->
  -                false
  -        end).
  +case application:get_env(?APP_NAME,
  +is_enable_diagnosis_log) of
  +{ok, true} ->
  +true;
  +_ ->
  +false
  +end).
   
   -define(env_num_of_obj_storage_read_procs(),
  -        case application:get_env(?APP_NAME,
  -                                 num_of_obj_storage_read_procs) of
  -            {ok, EnvNumOfObjStorageReadProcs} ->
  -                EnvNumOfObjStorageReadProcs;
  -            _ ->
  -                ?DEF_NUM_OF_OBJ_STORAGE_READ_PROCS
  -        end).
  +case application:get_env(?APP_NAME,
  +num_of_obj_storage_read_procs) of
  +{ok, EnvNumOfObjStorageReadProcs} ->
  +EnvNumOfObjStorageReadProcs;
  +_ ->
  +?DEF_NUM_OF_OBJ_STORAGE_READ_PROCS
  +end).
   
   -define(get_obj_storage_read_proc(_PidL,_AddrId),
  -        begin
  -            lists:nth((_AddrId rem erlang:length(_PidL)) + 1,_PidL)
  -        end).
  +begin
  +lists:nth((_AddrId rem erlang:length(_PidL)) + 1,_PidL)
  +end).
   
   
   -define(env_limit_num_of_compaction_procs(),
  -        case application:get_env(?APP_NAME,
  -                                 limit_num_of_compaction_procs) of
  -            {ok, EnvLimitCompactionProcs} when is_integer(EnvLimitCompactionProcs) ->
  -                EnvLimitCompactionProcs;
  -            _ ->
  -                ?DEF_LIMIT_COMPACTION_PROCS
  -        end).
  +case application:get_env(?APP_NAME,
  +limit_num_of_compaction_procs) of
  +{ok, EnvLimitCompactionProcs} when is_integer(EnvLimitCompactionProcs) ->
  +EnvLimitCompactionProcs;
  +_ ->
  +?DEF_LIMIT_COMPACTION_PROCS
  +end).
   
   -define(env_threshold_slow_processing(),
  -        case application:get_env(?APP_NAME,
  -                                 threshold_slow_processing) of
  -            {ok, EnvThresholdSlowProc} when is_integer(EnvThresholdSlowProc) ->
  -                EnvThresholdSlowProc;
  -            _ ->
  -                ?DEF_THRESHOLD_SLOW_PROC
  -        end).
  +case application:get_env(?APP_NAME,
  +threshold_slow_processing) of
  +{ok, EnvThresholdSlowProc} when is_integer(EnvThresholdSlowProc) ->
  +EnvThresholdSlowProc;
  +_ ->
  +?DEF_THRESHOLD_SLOW_PROC
  +end).
   
   %% [Interval between batch processes]
   -define(env_compaction_interval_reg(),
  -        case application:get_env(?APP_NAME,
  -                                 compaction_waiting_time_regular) of
  -            {ok, EnvRegCompactionWT} when is_integer(EnvRegCompactionWT) ->
  -                EnvRegCompactionWT;
  -            _ ->
  -                ?DEF_REG_COMPACTION_WT
  -        end).
  +case application:get_env(?APP_NAME,
  +compaction_waiting_time_regular) of
  +{ok, EnvRegCompactionWT} when is_integer(EnvRegCompactionWT) ->
  +EnvRegCompactionWT;
  +_ ->
  +?DEF_REG_COMPACTION_WT
  +end).
   
   -define(env_compaction_interval_max(),
  -        case application:get_env(?APP_NAME,
  -                                 compaction_waiting_time_max) of
  -            {ok, EnvMaxCompactionWT} when is_integer(EnvMaxCompactionWT) ->
  -                EnvMaxCompactionWT;
  -            _ ->
  -                ?DEF_MAX_COMPACTION_WT
  -        end).
  +case application:get_env(?APP_NAME,
  +compaction_waiting_time_max) of
  +{ok, EnvMaxCompactionWT} when is_integer(EnvMaxCompactionWT) ->
  +EnvMaxCompactionWT;
  +_ ->
  +?DEF_MAX_COMPACTION_WT
  +end).
   
   %% [Number of batch processes]
   -define(env_compaction_num_of_batch_procs_max(),
  -        case application:get_env(?APP_NAME,
  -                                 batch_procs_max) of
  -            {ok, EnvMaxCompactionBP} when is_integer(EnvMaxCompactionBP) ->
  -                EnvMaxCompactionBP;
  -            _ ->
  -                ?DEF_MAX_COMPACTION_BP
  -        end).
  +case application:get_env(?APP_NAME,
  +batch_procs_max) of
  +{ok, EnvMaxCompactionBP} when is_integer(EnvMaxCompactionBP) ->
  +EnvMaxCompactionBP;
  +_ ->
  +?DEF_MAX_COMPACTION_BP
  +end).
   
   -define(env_compaction_num_of_batch_procs_reg(),
  -        case application:get_env(?APP_NAME,
  -                                 batch_procs_regular) of
  -            {ok, EnvRegCompactionBP} when is_integer(EnvRegCompactionBP) ->
  -                EnvRegCompactionBP;
  -            _ ->
  -                ?DEF_REG_COMPACTION_BP
  -        end).
  +case application:get_env(?APP_NAME,
  +batch_procs_regular) of
  +{ok, EnvRegCompactionBP} when is_integer(EnvRegCompactionBP) ->
  +EnvRegCompactionBP;
  +_ ->
  +?DEF_REG_COMPACTION_BP
  +end).
   
   -define(env_compaction_skip_prefetch_size(),
  -        case application:get_env(?APP_NAME,
  -                                 skip_prefetch_size) of
  -            {ok, EnvPrefetchSize} when is_integer(EnvPrefetchSize) ->
  -                EnvPrefetchSize;
  -            _ ->
  -                ?DEF_COMPACTION_SKIP_PS
  -        end).
  +case application:get_env(?APP_NAME,
  +skip_prefetch_size) of
  +{ok, EnvPrefetchSize} when is_integer(EnvPrefetchSize) ->
  +EnvPrefetchSize;
  +_ ->
  +?DEF_COMPACTION_SKIP_PS
  +end).
   
   -define(num_of_compaction_concurrency(_PrmNumOfConcurrency),
  -        begin
  -            _EnvNumOfConcurrency = ?env_limit_num_of_compaction_procs(),
  -            case (_PrmNumOfConcurrency > _EnvNumOfConcurrency) of
  -                true  -> _EnvNumOfConcurrency;
  -                false -> _PrmNumOfConcurrency
  -            end
  -        end).
  +begin
  +_EnvNumOfConcurrency = ?env_limit_num_of_compaction_procs(),
  +case (_PrmNumOfConcurrency > _EnvNumOfConcurrency) of
  +true  -> _EnvNumOfConcurrency;
  +false -> _PrmNumOfConcurrency
  +end
  +end).
   
   -define(env_compaction_force_quit_in_bytes(),
  -        case application:get_env(?APP_NAME, force_quit_in_bytes) of
  -            {ok, ForceQuitInBytes} ->
  -                ForceQuitInBytes;
  -            _ ->
  -                ?DEF_COMPACTION_FQ_IN_BYTES
  -        end).
  +case application:get_env(?APP_NAME, force_quit_in_bytes) of
  +{ok, ForceQuitInBytes} ->
  +ForceQuitInBytes;
  +_ ->
  +?DEF_COMPACTION_FQ_IN_BYTES
  +end).
   
   -define(get_object_storage_id(_TargetContainers),
  -        begin
  -            lists:flatten(
  -              lists:map(
  -                fun(_Id) ->
  -                        case leo_object_storage_api:get_object_storage_pid_by_container_id(_Id) of
  -                            not_found -> [];
  -                            _Pid -> _Pid
  -                        end
  -                end,_TargetContainers))
  -        end).
  +begin
  +lists:flatten(
  +lists:map(
  +fun(_Id) ->
  +case leo_object_storage_api:get_object_storage_pid_by_container_id(_Id) of
  +not_found -> [];
  +_Pid -> _Pid
  +end
  +end,_TargetContainers))
  +end).
   
   -define(env_diskspace_check_intervals(),
  -        case application:get_env(?APP_NAME, diskspace_check_intervals) of
  -            {ok, EnvDiskSpaceCheckIntervals} ->
  -                EnvDiskSpaceCheckIntervals;
  -            _ ->
  -                timer:minutes(1)
  -        end).
  +case application:get_env(?APP_NAME, diskspace_check_intervals) of
  +{ok, EnvDiskSpaceCheckIntervals} ->
  +EnvDiskSpaceCheckIntervals;
  +_ ->
  +timer:minutes(1)
  +end).
   
   -define(env_enable_msg_collector(),
  -        case application:get_env(?APP_NAME, msg_collector) of
  -            {ok, true} ->
  -                true;
  -            _ ->
  -                false
  -        end).
  +case application:get_env(?APP_NAME, msg_collector) of
  +{ok, true} ->
  +true;
  +_ ->
  +false
  +end).
   
   %% custom-metadata's items for MDC-replication:
   -define(PROP_CMETA_CLUSTER_ID, 'cluster_id').
  
positive.code: -define(DEF_REG_COMPACTION_BP,  50). %% 50
  -define(DEF_MAX_COMPACTION_BP, 150). %% 150
  -else.
  -define(DEF_MIN_COMPACTION_BP,   100). %%    100
  -define(DEF_REG_COMPACTION_BP,  1000). %%  1,000
  -define(DEF_MAX_COMPACTION_BP, 10000). %% 10,000
  -endif.
  
  
negative.code: 
  %% @doc Generate a raw file path
  -define(gen_raw_file_path(_FilePath),
  lists:append([_FilePath, "_", integer_to_list(leo_date:now())])).
  
  %% @doc Retrieve object-storage info
  -define(get_obj_storage_info(_ObjStorageId),
  leo_object_storage_server:get_backend_info(_ObjStorageId, ?SERVER_OBJ_STORAGE)).
  
  
  %% @doc Diagnosis log-related definitions
  -define(DEF_LOG_SUB_DIR, "log/").
  -define(LOG_GROUP_ID_DIAGNOSIS, 'log_diagnosis_grp').
  -define(LOG_ID_DIAGNOSIS, 'log_diagnosis').
  -define(LOG_FILENAME_DIAGNOSIS, "leo_object_storage_").
  -define(DIAGNOSIS_REP_SUFFIX, ".report").
  
  
  %% @doc Output diagnosis log
  -define(output_diagnosis_log(Metadata),
  begin
  #?METADATA{offset = _Offset,
  addr_id = _AddrId,
  key = _Key,
  dsize = _Dsize,
  clock = _Clock,
  timestamp = _Timestamp,
  del = _Del
  } = Metadata,
  _Path_1 = binary_to_list(_Key),
  
  {_Path_2, _CIndex} =
  begin
  _Tokens = string:tokens(_Path_1, "\n"),
  case length(_Tokens) of
  1 ->
  {_Path_1, 0};
  _ ->
  [_ParentPath,_CNum|_] = _Tokens,
  case catch list_to_integer(_CNum) of
  {'EXIT',_} ->
  {_ParentPath, 0};
  _Num->
  {_ParentPath, _Num}
  end
  end
  end,
  
  leo_logger_client_base:append(
  {LoggerId, #message_log{format  = "~w\t~w\t~s\t~w\t~w\t~w\t~s\t~w~n",
  message = [_Offset,
  _AddrId,
  _Path_2,
  _CIndex,
  _Dsize,
  _Clock,
  leo_date:date_format(_Timestamp),
  _Del
  ]}
  })
  end).
  
  %% @doc Default value of step of a batch-processing
  -define(DEF_COMPACTION_NUM_OF_STEPS, 10).
  
  %% @doc Compaction-related records:
  -record(compaction_event_info, {
  id :: atom(),
  event = ?EVENT_RUN :: compaction_event(),
  controller_pid :: pid(),
  client_pid :: pid(),
  is_diagnosing = false :: boolean(),
  is_recovering = false :: boolean(),
  is_forced_run = false :: boolean(),
  callback :: function()
  }).
  
  -record(compaction_prms, {
  key_bin = <<>> :: binary(),
  body_bin = <<>> :: binary(),
  metadata = #?METADATA{} :: #?METADATA{},
  next_offset = 0 :: non_neg_integer()|eof,
  start_lock_offset = 0 :: non_neg_integer(),
  callback_fun :: function(),
  num_of_active_objs = 0  :: non_neg_integer(),
  size_of_active_objs = 0 :: non_neg_integer(),
  total_num_of_objs = 0 :: non_neg_integer(),
  total_size_of_objs = 0 :: non_neg_integer()
  }).
  
  -record(compaction_skip_garbage, {
  buf = <<>> :: binary(),
  read_pos = 0 :: non_neg_integer(),
  prefetch_size = ?DEF_COMPACTION_SKIP_PS :: pos_integer(),
  is_skipping = false :: boolean(),
  is_close_eof = false :: boolean()
  }).
  
  -record(compaction_worker_state, {
  id :: atom(),
  obj_storage_id :: atom(),
  obj_storage_id_read :: atom(),
  meta_db_id :: atom(),
  obj_storage_info = #backend_info{} :: #backend_info{},
  compact_cntl_pid :: pid(),
            diagnosis_log_id :: atom(),
            status = ?ST_IDLING :: compaction_state(),
            is_locked = false :: boolean(),
  