Package org.apache.hadoop.chukwa.util

Examples of org.apache.hadoop.chukwa.util.DatabaseWriter


            try {
                String cluster = System.getProperty("CLUSTER");
                if(cluster==null) {
                    cluster="unknown";
                }
                db = new DatabaseWriter(cluster);
                DatabaseMetaData dbMetaData = db.getConnection().getMetaData();
                ResultSet rs = dbMetaData.getColumns ( null,null,table[0], null);
                boolean first=true;
                while(rs.next()) {
                    if(!first) {
View Full Code Here


    /*
     * find by timestamp
     */
    public static DfsFsNameSystem find(String timestamp) {
  String cluster = getCluster();
  DatabaseWriter dbw = new DatabaseWriter(cluster);

  if (timestamp != null) {
      // get simple value
            try {
    String query = getSingleQuery(DfsFsNameSystemHome.table,"timestamp",timestamp);
        ResultSet rs = dbw.query(query);
        if (rs.next()) {
        DfsFsNameSystem obj = createDfsFsNameSystem(rs);
        return obj;
    }
      } catch (Exception e) {
View Full Code Here

    /*
     * find by key
     */
    public static DfsFsNameSystem find(String timestamp, String host) {
  String cluster = getCluster();
  DatabaseWriter dbw = new DatabaseWriter(cluster);

  if (timestamp != null) {
      // get simple value
            try {
    Map<String, String> criteriaMap = new HashMap<String,String>();
    criteriaMap.put("timestamp",convertLongToDateString(Long.parseLong(timestamp)));
    criteriaMap.put("host",host);

    String query = getCriteriaQuery(DfsFsNameSystemHome.table,criteriaMap);
        ResultSet rs = dbw.query(query);
        if (rs.next()) {
        DfsFsNameSystem obj = createDfsFsNameSystem(rs);
        return obj;
    }
      } catch (Exception e) {
View Full Code Here

    /*
     * find within the start time and end time
     */
    public static Collection<DfsFsNameSystem> findBetween(String starttime, String endtime) {
  String cluster = getCluster();
  DatabaseWriter dbw = new DatabaseWriter(cluster);

  Collection<DfsFsNameSystem> collection = new Vector<DfsFsNameSystem>();

  try {
      String query = getTimeBetweenQuery(DfsFsNameSystemHome.table,starttime,endtime);     
      ResultSet rs = dbw.query(query);
      while (rs.next()) {
    DfsFsNameSystem obj = createDfsFsNameSystem(rs);
    collection.add(obj);
      }
  } catch (Exception e) {
View Full Code Here

  return obj;
    }
   
    public static MrTask find(String task_id) {
  String cluster = getCluster();
  DatabaseWriter dbw = new DatabaseWriter(cluster);

  if (task_id != null) {
      // get simple value
            try {
    String query = getSingleQuery(MrTaskHome.table,"task_id",task_id);
        ResultSet rs = dbw.query(query);
        if (rs.next()) {
        MrTask obj = createMrTask(rs);
        return obj;
    }
      } catch (Exception e) {
View Full Code Here

  return obj;
    }
   
    public static MrJob find(String job_id) {
  String cluster = getCluster();
  DatabaseWriter dbw = new DatabaseWriter(cluster);

  if (job_id != null) {
      // get simple value
            try {
    String query = getSingleQuery(MrJobHome.table,"job_id",job_id);
        ResultSet rs = dbw.query(query);
        if (rs.next()) {
        MrJob obj = createMrJob(rs);
        return obj;
    }
      } catch (Exception e) {
View Full Code Here

  return obj;
    }
   
    public static MrJobConf find(String job_id) {
  String cluster = getCluster();
  DatabaseWriter dbw = new DatabaseWriter(cluster);
 
  if (job_id != null) {
      // get simple value
            try {
    String query = getSingleQuery(MrJobConfHome.table,"job_id",job_id);
        ResultSet rs = dbw.query(query);
        if (rs.next()) {
        MrJobConf obj = createMrJobConf(rs);
        return obj;
    }
      } catch (Exception e) {
View Full Code Here

    } catch (AlreadyRunningException e) {
      fail("Chukwa Agent is already running");
    }
     
    System.setProperty("CLUSTER","demo");
    DatabaseWriter db = new DatabaseWriter(cluster);
    String buffer = "";
    File aFile = new File(System.getenv("CHUKWA_CONF_DIR")
                 + File.separator + "database_create_tables.sql");
    buffer = readFile(aFile);
    String tables[] = buffer.split(";");
    for(String table : tables) {
      if(table.length()>5) {
        try {
          db.execute(table);
        } catch (Exception e) {
          fail("Fail to retrieve meta data for database table: "+table);
        }
      }
    }
    db.close();
    for(int i=0;i<timeWindow.length;i++) {
      TableCreator tc = new TableCreator();
      long start = current;
      long end = current + (timeWindow[i]*1440*60*1000);
      try {
View Full Code Here

      Thread.sleep(2000);
    } catch(Exception e) {
      e.printStackTrace();
      fail(e.toString());
    }
    DatabaseWriter db = null;
    try {
      db = new DatabaseWriter(cluster);
      ResultSet rs = db.query("show tables");
      ArrayList<String> list = new ArrayList<String>();
      while(rs.next()) {
        String table = rs.getString(1);
        list.add(table);
      }
      for(String table : list) {
        db.execute("drop table "+table);
      }
    } catch(Throwable ex) {
    } finally {
      if(db!=null) {
        db.close();
      }
    }
  }
View Full Code Here

  return obj;
    }
   
    public static ClientTrace find(String timestamp) {
  String cluster = getCluster();
  DatabaseWriter dbw = new DatabaseWriter(cluster);

  if (timestamp != null) {
      // get simple value
            try {
    String query = getSingleQuery(ClientTraceHome.table,"timestamp",timestamp);
    log.error(query);
        ResultSet rs = dbw.query(query);
        if (rs.next()) {
        log.error("find it.");
        ClientTrace obj = createClientTrace(rs);
        return obj;
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.chukwa.util.DatabaseWriter

Copyright © 2018 www.massapicom. 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.