Package java.nio.channels

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


            while (position < DATA) {
                channel.write(ByteBuffer.wrap(data), position);
                position += data.length;
            }
            watch.stop().start("flush");
            channel.force(true);
        } else {
            long position = 0;
            while (position < DATA) {
                raf.write(data);
                position += data.length;
View Full Code Here


        buffer.putInt(-1);
        buffer.flip();
        channel.write(buffer, (long) (byteNumber(i)));
      }

      channel.force(true);

      buffer = null;
      channel.close();
      fos.close();
    }
View Full Code Here

                        synchronized(this) {
                            iosInProgress++;
                        }
                    }
                    if (!dataFactory.dataNotSyncedAtAllocation) {
                        ioChannel.force(false);
                    }
                } finally {
                    if (SanityManager.DEBUG) {
                        synchronized(this) {
                            iosInProgress--;
View Full Code Here

            RandomAccessFile file = endOfLogSyncFile;
            if (file != null) {
           
                FileChannel channel = file.getChannel();
                try {
                    channel.force(false);
                } catch (ClosedChannelException e) {

                    /*
                     * The channel should never be closed. It may be
                     * closed because of an interrupt received by
View Full Code Here

                }
                if (written <= 0 && size > 0) {
                    throw new IOException("Copying to new location " + rlocFile + " failed");
                }
            } finally {
                newFc.force(true);
                newFc.close();
            }
            // delete old.idx
            fc.close();
            if (!delete()) {
View Full Code Here

      for (CharBuffer b : added) {
        fncacheFile.write(fnEncoder.toFNCache(b));
        fncacheFile.write(lf);
        lf.rewind();
      }
      fncacheFile.force(true);
      tr.done(f);
    } catch (IOException ex) {
      tr.failure(f, ex);
      throw new HgIOException("Failed to write fncache", ex, f);
    } finally {
View Full Code Here

                if (toFlush.isEmpty()) {
                    qe = queue.take();
                } else {
                    qe = queue.poll();
                    if (qe == null || toFlush.size() > 100) {
                        logFile.force(false);
                        for (QueueEntry e : toFlush) {
                            e.cb.addComplete(0, e.ledgerId, e.entryId, e.ctx);
                        }
                        toFlush.clear();
                    }
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

      FileChannel idxChannel = new FileOutputStream(tmpIdx).getChannel();
      OutputStream idxStream = Channels.newOutputStream(idxChannel);
      try {
        pw.writeIndex(idxStream);
      } finally {
        idxChannel.force(true);
        idxStream.close();
        idxChannel.close();
      }

      // rename the temporary files to real files
View Full Code Here

                        synchronized(this) {
                            iosInProgress++;
                        }
                    }
                    if (!dataFactory.dataNotSyncedAtAllocation) {
                        ioChannel.force(false);
                    }
                } finally {
                    if (SanityManager.DEBUG) {
                        synchronized(this) {
                            iosInProgress--;
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.