@Override public void serialize(Label label, JsonGenerator generator, SerializerProvider provider) throws IOException { generator.writeString(label.toString()); } }
@Override public Label deserialize(JsonParser parser, DeserializationContext context) throws IOException { return Label.valueOf(parser.getText()); } }
if (updates.getLabel() != null && !updates.getLabel().equals(experiment.getLabel())) { builder.withLabel(updates.getLabel()); requiresUpdate = true;
expLabelString = auditLog.getExperimentLabel(); if (!StringUtils.isBlank(expLabelString)) experimentLabel = Label.valueOf(expLabelString); } catch (Exception e) { LOGGER.warn("Exception while creating audit log experiment label: "
newExperiment.getEndTime(), DRAFT.name(), newExperiment.getLabel().toString(), newExperiment.getApplicationName().toString(), NOW, batchStmt.add(experimentLabelIndexAccessor.insertOrUpdateStatementBy(newExperiment.getId().getRawID(), NOW, newExperiment.getStartTime(), newExperiment.getEndTime(), DRAFT.name(), newExperiment.getApplicationName().toString(), newExperiment.getLabel().toString()));
mutexRepository.createExclusion(baseID, pairID); eventLog.postEvent(new ExperimentChangeEvent(user, baseExp, "mutex", null, pairExp.getLabel() == null ? null : pairExp.getLabel().toString())); } catch (RepositoryException rExp) { LOGGER.error("Unable to store data in repository: ", rExp);
experiment.getEndTime(), experiment.getState().name(), experiment.getLabel().toString(), experiment.getApplicationName().toString(), NOW,
List results = newTransaction().select(SQL, appName.toString(), experimentLabel.toString(), State.DELETED.toString()); .withLabel(Experiment.Label.valueOf((String) experimentMap.get("label"))) .withEndTime((Date) experimentMap.get("end_time")) .withDescription((String) experimentMap.get("description"))
.withLabel(Experiment.Label.valueOf((String) experimentMap.get("label"))) .withEndTime((Date) experimentMap.get("end_time")) .withDescription((String) experimentMap.get("description"))
"Cannot change application name when the experiment is in TERMINATED state"); if (updates.getLabel() != null && !updates.getLabel().equals(experiment.getLabel())) { throw new IllegalArgumentException("Invalid label \"" + updates.getLabel() + "\" " + "Cannot change label when the experiment is in TERMINATED state");
} catch (BucketDistributionNotFetchableException e) { LOGGER.error("Error obtaining the Bucket List from {} for user_id {}, for experiment: {} due to {}", assignmentDecorator.getClass().getSimpleName(), userID, experiment.getLabel().toString(), e); } finally {
.getExperimentId().getRawID(); String experimentLabel = entry.getExperimentLabel() == null ? "" : entry.getExperimentLabel().toString(); String bucketLabel = entry.getBucketLabel() == null ? "" : entry .getBucketLabel().toString();
eventJson.put("experimentLabel", experimentLabel != null ? experimentLabel.toString(): null); eventJson.put("userID", assignment != null && assignment.getUserID() != null ? assignment.getUserID().toString(): null);
).build(); experimentObject.setLabel(Experiment.Label.valueOf( Preconditions.checkNotNull(experimentPojo.getLabel()))); experimentObject.setApplicationName(
@Override public List<PageExperiment> getExperiments(Application.Name applicationName, Page.Name pageName) { Stream<PageExperimentByAppNamePage> resultList = Stream.empty(); try { Result<PageExperimentByAppNamePage> result = pageExperimentIndexAccessor.selectBy(applicationName.toString(), pageName.toString()); resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException(new StringBuilder("Could not retrieve the experiments for applicationName:\"").append(applicationName).append("\", page:\"").append(pageName).append("\"").toString(), e); } //TODO: make the experiment label part of the pageExperimentIndex to save a query per page return resultList .map(t -> { Optional<com.intuit.wasabi.repository.cassandra.pojo.Experiment> experiment = Optional.ofNullable(experimentAccessor.selectBy(t.getExperimentId()).one()); PageExperiment.Builder builder = new PageExperiment.Builder( Experiment.ID.valueOf(t.getExperimentId()), null, t.isAssign() ); if (experiment.isPresent()) { builder.setLabel(Experiment.Label.valueOf(experiment.get().getLabel())); } return builder.build(); } ).filter(t -> t.getLabel() != null) .collect(Collectors.toList()); }
@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; }
: "", newExperiment.getSamplingPercent(), newExperiment.getLabel().toString(), newExperiment.getStartTime(), newExperiment.getEndTime(),
/** * {@inheritDoc} */ protected Experiment internalGetExperiment(Application.Name appName, Experiment.Label experimentLabel) { LOGGER.debug("Getting experiment by app {} with label {} ", new Object[]{appName, experimentLabel}); Preconditions.checkNotNull(appName, "Parameter \"appName\" cannot be null"); Preconditions.checkNotNull(experimentLabel, "Parameter \"experimentLabel\" cannot be null"); Experiment experiment = null; try { ExperimentByAppNameLabel experimentAppLabel = experimentLabelIndexAccessor .getExperimentBy(appName.toString(), experimentLabel.toString()).one(); if (experimentAppLabel != null) { com.intuit.wasabi.repository.cassandra.pojo.Experiment experimentPojo = experimentAccessor .getExperimentById(experimentAppLabel.getId()).one(); experiment = ExperimentHelper.makeExperiment(experimentPojo); } } catch (Exception e) { LOGGER.error("Error while getting experiment by app {} with label {} ", new Object[]{appName, experimentLabel}, e); throw new RepositoryException("Could not retrieve experiment \"" + appName + "\".\"" + experimentLabel + "\"", e); } LOGGER.debug("Returning experiment {}", experiment); return experiment; }
/** * {@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()); }