当前位置: 首页>>代码示例>>Java>>正文


Java FileLockInterruptionException类代码示例

本文整理汇总了Java中java.nio.channels.FileLockInterruptionException的典型用法代码示例。如果您正苦于以下问题:Java FileLockInterruptionException类的具体用法?Java FileLockInterruptionException怎么用?Java FileLockInterruptionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileLockInterruptionException类属于java.nio.channels包,在下文中一共展示了FileLockInterruptionException类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSerializationSelf

import java.nio.channels.FileLockInterruptionException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization compatibility.
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "!SerializationSelf",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "FileLockInterruptionException",
        args = {}
    )
})
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new FileLockInterruptionException());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:22,代码来源:FileLockInterruptionExceptionTest.java

示例2: testSerializationCompatibility

import java.nio.channels.FileLockInterruptionException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization compatibility with RI.
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "!SerializationGolden",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "FileLockInterruptionException",
        args = {}
    )
})
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this,
            new FileLockInterruptionException());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:23,代码来源:FileLockInterruptionExceptionTest.java

示例3: lock

import java.nio.channels.FileLockInterruptionException; //导入依赖的package包/类
@Override
public FileLock lock(long position, long size, boolean shared) throws IOException {
  checkLockArguments(position, size, shared);

  // lock is interruptible
  boolean completed = false;
  try {
    begin();
    completed = true;
    return new FakeFileLock(this, position, size, shared);
  } finally {
    try {
      end(completed);
    } catch (ClosedByInterruptException e) {
      throw new FileLockInterruptionException();
    }
  }
}
 
开发者ID:google,项目名称:jimfs,代码行数:19,代码来源:JimfsFileChannel.java

示例4: assertClosedByInterrupt

import java.nio.channels.FileLockInterruptionException; //导入依赖的package包/类
/**
 * Asserts that when the given operation is run on an interrupted thread,
 * {@code ClosedByInterruptException} is thrown, the channel is closed and the thread is no
 * longer interrupted.
 */
private static void assertClosedByInterrupt(FileChannelMethod method) throws IOException {
  FileChannel channel = channel(regularFile(10), READ, WRITE);
  Thread.currentThread().interrupt();
  try {
    method.call(channel);
    fail(
        "expected the method to throw ClosedByInterruptException or "
            + "FileLockInterruptionException");
  } catch (ClosedByInterruptException | FileLockInterruptionException expected) {
    assertFalse("expected the channel to be closed", channel.isOpen());
    assertTrue("expected the thread to still be interrupted", Thread.interrupted());
  } finally {
    Thread.interrupted(); // ensure the thread isn't interrupted when this method returns
  }
}
 
开发者ID:google,项目名称:jimfs,代码行数:21,代码来源:JimfsFileChannelTest.java

示例5: updateServerMonitorData

import java.nio.channels.FileLockInterruptionException; //导入依赖的package包/类
public synchronized boolean updateServerMonitorData(Server s) {
    if (!s.isLinked()) {
        return false;
    }
    File file = new File(Storage.getSettings().getCommunicationDir() + "/" + s.getName() + EXTENSION);
    if (file.isFile()) {
        try (FileOutputStream fos = new FileOutputStream(file, true); FileInputStream fis = new FileInputStream(file)) {
            locker = new Thread() {
                public void run() {
                    try {
                        fos.getChannel().lock();
                    } catch (FileLockInterruptionException ex) {
                    } catch (IOException ex) {
                        Printer.printError(PNAME, "Failed to acquire lock on file \"" + file + "\".", ex);
                    }
                }
            };
            locker.start();
            locker.join(3000);
            if (locker.isAlive()) {
                Printer.printBackgroundFail(PNAME, "Failed to read the file \"" + file + "\". Could not acquire lock.");
                return false;
            }
            Scanner sc = new Scanner(fis);
            s.setFileUpdateInterval(Long.parseLong(sc.nextLine()));
            s.setLastPing(Long.parseLong(sc.nextLine()));
            ArrayList<String> msgs = new ArrayList();
            while (sc.hasNextLine()) {
                msgs.add(sc.nextLine());
            }
            s.setCustomMessages(msgs);
            return true;
        } catch (Exception e) {
            Printer.printError(PNAME, "The server \"" + s.getName() + "\" monitor data file is broken.", e);
        }
    } else {
        Printer.printBackgroundFail(PNAME, "The monitor data file \"" + file.getAbsolutePath() + "\" was not found for the server \"" + s.getName() + "\".");
    }
    return false;
}
 
开发者ID:OasisArtisan,项目名称:OasisLight-ServerManager,代码行数:41,代码来源:ServerFileCommunicatorTask.java

示例6: test_Constructor

import java.nio.channels.FileLockInterruptionException; //导入依赖的package包/类
/**
 * @tests {@link java.nio.channels.FileLockInterruptionException#FileLockInterruptionException()}
 */
public void test_Constructor() {
    FileLockInterruptionException e = new FileLockInterruptionException();
    assertNull(e.getMessage());
    assertNull(e.getLocalizedMessage());
    assertNull(e.getCause());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:10,代码来源:FileLockInterruptionExceptionTest.java

示例7: testSerializationSelf

import java.nio.channels.FileLockInterruptionException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization compatibility.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new FileLockInterruptionException());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:8,代码来源:FileLockInterruptionExceptionTest.java

示例8: testSerializationCompatibility

import java.nio.channels.FileLockInterruptionException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this,
            new FileLockInterruptionException());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:FileLockInterruptionExceptionTest.java


注:本文中的java.nio.channels.FileLockInterruptionException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。