Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- java.nio.BufferUnderflowException
- 2013-12-24 18:05:32 [INFO] [STDERR] at java.nio.Buffer.nextGetIndex(Unknown Source)
- 2013-12-24 18:05:32 [INFO] [STDERR] at java.nio.HeapByteBuffer.getLong(Unknown Source)
- 2013-12-24 18:05:32 [INFO] [STDERR] at deadmansswitch.DeadMansSwitch.checkForDeadMansSwitchReset(DeadMansSwitch.java:148)
- which is long timeMilliseconds = bb.getLong();
- public static boolean checkForDeadMansSwitchReset() {
- try {
- RandomAccessFile file = new RandomAccessFile("." + File.separator + "DeadMansSwitch.txt", "rw");
- FileChannel fc = file.getChannel();
- ByteBuffer bb = ByteBuffer.allocate(8);
- int bytesRead = fc.read(bb);
- long timeMilliseconds = bb.getLong();
- fc.close();
- System.out.println("read timeMilliseconds: " + timeMilliseconds);
- if (timeMilliseconds != -1 && timeMilliseconds + restartThreshold > System.currentTimeMillis()) {
- System.out.println("we should restart!");
- return true;
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- } finally {
- }
- return false;
- }
- public static void resetDeadMansSwitch(long timeVal) {
- FileChannel fc = null;
- try {
- RandomAccessFile file = new RandomAccessFile("." + File.separator + "DeadMansSwitch.txt", "rw");
- fc = file.getChannel();
- ByteBuffer bb = ByteBuffer.allocate(8);
- bb.clear();
- bb.putLong(timeVal);
- bb.flip();
- while(bb.hasRemaining()) {
- fc.write(bb);
- }
- fc.close();
- System.out.println("write timeMilliseconds: " + timeVal);
- } catch (Exception ex) {
- ex.printStackTrace();
- } finally {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement