![JAR search and dependency download from the Maven repository](/logo.png)
azkaban.trigger.Condition Maven / Gradle / Ivy
/*
* Copyright 2012 LinkedIn Corp.
*
* 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 azkaban.trigger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.jexl2.Expression;
import org.apache.commons.jexl2.JexlEngine;
import org.apache.commons.jexl2.MapContext;
import org.apache.log4j.Logger;
import org.joda.time.DateTime;
public class Condition {
private static final Logger logger = Logger.getLogger(Condition.class);
private static final JexlEngine jexl = new JexlEngine();
private static CheckerTypeLoader checkerLoader = null;
private final MapContext context = new MapContext();
private Expression expression;
private Map checkers =
new HashMap<>();
private Long nextCheckTime = -1L;
public Condition(final Map checkers, final String expr) {
setCheckers(checkers);
this.expression = jexl.createExpression(expr);
updateNextCheckTime();
}
public Condition(final Map checkers, final String expr,
final long nextCheckTime) {
this.nextCheckTime = nextCheckTime;
setCheckers(checkers);
this.expression = jexl.createExpression(expr);
}
public synchronized static void setCheckerLoader(final CheckerTypeLoader loader) {
Condition.checkerLoader = loader;
}
public static Condition fromJson(final Object obj) throws Exception {
if (checkerLoader == null) {
throw new Exception("Condition Checker loader not initialized!");
}
final Map jsonObj = (HashMap) obj;
Condition cond = null;
try {
final Map checkers =
new HashMap<>();
final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy