@Override public boolean lock(){
  try {
    if (!FileFactory.isFileExist(location,FileFactory.getFileType(tmpPath))) {
      FileFactory.mkdirs(location,FileFactory.getFileType(tmpPath));
    }
    lockFilePath=location + CarbonCommonConstants.FILE_SEPARATOR + lockFile;
    if (!FileFactory.isFileExist(lockFilePath,FileFactory.getFileType(location))) {
      FileFactory.createNewLockFile(lockFilePath,FileFactory.getFileType(location));
    }
    fileOutputStream=new FileOutputStream(lockFilePath);
    channel=fileOutputStream.getChannel();
    try {
      fileLock=channel.tryLock();
    }
 catch (    OverlappingFileLockException e) {
      return false;
    }
    if (null != fileLock) {
      return true;
    }
 else {
      return false;
    }
  }
 catch (  IOException e) {
    return false;
  }
}

@ Override public boolean lock ( ) { try { if ( ! FileFactory . isFileExist ( location , FileFactory . getFileType ( tmpPath ) ) ) { FileFactory . mkdirs ( location , FileFactory . getFileType ( tmpPath ) ) ; } lockFilePath = location + CarbonCommonConstants . FILE_SEPARATOR + lockFile ; if ( ! FileFactory . isFileExist ( lockFilePath , FileFactory . getFileType ( location ) ) ) { FileFactory . createNewLockFile ( lockFilePath , FileFactory . getFileType ( location ) ) ; } fileOutputStream = new FileOutputStream ( lockFilePath ) ; channel = fileOutputStream . getChannel ( ) ; try { fileLock = channel . tryLock ( ) ; } catch ( OverlappingFileLockException e ) { return false ; } if ( null != fileLock ) { return true ; } else { return false ; } } catch ( IOException e ) { return false ; } }
lock api for locking of the file channel of the lock file .
