class ServerLockCleaner {

  public void cleanLock(ThemisLock lock) throws IOException {
    long beginTs = System.nanoTime();
    try {
      PrimaryLock primary = getPrimaryLockWithColumn(lock);
      // judge whether the transaction committed by clean the primary lock
      Pair<Long, PrimaryLock> cleanResult = cleanPrimaryLock(primary.getColumn(), primary.getTimestamp());
      // if the primary lock is cleaned in cleanPrimaryLock, we could get the primary lock with all secondaries
      primary = cleanResult.getSecond() == null ? primary : cleanResult.getSecond();
      // clean secondary locks
      cleanSecondaryLocks(primary, cleanResult.getFirst());
      ThemisCpStatistics.getThemisCpStatistics().cleanLockSuccessCount.inc();
    } catch (IOException e) {
      ThemisCpStatistics.getThemisCpStatistics().cleanLockFailCount.inc();
      throw e;
    } finally {
      ThemisCpStatistics.updateLatency(ThemisCpStatistics.getThemisCpStatistics().cleanLockLatency,
        beginTs, "lock=" + lock);
    }
  }

  public  ServerLockCleaner(HConnection conn, ThemisCoprocessorClient cpClient);

}