All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.helger.quartz.SchedulerMetaData Maven / Gradle / Ivy

/**
 * All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
 *
 * Copyright (C) 2016-2020 Philip Helger (www.helger.com)
 * philip[at]helger[dot]com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.helger.quartz;

import java.io.Serializable;
import java.util.Date;

/**
 * Describes the settings and capabilities of a given
 * {@link IScheduler} instance.
 *
 * @author James House
 */
public class SchedulerMetaData implements Serializable
{
  private final String m_sSchedName;
  private final String m_sSchedInst;
  private final Class  m_sSchedClass;
  private final boolean m_bStarted;
  private final boolean m_bIsInStandbyMode;
  private final boolean m_bShutdown;
  private final Date m_aStartTime;
  private final int m_nNumJobsExec;
  private final Class  m_aJsClass;
  private final boolean m_bJsPersistent;
  private final boolean m_bJsClustered;
  private final Class  m_aTpClass;
  private final int m_nTpSize;
  private final String m_sVersion;

  public SchedulerMetaData (final String schedName,
                            final String schedInst,
                            final Class  schedClass,
                            final boolean started,
                            final boolean isInStandbyMode,
                            final boolean shutdown,
                            final Date startTime,
                            final int numJobsExec,
                            final Class  jsClass,
                            final boolean jsPersistent,
                            final boolean jsClustered,
                            final Class  tpClass,
                            final int tpSize,
                            final String version)
  {
    m_sSchedName = schedName;
    m_sSchedInst = schedInst;
    m_sSchedClass = schedClass;
    m_bStarted = started;
    m_bIsInStandbyMode = isInStandbyMode;
    m_bShutdown = shutdown;
    m_aStartTime = startTime;
    m_nNumJobsExec = numJobsExec;
    m_aJsClass = jsClass;
    m_bJsPersistent = jsPersistent;
    m_bJsClustered = jsClustered;
    m_aTpClass = tpClass;
    m_nTpSize = tpSize;
    m_sVersion = version;
  }

  /**
   * 

* Returns the name of the Scheduler. *

*/ public String getSchedulerName () { return m_sSchedName; } /** *

* Returns the instance Id of the Scheduler. *

*/ public String getSchedulerInstanceId () { return m_sSchedInst; } /** *

* Returns the class-name of the Scheduler instance. *

*/ public Class getSchedulerClass () { return m_sSchedClass; } /** *

* Returns the Date at which the Scheduler started running. *

* * @return null if the scheduler has not been started. */ public Date getRunningSince () { return m_aStartTime; } /** *

* Returns the number of jobs executed since the Scheduler * started.. *

*/ public int getNumberOfJobsExecuted () { return m_nNumJobsExec; } /** *

* Returns whether the scheduler has been started. *

*

* Note: isStarted() may return true even if * isInStandbyMode() returns true. *

*/ public boolean isStarted () { return m_bStarted; } /** * Reports whether the Scheduler is in standby mode. */ public boolean isInStandbyMode () { return m_bIsInStandbyMode; } /** *

* Reports whether the Scheduler has been shutdown. *

*/ public boolean isShutdown () { return m_bShutdown; } /** *

* Returns the class-name of the JobStore instance that is being * used by the Scheduler. *

*/ public Class getJobStoreClass () { return m_aJsClass; } /** *

* Returns whether or not the Scheduler'sJobStore * instance supports persistence. *

*/ public boolean isJobStoreSupportsPersistence () { return m_bJsPersistent; } /** *

* Returns whether or not the Scheduler'sJobStore is * clustered. *

*/ public boolean isJobStoreClustered () { return m_bJsClustered; } /** *

* Returns the class-name of the ThreadPool instance that is * being used by the Scheduler. *

*/ public Class getThreadPoolClass () { return m_aTpClass; } /** *

* Returns the number of threads currently in the Scheduler's * ThreadPool. *

*/ public int getThreadPoolSize () { return m_nTpSize; } /** *

* Returns the version of Quartz that is running. *

*/ public String getVersion () { return m_sVersion; } /** *

* Return a simple string representation of this object. *

*/ @Override public String toString () { try { return getSummary (); } catch (final SchedulerException se) { return "SchedulerMetaData: undeterminable."; } } /** *

* Returns a formatted (human readable) String describing all the * Scheduler's meta-data values. *

*

* The format of the String looks something like this: *

* *
   *  Mini Quartz Scheduler 'SchedulerName' with instanceId 'SchedulerInstanceId' Scheduler class: 'com.helger.quartz.impl.StdScheduler' - running locally. Running since: '11:33am on Jul 19, 2002' Not currently paused. Number of Triggers fired: '123' Using thread pool 'com.helger.quartz.simpl.SimpleThreadPool' - with '8' threads Using job-store 'com.helger.quartz.impl.JDBCJobStore' - which supports persistence.
   * 
* * @throws SchedulerException * On error */ public String getSummary () throws SchedulerException { final StringBuilder aSB = new StringBuilder ("Mini Quartz Scheduler (v"); aSB.append (getVersion ()); aSB.append (") '"); aSB.append (getSchedulerName ()); aSB.append ("' with instanceId '"); aSB.append (getSchedulerInstanceId ()); aSB.append ("'\n"); aSB.append (" Scheduler class: '"); aSB.append (getSchedulerClass ().getName ()); aSB.append ("'"); aSB.append (" - running locally."); aSB.append ("\n"); if (!isShutdown ()) { if (getRunningSince () != null) { aSB.append (" Running since: "); aSB.append (getRunningSince ()); } else { aSB.append (" NOT STARTED."); } aSB.append ("\n"); if (isInStandbyMode ()) { aSB.append (" Currently in standby mode."); } else { aSB.append (" Not currently in standby mode."); } } else { aSB.append (" Scheduler has been SHUTDOWN."); } aSB.append ("\n"); aSB.append (" Number of jobs executed: "); aSB.append (getNumberOfJobsExecuted ()); aSB.append ("\n"); aSB.append (" Using thread pool '"); aSB.append (getThreadPoolClass ().getName ()); aSB.append ("' - with "); aSB.append (getThreadPoolSize ()); aSB.append (" threads."); aSB.append ("\n"); aSB.append (" Using job-store '"); aSB.append (getJobStoreClass ().getName ()); aSB.append ("' - which "); if (isJobStoreSupportsPersistence ()) { aSB.append ("supports persistence."); } else { aSB.append ("does not support persistence."); } if (isJobStoreClustered ()) { aSB.append (" and is clustered."); } else { aSB.append (" and is not clustered."); } aSB.append ("\n"); return aSB.toString (); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy