Example usage for org.apache.hadoop.conf Configuration dumpConfiguration

List of usage examples for org.apache.hadoop.conf Configuration dumpConfiguration

Introduction

In this page you can find the example usage for org.apache.hadoop.conf Configuration dumpConfiguration.

Prototype

public static void dumpConfiguration(Configuration config, Writer out) throws IOException 

Source Link

Document

Writes out all properties and their attributes (final and resource) to the given Writer , the format of the output would be,
 { "properties" : [ { key : "key1", value : "value1", isFinal : "key1.isFinal", resource : "key1.resource" }, { key : "key2", value : "value2", isFinal : "ke2.isFinal", resource : "key2.resource" } ] } 
It does not output the properties of the configuration object which is loaded from an input stream.

Usage

From source file:org.kiji.mapreduce.tools.KijiJobHistory.java

License:Apache License

/**
 * Prints a representation of the Configuration for the Job.
 * @param data A row data containing a serialization of the configuraton.
 * @throws IOException If there is an error retrieving the configuration.
 *//*from ww w. j  a va2s .c  o m*/
private void printConfiguration(KijiRowData data) throws IOException {
    OutputStreamWriter osw = null;
    try {
        PrintStream ps = getPrintStream();
        osw = new OutputStreamWriter(ps, "UTF-8");
        Configuration config = new Configuration();
        ByteBuffer configByteBuffer = data.getMostRecentValue("info", "configuration");
        config.readFields(new DataInputStream(new ByteArrayInputStream(configByteBuffer.array())));

        ps.print("Configuration:\n");
        Configuration.dumpConfiguration(config, osw);
        ps.print("\n");
    } finally {
        IOUtils.closeQuietly(osw);
    }
}

From source file:skewtune.mapreduce.STJobTracker.java

License:Apache License

/**
 * Dumps the configuration properties in Json format
 * /*from   w  w w  . j a  v  a 2 s .c o m*/
 * @param writer
 *            {@link}Writer object to which the output is written
 * @throws IOException
 */
private static void dumpConfiguration(Writer writer) throws IOException {
    Configuration.dumpConfiguration(new JobConf(), writer);
    writer.write("\n");
}

From source file:uk.ac.gla.terrier.probos.master.ProbosApplicationMasterServiceImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
public ProbosApplicationMasterServiceImpl(ApplicationMasterParameters parameters, Configuration _conf)
        throws Exception {
    super(parameters, _conf);
    LOG.info("Starting " + this.getClass().getSimpleName() + " on " + Utils.getHostname());

    Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials();
    probosTokens = new ArrayList<Token<ProbosDelegationTokenIdentifier>>();
    Iterator<Token<?>> iter = credentials.getAllTokens().iterator();
    LOG.info("Executing on " + Utils.getHostname() + " with tokens:");
    while (iter.hasNext()) {
        Token<?> token = iter.next();
        LOG.info(token.toString());//from w w w. ja  v a2 s . co  m
        if (token.getKind().equals(ProbosDelegationTokenIdentifier.KIND_NAME)) {
            probosTokens.add((Token<ProbosDelegationTokenIdentifier>) token);
        }
    }
    renewer = new ProbosTokenRenewer();

    this.conf = _conf;
    StringWriter sw = new StringWriter();
    Configuration.dumpConfiguration(conf, sw);
    //LOG.info("Master conf is " + sw.toString());

    for (String k : REQUIRED_ENV) {
        if (System.getenv(k) == null)
            throw new IllegalArgumentException("Env " + k + " must be set");
    }

    String hostPort = System.getenv("PBS_CONTROLLER");
    String[] hostPortSplit = hostPort.split(":");
    final String serverHostname = hostPortSplit[0];
    final int port = Integer.parseInt(hostPortSplit[1]);

    final InetSocketAddress server = new InetSocketAddress(serverHostname, port);
    masterClient = RPC.getProxy(PBSMasterClient.class, RPC.getProtocolVersion(PBSMasterClient.class), server,
            UserGroupInformation.getCurrentUser(), conf, NetUtils.getDefaultSocketFactory(conf));
    controllerClient = PBSClientFactory.getPBSClient();
    LOG.info("Connected to controller " + hostPort);

    jobId = Integer.parseInt(System.getenv("PBS_JOBID"));
    container = System.getenv("CONTAINER_ID");
    masterClient.jobEvent(jobId, EventType.MASTER_START, container, null);

    final List<Entry<String, HttpServlet>> masterServlets = new ArrayList<>();
    masterServlets.add(new MapEntry<String, HttpServlet>("/",
            new JobProgressServlet("./", masterServlets, controllerClient, this)));
    masterServlets.add(new MapEntry<String, HttpServlet>("/qstatjob",
            new QstatJobServlet("./qstatjob", masterServlets, controllerClient, this)));
    masterServlets.add(new MapEntry<String, HttpServlet>("/conf",
            new ConfServlet("./conf", masterServlets, controllerClient, this)));
    masterServlets.add(new MapEntry<String, HttpServlet>("/kittenconf",
            new KittenConfServlet("./kittenconf", masterServlets, controllerClient, this)));
    masterServlets.add(new MapEntry<String, HttpServlet>("/logs",
            new LogsServlet("./logs", masterServlets, controllerClient, this)));

    //0 means any random free port
    webServer = new WebServer("ProbosControllerHttp", masterServlets, 0);
    webServer.init(_conf);
}

From source file:uk.ac.gla.terrier.probos.master.webapp.ConfServlet.java

License:Open Source License

@Override
protected void getPreformattedContent(HttpServletRequest req, HttpServletResponse resp, PrintStream ps)
        throws ServletException, IOException {

    ps.println("<code class=\"json\">");
    Configuration.dumpConfiguration(pams.getConf(), new OutputStreamWriter(ps));
    ps.println("</code>");
}