public void deleteFromStaging(UUID timeUUID){ try{ stagingAccessor.deleteBy(timeUUID); } catch (UnavailableException | NoHostAvailableException e){ throw new RepositoryException("Could not delete the payloads from staging", e); } }
Stream<AppPage> getAppPagesFromCassandra(Application.Name applicationName) { Optional<Iterator<AppPage>> optionalResult = Optional.empty(); try { optionalResult = Optional.ofNullable(appPageIndexAccessor.selectBy(applicationName.toString()).iterator()); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve the pages and its associated experiments for application:\"" + applicationName + "\"", e); } return StreamSupport.stream( Spliterators.spliteratorUnknownSize(optionalResult.orElse(Collections.emptyIterator()) , Spliterator.ORDERED), false); }
List<AppRole> getAppRoleList(Application.Name applicationName) { List<AppRole> resultList = Collections.EMPTY_LIST; try { Result<AppRole> result = appRoleAccessor.getAppRoleByAppName(applicationName.toString()); resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false) .collect(Collectors.toList()); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve info for app \"" + applicationName + "\"", e); } return resultList; }
Stream<ExperimentUserByUserIdContextAppNameExperimentId> getUserIndexStream(String userId, String appName, String context) { Stream<ExperimentUserByUserIdContextAppNameExperimentId> resultStream = Stream.empty(); try { final Result<ExperimentUserByUserIdContextAppNameExperimentId> result = experimentUserIndexAccessor.selectBy(userId, appName, context); resultStream = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve assignments for " + "experimentID = \"" + appName + "\" userID = \"" + userId + "\" and context " + context, e); } return resultStream; }
List<com.intuit.wasabi.repository.cassandra.pojo.UserInfo> getUserInfoList(UserInfo.Username userID) { List<com.intuit.wasabi.repository.cassandra.pojo.UserInfo> resultList = Collections.EMPTY_LIST; try { Result<com.intuit.wasabi.repository.cassandra.pojo.UserInfo> result = userInfoAccessor.getUserInfoBy(userID.getUsername()); resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false) .collect(Collectors.toList()); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve info for user \"" + userID + "\"", e); } return resultList; }
/** * {@inheritDoc} */ @Override public List<UserFeedback> getAllUserFeedback() { LOGGER.debug("Getting all user feedbacks "); List<UserFeedback> feedbacks = new ArrayList<>(); try { Result<com.intuit.wasabi.repository.cassandra.pojo.UserFeedback> result = userFeedbackAccessor.getAllUserFeedback(); feedbacks = makeFeedbacksFromResult(result); } catch (Exception e) { LOGGER.error("Error while getting all user feedback", e); throw new RepositoryException("Could not retrieve feedback from all users", e); } return feedbacks; }
@Override @Timed public void pushAssignmentToStaging(String type, String exception, String data) { try { stagingAccessor.insertBy(type, exception, data); } catch (WriteTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not push the assignment to staging", e); } }
public Map<UUID, String> getBatchPayloadsFromStaging(int batchSize){ Map<UUID, String> payloads = null; try { ResultSet result = stagingAccessor.batchSelectBy(batchSize); payloads = getPayloadsFromCassandraResult(result); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e){ throw new RepositoryException("Could not get the payloads from staging", e); } return payloads; }
List<com.intuit.wasabi.repository.cassandra.pojo.UserRole> getUserRolesWithWildcardAppName( UserInfo.Username userID, Application.Name applicationName ) { //intialize to safe guard against null points List<com.intuit.wasabi.repository.cassandra.pojo.UserRole> resultList = Collections.emptyList(); try { Result<com.intuit.wasabi.repository.cassandra.pojo.UserRole> result = userRoleAccessor.getUserRolesByUserIdWithWildcardAppName(userID.getUsername()); resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false) .collect(Collectors.toList()); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve permissions for user \"" + userID + "\" and application " + "\"" + applicationName + "\"", e); } return resultList; }
/** * {@inheritDoc} */ @Override public ExperimentList getExperiments(Collection<Experiment.ID> experimentIDs) { LOGGER.debug("Getting experiments {}", experimentIDs); ExperimentList result = new ExperimentList(); try { if (!experimentIDs.isEmpty()) { Map<Experiment.ID, Experiment> experimentMap = getExperimentsMap(experimentIDs); List<Experiment> experiments = new ArrayList<>(experimentMap.values()); result.setExperiments(experiments); } } catch (Exception e) { LOGGER.error("Error while getting experiments {}", experimentIDs, e); throw new RepositoryException("Could not retrieve the experiments for the collection of experimentIDs", e); } return result; }
/** * {@inheritDoc} */ @Override public void deleteBucket(Experiment.ID experimentID, Bucket.Label bucketLabel) { Preconditions.checkNotNull(experimentID, "Parameter \"experimentID\" cannot be null"); Preconditions.checkNotNull(bucketLabel, "Parameter \"bucketLabel\" cannot be null"); try { bucketAccessor.deleteByExperimentIdAndLabel(experimentID.getRawID(), bucketLabel.toString()); } catch (Exception e) { throw new RepositoryException("Could not delete bucket \"" + bucketLabel + "\" from experiment with ID \"" + experimentID + "\"", e); } }
/** * {@inheritDoc} */ @Override public List<Application.Name> getApplicationsList() { List<Application.Name> result = new ArrayList<>(); try { result = applicationListAccessor.getUniqueAppName().all().stream() .map(app -> Application.Name.valueOf(app.getAppName())).collect(Collectors.toList()); } catch (Exception e) { throw new RepositoryException("Could not retrieve the application names because : " + e, e); } return result; }
/** * {@inheritDoc} */ @Override public Statement createApplication(Application.Name applicationName) { LOGGER.debug("Creating application {}", applicationName); try { return applicationListAccessor.insert(applicationName.toString()); } catch (Exception e) { LOGGER.error("Error while creating application {}", applicationName, e); throw new RepositoryException("Unable to insert into top level application list: \"" + applicationName.toString() + "\"" + e); } }
protected void removeExperimentLabelIndex(Application.Name appName, Experiment.Label experimentLabel) { LOGGER.debug("Removing experiment label index for app {}, label {} ", new Object[]{ appName, experimentLabel}); try { experimentLabelIndexAccessor.deleteBy(appName.toString(), experimentLabel.toString()); } catch (Exception e) { LOGGER.error("Error while removing experiment label index for app {}, label {} ", new Object[]{ appName, experimentLabel}, e); throw new RepositoryException("Could not remove index for " + "experiment \"" + appName + "\".\"" + experimentLabel + "\"", e); } }
/** * {@inheritDoc} */ @Override public List<AuditLogEntry> getCompleteAuditLogEntryList() { LOGGER.debug("Getting complete audit log entries"); try { Result<AuditLog> result = accessor.getCompleteAuditLogEntryList(); return makeAuditLogEntries(result.all()); } catch (Exception e) { LOGGER.error("Error while getting audit log entries list", e); throw new RepositoryException( "Unable to receive complete audit log entry list"); } }
/** * {@inheritDoc} */ @Override public void updateStateIndex(Experiment experiment) { LOGGER.debug("update state index experiment {} ", experiment); try { updateStateIndex(experiment.getID(), experiment.getState() != State.DELETED ? ExperimentState.NOT_DELETED : ExperimentState.DELETED); } catch (Exception e) { LOGGER.error("update state index experiment {} ", experiment, e); throw new RepositoryException("Exception while updating state index: " + e, e); } }
/** * {@inheritDoc} */ @Override public List<Experiment.ID> getExperiments() { LOGGER.debug("Getting experiment ids which are live {}", ExperimentState.NOT_DELETED); try { // Get all experiments that are live Result<StateExperimentIndex> ids = stateExperimentIndexAccessor .selectByKey(ExperimentState.NOT_DELETED.name()); List<ID> experimentIds = ids.all().stream().map( sei -> Experiment.ID.valueOf(sei.getExperimentId())).collect(Collectors.toList()); return experimentIds; } catch (Exception e) { LOGGER.error("Error while getting experiment ids which are live {}", ExperimentState.NOT_DELETED, e); throw new RepositoryException("Could not retrieve experiments", e); } }
/** * {@inheritDoc} */ @Override public List<UserFeedback> getUserFeedback(UserInfo.Username username) throws RepositoryException { LOGGER.debug("Getting user feedback for {}", username); Preconditions.checkNotNull(username, "Parameter \"username\" cannot be null"); List<UserFeedback> feedbacks = new ArrayList<>(); try { Result<com.intuit.wasabi.repository.cassandra.pojo.UserFeedback> result = userFeedbackAccessor.getUserFeedback(username.getUsername()); feedbacks = makeFeedbacksFromResult(result); } catch (Exception e) { LOGGER.error("Error while getting feedback for user " + username.getUsername(), e); throw new RepositoryException("Could not retrieve feedback from user " + username, e); } return feedbacks; }
void executeBatchStatement(Experiment.ID experimentID, BatchStatement batch) { try { ResultSet resultSet = mappingManager.getSession().execute(batch); logger.debug("Batch statement is applied: {} using consistency level: {}", resultSet.wasApplied(), resultSet.getExecutionInfo().getAchievedConsistencyLevel()); } catch (WriteTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not add the page(s) to the experiment:\"" + experimentID + "\"", e); } }
/** * {@inheritDoc} */ @Override public void deleteExperiment(NewExperiment newExperiment) { LOGGER.debug("Deleting experiment {}", newExperiment); try { experimentAccessor.deleteExperiment(newExperiment.getID().getRawID()); } catch (Exception e) { LOGGER.debug("Error while deleting experiment {}", newExperiment, e); throw new RepositoryException("Could not delete experiment " + "with id \"" + newExperiment.getId() + "\"", e); } }