public void validateExperimentBuckets(List<Bucket> buckets) { if ((buckets == null) || (buckets.isEmpty())) { throw new IllegalArgumentException("No experiment buckets specified"); } Double totalAllocation = 0.0; Integer numControl = 0; Integer nOpen = 0; for (Bucket bucket : buckets) { Double val = bucket.getAllocationPercent(); totalAllocation += val; if (bucket.getState() == Bucket.State.OPEN || bucket.getState() == null) { nOpen++; } if (bucket.isControl()) { numControl++; } } if ((nOpen > 0 && Math.abs(totalAllocation - 1.0) > 1e-12) || (nOpen == 0 && Double.doubleToRawLongBits(totalAllocation) != 0)) { throw new IllegalArgumentException("Total allocation must be 1.0 (or 0.0 if all buckets are closed/empty"); } if (numControl > 1) { throw new IllegalArgumentException("Only one bucket may be specified as a control bucket"); } }
private Builder(Bucket other) { instance = new Bucket(); instance.experimentID = other.getExperimentID(); instance.label = other.getLabel(); instance.control = other.isControl() == null ? Boolean.FALSE : other.isControl(); instance.allocationPercent = other.getAllocationPercent(); instance.description = other.getDescription(); instance.payload = other.getPayload(); instance.state = other.getState(); }
public Bucket build() { Bucket result = new Bucket(); result.setControl(instance.isControl()); result.setState(instance.getState()); result.setLabel(instance.getLabel()); result.setPayload(instance.getPayload()); result.setAllocationPercent(instance.getAllocationPercent()); result.setDescription(instance.getDescription()); result.setExperimentID(instance.getExperimentID()); instance = null; return result; } }
public void validateExperimentBuckets(List<Bucket> buckets) { if ((buckets == null) || (buckets.isEmpty())) { throw new IllegalArgumentException("No experiment buckets specified"); } Double totalAllocation = 0.0; Integer numControl = 0; Integer nOpen = 0; for (Bucket bucket : buckets) { Double val = bucket.getAllocationPercent(); totalAllocation += val; if (bucket.getState() == Bucket.State.OPEN || bucket.getState() == null) { nOpen++; } if (bucket.isControl()) { numControl++; } } if ((nOpen > 0 && Math.abs(totalAllocation - 1.0) > 1e-12) || (nOpen == 0 && Double.doubleToRawLongBits(totalAllocation) != 0)) { throw new IllegalArgumentException("Total allocation must be 1.0 (or 0.0 if all buckets are closed/empty"); } if (numControl > 1) { throw new IllegalArgumentException("Only one bucket may be specified as a control bucket"); } }
/** * This method takes a list of buckets and transforms it to the {@link BucketDetail}s that are needed * for later extension. * * @param buckets a list of {@link Bucket}s */ public void addBuckets(List<Bucket> buckets) { List<BucketDetail> details = buckets.stream() .map(b -> new BucketDetail(b.getLabel(), b.isControl(), b.getAllocationPercent(), b.getState(), b.getDescription())) .collect(Collectors.toList()); setBuckets(details); }
/** * {@inheritDoc} */ @Override public void validateBucketChanges(Bucket bucket, Bucket updates) { if (updates.getExperimentID() != null && !updates.getExperimentID().equals(bucket.getExperimentID())) { throw new IllegalArgumentException("Invalid value for experimentID \"" + updates.getExperimentID() + " \"." + " Cannot update ExperimentID"); } if (updates.getLabel() != null && !updates.getLabel().equals(bucket.getLabel())) { throw new IllegalArgumentException("Invalid value for bucket label \"" + updates.getLabel() + " \". " + "Cannot update bucket label"); } if (updates.getState() != null && !updates.getState().equals(bucket.getState())) { throw new IllegalArgumentException("Cannot update the state of a bucket using this api"); } }
if (bucketList.getBuckets().get(i).getState() != null) { hasval = true; break; for (int i = 0; i < bucketListSize; i++) { Bucket b = bucketList.getBuckets().get(i); if (b.getState() != null) { SQL.append("WHEN ? then ? "); if (b.getState() != null) { args.add(b.getLabel().toString()); args.add(b.getState().toString());
private Builder(Bucket other) { instance = new Bucket(); instance.experimentID = other.getExperimentID(); instance.label = other.getLabel(); instance.control = other.isControl() == null ? Boolean.FALSE : other.isControl(); instance.allocationPercent = other.getAllocationPercent(); instance.description = other.getDescription(); instance.payload = other.getPayload(); instance.state = other.getState(); }
for (Bucket b : bucketList.getBuckets()) { if (bucketLabel.equals(b.getLabel().toString())) { if (b.getState() == Bucket.State.EMPTY) { bucketLabel = "null"; isBucketEmpty = true;
boolean isBucketEmpty = false; if (bucketLabel != null && experimentRepository.getBucket(experimentID, t.getBucketLabel()).getState().equals(Bucket.State.EMPTY)) { bucketLabel = null; isBucketEmpty = true;
validator.validateBucketStateTransition(bucket.getState(), desiredState); if (!desiredState.equals(bucket.getState()) && (desiredState == Bucket.State.CLOSED || desiredState == Bucket.State.EMPTY)) { for (Bucket buck : bucketList.getBuckets()) { if (!buck.getLabel().equals(bucket.getLabel()) && buck.getState() == Bucket.State.OPEN) { nOpen++; lastBucket = buck; Bucket.BucketAuditInfo changeData = new Bucket.BucketAuditInfo("state", buck.getState().toString(), desiredState.toString()); if (buck.getState() == Bucket.State.OPEN) { if (bucketB < 1.) { Double A = buck.getAllocationPercent(); newState = buck.getState(); experiment.getApplicationName(), experiment.getLabel(), bucket.getState(),desiredState);
public Bucket build() { Bucket result = new Bucket(); result.setControl(instance.isControl()); result.setState(instance.getState()); result.setLabel(instance.getLabel()); result.setPayload(instance.getPayload()); result.setAllocationPercent(instance.getAllocationPercent()); result.setDescription(instance.getDescription()); result.setExperimentID(instance.getExperimentID()); instance = null; return result; } }
Boolean bucketFound = false; for (Bucket bucket : buckets.getBuckets()) { if (bucket.getLabel().equals(desiredBucketLabel) && !bucket.getState().equals(Bucket.State.EMPTY)) { bucketFound = true; break;
.withDescription(bucket.getDescription()) .withPayload(bucket.getPayload()) .withState(bucket.getState()) .build(); cassandraRepository.createBucket(newBucket);