Exemplo n.º 1
0
 public EventResult action() throws EventExecutionException {
   logger.debug(
       "Processing a chart creation event - id: "
           + getId()
           + " - collector name: "
           + getCollector().getName());
   HashMap<String, String> params = new HashMap<String, String>();
   for (Object o : getCollector().getParam()) {
     Param param = (Param) o;
     params.put(param.getName(), param.getValue());
   }
   Chart chart = null;
   try {
     chart = new Chart(getCollector().getName(), params);
     ChartManager.getInstance().addChart(getId(), chart);
   } catch (ChartParameterException e) {
     logger.error("Exception in chart parameters.");
     throw new EventExecutionException(e);
   }
   logger.info("Chart created.");
   return new EventResult(chart);
 }
Exemplo n.º 2
0
  public ChartCreation(String id, String collectorName, HashMap<String, String> params) {
    setId(id);

    try {
      ObjectFactory factory = new ObjectFactory();
      CollectorType collector = factory.createChartCreationTypeCollectorType();
      setCollector(collector);
      collector.setName(collectorName);
      if (params == null) {
        return;
      }
      for (Entry<String, String> entry : params.entrySet()) {
        Param param = factory.createParam();
        param.setName(entry.getKey());
        param.setValue(entry.getValue());
        collector.getParam().add(param);
      }
    } catch (JAXBException e) {
      logger.error("JAXBException in constructor of ChartCreation. Message: " + e.getMessage());
      if (logger.isDebugEnabled()) {
        e.printStackTrace();
      }
    }
  }