Given the current and final cluster dumps it into the output directory

@param currentCluster Initial cluster metadata
@param finalCluster Final cluster metadata
@param outputDirName Output directory where to dump this file
@throws IOException
557088
public static void dumpClusters(Cluster currentCluster,
                                    Cluster finalCluster,
                                    String outputDirName) {
        dumpClusters(currentCluster, finalCluster, outputDirName, "");
    }
90849
private void openOutputFile(final String outputFileName) throws IOException
	{
		myOutputFile = new File(outputFileName);
		myOutputStream = new FileOutputStream(myOutputFile);
		myStreamWriter = new OutputStreamWriter(myOutputStream, getOutputEncodingCode());
		myBufferedWriter = new BufferedWriter(myStreamWriter);
	}
279471
public void completeLocalOutput(Path fsOutputFile, Path tmpLocalFile)
    throws IOException {
    fs.completeLocalOutput(fsOutputFile, tmpLocalFile);
  }
205604
public static void main(String[] args) throws IOException {
        OptionParser parser = new OptionParser();
        parser.accepts("help", "print usage information");
        parser.accepts("cluster", "[REQUIRED] path to cluster xml config file")
              .withRequiredArg()
              .describedAs("cluster.xml");
        parser.accepts("stores", "[REQUIRED] path to stores xml config file")
              .withRequiredArg()
              .describedAs("stores.xml");
        parser.accepts("name", "[REQUIRED] store name").withRequiredArg().describedAs("store name");
        parser.accepts("buffer", "[REQUIRED] number of key/value pairs to buffer in memory")
              .withRequiredArg()
              .ofType(Integer.class);
        parser.accepts("input", "[REQUIRED] input file to read from")
              .withRequiredArg()
              .describedAs("input-file");
        parser.accepts("output", "[REQUIRED] directory to output stores to")
              .withRequiredArg()
              .describedAs("output directory");
        parser.accepts("threads", "number of threads").withRequiredArg().ofType(Integer.class);
        parser.accepts("chunks",
                       "number of chunks [per node, per partition, per partition + replica]")
              .withRequiredArg()
              .ofType(Integer.class);
        parser.accepts("io-buffer-size", "size of i/o buffers in bytes")
              .withRequiredArg()
              .ofType(Integer.class);
        parser.accepts("temp-dir", "temporary directory for sorted file pieces")
              .withRequiredArg()
              .describedAs("temp dir");
        parser.accepts("gzip", "compress intermediate chunk files");
        parser.accepts("format",
                       "read-only store format [" + ReadOnlyStorageFormat.READONLY_V0.getCode()
                               + "," + ReadOnlyStorageFormat.READONLY_V1.getCode() + ","
                               + ReadOnlyStorageFormat.READONLY_V2.getCode() + "]")
              .withRequiredArg()
              .ofType(String.class);
        OptionSet options = parser.parse(args);

        if(options.has("help")) {
            parser.printHelpOn(System.out);
            System.exit(0);
        }

        Set<String> missing = CmdUtils.missing(options,
                                               "cluster",
                                               "stores",
                                               "name",
                                               "buffer",
                                               "input",
                                               "output");
        if(missing.size() > 0) {
            System.err.println("Missing required arguments: " + Joiner.on(", ").join(missing));
            parser.printHelpOn(System.err);
            System.exit(1);
        }

        String clusterFile = (String) options.valueOf("cluster");
        String storeDefFile = (String) options.valueOf("stores");
        String storeName = (String) options.valueOf("name");
        int sortBufferSize = (Integer) options.valueOf("buffer");
        String inputFile = (String) options.valueOf("input");
        File outputDir = new File((String) options.valueOf("output"));
        int numThreads = CmdUtils.valueOf(options, "threads", 2);
        int chunks = CmdUtils.valueOf(options, "chunks", 2);
        int ioBufferSize = CmdUtils.valueOf(options, "io-buffer-size", 1000000);
        ReadOnlyStorageFormat storageFormat = ReadOnlyStorageFormat.fromCode(CmdUtils.valueOf(options,
                                                                                              "format",
                                                                                              ReadOnlyStorageFormat.READONLY_V2.getCode()));
        boolean gzipIntermediate = options.has("gzip");
        File tempDir = new File(CmdUtils.valueOf(options,
                                                 "temp-dir",
                                                 System.getProperty("java.io.tmpdir")));

        try {
            JsonReader reader = new JsonReader(new BufferedReader(new FileReader(inputFile),
                                                                  ioBufferSize));
            Cluster cluster = new ClusterMapper().readCluster(new BufferedReader(new FileReader(clusterFile)));
            StoreDefinition storeDef = null;
            List<StoreDefinition> stores = new StoreDefinitionsMapper().readStoreList(new BufferedReader(new FileReader(storeDefFile)));
            for(StoreDefinition def: stores) {
                if(def.getName().equals(storeName))
                    storeDef = def;
            }

            if(storeDef == null)
                Utils.croak("No store found with name \"" + storeName + "\"");

            if(!outputDir.exists())
                Utils.croak("Directory \"" + outputDir.getAbsolutePath() + "\" does not exist.");

            RoutingStrategy routingStrategy = new RoutingStrategyFactory().updateRoutingStrategy(storeDef,
                                                                                                 cluster);

            new JsonStoreBuilder(reader,
                                 cluster,
                                 storeDef,
                                 routingStrategy,
                                 outputDir,
                                 tempDir,
                                 sortBufferSize,
                                 numThreads,
                                 chunks,
                                 ioBufferSize,
                                 gzipIntermediate).build(storageFormat);
        } catch(FileNotFoundException e) {
            Utils.croak(e.getMessage());
        }
    }
