Package java.nio.channels

Examples of java.nio.channels.FileLock.release()


                mapper.writeValue(file, metric);
            }
            catch(Exception e) {
                logger.error("write metric error: ", e);
            }
            lock.release();
        }
        catch(Exception e) {
            logger.error("Cannot lock file {}", file.getAbsolutePath());
        }
        finally {
View Full Code Here


            PrintWriter writer = new PrintWriter(out, false);
            writer.println(DATE_FORMAT.format(date)+" - "+action+" - "+username);
            writer.flush();
            writer.close();
            if(lock.isValid()) {
                lock.release();
            }
        } catch (IOException e) {
            throw new RuntimeException("Unable to write to authentication log file", e);
        }
    }
View Full Code Here

            PrintWriter writer = new PrintWriter(out, false);
            writer.println(DATE_FORMAT.format(date)+" - "+action+" - "+username);
            writer.flush();
            writer.close();
            if(lock.isValid()) {
                lock.release();
            }
        } catch (IOException e) {
            throw new RuntimeException("Unable to write to authentication log file", e);
        }
    }
View Full Code Here

      result = reader.readLine();
    } finally {
      if (reader != null) {
        reader.close();
      }
      lock.release();
    }
    return result;
  }

  private FileLock tryLock(boolean retry, ZooKeeperCall call)
View Full Code Here

        // Cache has not been updated and we need to populate it
        val = retrieveAndPopulateCache(cache, call);
      }
    } finally {
      if (lock != null) {
        lock.release();
      }
    }
    if (val == null) {
      val = getFromCache(call);
    }
View Full Code Here

      Method m = CachingAvatarZooKeeperClient.class.getDeclaredMethod(
          "tryLock", Boolean.TYPE, ZooKeeperCall.class);
      ZooKeeperCall call = cazkc.new GetStat(null);
      m.setAccessible(true);
      FileLock fl = (FileLock) m.invoke(cazkc, true, call);
      fl.release();
      TestCase.assertNotNull(fl);
      fl = (FileLock) m.invoke(cazkc, true, call);
      TestCase.assertNotNull(fl);
      fl.release();
      new File(directoryName, ".avatar_zk_cache_lock").delete();
View Full Code Here

      FileLock fl = (FileLock) m.invoke(cazkc, true, call);
      fl.release();
      TestCase.assertNotNull(fl);
      fl = (FileLock) m.invoke(cazkc, true, call);
      TestCase.assertNotNull(fl);
      fl.release();
      new File(directoryName, ".avatar_zk_cache_lock").delete();
      m.invoke(cazkc, true, call);
    } finally {
      new File(directoryName, ".avatar_zk_cache_lock").delete();
      new File(directoryName).delete();
View Full Code Here

      if(firstLock != null && firstLock != sd.lock) {
        firstLock.release();
        firstLock.channel().close();
      }
      if(secondLock != null) {
        secondLock.release();
        secondLock.channel().close();
      }
    }
    return false;
  }
View Full Code Here

        if(firstLock != null && firstLock != lock) {
          firstLock.release();
          firstLock.channel().close();
        }
        if(secondLock != null) {
          secondLock.release();
          secondLock.channel().close();
        }
      }
      return false;
    }
View Full Code Here

            file = new RandomAccessFile(f, "rw");
            lock = file.getChannel().lock();
            RTree.create().visualize(600, 600).save(filename, "PNG");
        } finally {
            try {
                lock.release();
                file.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.