Example usage for org.apache.hadoop.yarn.logaggregation LogAggregationUtils getRemoteNodeLogDirSuffix

List of usage examples for org.apache.hadoop.yarn.logaggregation LogAggregationUtils getRemoteNodeLogDirSuffix

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.logaggregation LogAggregationUtils getRemoteNodeLogDirSuffix.

Prototype

public static String getRemoteNodeLogDirSuffix(Configuration conf) 

Source Link

Document

Returns the suffix component of the log dir.

Usage

From source file:AggregatedLogsPurger.java

License:Apache License

@Override
public int run(String[] args) throws Exception {
    this.conf = getConf();
    this.deleteOlderThanDays = getConf().getInt("deleteOlderThan", 0);
    Preconditions.checkArgument(deleteOlderThanDays > 1,
            "Usage: yarn jar " + "./target/yarn-logs-purger-1.0-SNAPSHOT.jar -DdeleteOlderThan=300 "
                    + "-DdeleteFiles=true.  Please provide valid argument for deleteOlderThanDays. It has to "
                    + "be > 0");
    this.shouldDelete = getConf().getBoolean("deleteFiles", false);

    this.suffix = LogAggregationUtils.getRemoteNodeLogDirSuffix(conf);
    this.rootLogDir = new Path(
            conf.get(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, YarnConfiguration.DEFAULT_NM_REMOTE_APP_LOG_DIR));
    return (purge()) ? 0 : -1;
}

From source file:com.netflix.bdp.inviso.log.LogService.java

License:Apache License

@javax.ws.rs.Path("load/{owner}/{appId}/{containerId}/{nodeId}")
@GET/*from  w  w  w  .  j a v a2s.c  o m*/
@Produces("text/plain")
public Response log(@PathParam("owner") String owner, @PathParam("appId") String appId,
        @PathParam("containerId") String containerId, @PathParam("nodeId") String nodeId,
        @QueryParam("fs") String fs, @QueryParam("root") String root) throws IOException {

    Configuration conf = new Configuration();

    if (fs != null) {
        conf.set("fs.default.name", fs);
    }

    Path logRoot = new Path(
            conf.get(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, YarnConfiguration.DEFAULT_NM_REMOTE_APP_LOG_DIR));

    if (root != null) {
        logRoot = new Path(root);
    }

    Path logPath = LogAggregationUtils.getRemoteNodeLogFileForApp(logRoot,
            ConverterUtils.toApplicationId(appId), owner, ConverterUtils.toNodeId(nodeId),
            LogAggregationUtils.getRemoteNodeLogDirSuffix(conf));

    AggregatedLogFormat.LogReader reader = new AggregatedLogFormat.LogReader(conf, logPath);

    LogKey key = new LogKey();

    DataInputStream in = reader.next(key);

    while (in != null && !key.toString().equals(containerId)) {
        key = new LogKey();
        in = reader.next(key);
    }

    if (in == null) {
        throw new WebApplicationException(404);
    }

    final DataInputStream fin = in;

    StreamingOutput stream = new StreamingOutput() {
        @Override
        public void write(OutputStream os) throws IOException, WebApplicationException {
            PrintStream out = new PrintStream(os);

            while (true) {
                try {
                    LogReader.readAContainerLogsForALogType(fin, out);
                    out.flush();
                } catch (EOFException e) {
                    break;
                }
            }
        }
    };

    return Response.ok(stream).build();
}