Search in sources :

Example 1 with JSON

use of org.eclipse.jetty.util.ajax.JSON in project hadoop by apache.

the class AzureNativeFileSystemStore method createPermissionJsonSerializer.

/**
   * Creates a JSON serializer that can serialize a PermissionStatus object into
   * the JSON string we want in the blob metadata.
   * 
   * @return The JSON serializer.
   */
private static JSON createPermissionJsonSerializer() {
    JSON serializer = new JSON();
    serializer.addConvertor(PermissionStatus.class, new PermissionStatusJsonSerializer());
    return serializer;
}
Also used : JSON(org.eclipse.jetty.util.ajax.JSON)

Example 2 with JSON

use of org.eclipse.jetty.util.ajax.JSON in project hadoop by apache.

the class MiniHadoopClusterManager method start.

/**
   * Starts DFS and MR clusters, as specified in member-variable options. Also
   * writes out configuration and details, if requested.
   *
   * @throws IOException
   * @throws FileNotFoundException
   * @throws URISyntaxException
   */
public void start() throws IOException, FileNotFoundException, URISyntaxException {
    if (!noDFS) {
        dfs = new MiniDFSCluster.Builder(conf).nameNodePort(nnPort).nameNodeHttpPort(nnHttpPort).numDataNodes(numDataNodes).startupOption(dfsOpts).build();
        LOG.info("Started MiniDFSCluster -- namenode on port " + dfs.getNameNodePort());
    }
    if (!noMR) {
        if (fs == null && dfs != null) {
            fs = dfs.getFileSystem().getUri().toString();
        } else if (fs == null) {
            fs = "file:///tmp/minimr-" + System.nanoTime();
        }
        FileSystem.setDefaultUri(conf, new URI(fs));
        // Instruct the minicluster to use fixed ports, so user will know which
        // ports to use when communicating with the cluster.
        conf.setBoolean(YarnConfiguration.YARN_MINICLUSTER_FIXED_PORTS, true);
        conf.setBoolean(JHAdminConfig.MR_HISTORY_MINICLUSTER_FIXED_PORTS, true);
        conf.set(YarnConfiguration.RM_ADDRESS, MiniYARNCluster.getHostname() + ":" + this.rmPort);
        conf.set(JHAdminConfig.MR_HISTORY_ADDRESS, MiniYARNCluster.getHostname() + ":" + this.jhsPort);
        mr = MiniMRClientClusterFactory.create(this.getClass(), numNodeManagers, conf);
        LOG.info("Started MiniMRCluster");
    }
    if (writeConfig != null) {
        FileOutputStream fos = new FileOutputStream(new File(writeConfig));
        conf.writeXml(fos);
        fos.close();
    }
    if (writeDetails != null) {
        Map<String, Object> map = new TreeMap<String, Object>();
        if (dfs != null) {
            map.put("namenode_port", dfs.getNameNodePort());
        }
        if (mr != null) {
            map.put("resourcemanager_port", mr.getConfig().get(YarnConfiguration.RM_ADDRESS).split(":")[1]);
        }
        FileWriter fw = new FileWriter(new File(writeDetails));
        fw.write(new JSON().toJSON(map));
        fw.close();
    }
}
Also used : OptionBuilder(org.apache.commons.cli.OptionBuilder) FileOutputStream(java.io.FileOutputStream) FileWriter(java.io.FileWriter) JSON(org.eclipse.jetty.util.ajax.JSON) TreeMap(java.util.TreeMap) URI(java.net.URI) File(java.io.File)

Example 3 with JSON

use of org.eclipse.jetty.util.ajax.JSON in project hadoop by apache.

the class MiniDFSClusterManager method start.

/**
   * Starts DFS as specified in member-variable options. Also writes out
   * configuration and details, if requested.
   */
public void start() throws IOException, FileNotFoundException {
    dfs = new MiniDFSCluster.Builder(conf).nameNodePort(nameNodePort).nameNodeHttpPort(nameNodeHttpPort).numDataNodes(numDataNodes).startupOption(dfsOpts).format(format).build();
    dfs.waitActive();
    LOG.info("Started MiniDFSCluster -- namenode on port " + dfs.getNameNodePort());
    if (writeConfig != null) {
        FileOutputStream fos = new FileOutputStream(new File(writeConfig));
        conf.writeXml(fos);
        fos.close();
    }
    if (writeDetails != null) {
        Map<String, Object> map = new TreeMap<String, Object>();
        if (dfs != null) {
            map.put("namenode_port", dfs.getNameNodePort());
        }
        FileWriter fw = new FileWriter(new File(writeDetails));
        fw.write(new JSON().toJSON(map));
        fw.close();
    }
}
Also used : MiniDFSCluster(org.apache.hadoop.hdfs.MiniDFSCluster) FileOutputStream(java.io.FileOutputStream) FileWriter(java.io.FileWriter) JSON(org.eclipse.jetty.util.ajax.JSON) TreeMap(java.util.TreeMap) File(java.io.File)

Aggregations

JSON (org.eclipse.jetty.util.ajax.JSON)3 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 FileWriter (java.io.FileWriter)2 TreeMap (java.util.TreeMap)2 URI (java.net.URI)1 OptionBuilder (org.apache.commons.cli.OptionBuilder)1 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)1