.append(endTime, other.getEndTime()) .append(state, other.getState()) .append(label, other.getLabel()) .append(applicationName, other.getApplicationName()) .append(isPersonalizationEnabled, other.getIsPersonalizationEnabled())
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()); }
/** * Get the experiment label based on experiment ID * If metadata cache is enabled then fetch from cache else fetch from database. * * @param experimentID * @return */ protected Experiment.Label getExperimentLabel(Experiment.ID experimentID) { if (isNull(experimentID)) return null; Experiment.Label label = null; Experiment exp = null; if (metadataCacheEnabled) { Optional<Experiment> expOptional = metadataCache.getExperimentById(experimentID); exp = expOptional.isPresent() ? expOptional.get() : null; } else { exp = repository.getExperiment(experimentID); } if (nonNull(exp)) { label = exp.getLabel(); } return label; }
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(); }
/** * {@inheritDoc} */ @Override public void deleteExclusion(Experiment.ID expID_1, Experiment.ID expID_2, UserInfo user) { Experiment exp_1 = experiments.getExperiment(expID_1); Experiment exp_2 = experiments.getExperiment(expID_2); // Check that expID_1 is a valid experiment if (exp_1 == null) { throw new ExperimentNotFoundException(expID_1); } // Check that expID_2 is a valid experiment if (exp_2 == null) { throw new ExperimentNotFoundException(expID_2); } mutexRepository.deleteExclusion(expID_1, expID_2); eventLog.postEvent(new ExperimentChangeEvent(user, exp_1, "mutex", exp_2.getLabel().toString(), null)); LOGGER.info("event=EXPERIMENT_METADATA_CHANGE, message=MUTUAL_EXCLUSION_DELETED, applicationName={}, configuration=[experiment1={}, experiment2={}]", exp_1.getApplicationName(), exp_1.getLabel(), exp_2.getLabel()); }
experiment.getApplicationName(), experiment.getLabel(), priorityNum);
.append(endTime, other.getEndTime()) .append(state, other.getState()) .append(label, other.getLabel()) .append(applicationName, other.getApplicationName()) .append(isPersonalizationEnabled, other.getIsPersonalizationEnabled())
/** * {@inheritDoc} */ @Override public void postPages(Experiment.ID experimentID, ExperimentPageList experimentPageList, UserInfo user) { Application.Name applicationName = getApplicationNameForModifyingPages(experimentID); pagesRepository.postPages(applicationName, experimentID, experimentPageList); Experiment experiment = experiments.getExperiment(experimentID); if (experiment != null) { List<String> pageNames = new ArrayList<>(); for (ExperimentPage experimentPage : experimentPageList.getPages()) { pageNames.add(experimentPage.getName().toString()); } String pageString = StringUtils.join(pageNames, ", "); eventLog.postEvent(new ExperimentChangeEvent(user, experiment, "pages", null, pageString)); LOGGER.info("event=EXPERIMENT_METADATA_CHANGE, message=PAGES_ADDED, applicationName={}, experimentName={}, configuration=[pages={}]", experiment.getApplicationName(), experiment.getLabel(), pageString); } }
/** * {@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); } }
/** * {@inheritDoc} */ @Override public void deletePage(Experiment.ID experimentID, Page.Name pageName, UserInfo user) { Application.Name applicationName = getApplicationNameForModifyingPages(experimentID); pagesRepository.deletePage(applicationName, experimentID, pageName); Experiment experiment = experiments.getExperiment(experimentID); if (experiment != null) { eventLog.postEvent(new ExperimentChangeEvent(user, experiment, "pages", pageName.toString(), null)); } LOGGER.info("event=EXPERIMENT_METADATA_CHANGE, message=PAGE_REMOVED, applicationName={}, experimentName={}, configuration=[pageName={}, userName={}]", experiment.getApplicationName(), experiment.getLabel(), pageName, user.getUsername()); }
/** * 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 void updateExperimentState(final Experiment experiment, final Experiment.State state) { try { cassandraRepository.updateExperimentState(experiment, state); // To maintain consistency, revert the changes made in cassandra in case the mysql update fails try { databaseRepository.updateExperimentState(experiment, state); } catch (Exception exception) { cassandraRepository.updateExperimentState(experiment, experiment.getState()); throw exception; } eventLog.postEvent(new ExperimentChangeEvent(experiment, "state", experiment.getState().toString(), state.toString())); } catch (Exception exception) { LOGGER.error("Updating experiment state for experiment:{} failed with error:", experiment, exception); throw exception; } LOGGER.info("event=EXPERIMENT_METADATA_CHANGE, message=EXPERIMENT_STATE_UPDATED, applicationName={}, configuration=[experimentName={}, oldState={}, newState={}]", experiment.getApplicationName(), experiment.getLabel(), experiment.getState(), state); } }
/** * {@inheritDoc} */ @Override public Table<Experiment.ID, Experiment.Label, Experiment> getExperimentList(Application.Name appName) { try { List<com.intuit.wasabi.repository.cassandra.pojo.Experiment> experimentPojos = experimentAccessor.getExperimentByAppName(appName.toString()).all(); Table<Experiment.ID, Experiment.Label, Experiment> result = HashBasedTable.create(); for (com.intuit.wasabi.repository.cassandra.pojo.Experiment experimentPojo : experimentPojos) { Experiment experiment = ExperimentHelper.makeExperiment(experimentPojo); if (experiment.getState() != State.TERMINATED && experiment.getState() != State.DELETED) { result.put(experiment.getID(), experiment.getLabel(), experiment); } } return result; } catch (Exception e) { throw new RepositoryException("Could not retrieve experiment list " + appName.toString() + "because: " + e, e); } }
/** * {@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()); }
@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; }
experiment.getApplicationName(), experiment.getLabel(), bucket);
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(); }