Package cl.alma.camel.acslog

Source Code of cl.alma.camel.acslog.ACSLogConsumerLC

package cl.alma.camel.acslog;

import org.apache.camel.Processor;

import com.cosylab.logging.engine.ACS.ACSLogConnectionListener;
import com.cosylab.logging.engine.ACS.LCEngine;

/**
* This class consume ACS logs from the logging channel.
* Inherit jLog classes in order to connect to ACS, must be defined
* -DACS.manager=$MANAGER_REFERENCE
* if -DACS.tmp=$ACS_TMP is defined, also should be as well:
* -Djlog.cache.size=4096 -Djlog.cache.writebuffersize=1024
*
* @author atejeda
*/
public class ACSLogConsumerLC extends ACSLogConsumer implements ACSLogConnectionListener {

  private LCEngine engine = null;
  private boolean isConnected = false;
 
  /*
   * @param endpoint
   * @param processor
   */
    public ACSLogConsumerLC(ACSLogEndpoint endpoint, Processor processor) {
        super(endpoint, processor);
    }
   
  public void connect() {
    try {
      log.info("connecting...");
      getEngine().connect("ACS");
      getEngine().enableAutoReconnection(true);
      getEngine().setDiscardLevel(this.getLogDiscardLevel());
      getEngine().setAudience(this.getAudience());
    } catch (java.lang.Throwable ivjExc) {
      handleException(ivjExc);
    }
  }
 
  public void disconnect() {
    log.info("disconnecting...");
    getEngine().disconnect();
  }

  public LCEngine getEngine() {
    if (this.engine == null) {
      try {
        this.engine = new LCEngine();
        this.engine.addLogConnectionListener(this);
        this.engine.addLogListener(this);
        this.engine.addLogErrorListener(this);
      } catch (java.lang.Throwable ivjExc) {
        handleException(ivjExc);
      }
    }
    return this.engine;
  }
 
  /**
     * Start the common validation files and reading process
     * of the log, if is a file, or the logs located at that directory.
     *
     * Invoke {@link #doStop()} whe all logs files were processed.
     */
    @Override
    protected void doStart() throws Exception {
      this.connect();
    }
 
  public void errorReceived(String xml) {
    log.error("error received, not connected to ACS logging");
  }

  public void acsLogConnEstablished() {
    log.info("ACS loggin connection established");
    this.isConnected = true;
  }

  public void acsLogConnDisconnected() {
    log.info("Disconnected from ACS logging");
    this.isConnected = false;
  }

  public void acsLogConnLost() {
    log.error("ACS logging connection lost");
    this.isConnected = false;
  }

  public void acsLogConnConnecting() {
    log.info("Connecting to ACS logging");
  }

  public void acsLogConnSuspended() {
    log.warn("ACS logging connection suspended");
  }

  public void acsLogsDelay() {
    log.warn("Delay in ACS logging");
  }

  public void reportStatus(String status) {
    log.info(status);
  }
}
TOP

Related Classes of cl.alma.camel.acslog.ACSLogConsumerLC

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.