.append(samplingPercent, other.getSamplingPercent()) .append(startTime, other.getStartTime()) .append(endTime, other.getEndTime()) .append(state, other.getState()) .append(label, other.getLabel())
public void validateExperiment(Experiment experiment) { Experiment.State state = experiment.getState(); if (state.equals(Experiment.State.DELETED) || state.equals(Experiment.State.TERMINATED)) { return; } validateLabel(experiment.getLabel()); validateExperimentStartEnd(experiment.getStartTime(), experiment.getEndTime()); validateSamplingPercent(experiment.getSamplingPercent()); validateExperimentRule(experiment.getRule()); validateModelNameNotNullForPersonalizedExperiments(experiment.getIsPersonalizationEnabled() , experiment.getModelName()); }
void checkForIllegalExperimentEndTime(Experiment current, Experiment update) { if (update.getEndTime().before(currentDate)) { throw new IllegalArgumentException("Invalid endTime \"" + update.getEndTime() + "\". " + "Cannot set the experiment end time to a value in the past"); } else if (current.getEndTime().before(currentDate)) { throw new IllegalArgumentException("Invalid endTime \"" + update.getEndTime() + "\". " + "Cannot update the experiment endTime that has already passed"); } else { if (update.getStartTime() != null) { if (update.getEndTime().before(update.getStartTime())) { throw new IllegalArgumentException("Invalid startTime \"" + update.getEndTime() + "\". " + "Cannot update the experiment endTime to a value preceding the experiment startTime"); } } else { if (update.getEndTime().before(current.getStartTime())) { throw new IllegalArgumentException("Invalid startTime \"" + update.getEndTime() + "\". " + "Cannot update the experiment endTime to a value preceding the experiment startTime"); } } } }
void checkForIllegalExperimentStartTime(Experiment current, Experiment update) { if (update.getStartTime().before(currentDate)) { throw new IllegalArgumentException("Invalid startTime \"" + update.getStartTime() + "\". " + "Cannot set the experiment start time to a value in the past"); } else if (current.getStartTime().before(currentDate)) { throw new IllegalArgumentException("Invalid startTime \"" + update.getStartTime() + "\". " + "Cannot update the experiment startTime that has already passed"); } else { if (update.getEndTime() != null) { if (update.getStartTime().after(update.getEndTime())) { throw new IllegalArgumentException("Invalid startTime \"" + update.getStartTime() + "\". " + "Cannot update the experiment startTime to a value beyond the experiment endTime"); } } else { if (update.getStartTime().after(current.getEndTime())) { throw new IllegalArgumentException("Invalid startTime \"" + update.getStartTime() + "\". " + "Cannot update the experiment startTime to a value beyond the experiment endTime"); } } } }
private Builder(Experiment other, Integer priority) { this(other.getID()); instance.creationTime = copyDate(other.getCreationTime()); instance.modificationTime = copyDate(other.getModificationTime()); instance.setDescription(other.getDescription()); instance.setSamplingPercent(other.getSamplingPercent()); instance.setRule(other.getRule()); instance.setStartTime(copyDate(other.getStartTime())); instance.setEndTime(copyDate(other.getEndTime())); instance.setState(other.getState()); instance.setLabel(other.getLabel()); instance.setApplicationName(other.getApplicationName()); instance.setPriority(priority); instance.setIsPersonalizationEnabled(other.getIsPersonalizationEnabled()); instance.setModelName(other.getModelName()); instance.setModelVersion(other.getModelVersion()); instance.isRapidExperiment = other.getIsRapidExperiment(); instance.userCap = other.getUserCap(); instance.creatorID = other.getCreatorID(); instance.tags = other.getTags(); }
Date toTs = parameters.getToTime(); Timestamp fromTsNew = fromTs != null ? new Timestamp(fromTs.getTime()) : new Timestamp(id.getStartTime().getTime()); Timestamp toTsNew = toTs != null ? new Timestamp(toTs.getTime()) : new Timestamp(id.getEndTime().getTime());
private Application.Name getApplicationNameForModifyingPages(Experiment.ID experimentID) { Experiment experiment = experiments.getExperiment(experimentID); // Throw an exception if the experiment is not found if (experiment == null) { throw new ExperimentNotFoundException(experimentID); } Application.Name applicationName = experiment.getApplicationName(); // Throw an exception if the experiment is in a TERMINATED state if (experiment.getState() == TERMINATED) { throw new InvalidExperimentStateException("Experiment must be in DRAFT, RUNNING or PAUSED states\"" + experimentID); } // Throw an exception if the experiment's end time has passed if (experiment.getEndTime().before(NOW)) { throw new IllegalArgumentException("Cannot modify pages of the experiment \"" + experimentID + "\" that has passed its end time"); } return applicationName; }
Date baseEndTime = baseExp.getEndTime(); final Date baseTimestamp = new Timestamp(baseEndTime.getTime()); Date pairEndTime = pairExp.getEndTime(); final Date pairTimestamp = new Timestamp(pairEndTime.getTime());
.append(samplingPercent, other.getSamplingPercent()) .append(startTime, other.getStartTime()) .append(endTime, other.getEndTime()) .append(state, other.getState()) .append(label, other.getLabel())
if (currentTime > experiment.getEndTime().getTime()) { return nullAssignment(userID, applicationName, experimentID, Assignment.Status.EXPERIMENT_EXPIRED);
/** * {@inheritDoc} */ @Override public void checkForIllegalPausedRunningUpdate(Experiment experiment, Experiment updates) { /* Throw an exception if the experiment is in RUNNING/PAUSED state and if applicationName or Label is being updated. Also, if startTime/endTime is being updated with a value that has already passed or when the established startTime/endTime has already passed. */ if (experiment.getState().equals(RUNNING) || experiment.getState().equals(PAUSED)) { if (updates.getApplicationName() != null && !updates.getApplicationName().equals(experiment.getApplicationName())) throw new IllegalArgumentException("Cannot change AppName when the experiment is not in DRAFT state"); if (updates.getLabel() != null && !updates.getLabel().equals(experiment.getLabel())) throw new IllegalArgumentException("Cannot change Label when the experiment is not in DRAFT state"); if (updates.getStartTime() != null && !updates.getStartTime().equals(experiment.getStartTime())) checkForIllegalExperimentStartTime(experiment, updates); if (updates.getEndTime() != null && !updates.getEndTime().equals(experiment.getEndTime())) checkForIllegalExperimentEndTime(experiment, updates); } }
end_ts = exp.getEndTime();
"Cannot change start time when the experiment is in TERMINATED state"); if (updates.getEndTime() != null && !updates.getEndTime().equals(experiment.getEndTime())) { throw new IllegalArgumentException("Invalid endTime \"" + updates.getEndTime() + "\" " + "Cannot change end time when the experiment is in TERMINATED state");
Date end_ts = exp.getEndTime(); Calendar end_cal = createCalendarMidnight(end_ts); DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
/** * Creates the ExperimentDetail with a given Experiment and the total number of users. * * @param exp the experiment that provides the basic information */ public ExperimentDetail(Experiment exp) { this(exp.getID(), exp.getState(), exp.getLabel(), exp.getApplicationName(), exp.getModificationTime(), exp.getStartTime(), exp.getEndTime(), exp.getDescription(), exp.getTags()); }
/** * {@inheritDoc} */ @Override public Experiment updateExperimentState(Experiment experiment, State state) { LOGGER.debug("Updating experiment {} state {} ", new Object[]{experiment, state}); validator.validateExperiment(experiment); try { // Note that this timestamp gets serialized as mulliseconds from // the epoch, so timezone is irrelevant final Date NOW = new Date(); experimentAccessor.updateExperiment(state.name(), NOW, experiment.getID().getRawID()); experiment = Experiment.from(experiment).withState(state).build(); // Point the experiment index to this experiment updateExperimentLabelIndex(experiment.getID(), experiment.getApplicationName(), experiment.getLabel(), experiment.getStartTime(), experiment.getEndTime(), experiment.getState()); updateStateIndex(experiment); } catch (Exception e) { LOGGER.error("Error while updating experiment {} state {} ", new Object[]{experiment, state}, e); throw new RepositoryException("Could not update experiment with ID \"" + experiment.getID() + "\"" + " to state " + state.toString(), e); } return experiment; }
public void validateExperiment(Experiment experiment) { Experiment.State state = experiment.getState(); if (state.equals(Experiment.State.DELETED) || state.equals(Experiment.State.TERMINATED)) { return; } validateLabel(experiment.getLabel()); validateExperimentStartEnd(experiment.getStartTime(), experiment.getEndTime()); validateSamplingPercent(experiment.getSamplingPercent()); validateExperimentRule(experiment.getRule()); validateModelNameNotNullForPersonalizedExperiments(experiment.getIsPersonalizationEnabled() , experiment.getModelName()); }
experiment.getSamplingPercent(), experiment.getStartTime(), experiment.getEndTime(), experiment.getState().name(), experiment.getLabel().toString(), experiment.getStartTime(), experiment.getEndTime(), experiment.getState());
@Override public Experiment updateExperiment(Experiment experiment) throws RepositoryException { validator.validateExperiment(experiment); final String SQL = "update experiment " + "set description=?, sampling_percent=?, state=?, " + "label=?, start_time=?, end_time=?, app_name=? " + "where id=?"; int rowCount = newTransaction().update( SQL, experiment.getDescription() != null ? experiment.getDescription() : "", experiment.getSamplingPercent(), experiment.getState().toString(), experiment.getLabel().toString(), experiment.getStartTime(), experiment.getEndTime(), experiment.getApplicationName().toString(), experiment.getID()); if (rowCount > 1) { throw new RepositoryException("Concurrent updates; please retry"); } if (rowCount < 1) { throw new RepositoryException("No rows were updated"); } return experiment; }
private Builder(Experiment other, Integer priority) { this(other.getID()); instance.creationTime = copyDate(other.getCreationTime()); instance.modificationTime = copyDate(other.getModificationTime()); instance.setDescription(other.getDescription()); instance.setSamplingPercent(other.getSamplingPercent()); instance.setRule(other.getRule()); instance.setStartTime(copyDate(other.getStartTime())); instance.setEndTime(copyDate(other.getEndTime())); instance.setState(other.getState()); instance.setLabel(other.getLabel()); instance.setApplicationName(other.getApplicationName()); instance.setPriority(priority); instance.setIsPersonalizationEnabled(other.getIsPersonalizationEnabled()); instance.setModelName(other.getModelName()); instance.setModelVersion(other.getModelVersion()); instance.isRapidExperiment = other.getIsRapidExperiment(); instance.userCap = other.getUserCap(); instance.creatorID = other.getCreatorID(); instance.tags = other.getTags(); }