@Test public void testAllowsLaunchOfQueryWhenCeilingIsAbsent() { final QueryLaunchingConstraint queryConstraint = new TotalQueryCostCeilingConstraint(Optional.<QueryCost>absent()); final QueryContext query = mock(QueryContext.class); final EstimatedImmutableQueryCollection launchedQueries = mock(EstimatedImmutableQueryCollection.class); String actualCanLaunch = queryConstraint.allowsLaunchOf(query, launchedQueries); assertNull(actualCanLaunch); }
@Override public String allowsLaunchOf( final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries) { if (!totalQueryCostCeilingPerUser.isPresent()) { return null; } final String currentUser = candidateQuery.getSubmittedUser(); QueryCost totalQueryCostForCurrentUser = launchedQueries.getTotalQueryCost(currentUser); if (totalQueryCostForCurrentUser.compareTo(totalQueryCostCeilingPerUser.get()) > 0) { return totalQueryCostForCurrentUser + "/" + totalQueryCostCeilingPerUser + " capacity utilized by " + candidateQuery.getSubmittedUser(); } return null; }
TotalQueryCostCeilingConstraint implements QueryLaunchingConstraint { @Override public String allowsLaunchOf( final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries) { if (!totalQueryCostCeilingPerUser.isPresent()) { return null; } final String currentUser = candidateQuery.getSubmittedUser(); QueryCost totalQueryCostForCurrentUser = launchedQueries.getTotalQueryCost(currentUser); if (totalQueryCostForCurrentUser.compareTo(totalQueryCostCeilingPerUser.get()) > 0) { return totalQueryCostForCurrentUser + "/" + totalQueryCostCeilingPerUser + " capacity utilized by " + candidateQuery.getSubmittedUser(); } return null; } }
TotalQueryCostCeilingConstraint implements QueryLaunchingConstraint { @Override public String allowsLaunchOf( final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries) { if (!totalQueryCostCeilingPerUser.isPresent()) { return null; } final String currentUser = candidateQuery.getSubmittedUser(); QueryCost totalQueryCostForCurrentUser = launchedQueries.getTotalQueryCost(currentUser); if (totalQueryCostForCurrentUser.compareTo(totalQueryCostCeilingPerUser.get()) > 0) { return totalQueryCostForCurrentUser + "/" + totalQueryCostCeilingPerUser + " capacity utilized by " + candidateQuery.getSubmittedUser(); } return null; } TotalQueryCostCeilingConstraint(@NonNull final Optional<QueryCost> totalQueryCostCeilingPerUser); }
TotalQueryCostCeilingConstraint implements QueryLaunchingConstraint { @Override public String allowsLaunchOf( final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries) { if (!totalQueryCostCeilingPerUser.isPresent()) { return null; } final String currentUser = candidateQuery.getSubmittedUser(); QueryCost totalQueryCostForCurrentUser = launchedQueries.getTotalQueryCost(currentUser); if (totalQueryCostForCurrentUser.compareTo(totalQueryCostCeilingPerUser.get()) > 0) { return totalQueryCostForCurrentUser + "/" + totalQueryCostCeilingPerUser + " capacity utilized by " + candidateQuery.getSubmittedUser(); } return null; } TotalQueryCostCeilingConstraint(@NonNull final Optional<QueryCost> totalQueryCostCeilingPerUser); @Override String allowsLaunchOf(
    final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries); }
TotalQueryCostCeilingConstraint implements QueryLaunchingConstraint { @Override public String allowsLaunchOf( final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries) { if (!totalQueryCostCeilingPerUser.isPresent()) { return null; } final String currentUser = candidateQuery.getSubmittedUser(); QueryCost totalQueryCostForCurrentUser = launchedQueries.getTotalQueryCost(currentUser); if (totalQueryCostForCurrentUser.compareTo(totalQueryCostCeilingPerUser.get()) > 0) { return totalQueryCostForCurrentUser + "/" + totalQueryCostCeilingPerUser + " capacity utilized by " + candidateQuery.getSubmittedUser(); } return null; } TotalQueryCostCeilingConstraint(@NonNull final Optional<QueryCost> totalQueryCostCeilingPerUser); @Override String allowsLaunchOf(
    final QueryContext candidateQuery, final EstimatedImmutableQueryCollection launchedQueries);  }