Package org.apache.hadoop.chukwa.datacollection.adaptor

Examples of org.apache.hadoop.chukwa.datacollection.adaptor.Adaptor


      String dataType = m.group(3);
      String params = m.group(4);
      if (params == null)
        params = "";
     
      Adaptor adaptor = AdaptorFactory.createAdaptor(adaptorClassName);
      if (adaptor == null) {
        log.warn("Error creating adaptor of class " + adaptorClassName);
        throw new AdaptorException("Can't load class " + adaptorClassName);
      }
      String coreParams = adaptor.parseArgs(dataType,params,this);
      if(coreParams == null) {
        log.warn("invalid params for adaptor: " + params);      
        throw new AdaptorException("invalid params for adaptor: " + params);
      }
     
      if(adaptorID == null) { //user didn't specify, so synthesize
        try {
         adaptorID = AdaptorNamingUtils.synthesizeAdaptorID(adaptorClassName, dataType, coreParams);
        } catch(NoSuchAlgorithmException e) {
          log.fatal("MD5 apparently doesn't work on your machine; bailing", e);
          shutdown(true);
        }
      } else if(!adaptorID.startsWith("adaptor_"))
        adaptorID = "adaptor_"+adaptorID;
     
      synchronized (adaptorsByName) {
       
        if(adaptorsByName.containsKey(adaptorID))
          return adaptorID;
        adaptorsByName.put(adaptorID, adaptor);
        adaptorPositions.put(adaptor, new Offset(offset, adaptorID));
        needNewCheckpoint = true;
        try {
          adaptor.start(adaptorID, dataType, offset, DataFactory
              .getInstance().getEventQueue());
          log.info("started a new adaptor, id = " + adaptorID + " function=["+adaptor.toString()+"]");
          ChukwaAgent.agentMetrics.adaptorCount.set(adaptorsByName.size());
          ChukwaAgent.agentMetrics.addedAdaptor.inc();
          return adaptorID;

        } catch (Exception e) {
          Adaptor failed = adaptorsByName.remove(adaptorID);
          adaptorPositions.remove(failed);
          adaptorStatsManager.remove(failed);
          log.warn("failed to start adaptor", e);
          if(e instanceof AdaptorException)
            throw (AdaptorException)e;
View Full Code Here


   * @param name the adaptor to stop
   * @param shutdownMode if true, shutdown, if false, hardStop
   * @return the number of bytes synched at stop. -1 on error
   */
  public long stopAdaptor(String name, AdaptorShutdownPolicy shutdownMode) {
    Adaptor toStop;
    long offset = -1;

    // at most one thread can get past this critical section with toStop != null
    // so if multiple callers try to stop the same adaptor, all but one will
    // fail
    synchronized (adaptorsByName) {
      toStop = adaptorsByName.remove(name);
    }
    if (toStop == null) {
      log.warn("trying to stop " + name + " that isn't running");
      return offset;
    } else {
      adaptorPositions.remove(toStop);
      adaptorStatsManager.remove(toStop);
    }
    ChukwaAgent.agentMetrics.adaptorCount.set(adaptorsByName.size());
    ChukwaAgent.agentMetrics.removedAdaptor.inc();
   
    try {
      offset = toStop.shutdown(shutdownMode);
      log.info("shutdown ["+ shutdownMode + "] on " + name + ", "
          + toStop.getCurrentStatus());
    } catch (AdaptorException e) {
      log.error("adaptor failed to stop cleanly", e);
    } finally {
      needNewCheckpoint = true;
    }
View Full Code Here

    public void run() {
      long now = System.currentTimeMillis();

      for(String adaptorId : getAdaptorList().keySet()) {
        Adaptor adaptor = getAdaptor(adaptorId);
        if(adaptor == null) continue;

        Offset offset = adaptorPositions.get(adaptor);
        if(offset == null) continue;
View Full Code Here

    if (adaptorId == null) {
      Map<String, String> adaptorMap = agent.getAdaptorList();
      appendStartTag(out, "Adaptors", "total", adaptorMap.size());

      for (String name : adaptorMap.keySet()) {
        Adaptor adaptor = agent.getAdaptor(name);
        appendAdaptorXML(out, agent, adaptor);
      }

      appendEndTag(out, "Adaptors");
    }
    else {
      Adaptor adaptor = agent.getAdaptor(adaptorId);
      if (adaptor != null) {
        appendAdaptorXML(out, agent, adaptor);
      }
      else {
        appendElement(out, "Error", "Invalid adaptor id: " + adaptorId);
View Full Code Here

      appendNvp(out, indent, "adaptor_count", adaptorMap.size());
      appendNvp(out, indent, "adaptors", "");

      indent += 4;
      for(String name : adaptorMap.keySet()) {
        Adaptor adaptor = agent.getAdaptor(name);
        appendAdaptorText(out, indent, agent, adaptor);
      }
    }
    else {
      Adaptor adaptor = agent.getAdaptor(adaptorId);
      if (adaptor != null) {
        appendNvp(out, indent, "adaptor", "");
        indent += 4;
        appendAdaptorText(out, indent, agent, adaptor);
      }
View Full Code Here

    ArrayList<String> collectors = new ArrayList<String>();
    collectors.add("http://somehost.invalid/chukwa");
    send.setCollectors(new RetryListOfCollectors(collectors, conf));
   
    byte[] data = "sometestdata".getBytes();
    Adaptor a = new FileTailingAdaptor();
    ChunkImpl ci = new ChunkImpl("testtype", "sname", data.length, data, a);
    ArrayList<Chunk> toSend = new ArrayList<Chunk>();
    toSend.add(ci);
    try {
      List<CommitListEntry> resp = send.send(toSend);
View Full Code Here

      ConsoleOutConnector conn = new ConsoleOutConnector(agent, true);
      conn.start();
      String l = agent
          .processAddCommand("ADD org.apache.hadoop.chukwa.datacollection.adaptor.ChukwaTestAdaptor  chukwaTestAdaptorType 0 my param1 param2 /var/log/messages 114027");
      assertTrue(l != null);
      Adaptor adaptor = agent.getAdaptor(l);
      ChukwaTestAdaptor chukwaTestAdaptor = (ChukwaTestAdaptor) adaptor;
      assertTrue("error in type",
          "chukwaTestAdaptorType".intern() == chukwaTestAdaptor.getType()
              .intern());
      assertTrue("error in param", "0 my param1 param2 /var/log/messages"
View Full Code Here

      ConsoleOutConnector conn = new ConsoleOutConnector(agent, true);
      conn.start();
      String name = agent
          .processAddCommand("ADD org.apache.hadoop.chukwa.datacollection.adaptor.ChukwaTestAdaptor  chukwaTestAdaptorType 114027");
      assertTrue(name != null);
      Adaptor adaptor = agent.getAdaptor(name);
      ChukwaTestAdaptor chukwaTestAdaptor = (ChukwaTestAdaptor) adaptor;
      assertTrue("error in type",
          "chukwaTestAdaptorType".intern() == chukwaTestAdaptor.getType()
              .intern());
      assertTrue("error in param", "".intern() == chukwaTestAdaptor.getParams()
View Full Code Here

      conn.start();
      String n = agent
          .processAddCommand("ADD org.apache.hadoop.chukwa.datacollection.adaptor.ChukwaTestAdaptor"
              + "  chukwaTestAdaptorType 0  114027");
      assertTrue(n != null);
      Adaptor adaptor = agent.getAdaptor(n);
      ChukwaTestAdaptor chukwaTestAdaptor = (ChukwaTestAdaptor) adaptor;
      assertTrue("error in type",
          "chukwaTestAdaptorType".intern() == chukwaTestAdaptor.getType()
              .intern());
      assertTrue("error in param", "0".intern() == chukwaTestAdaptor
View Full Code Here

      ConsoleOutConnector conn = new ConsoleOutConnector(agent, true);
      conn.start();
      String l = agent
          .processAddCommand("ADD org.apache.hadoop.chukwa.datacollection.adaptor.ChukwaTestAdaptor  chukwaTestAdaptorType 0 my param1 param2 /var/log/messages 114027");
      assertTrue(l != null);
      Adaptor adaptor = agent.getAdaptor(l);
      ChukwaTestAdaptor chukwaTestAdaptor = (ChukwaTestAdaptor) adaptor;
      assertTrue("error in type",
          "chukwaTestAdaptorType".intern() == chukwaTestAdaptor.getType()
              .intern());
      assertTrue("error in param", "0 my param1 param2 /var/log/messages"
View Full Code Here

TOP

Related Classes of org.apache.hadoop.chukwa.datacollection.adaptor.Adaptor

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.