Package org.apache.hadoop.chukwa.inputtools.plugin.metrics

Source Code of org.apache.hadoop.chukwa.inputtools.plugin.metrics.Exec

package org.apache.hadoop.chukwa.inputtools.plugin.metrics;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.chukwa.inputtools.plugin.ExecPlugin;
import org.apache.hadoop.chukwa.inputtools.plugin.IPlugin;
import org.json.JSONException;
import org.json.JSONObject;

public class Exec extends ExecPlugin
{
  private static Log log = LogFactory.getLog(Exec.class);
  private String cmde = null;
 
  public Exec(String[] cmds)
  {
    StringBuffer c = new StringBuffer();
    for(String cmd : cmds) {
      c.append(cmd);
      c.append(" ");
    }
    cmde = c.toString();
  }
 
  @Override
  public String getCmde()
  {
    return cmde;
  }

  public static void main(String[] args) throws JSONException
  {
    IPlugin plugin = new Exec(args);
    JSONObject result = plugin.execute();   
    if (result.getInt("status") < 0)
    {
      System.out.println("Error");
      log.warn("[ChukwaError]:"+ Exec.class + ", " + result.getString("stderr"));
      System.exit(-1);
    }
    else
    {
      log.info(result.get("stdout"));
    }
    System.exit(0);
  }
}
TOP

Related Classes of org.apache.hadoop.chukwa.inputtools.plugin.metrics.Exec

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.