Package java.nio.channels

Examples of java.nio.channels.OverlappingFileLockException


      String jvmName = ManagementFactory.getRuntimeMXBean().getName();
      FileLock res = null;
      try {
        res = file.getChannel().tryLock();
        if (null == res) {
          throw new OverlappingFileLockException();
        }
        file.write(jvmName.getBytes(Charsets.UTF_8));
        LOG.info("Lock on " + lockF + " acquired by nodename " + jvmName);
      } catch(OverlappingFileLockException oe) {
        // Cannot read from the locked file on Windows.
View Full Code Here


    /**
     * @tests serialization/deserialization compatibility.
     */
    public void testSerializationSelf() throws Exception {

        SerializationTest.verifySelf(new OverlappingFileLockException());
    }
View Full Code Here

     * @tests serialization/deserialization compatibility with RI.
     */
    public void testSerializationCompatibility() throws Exception {

        SerializationTest
                .verifyGolden(this, new OverlappingFileLockException());
    }
View Full Code Here

      try {
        os = new FileOutputStream(lck);
        try {
          fLck = os.getChannel().tryLock();
          if (fLck == null)
            throw new OverlappingFileLockException();
        } catch (OverlappingFileLockException ofle) {
          // We cannot use unlock() here as this file is not
          // held by us, but we thought we created it. We must
          // not delete it, as it belongs to some other process.
          //
View Full Code Here

                // This, and all remaining locks, start beyond our end (so
                // cannot overlap).
                break;
            }
            if (existingLock.overlaps(lock.position(), lock.size())) {
                throw new OverlappingFileLockException();
            }
        }
        locks.add(lock);
    }
View Full Code Here

   
    /**
     * @tests {@link java.nio.channels.OverlappingFileLockException#OverlappingFileLockException()}
     */
    public void test_Constructor() {
        OverlappingFileLockException e = new OverlappingFileLockException();
        assertNull(e.getMessage());
        assertNull(e.getLocalizedMessage());
        assertNull(e.getCause());
    }
View Full Code Here

    /**
     * @tests serialization/deserialization compatibility.
     */
    public void testSerializationSelf() throws Exception {

        SerializationTest.verifySelf(new OverlappingFileLockException());
    }
View Full Code Here

     * @tests serialization/deserialization compatibility with RI.
     */
    public void testSerializationCompatibility() throws Exception {

        SerializationTest
                .verifyGolden(this, new OverlappingFileLockException());
    }
View Full Code Here

        {
          if (lockTable == null)
            lockTable = new FileLockTable();
        }
    if (lockTable.overlaps(position, size))
      throw new OverlappingFileLockException();
  }
View Full Code Here

TOP

Related Classes of java.nio.channels.OverlappingFileLockException

Copyright © 2018 www.massapicom. 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.