public void setHash(Hash hash) { if (hash==null) hash = Hash.zero(); this.hash = hash; }
/** * Called when a {@link Trigger} is loaded into memory and started. * * @param project * given so that the persisted form of this object won't have to have a back pointer. * @param newInstance * True if this may be a newly created trigger first attached to the {@link Project} (generally if the project is being created or configured). * False if this is invoked for a {@link Project} loaded from disk. * @see Items#currentlyUpdatingByXml */ public void start(J project, boolean newInstance) { this.job = project; try {// reparse the tabs with the job as the hash if (spec != null) { this.tabs = CronTabList.create(spec, Hash.from(project.getFullName())); } else { LOGGER.log(Level.WARNING, "The job {0} has a null crontab spec which is incorrect", job.getFullName()); } } catch (ANTLRException e) { // this shouldn't fail because we've already parsed stuff in the constructor, // so if it fails, use whatever 'tabs' that we already have. LOGGER.log(Level.WARNING, String.format("Failed to parse crontab spec %s in job %s", spec, project.getFullName()), e); } }
protected long doHash(int s, int e, int step, int field) throws ANTLRException { rangeCheck(s, field); rangeCheck(e, field); if (step > e - s + 1) { error(Messages.BaseParser_OutOfRange(step, 1, e - s + 1)); throw new AssertionError(); } else if (step > 1) { long bits = 0; for (int i = hash.next(step) + s; i <= e; i += step) { bits |= 1L << i; } assert bits != 0; return bits; } else if (step <=0) { error(Messages.BaseParser_MustBePositive(step)); throw new AssertionError(); } else { assert step==NO_STEP; // step=1 (i.e. omitted) in the case of hash is actually special; means pick one value, not step by 1 return 1L << (s+hash.next(e+1-s)); } }
/** * Performs syntax check. */ public FormValidation doCheckSpec(@QueryParameter String value, @AncestorInPath Item item) { try { CronTabList ctl = CronTabList.create(fixNull(value), item != null ? Hash.from(item.getFullName()) : null); Collection<FormValidation> validations = new ArrayList<>(); updateValidationsForSanity(validations, ctl); updateValidationsForNextRun(validations, ctl); return FormValidation.aggregate(validations); } catch (ANTLRException e) { if (value.trim().indexOf('\n')==-1 && value.contains("**")) return FormValidation.error(Messages.TimerTrigger_MissingWhitespace()); return FormValidation.error(e.getMessage()); } }
protected long doHash(int s, int e, int step, int field) throws ANTLRException { rangeCheck(s, field); rangeCheck(e, field); if (step > e - s + 1) { error(Messages.BaseParser_OutOfRange(step, 1, e - s + 1)); throw new AssertionError(); } else if (step > 1) { long bits = 0; for (int i = hash.next(step) + s; i <= e; i += step) { bits |= 1L << i; } assert bits != 0; return bits; } else if (step <=0) { error(Messages.BaseParser_MustBePositive(step)); throw new AssertionError(); } else { assert step==NO_STEP; // step=1 (i.e. omitted) in the case of hash is actually special; means pick one value, not step by 1 return 1L << (s+hash.next(e+1-s)); } }
protected Hash getHashForTokens() { return HASH_TOKENS ? hash : Hash.zero(); }
/** * Performs syntax check. */ public FormValidation doCheckSpec(@QueryParameter String value, @AncestorInPath Item item) { try { CronTabList ctl = CronTabList.create(fixNull(value), item != null ? Hash.from(item.getFullName()) : null); Collection<FormValidation> validations = new ArrayList<>(); updateValidationsForSanity(validations, ctl); updateValidationsForNextRun(validations, ctl); return FormValidation.aggregate(validations); } catch (ANTLRException e) { if (value.trim().indexOf('\n')==-1 && value.contains("**")) return FormValidation.error(Messages.TimerTrigger_MissingWhitespace()); return FormValidation.error(e.getMessage()); } }
public void setHash(Hash hash) { if (hash==null) hash = Hash.zero(); this.hash = hash; }
/** * Called when a {@link Trigger} is loaded into memory and started. * * @param project * given so that the persisted form of this object won't have to have a back pointer. * @param newInstance * True if this may be a newly created trigger first attached to the {@link Project} (generally if the project is being created or configured). * False if this is invoked for a {@link Project} loaded from disk. * @see Items#currentlyUpdatingByXml */ public void start(J project, boolean newInstance) { this.job = project; try {// reparse the tabs with the job as the hash if (spec != null) { this.tabs = CronTabList.create(spec, Hash.from(project.getFullName())); } else { LOGGER.log(Level.WARNING, "The job {0} has a null crontab spec which is incorrect", job.getFullName()); } } catch (ANTLRException e) { // this shouldn't fail because we've already parsed stuff in the constructor, // so if it fails, use whatever 'tabs' that we already have. LOGGER.log(Level.WARNING, String.format("Failed to parse crontab spec %s in job %s", spec, project.getFullName()), e); } }
protected Hash getHashForTokens() { return HASH_TOKENS ? hash : Hash.zero(); }