Package java.nio.channels

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


        while (read > 0) {
            byteBuffer.position(read).flip();
            written += localfileChannel.write(byteBuffer);
            read = inputStream.read(bytes);
        }
        localfileChannel.force(false);
        localfileChannel.close();
        size = written;
        if (definedSize > 0 && definedSize < size) {
            file.delete();
            file = null;
View Full Code Here


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

         ByteBuffer bb = generateBuffer(fileSize, (byte)'x');

         write(bb, channel, fileSize);

         channel.force(true);

         channel.position(0);

         ByteBuffer bb1 = generateBuffer(recordSize, (byte)'h');
View Full Code Here

               start = System.currentTimeMillis();
            }

            bb1.flip();
            channel.write(bb1);
            channel.force(false);
         }

         long end = System.currentTimeMillis();

         double rate = 1000 * (double)its / (end - start);
View Full Code Here

        file.delete();
        RandomAccessFile ra = new RandomAccessFile(file, "rw");
        FileUtils.delete(s);
        FileChannel f = FileUtils.open(s, "rw");
        assertEquals(-1, f.read(ByteBuffer.wrap(new byte[1])));
        f.force(true);
        Random random = new Random(seed);
        int size = 500;
        try {
            for (int i = 0; i < size; i++) {
                trace("op " + i);
View Full Code Here

      if (wc.getFSyncRefFiles()) {
        FileChannel fc = out.getChannel();
        ByteBuffer buf = ByteBuffer.wrap(rec);
        while (0 < buf.remaining())
          fc.write(buf);
        fc.force(true);
      } else
        out.write(rec);
    } finally {
      out.close();
    }
View Full Code Here

      if (fsync) {
        FileChannel fc = os.getChannel();
        ByteBuffer buf = ByteBuffer.wrap(content);
        while (0 < buf.remaining())
          fc.write(buf);
        fc.force(true);
      } else {
        os.write(content);
      }
      os.close();
      os = null;
View Full Code Here

        writeVersion(channel);
        int length = sib.write(channel);
        length += STORAGE_VERSION_LENGTH;
       
        raf.setLength(length);
        channel.force(true);
        channel.close();
        raf.close();
       
        if(_logger.isTraceEnabled()) {
            _logger.trace("write " + sibFile.getAbsolutePath());
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

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.