114592
public void write(final File folder) throws IOException {
    try (final DataInputStream keyStream = entry.getKeyStream();
         final DataInputStream valueStream = entry.getValueStream();) {
      final String containerId = keyStream.readUTF();
      try (final Writer outputWriter = new OutputStreamWriter(
          new FileOutputStream(new File(folder, containerId + ".txt")), StandardCharsets.UTF_8)) {
        this.writeFiles(valueStream, outputWriter);
      }
    }
  }
118619
private void initOutputDir(File outputDir) {

        if (!outputDir.exists()) {
            if (!outputDir.mkdirs()) {
                throw new IllegalArgumentException("Output Directory "+outputDir+" could not be created");
            }
        }
        if (!outputDir.isDirectory() || (!outputDir.canWrite())) {
            throw new IllegalArgumentException("Output Directory "+outputDir+" is not a directory or cannot be written to.");
        }
    }
177526
protected void aggregateCluster(ClusKernel otherData, long currentTime,
            double negLambda) {
        this.getData().aggregate(otherData, currentTime - this.timestamp,
                negLambda);
        this.timestamp = currentTime;
    }
904997
public long allocAppend(long cluster)
            throws IOException {
        
        testCluster(cluster);
        
        while (!isEofCluster(entries[(int) cluster])) {
            cluster = entries[(int) cluster];
        }
        
        long newCluster = allocNew();
        entries[(int) cluster] = newCluster;

        return newCluster;
    }
814460
public void printClusteringCenters(Writer stream) throws IOException {
		if (center != null && getClusteringFeature() != null) {
			getClusteringFeature().printClusterCenter(stream);
		}
		for (ClusteringTreeNode child : children) {
			child.printClusteringCenters(stream);
		}
	}
390350
private void writeObject(ObjectOutputStream out) throws IOException {
		// serialize the parent fields and the final fields
		out.defaultWriteObject();

		// the job conf knows how to serialize itself
		jobConf.write(out);

		// write the input split
		hadoopInputSplit.write(out);
	}
1311046
public void gridToPmesh(String outPutFileName) {
        try {
            gridGenerator.writeGridInPmeshFormat(outPutFileName);
        } catch (IOException e) {
            logger.debug(e);
        }
    }
815257
private void writeObject(ObjectOutputStream out) throws IOException {
		out.writeUTF(hadoopOutputFormatName);
		jobConf.write(out);
		out.writeObject(converter);
		out.writeObject(fileOutputCommitterWrapper);
	}
838044
public static void main(String[] args) {

        final String clusterName = args[0];

        final DynoDistributedCounterDemo demo = new DynoDistributedCounterDemo(clusterName, "us-east-1e");
        int numCounters = (args.length == 2) ? Integer.valueOf(args[1]) : 1;

        try {
            demo.initWithRemoteClusterFromEurekaUrl(args[0], 8102);

            //demo.runMultiThreadedCounter(numCounters);
            //demo.runMultiThreadedPipelineCounter(numCounters);
            //demo.runSingleThreadedPipelineCounter();
            demo.runMultiThreadedBatchCounter(numCounters);

        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            demo.stop();
            System.out.println("Done");
        }
    }
416481
def output_clusters(labels, cluster_centers_indices):
    
            
    here = os.getcwd()
    try:
        output_directory = os.path.join(here, 'concurrent_AP_output')
        os.makedirs(output_directory)
    except OSError:
        if not os.path.isdir(output_directory):
            print("ERROR: concurrent_AP: output_clusters: cannot create a directory "
                  "for storage of the results of Affinity Propagation clustering "
                  "in your current working directory")
            sys.exit(1)
            
    if any(np.isnan(labels)):
        fmt = '%.1f'
    else:
        fmt = '%d'
                
    with open(os.path.join(output_directory, 'labels.tsv'), 'w') as fh:
        np.savetxt(fh, labels, fmt = fmt, delimiter = '\t')
        
    if cluster_centers_indices is not None:    
        with open(os.path.join(output_directory, 'cluster_centers_indices.tsv'), 'w') as fh:
            np.savetxt(fh, cluster_centers_indices, fmt = '%.1f', 
                       delimiter = '\t')
584235
protected OutputStream createOutputStream (File target)
        throws IOException
    {
        // make sure the parent directory exists
        target.getParentFile().mkdirs();
        // now create our file
        JarOutputStream jout = new JarOutputStream(new FileOutputStream(target));
        jout.setLevel(uncompressed() ? Deflater.NO_COMPRESSION : Deflater.BEST_COMPRESSION);
        return jout;
    }
34264
public void printClusterCenter(Writer stream) throws IOException {
		stream.write(String.valueOf(this.numPoints));
		for (int j = 0; j < this.sumPoints.length; j++) {
			stream.write(' ');
			stream.write(String.valueOf(this.sumPoints[j] / this.numPoints));
		}
		stream.write(System.getProperty("line.separator"));
	}
14415
public File outputDir(File src, File explicitOutputDir, String mapperName) throws IOException {
        File outputDir;
        int prev;
        int idx;
        File subDir;

        if (explicitOutputDir == null) {
            outputDir = src.getParentFile();
        } else {
            outputDir = explicitOutputDir;
            idx = mapperName.indexOf('.');
            prev = 0;
            while (idx != -1) {
                subDir = new File(outputDir, mapperName.substring(prev, idx));
                if (!subDir.isDirectory()) {
                    if (!subDir.mkdir()) {
                        throw new IOException("cannot create directory: " + subDir);
                    }
                }
                prev = idx + 1;
                idx = mapperName.indexOf('.', prev);
                outputDir = subDir;
            }
        }
        return outputDir;
    }