Forces a disk flush for this segment file.
164434
synchronized void sync()
    {
        try
        {
            // check we have more work to do
            if (allocatePosition.get() <= lastSyncedOffset + SYNC_MARKER_SIZE)
                return;

            // allocate a new sync marker; this is both necessary in itself, but also serves to demarcate
            // the point at which we can safely consider records to have been completely written to
            int nextMarker;
            nextMarker = allocate(SYNC_MARKER_SIZE);
            boolean close = false;
            if (nextMarker < 0)
            {
                // ensure no more of this CLS is writeable, and mark ourselves for closing
                discardUnusedTail();
                close = true;

                // wait for modifications guards both discardedTailFrom, and any outstanding appends
                waitForModifications();

                if (discardedTailFrom < buffer.capacity() - SYNC_MARKER_SIZE)
                {
                    // if there's room in the discard section to write an empty header, use that as the nextMarker
                    nextMarker = discardedTailFrom;
                }
                else
                {
                    // not enough space left in the buffer, so mark the next sync marker as the EOF position
                    nextMarker = buffer.capacity();
                }
            }
            else
            {
                waitForModifications();
            }

            assert nextMarker > lastSyncedOffset;

            // write previous sync marker to point to next sync marker
            // we don't chain the crcs here to ensure this method is idempotent if it fails
            int offset = lastSyncedOffset;
            final PureJavaCrc32 crc = new PureJavaCrc32();
            crc.updateInt((int) (id & 0xFFFFFFFFL));
            crc.updateInt((int) (id >>> 32));
            crc.updateInt(offset);
            buffer.putInt(offset, nextMarker);
            buffer.putInt(offset + 4, crc.getCrc());

            // zero out the next sync marker so replayer can cleanly exit
            if (nextMarker < buffer.capacity())
            {
                buffer.putInt(nextMarker, 0);
                buffer.putInt(nextMarker + 4, 0);
            }

            // actually perform the sync and signal those waiting for it
            buffer.force();

            if (close)
                nextMarker = buffer.capacity();

            lastSyncedOffset = nextMarker;
            syncComplete.signalAll();

            CLibrary.trySkipCache(fd, offset, nextMarker);
            if (close)
                internalClose();
        }
        catch (Exception e) // MappedByteBuffer.force() does not declare IOException but can actually throw it
        {
            throw new FSWriteError(e, getPath());
        }
    }
1033252
public synchronized void flush()
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass,
                        "flush");

        // Capture the ManagedObjects to write and delete.
        java.util.Map ourManagedObjectsToWrite = managedObjectsToWrite;
        managedObjectsToWrite = new ConcurrentHashMap(concurrency);
        java.util.Map ourTokensToDelete = tokensToDelete;
        tokensToDelete = new ConcurrentHashMap(concurrency);

        // Write the managed objects to disk.
        // Use of ConcurrentHashMap makes this a safe copy of the set at the time we construct the iterator.
        java.util.Iterator managedObjectIterator = ourManagedObjectsToWrite.values()
                        .iterator();
        while (managedObjectIterator.hasNext()) {
            ManagedObject managedObject = (ManagedObject) managedObjectIterator.next();
            write(managedObject);
        } // While managedObjectIterator.hasNext().

        // Delete the managed objects from disk.
        // Use of ConcurrentHashMap makes this a safe copy of the set at the time we construct the iterator.
        java.util.Iterator tokenIterator = ourTokensToDelete.values()
                        .iterator();
        while (tokenIterator.hasNext()) {
            Token token = (Token) tokenIterator.next();
            if (managedObjectsOnDisk.contains(new Long(token.storedObjectIdentifier))) {
                java.io.File storeFile = new java.io.File(storeDirectoryName
                                                          + java.io.File.separator
                                                          + token.storedObjectIdentifier);
                storeFile.delete();
                managedObjectsOnDisk.remove((new Long(token.storedObjectIdentifier)));
            } // if ... contains.
        } // While tokenIterator.hasNext().

        // Write the header and force to disk.
        writeHeader();

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass,
                       "flush");
    }
1317539
def force_delete_file(file_path):
        '''  '''
        if os.path.isfile(file_path):
            try:
                os.remove(file_path)
                return file_path
            except:           
                return FileSystemUtils.add_unique_postfix(file_path)
        else:
            return file_path
