Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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 static java.util.Objects.requireNonNull;
import azkaban.utils.JSONUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.joda.time.DateTime;
public class Trigger {
private static final Logger logger = Logger.getLogger(Trigger.class);
private static ActionTypeLoader actionTypeLoader;
private final long submitTime;
private final String submitUser;
private final String source;
private final List actions;
private final List expireActions;
private Condition expireCondition;
private Condition triggerCondition;
private int triggerId = -1;
private long lastModifyTime;
private TriggerStatus status = TriggerStatus.READY;
private Map info = new HashMap<>();
private Map context = new HashMap<>();
private boolean resetOnTrigger = true;
private boolean resetOnExpire = true;
private long nextCheckTime = -1;
private Trigger() throws TriggerManagerException {
throw new TriggerManagerException("Triggers should always be specified");
}
private Trigger(final int triggerId, final long lastModifyTime, final long submitTime,
final String submitUser, final String source, final Condition triggerCondition,
final Condition expireCondition, final List actions,
final List expireActions, final Map info,
final Map context) {
requireNonNull(submitUser);
requireNonNull(source);
requireNonNull(triggerCondition);
requireNonNull(expireActions);
requireNonNull(info);
requireNonNull(context);
this.lastModifyTime = lastModifyTime;
this.submitTime = submitTime;
this.submitUser = submitUser;
this.source = source;
this.triggerCondition = triggerCondition;
this.expireCondition = expireCondition;
this.actions = actions;
this.triggerId = triggerId;
this.expireActions = expireActions;
this.info = info;
this.context = context;
}
public static ActionTypeLoader getActionTypeLoader() {
return actionTypeLoader;
}
public static synchronized void setActionTypeLoader(final ActionTypeLoader loader) {
Trigger.actionTypeLoader = loader;
}
public static Trigger fromJson(final Object obj) throws Exception {
if (actionTypeLoader == null) {
throw new Exception("Trigger Action Type loader not initialized.");
}
final Map jsonObj = (HashMap) obj;
Trigger trigger = null;
try {
logger.info("Decoding for " + JSONUtils.toJSON(obj));
final Condition triggerCond = Condition.fromJson(jsonObj.get("triggerCondition"));
final Condition expireCond = Condition.fromJson(jsonObj.get("expireCondition"));
final List actions = new ArrayList<>();
final List