Package com.googlecode.jmxtrans.exceptions

Examples of com.googlecode.jmxtrans.exceptions.LifecycleException


   *
   * @throws LifecycleException the lifecycle exception
   */
  public synchronized void start() throws LifecycleException {
    if (isRunning) {
      throw new LifecycleException("Process already started");
    } else {
      log.info("Starting Jmxtrans on : " + this.configuration.getJsonDirOrFile().toString());
      try {
        this.serverScheduler.start();

        this.startupWatchdir();

        this.startupSystem();

      } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new LifecycleException(e);
      }

      // Ensure resources are free
      Runtime.getRuntime().addShutdownHook(shutdownHook);
      isRunning = true;
View Full Code Here


   *
   * @throws LifecycleException the lifecycle exception
   */
  public synchronized void stop() throws LifecycleException {
    if (!isRunning) {
      throw new LifecycleException("Process already stoped");
    } else {
      try {
        log.info("Stopping Jmxtrans");

        // Remove hook to not call twice
        if (shutdownHook != null) {
          Runtime.getRuntime().removeShutdownHook(shutdownHook);
        }

        this.stopServices();
        isRunning = false;
      } catch (LifecycleException e) {
        log.error(e.getMessage(), e);
        throw new LifecycleException(e);
      }
    }
  }
View Full Code Here

      // Shutdown the outputwriters
      this.stopWriterAndClearMasterServerList();

    } catch (Exception e) {
      log.error(e.getMessage(), e);
      throw new LifecycleException(e);
    }
  }
View Full Code Here

    // start when re-reading the json config files
    try {
      this.stopWriterAndClearMasterServerList();
    } catch (Exception e) {
      log.error("Error while clearing master server list: " + e.getMessage(), e);
      throw new LifecycleException(e);
    }

    for (File jsonFile : getJsonFiles()) {
      JmxProcess process;
      try {
        process = JsonUtils.getJmxProcess(jsonFile);
        if (log.isDebugEnabled()) {
          log.debug("Loaded file: " + jsonFile.getAbsolutePath());
        }
        this.masterServersList = mergeServerLists(this.masterServersList, process.getServers());
      } catch (Exception ex) {
        if (configuration.isContinueOnJsonError()) {
          throw new LifecycleException("Error parsing json: " + jsonFile, ex);
        } else {
          // error parsing one file should not prevent the startup of JMXTrans
          log.error("Error parsing json: " + jsonFile, ex);
        }
      }
View Full Code Here

        this.validateSetup(server, server.getQueries());

        // Now schedule the jobs for execution.
        this.scheduleJob(server);
      } catch (ParseException ex) {
        throw new LifecycleException("Error parsing cron expression: " + server.getCronExpression(), ex);
      } catch (SchedulerException ex) {
        throw new LifecycleException("Error scheduling job for server: " + server, ex);
      } catch (ValidationException ex) {
        throw new LifecycleException("Error validating json setup for query", ex);
      }
    }
  }
View Full Code Here

    }
    if (jexlExpr != null) {
      try {
        this.metricNameStrategy = new JexlNamingStrategy(jexlExpr);
      } catch (JexlException jexlExc) {
        throw new LifecycleException("failed to setup naming strategy", jexlExc);
      }
    } else {
      this.metricNameStrategy = new ClassAttributeNamingStrategy();
    }
View Full Code Here

   */
  @Override
  public void prepareSender() throws LifecycleException {

    if (host == null || port == null) {
      throw new LifecycleException("Host and port for " + this.getClass().getSimpleName() + " output can't be null");
    }

    try {
      this.dgSocket = new DatagramSocket();
      this.address = new InetSocketAddress(host, port);
    } catch (SocketException sockExc) {
      log.error("Failed to create a datagram socket", sockExc);
      throw new LifecycleException(sockExc);
    }
  }
View Full Code Here

   */
  @Override
  protected void prepareSender() throws LifecycleException {

    if (host == null || port == null) {
      throw new LifecycleException("Host and port for " + this.getClass().getSimpleName() + " output can't be null");
    }

    try {
      socket = new Socket(host, port);
    } catch (UnknownHostException e) {
      log.error("error opening socket to OpenTSDB", e);
      throw new LifecycleException(e);
    } catch (IOException e) {
      log.error("error opening socket to OpenTSDB", e);
      throw new LifecycleException(e);
    }
  }
View Full Code Here

  protected void shutdownSender() throws LifecycleException {
    try {
      socket.close();
    } catch (IOException e) {
      log.error("error closing socket to OpenTSDB", e);
      throw new LifecycleException(e);
    }
  }
View Full Code Here

      this.mbean = new ManagedGenericKeyedObjectPool((GenericKeyedObjectPool) pool, "StatsdConnectionPool");
      ManagementFactory.getPlatformMBeanServer()
          .registerMBean(this.mbean, this.mbean.getObjectName());
    } catch (Exception e) {
      throw new LifecycleException(e);
    }
  }
View Full Code Here

TOP

Related Classes of com.googlecode.jmxtrans.exceptions.LifecycleException

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.