Called during creation of the <code>Scheduler</code> in order to give the <code>SchedulerPlugin
</code> a chance to initialize.

@throws org.quartz.exceptions.SchedulerConfigException if there is an error initializing.
423074
@Override
  public void initialize(String name, final Scheduler scheduler) throws SchedulerException {

    logger.info("Initializing XMLSchedulingDataProcessorPlugin Plug-in.");

    this.scheduler = scheduler;
  }
422621
private void setupExceptionPropagator() {
    if (cache2kConfiguration.getExceptionPropagator() != null) {
      return;
    }
    cache2kConfiguration.setExceptionPropagator(
      new CustomizationReferenceSupplier<ExceptionPropagator<K>>(new ExceptionPropagator<K>() {
      @Override
      public RuntimeException propagateException(Object key, final ExceptionInformation exceptionInformation) {
        return new CacheLoaderException("propagate previous loader exception", exceptionInformation.getException());
      }
    }));
  }
1255530
@Override
    @SuppressWarnings("nls")
    public void initialize() {
        try {
            ScheduledExecutorService schedulerService = Executors.newSingleThreadScheduledExecutor();
            CountDownLatch cdl = new CountDownLatch(1);
            Holder<Exception> exception = new Holder<>();

            ScheduledFuture<?> sched = schedulerService.scheduleAtFixedRate(() -> {
                logger.info("Polling for Elasticsearch...");
                try {
                    esClient.execute(new Health.Builder().build());
                    cdl.countDown();
                } catch (IOException e) {
                    logger.info("Unable to reach Elasticsearch. Will continue polling.");
                    //System.out.println("Result of polling", e);
                    exception.setValue(e);
                }
            },
            0, // Start immediately
            1, // Poll every 1 seconds
            TimeUnit.SECONDS);

            cdl.await(30, TimeUnit.SECONDS); // Max wait 30 seconds
            sched.cancel(true);

            // CDL > 0 means we never successfully hit the health endpoint.
            if (exception.getValue() != null && cdl.getCount() > 0) {
                throw exception.getValue();
            }
            // TODO Do we need a loop to wait for all nodes to join the cluster?
            Action<JestResult> action = new IndicesExists.Builder(getIndexName()).build();
            synchronized(EsStorage.class) {
                JestResult result = esClient.execute(action);
                if (!result.isSucceeded()) {
                    createIndex(getIndexName());
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
567486
public void apply() {
        Scheduler.get().scheduleDeferred(() -> {
            if (widget != null) {
                $(widget.getElement()).pushpin(options);
            } else {
                GWT.log("Please set your widget before applying the pushpin", new IllegalStateException());
            }
        });
    }
227481
@Override
    public void init(final Scope scope, final ParticipantConfig participantConfig) throws InitializationException, InterruptedException {
        internalInit(scope, participantConfig);
    }
789279
public void scheduleAt(final org.easybatch.core.job.Job job, final Date startTime, MisfireHandlingStrategy strategy, int repeatCount) throws JobSchedulerException {
        checkNotNull(job, "job");
        checkNotNull(startTime, "startTime");

        String name = job.getName();
        String jobName = JOB_NAME_PREFIX + name;
        String triggerName = TRIGGER_NAME_PREFIX + name;

        SimpleScheduleBuilder simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule();
        // Quartz should have provided a strategy interface for this..
        if (strategy.equals(MisfireHandlingStrategy.FIRE_NOW)) {
            simpleScheduleBuilder.withMisfireHandlingInstructionFireNow();
        }
        if (strategy.equals(MisfireHandlingStrategy.IGNORE_MISFIRES)) {
            simpleScheduleBuilder.withMisfireHandlingInstructionIgnoreMisfires();
        }
        if (strategy.equals(MisfireHandlingStrategy.NEXT_WITH_EXISTING_COUNT)) {
            simpleScheduleBuilder.withMisfireHandlingInstructionNextWithExistingCount();
        }
        if (strategy.equals(MisfireHandlingStrategy.NEXT_WITH_REMAINING_COUNT)) {
            simpleScheduleBuilder.withMisfireHandlingInstructionNextWithRemainingCount();
        }
        if (strategy.equals(MisfireHandlingStrategy.NOW_WITH_EXISTING_COUNT)) {
            simpleScheduleBuilder.withMisfireHandlingInstructionNowWithExistingCount();
        }
        if (strategy.equals(MisfireHandlingStrategy.NOW_WITH_REMAINING_COUNT)) {
            simpleScheduleBuilder.withMisfireHandlingInstructionNowWithRemainingCount();
        }

        simpleScheduleBuilder.withRepeatCount(repeatCount);

        Trigger trigger = newTrigger()
                .withIdentity(triggerName)
                .startAt(startTime)
                .forJob(jobName)
                .withSchedule(simpleScheduleBuilder)
                .build();

        JobDetail jobDetail = getJobDetail(job, jobName);

        try {
            LOGGER.info("Scheduling job ''{}'' to start at {}", name, startTime);
            scheduler.scheduleJob(jobDetail, trigger);
        } catch (SchedulerException e) {
            throw new JobSchedulerException(format("Unable to schedule job '%s'", name), e);
        }
    }
365931
public void registerUpdater(Scheduler scheduler,
      SessionNotifier sessionNotifier) {
    this.scheduler = scheduler;
    this.sessionNotifier = sessionNotifier;
    context.registerUpdater(this);
  }
17152
public void start() throws Exception {
		this.logger.info( "Roboconf's scheduler is starting..." );

		// Verify the "scheduler" directory exists
		File schedulerDirectory = getSchedulerDirectory();
		Utils.createDirectory( schedulerDirectory );

		// Disable Quartz update checks
		StringBuilder quartzProperties = new StringBuilder();
		quartzProperties.append( "org.quartz.scheduler.instanceName: Roboconf Quartz Scheduler\n" );
		quartzProperties.append( "org.quartz.threadPool.threadCount = 3\n" );
		quartzProperties.append( "org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore\n" );
		quartzProperties.append( "org.quartz.scheduler.skipUpdateCheck: false\n" );

		StdSchedulerFactory factory = new StdSchedulerFactory();
		factory.initialize( new ByteArrayInputStream( quartzProperties.toString().getBytes( StandardCharsets.UTF_8 )));

		// Create a new scheduler
		this.scheduler = factory.getScheduler();
		this.scheduler.start();
		this.scheduler.getContext().put( MANAGER, this.manager );

		// Add a listener to the DM
		this.dmListener = new ManagerListener( this );
		this.manager.listenerAppears( this.dmListener );

		// Reload all the jobs
		loadJobs();
	}
1164943
@PostConstruct
    public void start() throws Exception {
        lifecycleLock.writeLock().lock();
        try {
            if (!State.STOPPED.equals(state)) {
                logger.warn("Ignore start() command for {} instance", state);
                return;
            }
            logger.info("Start...");

            for (Query query : queries) {
                query.start();
            }
            for (OutputWriter outputWriter : outputWriters) {
                outputWriter.start();
            }

            collectScheduledExecutor = Executors.newScheduledThreadPool(getNumQueryThreads(), new NamedThreadFactory("jmxtrans-collect-", true));
            exportScheduledExecutor = Executors.newScheduledThreadPool(getNumExportThreads(), new NamedThreadFactory("jmxtrans-export-", true));

            logger.info("Start queries and output writers...");
            for (final Query query : getQueries()) {
                collectScheduledExecutor.scheduleWithFixedDelay(new Runnable() {
                    @Override
                    public void run() {
                        lifecycleLock.readLock().lock();
                        try {
                            if (!State.STARTED.equals(state)) {
                                logger.debug("Ignore query.collectMetrics() command for {} instance", state);
                                return;
                            }
                            query.collectMetrics();
                        } finally {
                            lifecycleLock.readLock().unlock();
                        }
                    }

                    @Override
                    public String toString() {
                        return "Collector[" + query + "]";
                    }
                }, 0, getQueryIntervalInSeconds(), TimeUnit.SECONDS);

                // start export just after first collect
                exportScheduledExecutor.scheduleWithFixedDelay(new Runnable() {
                    @Override
                    public void run() {
                        lifecycleLock.readLock().lock();
                        try {
                            if (!State.STARTED.equals(state)) {
                                logger.debug("Ignore query.exportCollectedMetrics() command for {} instance", state);
                                return;
                            }

                            query.exportCollectedMetrics();
                        } finally {
                            lifecycleLock.readLock().unlock();
                        }
                    }

                    @Override
                    public String toString() {
                        return "Exporter[" + query + "]";
                    }
                }, getQueryIntervalInSeconds() + 1, getExportIntervalInSeconds(), TimeUnit.SECONDS);
            }

            shutdownHook = new EmbeddedJmxTransShutdownHook();
            shutdownHook.registerToRuntime();
            state = State.STARTED;
            logger.info("EmbeddedJmxTrans started");
        } catch (RuntimeException e) {
            this.state = State.ERROR;
            if (logger.isDebugEnabled()) {
                // to troubleshoot JMX call errors or equivalent, it may be useful to log and rethrow
                logger.warn("Exception starting EmbeddedJmxTrans", e);
            }
            throw e;
        } finally {
            lifecycleLock.writeLock().unlock();
        }
    }
431570
@Trivial
    void initForRepeatingTask(boolean isFixedRate, long initialDelay, long interval) {
        this.initialDelay = initialDelay;
        this.interval = interval;
        this.isFixedRate = isFixedRate;
    }
275755
public void scheduleRecurring(Runnable runnable, Date firstTime, long period)
   {
	timer.scheduleAtFixedRate(toTimerTask(runnable), firstTime, period);
	
   }
1189762
public synchronized void initTaskSchedulerIfNot() {

        if (scheduler == null) {
            scheduler = Executors
                    .newSingleThreadScheduledExecutor(DaemonThreadFactory
                            .getInstance());
            CapacityAwareTaskScheduler runner = new CapacityAwareTaskScheduler();
            scheduler.scheduleAtFixedRate(runner,
                    ParallecGlobalConfig.schedulerInitDelay,
                    ParallecGlobalConfig.schedulerCheckInterval,
                    TimeUnit.MILLISECONDS);
            logger.info("initialized daemon task scheduler to evaluate waitQ tasks.");
            
        }
    }
721658
public void starting() throws Exception {
		this.logger.fine( "iPojo registers REST and icons servlets related to Roboconf's DM." );

		// Create the REST application with its resources.
		// The scheduler may be null, it is optional.
		this.app = new RestApplication( this.manager );
		this.app.setScheduler( this.scheduler );
		this.app.setMavenResolver( this.mavenResolver );
		this.app.enableCors( this.enableCors );
		this.app.setAuthenticationManager( this.authenticationMngr );

		Dictionary<String,String> initParams = new Hashtable<> ();
		initParams.put( "servlet-name", "Roboconf DM (REST)" );

		this.jerseyServlet = new ServletContainer( this.app );
		this.httpService.registerServlet( REST_CONTEXT, this.jerseyServlet, initParams, null );

		// Deal with the icons servlet
		initParams = new Hashtable<> ();
		initParams.put( "servlet-name", "Roboconf DM (icons)" );

		IconServlet iconServlet = new IconServlet( this.manager );
		this.httpService.registerServlet( ICONS_CONTEXT, iconServlet, initParams, null );

		// Register the web socket
		initParams = new Hashtable<> ();
		initParams.put( "servlet-name", "Roboconf DM (websocket)" );

		RoboconfWebSocketServlet websocketServlet = new RoboconfWebSocketServlet();
		this.httpService.registerServlet( WEBSOCKET_CONTEXT, websocketServlet, initParams, null );

		// Register a filter for authentication
		this.authenticationFilter = new AuthenticationFilter( this );
		this.authenticationFilter.setAuthenticationEnabled( this.enableAuthentication );
		this.authenticationFilter.setAuthenticationManager( this.authenticationMngr );
		this.authenticationFilter.setSessionPeriod( this.sessionPeriod );
		this.authenticationFilter.setEnableCors( this.enableCors );

		initParams = new Hashtable<> ();
		initParams.put( "urlPatterns", "*" );

		// Consider the bundle context can be null (e.g. when used outside of OSGi)
		if( this.bundleContext != null )
			this.filterServiceRegistration = this.bundleContext.registerService( Filter.class, this.authenticationFilter, initParams );
		else
			this.logger.warning( "No bundle context was available, the authentication filter was not registered." );
	}
963510
public boolean runScheduler() {
    IScheduler scheduler = null;

    String statemgrClass = Context.stateManagerClass(config);
    IStateManager statemgr;

    try {
      // create an instance of state manager
      statemgr = ReflectionUtils.newInstance(statemgrClass);
    } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
      LOG.log(Level.SEVERE, "Failed to instantiate instances using config: " + config, e);
      return false;
    }

    SchedulerServer server = null;
    boolean isSuccessful = false;

    // Put it in a try block so that we can always clean resources
    try {
      // initialize the state manager
      statemgr.initialize(config);

      // TODO(mfu): timeout should read from config
      SchedulerStateManagerAdaptor adaptor = new SchedulerStateManagerAdaptor(statemgr, 5000);

      // get a packed plan and schedule it
      PackingPlans.PackingPlan serializedPackingPlan = adaptor.getPackingPlan(topology.getName());
      if (serializedPackingPlan == null) {
        LOG.log(Level.SEVERE, "Failed to fetch PackingPlan for topology:{0} from the state manager",
            topology.getName());
        return false;
      }
      LOG.log(Level.INFO, "Packing plan fetched from state: {0}", serializedPackingPlan);
      PackingPlan packedPlan = new PackingPlanProtoDeserializer().fromProto(serializedPackingPlan);

      // build the runtime config
      LauncherUtils launcherUtils = LauncherUtils.getInstance();
      Config runtime = Config.newBuilder()
          .putAll(launcherUtils.createPrimaryRuntime(topology))
          .putAll(launcherUtils.createAdaptorRuntime(adaptor))
          .put(Key.SCHEDULER_SHUTDOWN, getShutdown())
          .put(Key.SCHEDULER_PROPERTIES, properties)
          .build();

      Config ytruntime = launcherUtils.createConfigWithPackingDetails(runtime, packedPlan);

      // invoke scheduler
      scheduler = launcherUtils.getSchedulerInstance(config, ytruntime);
      if (scheduler == null) {
        return false;
      }

      isSuccessful = scheduler.onSchedule(packedPlan);
      if (!isSuccessful) {
        LOG.severe("Failed to schedule topology");
        return false;
      }

      // Failures in server initialization throw exceptions
      // get the scheduler server endpoint for receiving requests
      server = getServer(ytruntime, scheduler, schedulerServerPort);
      // start the server to manage runtime requests
      server.start();

      // write the scheduler location to state manager
      // Make sure it happens after IScheduler.onScheduler
      isSuccessful = SchedulerUtils.setSchedulerLocation(
          runtime, String.format("%s:%d", server.getHost(), server.getPort()), scheduler);

      if (isSuccessful) {
        // wait until kill request or some interrupt occurs if the scheduler starts successfully
        LOG.info("Waiting for termination... ");
        Runtime.schedulerShutdown(ytruntime).await();
      }
    } catch (IOException e) {
      LOG.log(Level.SEVERE, "Failed to start server", e);
      return false;
    } finally {
      // Clean the resources
      if (server != null) {
        server.stop();
      }

      // 4. Close the resources
      SysUtils.closeIgnoringExceptions(scheduler);
      SysUtils.closeIgnoringExceptions(statemgr);
    }

    return isSuccessful;
  }
1110831
protected void initJobExecutor() {
    if (jobExecutor == null) {
      jobExecutor = new DefaultJobExecutor();
    }

    jobHandlers = new HashMap<String, JobHandler>();
    TimerExecuteNestedActivityJobHandler timerExecuteNestedActivityJobHandler = new TimerExecuteNestedActivityJobHandler();
    jobHandlers.put(timerExecuteNestedActivityJobHandler.getType(), timerExecuteNestedActivityJobHandler);

    TimerCatchIntermediateEventJobHandler timerCatchIntermediateEvent = new TimerCatchIntermediateEventJobHandler();
    jobHandlers.put(timerCatchIntermediateEvent.getType(), timerCatchIntermediateEvent);

    TimerStartEventJobHandler timerStartEvent = new TimerStartEventJobHandler();
    jobHandlers.put(timerStartEvent.getType(), timerStartEvent);

    TimerStartEventSubprocessJobHandler timerStartEventSubprocess = new TimerStartEventSubprocessJobHandler();
    jobHandlers.put(timerStartEventSubprocess.getType(), timerStartEventSubprocess);

    AsyncContinuationJobHandler asyncContinuationJobHandler = new AsyncContinuationJobHandler();
    jobHandlers.put(asyncContinuationJobHandler.getType(), asyncContinuationJobHandler);

    ProcessEventJobHandler processEventJobHandler = new ProcessEventJobHandler();
    jobHandlers.put(processEventJobHandler.getType(), processEventJobHandler);

    TimerSuspendProcessDefinitionHandler suspendProcessDefinitionHandler = new TimerSuspendProcessDefinitionHandler();
    jobHandlers.put(suspendProcessDefinitionHandler.getType(), suspendProcessDefinitionHandler);

    TimerActivateProcessDefinitionHandler activateProcessDefinitionHandler = new TimerActivateProcessDefinitionHandler();
    jobHandlers.put(activateProcessDefinitionHandler.getType(), activateProcessDefinitionHandler);

    TimerSuspendJobDefinitionHandler suspendJobDefinitionHandler = new TimerSuspendJobDefinitionHandler();
    jobHandlers.put(suspendJobDefinitionHandler.getType(), suspendJobDefinitionHandler);

    TimerActivateJobDefinitionHandler activateJobDefinitionHandler = new TimerActivateJobDefinitionHandler();
    jobHandlers.put(activateJobDefinitionHandler.getType(), activateJobDefinitionHandler);

    BatchSeedJobHandler batchSeedJobHandler = new BatchSeedJobHandler();
    jobHandlers.put(batchSeedJobHandler.getType(), batchSeedJobHandler);

    BatchMonitorJobHandler batchMonitorJobHandler = new BatchMonitorJobHandler();
    jobHandlers.put(batchMonitorJobHandler.getType(), batchMonitorJobHandler);

    HistoryCleanupJobHandler historyCleanupJobHandler = new HistoryCleanupJobHandler();
    jobHandlers.put(historyCleanupJobHandler.getType(), historyCleanupJobHandler);

    for (JobHandler batchHandler : batchHandlers.values()) {
      jobHandlers.put(batchHandler.getType(), batchHandler);
    }

    // if we have custom job handlers, register them
    if (getCustomJobHandlers() != null) {
      for (JobHandler customJobHandler : getCustomJobHandlers()) {
        jobHandlers.put(customJobHandler.getType(), customJobHandler);
      }
    }

    jobExecutor.setAutoActivate(jobExecutorActivate);

    if (jobExecutor.getRejectedJobsHandler() == null) {
      if (customRejectedJobsHandler != null) {
        jobExecutor.setRejectedJobsHandler(customRejectedJobsHandler);
      } else {
        jobExecutor.setRejectedJobsHandler(new NotifyAcquisitionRejectedJobsHandler());
      }
    }

  }
499918
@Inject
    public void schedule( Scheduler scheduler )
        throws Exception
    {
        if ( cronExpression == null && trigger == null )
        {
            throw new ProvisionException( format( "Impossible to schedule Job '%s' without cron expression",
                                                  jobClass.getName() ) );
        }
        if ( cronExpression != null && trigger != null )
        {
          throw new ProvisionException( format( "Impossible to schedule Job '%s' with cron expression " +
                                                "and an associated Trigger at the same time", jobClass.getName() ) );
        }

        JobKey jobKey = jobKey( DEFAULT.equals( jobName ) ? jobClass.getName() : jobName, jobGroup );
        TriggerKey triggerKey = triggerKey( DEFAULT.equals( triggerName ) ? jobClass.getCanonicalName() : triggerName, triggerGroup );

        if ( updateExistingTrigger && scheduler.checkExists( triggerKey ) ) {
            scheduler.unscheduleJob( triggerKey );
        }

        scheduler.scheduleJob( newJob( jobClass )
                               .withIdentity( jobKey )
                               .requestRecovery( requestRecovery )
                               .storeDurably( storeDurably ).build(),
                               ( trigger == null ) ?
                               newTrigger()
                               .withIdentity( triggerKey )
                               .withSchedule( cronSchedule( cronExpression )
                                              .inTimeZone( timeZone ) )
                                              .withPriority( priority )
                                              .build()
                                : trigger);
    }
529372
private void scheduleCreateRemoteListener() {

        final String methodName = "scheduleCreateRemoteListener";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName);
        }

        _timer.schedule(new TimerTask() {

            public void run() {

                createRemoteListenerDeactivateOnException(false);

                synchronized(SibRaStaticDestinationEndpointActivation.this) {

                    if (_remoteConnection != null) {

                        /*
                         * Successfully created a connection
                         */

                        SibTr.info(TRACE, "CONNECTED_CWSIV0777", new Object[] {
                                _remoteConnection.getConnection().getMeName(),
                                _endpointConfiguration.getDestination()
                                        .getDestinationName(),
                                _endpointConfiguration.getBusName(),
                                SibRaStaticDestinationEndpointActivation.this });

                    }

                }

            }
        }, RETRY_INTERVAL);

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }

    }