Package com.quartz.monitor.object

Examples of com.quartz.monitor.object.QuartzInstance


                if (!fileList[i].isDirectory() && fileList[i].getName().startsWith("quartz-config-")){
                  try {
            QuartzConfig config = XstreamUtil.xml2Object(fileList[i].getAbsolutePath());
            QuartzInstanceContainer.addQuartzConfig(config);
            QuartzConnectService quartzConnectService = new QuartzConnectServiceImpl();
            QuartzInstance quartzInstance = quartzConnectService.initInstance(config);
            QuartzInstanceContainer.addQuartzInstance(config.getUuid(), quartzInstance);
          } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          } catch (Exception e) {
View Full Code Here


      JMXConnector connector = JMXConnectorFactory.connect(jmxServiceURL, env);
      MBeanServerConnection connection = connector.getMBeanServerConnection();

      ObjectName mBName = new ObjectName("quartz:type=QuartzScheduler,*");
      Set<ObjectName> names = connection.queryNames(mBName, null);
      QuartzInstance quartzInstance = new QuartzInstance();
      quartzInstance.setMBeanServerConnection(connection);
      quartzInstance.setJmxConnector(connector);

      List<Scheduler> schList = new ArrayList<Scheduler>();
      for (ObjectName objectName : names)   // for each scheduler.
      {
         QuartzJMXAdapter jmxAdapter = QuartzJMXAdapterFactory.initQuartzJMXAdapter(objectName, connection);
         quartzInstance.setJmxAdapter(jmxAdapter);

         Scheduler scheduler = jmxAdapter.getSchedulerByJmx(quartzInstance, objectName);
         schList.add(scheduler);

         // attach listener
//         connection.addNotificationListener(objectName, listener, null, null);
         log.info("added listener " + objectName.getCanonicalName());
        //QuartzInstance.putListener(listener);
      }
      quartzInstance.setSchedulerList(schList);
      return quartzInstance;
   }
View Full Code Here

  public String add() throws Exception {

    String id = Tools.generateUUID();
    QuartzConfig quartzConfig = new QuartzConfig(id,host, port, username,password);
    QuartzConnectService quartzConnectService = new QuartzConnectServiceImpl();
    QuartzInstance quartzInstance = quartzConnectService.initInstance(quartzConfig);
    //QuartzInstanceService.putQuartzInstance(quartzInstance);
    QuartzInstanceContainer.addQuartzConfig(quartzConfig);
    QuartzInstanceContainer.addQuartzInstance(id, quartzInstance);
    log.info("add a quartz info!");
   
View Full Code Here

 
  public String update() throws Exception {

    QuartzConfig quartzConfig = new QuartzConfig(uuid,host, port, username,password);
    QuartzConnectService quartzConnectService = new QuartzConnectServiceImpl();
    QuartzInstance quartzInstance = quartzConnectService.initInstance(quartzConfig);
    QuartzInstanceContainer.addQuartzConfig(quartzConfig);
    QuartzInstanceContainer.addQuartzInstance(uuid, quartzInstance);
    log.info("update a quartz info!");
   
    XstreamUtil.object2XML(quartzConfig);
View Full Code Here

  private TriggerInput triggerInput;
 
  public String list() throws Exception {

    QuartzInstance instance = Tools.getQuartzInstance();
    List<Scheduler> schedulers = instance.getSchedulerList();
    log.info(" schedulers list size:"+schedulers.size());

    Job job = JobContainer.getJobById(jobId);
    Scheduler scheduler = instance.getSchedulerByName(job.getSchedulerName());

    List<Trigger> temp = instance.getJmxAdapter().getTriggersForJob(instance, scheduler,job.getJobName(), job.getGroup());
    if(temp == null || temp.size() == 0){
      return "list";
    }
    for (Trigger trigger : temp) {
      String id = Tools.generateUUID();
View Full Code Here

    return "list";
  }

  public String add() throws Exception {

    QuartzInstance instance = Tools.getQuartzInstance();
   
    HashMap<String, Object> triggerMap = new HashMap<String, Object>();
    triggerMap.put("name", triggerInput.getName());
    triggerMap.put("group",triggerInput.getGroup());
    triggerMap.put("description", triggerInput.getDescription());
    if(triggerInput.getDateFlag() == 1){
      triggerMap.put("startTime", triggerInput.getDate());
      triggerMap.put("triggerClass", "org.quartz.impl.triggers.SimpleTriggerImpl");
    }else{
      triggerMap.put("cronExpression", triggerInput.getCron());
      triggerMap.put("triggerClass", "org.quartz.impl.triggers.CronTriggerImpl");
    }
    Job job = JobContainer.getJobById(jobId);
    triggerMap.put("jobName", job.getJobName());
    triggerMap.put("jobGroup", job.getGroup());
   
    instance.getJmxAdapter().addTriggerForJob(instance, instance.getSchedulerByName(job.getSchedulerName()), job,triggerMap);
   
    log.info("add trigger for job:"+job.getJobName());
   
   
    Result result = new Result();
View Full Code Here

    return null;
  }

  public String delete() throws Exception {
   
    QuartzInstance instance = Tools.getQuartzInstance();
   
    Trigger trigger = TriggerContainer.getTriggerById(uuid);
    TriggerContainer.removeTriggerById(uuid);

    Job job = JobContainer.getJobById(trigger.getJobId());
    instance.getJmxAdapter().deleteTrigger(instance, instance.getSchedulerByName(job.getSchedulerName()), trigger);
    log.info("delete job["+trigger.getJobName()+"]'s trigger!");
    Result result = new Result();
    result.setMessage("删除成功");
    result.setNavTabId("triggerList");
    result.setCallbackType("");
View Full Code Here

  private Integer pageCount;//总页数
  private Integer size;
 
  public String list() throws Exception {

    QuartzInstance instance = Tools.getQuartzInstance();
    if(instance == null){
      new InitAction().execute();
      instance = Tools.getQuartzInstance();
    }
    if(instance == null){
     
      Result result = new Result();
      result.setMessage("请先配置Quartz");
      result.setCallbackType("");
      JsonUtil.toJson(new Gson().toJson(result));
      return null;
    }
    List<Scheduler> schedulers = instance.getSchedulerList();
    log.info(" schedulers list size:"+schedulers.size());
     if (schedulers != null && schedulers.size() > 0)
         {
             for (int i = 0; i < schedulers.size(); i++)
             {
                 Scheduler scheduler = schedulers.get(i);
                 List<Job> temp = instance.getJmxAdapter().getJobDetails(instance, scheduler);
                 for(Job job : temp){
                   String id = Tools.generateUUID();
                   job.setUuid(id);
                   JobContainer.addJob(id, job);
                   jobList.add(job);
View Full Code Here

  }
 
 
  public String start() throws Exception {

    QuartzInstance instance = Tools.getQuartzInstance();
    Job job = JobContainer.getJobById(uuid);
    instance.getJmxAdapter().startJobNow(instance, instance.getSchedulerByName(job.getSchedulerName()), job);
   
    Result result = new Result();
    result.setStatusCode("200");
    result.setMessage("执行成功");
    result.setCallbackType("");
View Full Code Here

  }

  public String delete() throws Exception {

   
    QuartzInstance instance = Tools.getQuartzInstance();
   
    Job job = JobContainer.getJobById(uuid);
    JobContainer.removeJobById(uuid);
    log.info("delete a quartz job!");
    instance.getJmxAdapter().deleteJob(instance, instance.getSchedulerByName(job.getSchedulerName()), job);
    Result result = new Result();
    result.setMessage("删除成功");
    JsonUtil.toJson(new Gson().toJson(result));
    return null;
  }
View Full Code Here

TOP

Related Classes of com.quartz.monitor.object.QuartzInstance

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.