Start creating the optimized file. This operation resets the state of the
optimizer task, so it can be re-used for subsequent invocations.

@return A completeable future that yields the newly created file.
198827
public CompletableFuture<NewFile> run() {
        LOG.log(Level.FINE, "starting optimized file creation for {0} files", files.size());
        CompletableFuture<NewFile> fileCreation = new CompletableFuture<>();
        final List<TSData> fjpFiles = this.files;  // We clear out files below, which makes createTmpFile see an empty map if we don't use a separate variable.
        TASK_POOL.execute(() -> createTmpFile(fileCreation, destDir, fjpFiles, getCompression()));
        synchronized (OUTSTANDING) {
            OUTSTANDING.add(fileCreation);
        }
        this.files = new LinkedList<>();  // Do not use clear! This instance is now shared with the createTmpFile task.
        return fileCreation;
    }
125106
public File getNextFile()
   {
      File nextFile = null;

      try
      {
         String sNextName = generateName();

         nextFile = new File(backupSetDir.getAbsoluteFile() + File.separator + sNextName);
         if (isFullBackup && isDirectoryForFullBackup)
         {
            if (!PrivilegedFileHelper.exists(nextFile))
            {
               PrivilegedFileHelper.mkdirs(nextFile);
            }
         }
         else
         {
            PrivilegedFileHelper.createNewFile(nextFile);
         }
      }
      catch (IOException e)
      {
         LOG.error("Can nit get next file : " + e.getLocalizedMessage(), e);
      }

      return nextFile;
   }
434910
public static boolean createNewFile(File targetFile) {
        if (targetFile.exists()) delFileOrFolder(targetFile);
        try {
            return targetFile.createNewFile();
        } catch (IOException e) {
            return false;
        }
    }
1369562
def make(self):
        
        try:
                
            # Create the lock file
            self.mkfile(self.lock_file)
        except Exception as e:
            self.die('Failed to generate lock file: {}'.format(str(e)))
379530
public Execed start() throws IOException
	{
		Process p = getProcessBuilder().start();

		return new Execed(cmd, p, builder.redirectErrorStream());
	}
652645
@LifecycleStart
  @Override
  public void start() throws Exception
  {
    super.start();

    synchronized (lifecycleLock) {
      Preconditions.checkState(!started, "already started");
      started = true;

      try {
        cleanupStaleAnnouncements();
        registerRunListener();
        pathChildrenCache.start();

        log.info("Started WorkerTaskMonitor.");
        started = true;
      }
      catch (InterruptedException e) {
        throw e;
      }
      catch (Exception e) {
        log.makeAlert(e, "Exception starting WorkerTaskMonitor")
           .emit();
        throw e;
      }
    }
  }
1286215
def Start(self,
            file_size=0,
            maximum_pending_files=1000,
            use_external_stores=False):
    """"""
    super(MultiGetFileLogic, self).Start()

    self.state.files_hashed = 0
    self.state.use_external_stores = use_external_stores
    self.state.file_size = file_size
    self.state.files_to_fetch = 0
    self.state.files_fetched = 0
    self.state.files_skipped = 0

    # Counter to batch up hash checking in the filestore
    self.state.files_hashed_since_check = 0

    # A dict of file trackers which are waiting to be checked by the file
    # store.  Keys are vfs urns and values are FileTrack instances.  Values are
    # copied to pending_files for download if not present in FileStore.
    self.state.pending_hashes = {}

    # A dict of file trackers currently being fetched. Keys are vfs urns and
    # values are FileTracker instances.
    self.state.pending_files = {}

    # The maximum number of files we are allowed to download concurrently.
    self.state.maximum_pending_files = maximum_pending_files

    # As pathspecs are added to the flow they are appended to this array. We
    # then simply pass their index in this array as a surrogate for the full
    # pathspec. This allows us to use integers to track pathspecs in dicts etc.
    self.state.indexed_pathspecs = []
    self.state.request_data_list = []

    # The index of the next pathspec to start. Pathspecs are added to
    # indexed_pathspecs and wait there until there are free trackers for
    # them. When the number of pending_files falls below the
    # "maximum_pending_files" count] = we increment this index and start of
    # downloading another pathspec.
    self.state.next_pathspec_to_start = 0

    # Number of blob hashes we have received but not yet scheduled for download.
    self.state.blob_hashes_pending = 0
