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

org.linkedin.glu.agent.api.Timers.groovy Maven / Gradle / Ivy

/*
 * Copyright (c) 2010-2010 LinkedIn, Inc
 *
 * 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 org.linkedin.glu.agent.api

/**
 * This interface is available from any GLU script using timers property
 *
 * 
 * class MyScript
 * {
 *   def timer1 = {
 *     log.info "hello world"
 *   }
 *
 *   def install = {
 *     timers.schedule(timer: timer1, repeatFrequency: '1m') // property
 *     // timers.schedule(timer: 'timer1', repeatFrequency: '1m') // also valid (name of the property)
 *     // timers.schedule(timer: { println 'hello world'}, repeatFrequency: '1m') // invalid (anonymous closure)
 *   }
 *
 *   def uninstall = {
 *     timers.cancel(timer: timer1)
 *   }
 * }
 * 
* * @author [email protected] */ interface Timers { /** * Schedule a timer. Because of the fact that a timer needs to survive an agent restart, it needs * to be defined as a property of the GLU script and not an anonymous Closure. * * @param args.timer there can only be one timer with a given name (note that the timer needs * to be a pointer to a Closure, so it can either be the name of the property * holding the Closure or directly the property itself) * @param args.initialFrequency how long to wait the first time (optional) * @param args.repeatFrequency how long to wait after the first time * @return a future execution (asynchronous execution, cancellable...) */ FutureExecution schedule(args) /** * @param args.timer timer * @return false if the execution could not be cancelled, typically because it has already completed * normally; true otherwise */ boolean cancel(args) }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy