anchor.diff:  -define(DEF_THRESHOLD_SLOW_PROC, 1000).
   
   -ifdef(TEST).
  --define(DEF_MIN_COMPACTION_WT, 10).   %% 10msec
  --define(DEF_REG_COMPACTION_WT, 100).  %% 100msec
  --define(DEF_MAX_COMPACTION_WT, 300).  %% 300msec
  +-define(DEF_MIN_COMPACTION_WT, 10).  %% 10msec
  +-define(DEF_REG_COMPACTION_WT, 100). %% 100msec
  +-define(DEF_MAX_COMPACTION_WT, 300). %% 300msec
   -define(DEF_COMPACTION_TIMEOUT, timer:minutes(1)). %% 1min
   -else.
   -define(DEF_MIN_COMPACTION_WT,  300). %% 300msec
  
positive.code: 
  %% @doc Generate an key for backend db
  -define(gen_backend_key(_VSN, _AddrId, _Key),
          begin
              case _VSN of
                  ?AVS_HEADER_VSN_2_2 ->
                      term_to_binary({_AddrId, _Key});
                  ?AVS_HEADER_VSN_2_4 ->
                      _Key
              end
          end).
  
  -define(AVS_HEADER_VSN,     <<?AVS_HEADER_VSN_TOBE/binary,13,10>>).
  -define(AVS_PART_OF_HEADER, <<"CHKSUM:128,KSIZE:16,BLEN_MSIZE:32,DSIZE:32,OFFSET:64,ADDRID:128,CLOCK:64,TIMESTAMP:42,DEL:1,BUF:437,CHUNK_SIZE:32,CHUNK_NUM:24,CHUNK_INDEX:24",13,10>>).
  -define(AVS_PART_OF_BODY,   <<"KEY/binary,DATA/binary",13,10>>).
  -define(AVS_PART_OF_FOOTER, <<"PADDING:64",13,10>>).
  -define(AVS_SUPER_BLOCK,    <<?AVS_HEADER_VSN/binary,
                                ?AVS_PART_OF_HEADER/binary,
                                ?AVS_PART_OF_BODY/binary,
                                ?AVS_PART_OF_FOOTER/binary>>).
  -define(AVS_SUPER_BLOCK_LEN, byte_size(?AVS_SUPER_BLOCK)).
  
  %% ------------------------ %%
  
negative.code: -undef(EVENT_STATE).
  -undef(EVENT_INCREASE).
  -undef(EVENT_DECREASE).
  -define(EVENT_RUN, 'run').
  -define(EVENT_DIAGNOSE, 'diagnose').
  -define(EVENT_LOCK, 'lock').
  -define(EVENT_SUSPEND, 'suspend').
  -define(EVENT_RESUME, 'resume').
  -define(EVENT_FINISH, 'finish').
  -define(EVENT_STATE, 'state').
  -define(EVENT_INCREASE, 'increase').
  -define(EVENT_DECREASE, 'decrease').
  -type(compaction_event() ::?EVENT_RUN |
  ?EVENT_DIAGNOSE |
  ?EVENT_LOCK |
  ?EVENT_SUSPEND |
  ?EVENT_RESUME |
  ?EVENT_FINISH |
  ?EVENT_STATE |
  ?EVENT_INCREASE |
  ?EVENT_DECREASE
  ).
  
  %% @doc Compaction related definitions
  -define(RET_SUCCESS, 'success').
  -define(RET_FAIL,    'fail').
  -type(compaction_ret() :: ?RET_SUCCESS |
  ?RET_FAIL |
  undefined).
  
  -define(MAX_LEN_HIST, 50).
  -define(MAX_RETRY_TIMES, 2).
  -define(WAIT_TIME_AFTER_ERROR, 200). %% 200ms
  
  -record(compaction_report, {
  file_path = [] :: string(),
  avs_ver = <<>> :: binary(),
  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(),
  start_datetime = [] :: string(),
  end_datetime = [] :: string(),
  errors = [] :: [{non_neg_integer(),non_neg_integer()}],
  duration = 0 :: non_neg_integer(),
  result :: atom()
  }).
  
  -record(compaction_hist, {
  start_datetime = 0 :: non_neg_integer(),
  end_datetime   = 0 :: non_neg_integer(),
  duration = 0 :: non_neg_integer(),
  result :: compaction_ret()
  }).
  
  -record(compaction_stats, {
  status = ?ST_IDLING :: compaction_state(),
  total_num_of_targets = 0 :: non_neg_integer(),
  num_of_reserved_targets = 0 :: non_neg_integer(),
  num_of_pending_targets = 0 :: non_neg_integer(),
  num_of_ongoing_targets = 0 :: non_neg_integer(),
  reserved_targets = [] :: [atom()],
  pending_targets = [] :: [atom()],
  ongoing_targets = [] :: [atom()],
  locked_targets = [] :: [atom()],
  latest_exec_datetime = 0 :: non_neg_integer(),
  acc_reports = [] :: [#compaction_report{}]
  }).
  
  
  %% Error Constants
  %%
  -define(ERROR_FD_CLOSED, "already closed file-descriptor").
  -define(ERROR_FILE_OPEN, "file open error").
  -define(ERROR_INVALID_DATA, "invalid data").
  -define(ERROR_DATA_SIZE_DID_NOT_MATCH, "data-size did not match").
  -define(ERROR_COMPACT_SUSPEND_FAILURE, "comaction-suspend filure").
  -define(ERROR_COMPACT_RESUME_FAILURE, "comaction-resume filure").
  -define(ERROR_PROCESS_NOT_FOUND, "server process not found").
  -define(ERROR_COULD_NOT_GET_MOUNT_PATH, "could not get mout path").
  -define(ERROR_LOCKED_CONTAINER, "locked obj-conatainer").
  -define(ERROR_NOT_ALLOWED_ACCESS, "not allowed access").
  -define(ERROR_COULD_NOT_START_WORKER, "could NOT start worker processes").
  -define(ERROR_FREESPACE_LT_AVS, "The disk free space is less than the size of the AVS file").
  
  -define(ERROR_MSG_SLOW_OPERATION, 'slow_operation').
  -define(ERROR_MSG_TIMEOUT, 'timeout').
  -define(MSG_ITEM_SLOW_OP, 'slow_operation').
  -define(MSG_ITEM_TIMEOUT, 'timeout').
  
  