/** * {@inheritDoc} */ @Override public ExperimentList getExclusions(Experiment.ID experimentID) { // Throw an exception if the input experiment is not valid final Experiment expID = experiments.getExperiment(experimentID); if (expID.getID() == null) { throw new ExperimentNotFoundException(experimentID); } return mutexRepository.getExclusions(experimentID); }
/** * @param expId * @return List of experiments which are mutually exclusive to the given experiment. */ @Override public List<Experiment.ID> getExclusionList(Experiment.ID expId) { List<Experiment.ID> exclusionList = null; Cache cache = cacheManager.getCache(EXPERIMENT_ID_TO_EXCLUSION_CACHE.toString()); Element val = cache.get(expId); if (isNull(val)) { exclusionList = mutexRepository.getExclusivesList(singleEntrySet(expId)).get(expId); cache.put(new Element(expId, exclusionList)); } else { exclusionList = (List<Experiment.ID>) val.getObjectValue(); } return isNull(exclusionList) ? new ArrayList<>() : exclusionList; }
/** * {@inheritDoc} */ @Override public ExperimentList getNotExclusions(Experiment.ID experimentID) { // Throw an exception if the input experiment is not valid if (experimentID == null) { throw new ExperimentNotFoundException("error, experiment not found"); } return mutexRepository.getNotExclusions(experimentID); }
mutexRepository.createExclusion(baseID, pairID); eventLog.postEvent(new ExperimentChangeEvent(user, baseExp, "mutex", null, pairExp.getLabel() == null ? null : pairExp.getLabel().toString()));
/** * {@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()); }
/** * This method refresh the existing cache (keys) with the updated data from Database. * <p> * This method doesn't add new keys into the cache. * * @return TRUE if cache is successfully refreshed else FALSE. */ @Override public boolean refresh() { //------------------------------------------------------------------------------------------------ //Get updated data from database for each caches //------------------------------------------------------------------------------------------------ List<Element> appToExperiments = makeElementsList(experimentRepository.getExperimentsForApps(keys(APP_NAME_TO_EXPERIMENTS_CACHE))); List<Element> expIdsToExperiments = makeElementsList(experimentRepository.getExperimentsMap(keys(EXPERIMENT_ID_TO_EXPERIMENT_CACHE))); List<Element> appToPrioritizedExperiments = makeElementsList(prioritiesRepository.getPriorities(keys(APP_NAME_TO_PRIORITIZED_EXPERIMENTS_CACHE))); List<Element> expIdsToExclusions = makeElementsList(mutexRepository.getExclusivesList(keys(EXPERIMENT_ID_TO_EXCLUSION_CACHE))); List<Element> expIdsToBuckets = makeElementsList(experimentRepository.getBucketList(keys(EXPERIMENT_ID_TO_BUCKET_CACHE))); List<Element> appNPageToExperiments = makeElementsList(pagesRepository.getExperimentsWithoutLabels(keys(APP_NAME_N_PAGE_TO_EXPERIMENTS_CACHE))); //------------------------------------------------------------------------------------------------ //Now update individual caches //------------------------------------------------------------------------------------------------ cacheManager.getCache(APP_NAME_TO_EXPERIMENTS_CACHE.toString()).putAll(appToExperiments); cacheManager.getCache(EXPERIMENT_ID_TO_EXPERIMENT_CACHE.toString()).putAll(expIdsToExperiments); cacheManager.getCache(APP_NAME_TO_PRIORITIZED_EXPERIMENTS_CACHE.toString()).putAll(appToPrioritizedExperiments); cacheManager.getCache(EXPERIMENT_ID_TO_EXCLUSION_CACHE.toString()).putAll(expIdsToExclusions); cacheManager.getCache(EXPERIMENT_ID_TO_BUCKET_CACHE.toString()).putAll(expIdsToBuckets); cacheManager.getCache(APP_NAME_N_PAGE_TO_EXPERIMENTS_CACHE.toString()).putAll(appNPageToExperiments); LOGGER.debug("Assignments metadata cache has been refreshed successfully..."); return Boolean.TRUE; }