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

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


      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

      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);
        return null;
      }
      String coreParams = adaptor.parseArgs(params);
      if(coreParams == null) {
        log.warn("invalid params for adaptor: " + params);
        return null;
      }
     
      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);
        }
      }
     
      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(), this);
          log.info("started a new adaptor, id = " + adaptorID);
          ChukwaAgent.agentMetrics.adaptorCount.set(adaptorsByName.size());
          ChukwaAgent.agentMetrics.addedAdaptor.inc();
          return adaptorID;
View Full Code Here

   * @param number the adaptor to stop
   * @param gracefully if true, shutdown, if false, hardStop
   * @return the number of bytes synched at stop. -1 on error
   */
  public long stopAdaptor(String name, boolean gracefully) {
    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 adaptor " + name + " that isn't running");
      return offset;
    } else {
      adaptorPositions.remove(toStop);
    }
    ChukwaAgent.agentMetrics.adaptorCount.set(adaptorsByName.size());
    ChukwaAgent.agentMetrics.removedAdaptor.inc();
   
    try {
      if (gracefully) {
        offset = toStop.shutdown();
        log.info("shutdown on adaptor: " + name + ", "
            + toStop.getCurrentStatus());
      } else {
        toStop.hardStop();
        log.info("hardStop on adaptorId: " + name + ", "
            + toStop.getCurrentStatus());
      }
    } catch (AdaptorException e) {
      log.error("adaptor failed to stop cleanly", e);
    } finally {
      needNewCheckpoint = true;
View Full Code Here

      ConsoleOutConnector conn = new ConsoleOutConnector(agent, true);
      conn.start();
      long l = agent
          .processCommand("ADD org.apache.hadoop.chukwa.datacollection.adaptor.ChukwaTestAdaptor  chukwaTestAdaptorType 0 my param1 param2 /var/log/messages 114027");
      assertTrue(l != -1);
      Adaptor adaptor = agent.getAdaptorList().get(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();
      long l = agent
          .processCommand("ADD org.apache.hadoop.chukwa.datacollection.adaptor.ChukwaTestAdaptor  chukwaTestAdaptorType 114027");
      assertTrue(l != -1);
      Adaptor adaptor = agent.getAdaptorList().get(l);
      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();
      long l = agent
          .processCommand("ADD org.apache.hadoop.chukwa.datacollection.adaptor.ChukwaTestAdaptor"
              + "  chukwaTestAdaptorType 0  114027");
      assertTrue(l != -1);
      Adaptor adaptor = agent.getAdaptorList().get(l);
      ChukwaTestAdaptor chukwaTestAdaptor = (ChukwaTestAdaptor) adaptor;
      assertTrue("error in type",
          "chukwaTestAdaptorType".intern() == chukwaTestAdaptor.getType()
              .intern());
      assertTrue("error in param", "0".intern() == chukwaTestAdaptor
View Full Code Here

    ArrayList<String> collectors = new ArrayList<String>();
    collectors.add("http://somehost.invalid/chukwa");
    send.setCollectors(new RetryListOfCollectors(collectors, 1000));
   
    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

      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

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.