@Override public String getTriggerSources() { final Set<String> sources = new HashSet<>(); for (final Trigger t : triggerIdMap.values()) { sources.add(t.getSource()); } return sources.toString(); }
@Override public List<Trigger> getTriggers(final String triggerSource) { final List<Trigger> triggers = new ArrayList<>(); for (final Trigger t : triggerIdMap.values()) { if (t.getSource().equals(triggerSource)) { triggers.add(t); } } return triggers; }
@Override public List<Trigger> getTriggerUpdates(final String triggerSource, final long lastUpdateTime) throws TriggerManagerException { final List<Trigger> triggers = new ArrayList<>(); for (final Trigger t : triggerIdMap.values()) { if (t.getSource().equals(triggerSource) && t.getLastModifyTime() > lastUpdateTime) { triggers.add(t); } } return triggers; }
public String getDescription() { final StringBuffer actionsString = new StringBuffer(); for (final TriggerAction act : this.actions) { actionsString.append(", "); actionsString.append(act.getDescription()); } return "Trigger from " + getSource() + " with trigger condition of " + this.triggerCondition.getExpression() + " and expire condition of " + this.expireCondition.getExpression() + actionsString; }
private void updateTrigger(final Trigger t, final EncodingType encType) throws TriggerLoaderException { final String json = JSONUtils.toJSON(t.toJson()); byte[] data = null; try { final byte[] stringData = json.getBytes("UTF-8"); data = stringData; if (encType == EncodingType.GZIP) { data = GZIPUtils.gzipBytes(stringData); } logger.debug( "NumChars: " + json.length() + " UTF-8:" + stringData.length + " Gzip:" + data.length); } catch (final IOException e) { logger.error("Trigger encoding fails", e); throw new TriggerLoaderException("Error encoding the trigger " + t.toString(), e); } try { final int updates = this.dbOperator .update(UPDATE_TRIGGER, t.getSource(), t.getLastModifyTime(), encType.getNumVal(), data, t.getTriggerId()); if (updates == 0) { throw new TriggerLoaderException("No trigger has been updated."); } } catch (final SQLException ex) { logger.error("Updating Trigger " + t.getTriggerId() + " failed."); throw new TriggerLoaderException("DB Trigger update failed. ", ex); } }
@Test public void testAddTrigger() throws Exception { final Trigger t1 = createTrigger("testProj1", "testFlow1", "source1"); final Trigger t2 = createTrigger("testProj2", "testFlow2", "source2"); this.loader.addTrigger(t1); List<Trigger> ts = this.loader.loadTriggers(); assertTrue(ts.size() == 1); final Trigger t3 = ts.get(0); assertTrue(t3.getSource().equals("source1")); this.loader.addTrigger(t2); ts = this.loader.loadTriggers(); assertTrue(ts.size() == 2); for (final Trigger t : ts) { if (t.getTriggerId() == t2.getTriggerId()) { t.getSource().equals(t2.getSource()); } } }
private void checkAllTriggers() throws TriggerManagerException { // sweep through the rest of them for (final Trigger t : this.triggers) { try { TriggerManager.this.scannerStage = "Checking for trigger " + t.getTriggerId(); if (t.getStatus().equals(TriggerStatus.READY)) { /** * Prior to this change, expiration condition should never be called though * we have some related code here. ExpireCondition used the same BasicTimeChecker * as triggerCondition do. As a consequence, we need to figure out a way to distinguish * the previous ExpireCondition and this commit's ExpireCondition. */ if (t.getExpireCondition().getExpression().contains("EndTimeChecker") && t .expireConditionMet()) { onTriggerPause(t); } else if (t.triggerConditionMet()) { onTriggerTrigger(t); } } if (t.getStatus().equals(TriggerStatus.EXPIRED) && t.getSource().equals("azkaban")) { removeTrigger(t); } else { t.updateNextCheckTime(); } } catch (final Throwable th) { //skip this trigger, moving on to the next one logger.error("Failed to process trigger with id : " + t, th); } } }
@Override public List<Trigger> getTriggers(final String triggerSource) { final List<Trigger> triggers = new ArrayList<>(); for (final Trigger t : triggerIdMap.values()) { if (t.getSource().equals(triggerSource)) { triggers.add(t); } } return triggers; }
@Override public String getTriggerSources() { Set<String> sources = new HashSet<String>(); for(Trigger t : triggerIdMap.values()) { sources.add(t.getSource()); } return sources.toString(); }
@Override public List<Trigger> getTriggers(String triggerSource) { List<Trigger> triggers = new ArrayList<Trigger>(); for(Trigger t : triggerIdMap.values()) { if(t.getSource().equals(triggerSource)) { triggers.add(t); } } return triggers; }
@Override public String getTriggerSources() { final Set<String> sources = new HashSet<>(); for (final Trigger t : triggerIdMap.values()) { sources.add(t.getSource()); } return sources.toString(); }
@Override public List<Trigger> getTriggerUpdates(String triggerSource, long lastUpdateTime) throws TriggerManagerException{ List<Trigger> triggers = new ArrayList<Trigger>(); for(Trigger t : triggerIdMap.values()) { if(t.getSource().equals(triggerSource) && t.getLastModifyTime() > lastUpdateTime) { triggers.add(t); } } return triggers; }
@Override public List<Trigger> getTriggerUpdates(final String triggerSource, final long lastUpdateTime) throws TriggerManagerException { final List<Trigger> triggers = new ArrayList<>(); for (final Trigger t : triggerIdMap.values()) { if (t.getSource().equals(triggerSource) && t.getLastModifyTime() > lastUpdateTime) { triggers.add(t); } } return triggers; }
public String getDescription() { final StringBuffer actionsString = new StringBuffer(); for (final TriggerAction act : this.actions) { actionsString.append(", "); actionsString.append(act.getDescription()); } return "Trigger from " + getSource() + " with trigger condition of " + this.triggerCondition.getExpression() + " and expire condition of " + this.expireCondition.getExpression() + actionsString; }
public String getDescription() { StringBuffer actionsString = new StringBuffer(); for(TriggerAction act : actions) { actionsString.append(", "); actionsString.append(act.getDescription()); } return "Trigger from " + getSource() + " with trigger condition of " + triggerCondition.getExpression() + " and expire condition of " + expireCondition.getExpression() + actionsString; }
int updates = runner.update( connection, UPDATE_TRIGGER, t.getSource(), t.getLastModifyTime(), encType.getNumVal(),
private void updateTrigger(final Trigger t, final EncodingType encType) throws TriggerLoaderException { final String json = JSONUtils.toJSON(t.toJson()); byte[] data = null; try { final byte[] stringData = json.getBytes("UTF-8"); data = stringData; if (encType == EncodingType.GZIP) { data = GZIPUtils.gzipBytes(stringData); } logger.debug( "NumChars: " + json.length() + " UTF-8:" + stringData.length + " Gzip:" + data.length); } catch (final IOException e) { logger.error("Trigger encoding fails", e); throw new TriggerLoaderException("Error encoding the trigger " + t.toString(), e); } try { final int updates = this.dbOperator .update(UPDATE_TRIGGER, t.getSource(), t.getLastModifyTime(), encType.getNumVal(), data, t.getTriggerId()); if (updates == 0) { throw new TriggerLoaderException("No trigger has been updated."); } } catch (final SQLException ex) { logger.error("Updating Trigger " + t.getTriggerId() + " failed."); throw new TriggerLoaderException("DB Trigger update failed. ", ex); } }
if(t.getStatus().equals(TriggerStatus.EXPIRED) && t.getSource().equals("azkaban")) { removeTrigger(t); } else {
private void checkAllTriggers() throws TriggerManagerException { // sweep through the rest of them for (final Trigger t : this.triggers) { try { TriggerManager.this.scannerStage = "Checking for trigger " + t.getTriggerId(); if (t.getStatus().equals(TriggerStatus.READY)) { /** * Prior to this change, expiration condition should never be called though * we have some related code here. ExpireCondition used the same BasicTimeChecker * as triggerCondition do. As a consequence, we need to figure out a way to distinguish * the previous ExpireCondition and this commit's ExpireCondition. */ if (t.getExpireCondition().getExpression().contains("EndTimeChecker") && t .expireConditionMet()) { onTriggerPause(t); } else if (t.triggerConditionMet()) { onTriggerTrigger(t); } } if (t.getStatus().equals(TriggerStatus.EXPIRED) && t.getSource().equals("azkaban")) { removeTrigger(t); } else { t.updateNextCheckTime(); } } catch (final Throwable th) { //skip this trigger, moving on to the next one logger.error("Failed to process trigger with id : " + t, th); } } }