org.quartz.SchedulerMetaData Maven / Gradle / Ivy
/*
* Copyright 2004-2005 OpenSymphony
*
* 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.
*
*/
/*
* Previously Copyright (c) 2001-2004 James House
*/
package org.quartz;
import java.util.Date;
/**
*
* Describes the settings and capabilities of a given {@link Scheduler}
* instance.
*
*
* @author James House
*/
public class SchedulerMetaData implements java.io.Serializable {
/*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* Data members.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
private String schedName;
private String schedInst;
private Class schedClass;
private boolean isRemote;
private boolean started;
private boolean paused;
private boolean shutdown;
private Date startTime;
private int numJobsExec;
private Class jsClass;
private boolean jsPersistent;
private Class tpClass;
private int tpSize;
private String version;
/*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* Constructors.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
public SchedulerMetaData(String schedName, String schedInst,
Class schedClass, boolean isRemote, boolean started,
boolean paused, boolean shutdown, Date startTime, int numJobsExec,
Class jsClass, boolean jsPersistent, Class tpClass, int tpSize,
String version) {
this.schedName = schedName;
this.schedInst = schedInst;
this.schedClass = schedClass;
this.isRemote = isRemote;
this.started = started;
this.paused = paused;
this.shutdown = shutdown;
this.startTime = startTime;
this.numJobsExec = numJobsExec;
this.jsClass = jsClass;
this.jsPersistent = jsPersistent;
this.tpClass = tpClass;
this.tpSize = tpSize;
this.version = version;
}
/*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* Interface.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/**
*
* Returns the name of the Scheduler
.
*
*/
public String getSchedulerName() {
return schedName;
}
/**
*
* Returns the instance Id of the Scheduler
.
*
*/
public String getSchedulerInstanceId() {
return schedInst;
}
/**
*
* Returns the class-name of the Scheduler
instance.
*
*/
public Class getSchedulerClass() {
return schedClass;
}
/**
*
* Returns the Date
at which the Scheduler started running.
*
*
* @return null if the scheduler has not been started.
*/
public Date runningSince() {
return startTime;
}
/**
*
* Returns the number of jobs executed since the Scheduler
* started..
*
*/
public int numJobsExecuted() {
return numJobsExec;
}
/**
*
* Returns whether the Scheduler
is being used remotely (via
* RMI).
*
*/
public boolean isSchedulerRemote() {
return isRemote;
}
/**
*
* Returns whether the scheduler has been started.
*
*
*
* Note: isStarted()
may return true
even if
* isPaused()
returns true
.
*
*/
public boolean isStarted() {
return started;
}
/**
*
* Reports whether the Scheduler
is paused.
*
*
*
* Note: isStarted()
may return true
even if
* isPaused()
returns true
.
*
*/
public boolean isPaused() {
return paused;
}
/**
*
* Reports whether the Scheduler
has been shutdown.
*
*/
public boolean isShutdown() {
return shutdown;
}
/**
*
* Returns the class-name of the JobStore
instance that is
* being used by the Scheduler
.
*
*/
public Class getJobStoreClass() {
return jsClass;
}
/**
*
* Returns whether or not the Scheduler
'sJobStore
* instance supports persistence.
*
*/
public boolean jobStoreSupportsPersistence() {
return jsPersistent;
}
/**
*
* Returns the class-name of the ThreadPool
instance that is
* being used by the Scheduler
.
*
*/
public Class getThreadPoolClass() {
return tpClass;
}
/**
*
* Returns the number of threads currently in the Scheduler
's
* ThreadPool
.
*
*/
public int getThreadPoolSize() {
return tpSize;
}
/**
*
* Returns the version of Quartz that is running.
*
*/
public String getVersion() {
return version;
}
/**
*
* Return a simple string representation of this object.
*
*/
public String toString() {
try {
return getSummary();
} catch (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:
*
*
*
*
* Quartz Scheduler 'SchedulerName' with instanceId 'SchedulerInstanceId' Scheduler class: 'org.quartz.impl.StdScheduler' - running locally. Running since: '11:33am on Jul 19, 2002' Not currently paused. Number of Triggers fired: '123' Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with '8' threads Using job-store 'org.quartz.impl.JDBCJobStore' - which supports persistence.
*
*
*
*/
public String getSummary() throws SchedulerException {
StringBuffer str = new StringBuffer("Quartz Scheduler (v");
str.append(getVersion());
str.append(") '");
str.append(getSchedulerName());
str.append("' with instanceId '");
str.append(getSchedulerInstanceId());
str.append("'\n");
str.append(" Scheduler class: '");
str.append(getSchedulerClass().getName());
str.append("'");
if (isSchedulerRemote()) str.append(" - access via RMI.");
else
str.append(" - running locally.");
str.append("\n");
if (!isShutdown()) {
if (runningSince() != null) {
str.append(" Running since: ");
str.append(runningSince());
} else
str.append("NOT STARTED.");
str.append("\n");
if (isPaused()) str.append(" Currently PAUSED.");
else
str.append(" Not currently paused.");
} else {
str.append(" Scheduler has been SHUTDOWN.");
}
str.append("\n");
str.append(" Number of jobs executed: ");
str.append(numJobsExecuted());
str.append("\n");
str.append(" Using thread pool '");
str.append(getThreadPoolClass().getName());
str.append("' - with ");
str.append(getThreadPoolSize());
str.append(" threads.");
str.append("\n");
str.append(" Using job-store '");
str.append(getJobStoreClass().getName());
str.append("' - which ");
if (jobStoreSupportsPersistence()) str.append("supports persistence.");
else
str.append("does not support persistence.");
str.append("\n");
return str.toString();
}
}