142301
public function create()
	{
	    if(!$this->isFile($this->getName())){
            $this->createPath($this->path);
            $file = fopen($this->getName(), "w");
            fclose($file);
        }
	}
1288777
public boolean createFile() {
        try {
            try (FileWriter newDic = new FileWriter(path + "/" + name + "." + FILE_EXTENSION); BufferedWriter bufWriter = new BufferedWriter(newDic)) {
                bufWriter.write(HEAD);
                if (sentences.size() > 0) {
                    bufWriter.write("public <sentence> = (" + sentences.get(0));

                    for (int i = 1; i < sentences.size(); i++) {
                        bufWriter.write(" | " + sentences.get(i));
                    }
                    bufWriter.write(" );\n");
                }
                bufWriter.flush();
            }
            return true;
        } catch (IOException ex) {
            Logger.getLogger(GrammarFacilitator.class.getName()).log(Level.SEVERE, null, ex);
        }
        return false;
    }
38638
@Override
	public void restart() {
		try {
			if (fileReader != null) {
				fileReader.close();
			}
			InputStream fileStream = new FileInputStream(
					this.csvFileOption.getFile());
			this.fileProgressMonitor = new InputStreamProgressMonitor(
					fileStream);
			this.fileReader = new BufferedReader(new InputStreamReader(
					fileProgressMonitor));

			String line;
			do {
				line = this.fileReader.readLine();
				if (line == null) {
					break;
				}
				line = line.trim();
			} while (line.isEmpty() || line.charAt(0) == '%'
					|| line.charAt(0) == '@');

			if (line != null) {
				StringTokenizer token = new StringTokenizer(line,
						splitCharOption.getValue());
				this.numTokens = token.countTokens();
				this.numAttributes = this.numTokens
						- (classIndexOption.isSet() ? 1 : 0) + 1;

				ArrayList<Attribute> attributes = new ArrayList<Attribute>(
						this.numAttributes);
				for (int i = 1; i < this.numAttributes; i++) {
					attributes.add(new Attribute("Dim " + i));
				}
				ArrayList<String> classLabels = new ArrayList<String>();
				classLabels.add("0");
		        attributes.add(new Attribute("class", classLabels));
				this.dataset = new Instances(csvFileOption.getFile().getName(),
						attributes, 0);
				this.dataset.setClassIndex(this.numAttributes - 1);
				numAttsOption = new IntOption("numAtts", 'a', "",
						this.numAttributes);

				double[] value = new double[this.numAttributes];
				for (int i = 0; i < this.numTokens && token.hasMoreTokens(); i++) {
					value[i] = Double.valueOf(token.nextToken());
				}
				this.lastInstanceRead = new InstanceExample(new DenseInstance(1, value));
				this.lastInstanceRead.getData().setDataset(this.dataset);
				this.numInstancesRead = 0;
				this.hitEndOfFile = false;
			} else {
				this.lastInstanceRead = null;
				this.numInstancesRead = 0;
				this.hitEndOfFile = true;
			}
		} catch (IOException ioe) {
			throw new RuntimeException("SimpleCSVStream restart failed.", ioe);
		}
	}
1073757
public static synchronized File createSwapFile() throws IOException {
		File swapFile = createSwapFile(SWAP_FILE_PREFIX, SWAP_FILE_SUFFIX);
		// works reliably only on Unix platforms!
		swapFile.deleteOnExit();
		return swapFile;
	}
563710
def lifecycle
      # Create a new metric to hold the task and conditions.
      m = Metric.new(self)

      # Let the config file define some conditions on the metric.
      yield(m)

      # Populate the condition -> metric directory.
      m.conditions.each do |c|
        self.directory[c] = m
      end

      # Record the metric.
      self.metrics[nil] << m
    end
1254060
private void init() throws IOException {
        if (initialized.compareAndSet(false, true)) {
            log.debug("Init: {}", mode);
            // instance an executor for queue handling
            scheduledExecutorService = Executors.newScheduledThreadPool(schedulerThreadSize, new CustomizableThreadFactory("FileConsumerExecutor-"));
            // if the path is null, the consumer has been uninitialized
            if (path != null) {
                if (log.isDebugEnabled()) {
                    Path parent = path.getParent();
                    log.debug("Parent abs: {} dir: {}", parent.isAbsolute(), Files.isDirectory(parent));
                }
                if (IClientStream.MODE_APPEND.equals(mode)) {
                    if (Files.notExists(path)) {
                        throw new IOException("File to be appended doesnt exist, verify the record mode");
                    }
                    log.debug("Path: {}\nRead: {} write: {} size: {}", path, Files.isReadable(path), Files.isWritable(path), Files.size(path));
                    writer = new FLVWriter(path, true);
                } else if (IClientStream.MODE_RECORD.equals(mode)) {
                    try {
                        // delete existing file
                        if (Files.deleteIfExists(path)) {
                            log.debug("File deleted");
                        }
                        // ensure parent dirs exist
                        Files.createDirectories(path.getParent());
                        // create the file
                        path = Files.createFile(path);
                    } catch (IOException ioe) {
                        log.error("File creation error: {}", ioe);
                    }
                    if (!Files.isWritable(path)) {
                        throw new IOException("File is not writable");
                    }
                    log.debug("Path: {}\nRead: {} write: {}", path, Files.isReadable(path), Files.isWritable(path));
                    writer = new FLVWriter(path, false);
                    if (audioConfigurationTag != null) {
                        writer.writeTag(audioConfigurationTag);
                    }
                    if (videoConfigurationTag != null) {
                        writer.writeTag(videoConfigurationTag);
                        gotVideoKeyframe = true;
                    }
                } else {
                    //throw new IllegalStateException(String.format("Illegal mode type: %s", mode));
                    try {
                        // delete existing file since we're not recording nor appending
                        if (Files.deleteIfExists(path)) {
                            log.debug("File deleted");
                        }
                    } catch (IOException ioe) {
                        log.error("File creation error: {}", ioe);
                    }
                }
            } else {
                log.warn("Consumer is uninitialized");
            }
            log.debug("Init - complete");
        }
    }
329848
public static boolean createFile(File targetFile) {
        if (targetFile.exists()) {
            if (targetFile.isFile()) return true;
            delFileOrFolder(targetFile);
        }
        try {
            return targetFile.createNewFile();
        } catch (IOException e) {
            return false;
        }
    }
910443
private void optimizeStart() {
		if (configuration.isPayloadCache()) {

			if (configuration.getOptimizerStoreClass() == null) {
				store = new CacheOptimizerStore();
				store.start(configuration);
				return;
			}

			try {
				store = (OptimizerStore) Class.forName(configuration.getOptimizerStoreClass()).newInstance();
				store.start(configuration);
			} catch (ClassNotFoundException cnfe) {
				LOGGER.warn("Unable to find the class {}. The payload will be sent without optimizations.", configuration.getOptimizerStoreClass());
			} catch (InstantiationException ex) {
				LOGGER.warn("Unable to instantiate the class {}. Concrete class required.", configuration.getOptimizerStoreClass());
			} catch (IllegalAccessException ex) {
				LOGGER.warn("Unable to instantiate the class {}. Empty constructor required.", configuration.getOptimizerStoreClass());
			}
		}
	}
298914
@Override
    public void     start() throws Exception
    {
        if ( !state.compareAndSet(State.LATENT, State.STARTED) )
        {
            throw new IllegalStateException();
        }

        try
        {
            client.create().creatingParentContainersIfNeeded().forPath(queuePath);
        }
        catch ( KeeperException.NodeExistsException ignore )
        {
            // this is OK
        }
        if ( lockPath != null )
        {
            try
            {
                client.create().creatingParentContainersIfNeeded().forPath(lockPath);
            }
            catch ( KeeperException.NodeExistsException ignore )
            {
                // this is OK
            }
        }

        if ( !isProducerOnly || (maxItems != QueueBuilder.NOT_SET) )
        {
            childrenCache.start();
        }

        if ( !isProducerOnly )
        {
            service.submit
                (
                    new Callable<Object>()
                    {
                        @Override
                        public Object call()
                        {
                            runLoop();
                            return null;
                        }
                    }
                );
        }
    }
669183
def WriteTaskStart(self):
    
    self._RaiseIfNotWritable()

    if self._storage_type != definitions.STORAGE_TYPE_TASK:
      raise IOError('Unsupported storage type.')

    task_start = self._task.CreateTaskStart()
    self._storage_file.WriteTaskStart(task_start)