Package java.nio.channels

Examples of java.nio.channels.FileChannel.force()


                final FileChannel channel = getFileChannel(_currentAddress);
                Debug.$assert1.t(matches);
                if (matches) {
                    channel.truncate(length);
                }
                channel.force(true);
            } catch (final IOException ioe) {
                throw new PersistitIOException(ioe);
            }
            _currentAddress = ((_currentAddress / _blockSize) + 1) * _blockSize;
            _writeBuffer.clear();
View Full Code Here


      @Override
      public void flush(File f) throws IOException {
         FileChannel channel = streams.get(f.getPath());
         if (channel != null)
            channel.force(false);
      }

      @Override
      public void purge(File f) throws IOException {
         // Avoid a delete per-se because it hampers any fsync-like functionality
View Full Code Here

               for (Map.Entry<String, FileChannel> entry : streams.entrySet()) {
                  if (trace)
                     log.tracef("Flushing channel in %s", entry.getKey());
                  FileChannel channel = entry.getValue();
                  try {
                     channel.force(true);
                  } catch (IOException e) {
                     if (trace)
                        log.tracef(e, "Error flushing output stream for %s", entry.getKey());
                     flushErrors.putIfAbsent(entry.getKey(), e);
                     // If an error is encountered, close it. Next time it's used,
View Full Code Here

        long address = Long.MAX_VALUE;
        try {
            address = flush();
            if (address != Long.MAX_VALUE) {
                final FileChannel channel = getFileChannel(address);
                channel.force(false);
            }
        } catch (final IOException e) {
            throw new PersistitIOException("Writing to file " + addressToFile(address), e);
        }
    }
View Full Code Here

                final FileChannel channel = getFileChannel(_currentAddress);
                Debug.$assert1.t(matches);
                if (matches) {
                    channel.truncate(length);
                }
                channel.force(true);
            } catch (final IOException ioe) {
                throw new PersistitIOException(ioe);
            }
            _currentAddress = ((_currentAddress / _blockSize) + 1) * _blockSize;
            _writeBuffer.clear();
View Full Code Here

        ByteBuffer byteBuffer = channelBuffer.toByteBuffer();
        int written = 0;
        while (written < length) {
            written += fileChannel.write(byteBuffer);
        }
        fileChannel.force(false);
        fileChannel.close();
        outputStream.close();
        isRenamed = true;
        return written == length;
    }
View Full Code Here

                RandomAccessFile file = endOfLogSyncFile;
                if (file != null) {
                    bumpWriteCount("fsync");
                    FileChannel ch = file.getChannel();
                    try {
                        ch.force(false);
                        nLogFSyncs.increment();
                    } catch (ClosedChannelException e) {

                        /*
                         * The channel should never be closed. It may be closed
View Full Code Here

  }

  private FileChannel openForWrite(Path histPath) throws IOException {
    FileChannel byteChannel = FileChannel.open(histPath, StandardOpenOption.CREATE,
        StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE);
    byteChannel.force(true);
    FileChannel lockChannel = lock(histPath, byteChannel);
    return lockChannel;
  }

  private FileChannel openForRead(Path histPath) throws IOException {
View Full Code Here

   
    if(buf.hasRemaining()) {
      throw new RuntimeException();
    }
   
    fc.force(true);
   
    fc.close();
    foe.close();
   
    buf = ByteBuffer.allocate(bufferSize);
View Full Code Here

      FileChannel channel = new FileOutputStream(tmpPack).getChannel();
      OutputStream channelStream = Channels.newOutputStream(channel);
      try {
        pw.writePack(pm, pm, channelStream);
      } finally {
        channel.force(true);
        channelStream.close();
        channel.close();
      }

      // write the packindex
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.