Bucket newBucket = Bucket.from(newBucketEntity).withExperimentID(experimentID).build();
.withControl((Boolean) bucketMap.get("is_control")) .withPayload((String) bucketMap.get("payload")) .build();
/** * {@inheritDoc} */ @Override public BucketList adjustAllocationPercentages(Experiment experiment, Bucket newBucket) { double remainingAlloc = 1. - newBucket.getAllocationPercent(); BucketList bucketList = buckets.getBuckets(experiment.getID(), false /* don't check experiment again */); BucketList newBuckets = new BucketList(); for (Bucket bucket : bucketList.getBuckets()) { if (bucket.getLabel().equals(newBucket.getLabel())) { continue; } double newAlloc = roundToTwo(remainingAlloc * bucket.getAllocationPercent()); LOGGER.debug("Add Bucket: setting allocation percentage for bucket " + bucket.getLabel() + " in experiment " + experiment.getID() + " to: " + newAlloc); Bucket.Builder builder = Bucket.from(bucket).withAllocationPercent(newAlloc); Bucket updatedBucket = builder.build(); newBuckets.addBucket(updatedBucket); if (!Experiment.State.DRAFT.equals(experiment.getState()) && Double.compare(bucket.getAllocationPercent(), updatedBucket.getAllocationPercent()) != 0) { // this is a system event, so no user needed eventLog.postEvent(new BucketChangeEvent(experiment, updatedBucket, "allocation", String.valueOf(bucket.getAllocationPercent()), String.valueOf(updatedBucket.getAllocationPercent()))); } } return newBuckets; }
builder.withControl(buck.isControl()); builder.withDescription(buck.getDescription()); newBuckets.addBucket(builder.build());
bucket = builder.build();
.withPayload(bucket.getPayload()) .withState(bucket.getState()) .build(); cassandraRepository.createBucket(newBucket);
public static Bucket makeBucket( com.intuit.wasabi.repository.cassandra.pojo.Bucket bucketPojo) { Bucket bucket = Bucket.newInstance(Experiment.ID.valueOf(bucketPojo.getExperimentId()), Bucket.Label.valueOf(bucketPojo.getLabel())) .withAllocationPercent(bucketPojo.getAllocation()) .withControl(bucketPojo.isControl()) .withDescription(bucketPojo.getDescription()) .withPayload(bucketPojo.getPayload()) .withState(Bucket.State.valueOf(bucketPojo.getState())) .build(); return bucket; }