public int lock()
  {
      if (tc.isEntryEnabled()) Tr.entry(tc, "lock");

      int result = LOCK_FAILURE;

      // Ensure that the target lock files exist.
      if (!_lockFilesExist)
      {
          if (tc.isDebugEnabled()) Tr.debug(tc,"Confirming/Creating the lock files");

          _handle1 = ensureFileExists(RECOVERY_FILE_1_NAME);
          if (_handle1 != null)
          {
              _handle2 = ensureFileExists(RECOVERY_FILE_2_NAME);

              if (_handle2 != null)
              {
                _lockFilesExist = true;
              }
              else
              {
                Tr.error(tc,"CWRLS0004_RECOVERY_LOG_CREATE_FAILED", _lockDirectory + File.separator + RECOVERY_FILE_2_NAME);
                _handle1 = null;
              }
          }
          else
          {
            Tr.error(tc,"CWRLS0004_RECOVERY_LOG_CREATE_FAILED",  _lockDirectory + File.separator + RECOVERY_FILE_1_NAME);
          }
      }
      else
      {
          if (tc.isDebugEnabled()) Tr.debug(tc,"Already Confirmed/Created the lock files");
      }

      if (_lockFilesExist)
      {
        result = obtainLock(_handle1);

        if (result == LOCK_SUCCESS)
        {
          result = obtainLock(_handle2);

          if (result != LOCK_SUCCESS)
          {
            if (result == LOCK_FAILURE)
            {
               Tr.error(tc,"CWRLS0005_RECOVERY_LOG_LOCK_FAILED", _lockDirectory + File.separator + RECOVERY_FILE_2_NAME);
            }

            releaseLock(_handle1);
          }
        }
        else if (result == LOCK_FAILURE)
        {
          Tr.error(tc,"CWRLS0005_RECOVERY_LOG_LOCK_FAILED", _lockDirectory + File.separator + RECOVERY_FILE_1_NAME);
        }
      }

      if (tc.isEntryEnabled()) Tr.exit(tc, "lock",new Integer(result));
      return result;
  }
public int lock ( ) { if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "lock" ) ; int result = LOCK_FAILURE ; if ( ! _lockFilesExist ) { if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Confirming/Creating the lock files" ) ; _handle1 = ensureFileExists ( RECOVERY_FILE_1_NAME ) ; if ( _handle1 != null ) { _handle2 = ensureFileExists ( RECOVERY_FILE_2_NAME ) ; if ( _handle2 != null ) { _lockFilesExist = true ; } else { Tr . error ( tc , "CWRLS0004_RECOVERY_LOG_CREATE_FAILED" , _lockDirectory + File . separator + RECOVERY_FILE_2_NAME ) ; _handle1 = null ; } } else { Tr . error ( tc , "CWRLS0004_RECOVERY_LOG_CREATE_FAILED" , _lockDirectory + File . separator + RECOVERY_FILE_1_NAME ) ; } } else { if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Already Confirmed/Created the lock files" ) ; } if ( _lockFilesExist ) { result = obtainLock ( _handle1 ) ; if ( result == LOCK_SUCCESS ) { result = obtainLock ( _handle2 ) ; if ( result != LOCK_SUCCESS ) { if ( result == LOCK_FAILURE ) { Tr . error ( tc , "CWRLS0005_RECOVERY_LOG_LOCK_FAILED" , _lockDirectory + File . separator + RECOVERY_FILE_2_NAME ) ; } releaseLock ( _handle1 ) ; } } else if ( result == LOCK_FAILURE ) { Tr . error ( tc , "CWRLS0005_RECOVERY_LOG_LOCK_FAILED" , _lockDirectory + File . separator + RECOVERY_FILE_1_NAME ) ; } } if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "lock" , new Integer ( result ) ) ; return result ; }
Obtains the exclusive lock.