248461
public void forceCloseAndDelete() {
    try {
      if (objectOutputStream != null) {
        objectOutputStream.close();
        objectOutputStream = null;
      }
      if (fileOutputStream != null) {
        fileOutputStream.close();
        fileOutputStream = null;
      }
    } catch (IOException e) {
      log.debug(e);
    }
    closed = true;
    tokenNumber = 0;
    if (file != null) {
      if (file.exists() && file.canWrite() && !file.delete()) {
        log.debug("couldn't delete " + file.getName());
      }
      file = null;
    }
  }
355306
def force_flush(
            self):
        
        self.debug_log('force flush requested')
        self.perform_work(
            self.queue,
            self.shutdown_event,
            self.shutdown_ack,
            self.already_done)
63319
@Override
    public void flush() {

        PrintWriter out = null;
        try {
            try {
                out = new PrintWriter(Utils.createFile(dir, file), "UTF-8");
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            String contents = getBuffer().toString();
            out.write(processor.apply(contents));
        } finally {
            closeQuietly(out);
        }
    }
884435
function flush (cb) {
    _.forEach(components.entries(), function (component, idx) {

      var elements = _.map(component[1].entries(), function (item, text) {
        return '<' + item[0] + '>\n' + item[1] + '</' + item[0] + '>\n\n'
      })

      this.push(new gutil.File({
        path: component[0],
        contents: new Buffer(elements.join(''))
      }))

    }.bind(this))
    cb()
  }
696212
def flush(self):
        """"""
        if self._wbuf:
            buffer = ''.join(self._wbuf)
            self._wbuf = []
            self.write(buffer)
6213
@Override
  public void flush(boolean forceSync)
      throws IOException {
    if (blockDataWriter != null) {
      blockDataWriter.flush();
      if (forceSync) {
        blockDataWriter.force(true);
      }
    }
  }
1272921
public function flush()
    {
        if ($this->fileSystem->isDirectory($this->directory))
        {
            $this->fileSystem->deleteDirectory($this->directory, true);
        }
    }
65154
public void forceFlushWithBestEffort() {
    LOG.info("Forcing to flush data to socket with best effort.");
    while (!outgoingPacketsToWrite.isEmpty()) {
      int writeState = outgoingPacketsToWrite.poll().writeToChannel(socketChannel);
      if (writeState != 0) {
        LOG.info("Failed to write more to Socket. Clear and finish the flush.");
        clear();
        return;
      }
    }
  }
1347855
def flush(self):
        
        if self._writable:
            with self._seek_lock:
                self._flush_raw_or_buffered()

                # Clear the buffer
                self._write_buffer = bytearray(self._buffer_size)
                self._buffer_seek = 0
74273
public void flush(boolean durable) throws IOException {
    numSync++;
    long start = System.nanoTime();
    flushAndSync(durable);
    long time = DFSUtil.getElapsedTimeMicroSeconds(start);
    totalTimeSync += time;
    if (sync != null) {
      sync.inc(time);
    }
  }
1185854
protected void flushData()
    {
        try
        {
            out.write(buffer, 0, validBufferBytes);
            lastFlushOffset += validBufferBytes;
        }
        catch (IOException e)
        {
            throw new FSWriteError(e, getPath());
        }
        if (runPostFlush != null)
            runPostFlush.run();
    }
869052
public function flush()
    {
        if (file_exists($this->CacheFolder . "/" . $this->CacheIndex)) {
            unlink($this->CacheFolder . "/" . $this->CacheIndex);
            touch($this->CacheFolder . "/" . $this->CacheIndex);
        }
        if (file_exists($this->CacheFolder . "/" . $this->CacheDB)) {
            unlink($this->CacheFolder . "/" . $this->CacheDB);
            touch($this->CacheFolder . "/" . $this->CacheDB);
        }
    }
1050983
public function flush() {

		if(false !== $this -> file -> getExists()) {

			if(false === is_writable($this -> file -> getBasepath())) {
				return trigger_error(sprintf('File "%s" passed to %s() is not writable', $this -> file -> getBasepath(), __METHOD__), E_USER_ERROR);
	    	}

			$fh = fopen($this -> file -> getBasepath(), 'w');
			
			if(flock($fh, LOCK_EX)) {

    			ftruncate($fh, 0);
			    fflush($fh);
    			flock($fh, LOCK_UN);
    		}

			fclose($fh);

			$this -> refresh();
		}

		return $this;
	}
493547
def Flush(self):
    """"""
    if self._dirty:
      self.Set(self.Schema.SIZE(self.size))
      if self.content_last is not None:
        self.Set(self.Schema.CONTENT_LAST, self.content_last)

    # Flushing the cache will write all chunks to the blob store.
    self.chunk_cache.Flush()
    super(AFF4ImageBase, self).Flush()