Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions core-api/src/main/java/com/optimizely/ab/Optimizely.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private void sendImpression(@Nonnull ProjectConfig projectConfig,
* @param variation the variation that was returned from activate.
* @param flagKey It can either be empty if ruleType is experiment or it's feature key in case ruleType is feature-test or rollout
* @param ruleType It can either be experiment in case impression event is sent from activate or it's feature-test or rollout
* @param cmabUUID The cmabUUID if the experiment is a cmab experiment.
* @param cmabUuid The cmabUuid if the experiment is a cmab experiment.
*/
private boolean sendImpression(@Nonnull ProjectConfig projectConfig,
@Nullable ExperimentCore experiment,
Expand All @@ -328,7 +328,7 @@ private boolean sendImpression(@Nonnull ProjectConfig projectConfig,
@Nonnull String flagKey,
@Nonnull String ruleType,
@Nonnull boolean enabled,
@Nullable String cmabUUID) {
@Nullable String cmabUuid) {

UserEvent userEvent = UserEventFactory.createImpressionEvent(
projectConfig,
Expand All @@ -339,11 +339,12 @@ private boolean sendImpression(@Nonnull ProjectConfig projectConfig,
flagKey,
ruleType,
enabled,
cmabUUID);
cmabUuid);

if (userEvent == null) {
return false;
}
eventProcessor.getClass().getName();
eventProcessor.process(userEvent);
if (experiment != null) {
logger.info("Activating user \"{}\" in experiment \"{}\".", userId, experiment.getKey());
Expand Down Expand Up @@ -501,7 +502,7 @@ private Boolean isFeatureEnabled(@Nonnull ProjectConfig projectConfig,
if (featureDecision.decisionSource != null) {
decisionSource = featureDecision.decisionSource;
}
String cmabUUID = featureDecision.cmabUUID;
String cmabUuid = featureDecision.cmabUuid;
if (featureDecision.variation != null) {
// This information is only necessary for feature tests.
// For rollouts experiments and variations are an implementation detail only.
Expand All @@ -524,7 +525,7 @@ private Boolean isFeatureEnabled(@Nonnull ProjectConfig projectConfig,
featureKey,
decisionSource.toString(),
featureEnabled,
cmabUUID);
cmabUuid);

DecisionNotification decisionNotification = DecisionNotification.newFeatureDecisionNotificationBuilder()
.withUserId(userId)
Expand Down Expand Up @@ -1339,7 +1340,7 @@ private OptimizelyDecision createOptimizelyDecision(
Map<String, Object> attributes = user.getAttributes();
Map<String, ?> copiedAttributes = new HashMap<>(attributes);

String cmabUUID = flagDecision.cmabUUID;
String cmabUuid = flagDecision.cmabUuid;

if (!allOptions.contains(OptimizelyDecideOption.DISABLE_DECISION_EVENT)) {
decisionEventDispatched = sendImpression(
Expand All @@ -1351,7 +1352,7 @@ private OptimizelyDecision createOptimizelyDecision(
flagKey,
decisionSource.toString(),
flagEnabled,
cmabUUID);
cmabUuid);
}

DecisionNotification decisionNotification = DecisionNotification.newFlagDecisionNotificationBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public DecisionResponse<Variation> getVariation(@Nonnull Experiment experiment,
reasons.merge(decisionMeetAudience.getReasons());
if (decisionMeetAudience.getResult()) {
String bucketingId = getBucketingId(user.getUserId(), user.getAttributes());
String cmabUUID = null;
String cmabUuid = null;
decisionVariation = bucketer.bucket(experiment, bucketingId, projectConfig, decisionPath);
if (decisionPath == DecisionPath.WITH_CMAB && isCmabExperiment(experiment) && decisionVariation.getResult() != null) {
// group-allocation and traffic-allocation checking passed for cmab
Expand All @@ -184,7 +184,7 @@ public DecisionResponse<Variation> getVariation(@Nonnull Experiment experiment,
CmabDecision cmabResult = cmabDecision.getResult();
if (cmabResult != null) {
String variationId = cmabResult.getVariationId();
cmabUUID = cmabResult.getCmabUUID();
cmabUuid = cmabResult.getCmabUuid();
variation = experiment.getVariationIdToVariationMap().get(variationId);
}
} else {
Expand All @@ -201,7 +201,7 @@ public DecisionResponse<Variation> getVariation(@Nonnull Experiment experiment,
}
}

return new DecisionResponse<>(variation, reasons, false, cmabUUID);
return new DecisionResponse<>(variation, reasons, false, cmabUuid);
}

String message = reasons.addInfo("User \"%s\" does not meet conditions to be in experiment \"%s\".", user.getUserId(), experiment.getKey());
Expand Down Expand Up @@ -336,7 +336,7 @@ public List<DecisionResponse<FeatureDecision>> getVariationsForFeatureList(@Non
boolean error = decisionVariationResponse.isError();

if (decision != null) {
decisions.add(new DecisionResponse(decision, reasons, error, decision.cmabUUID));
decisions.add(new DecisionResponse(decision, reasons, error, decision.cmabUuid));
continue;
}

Expand Down Expand Up @@ -395,21 +395,21 @@ DecisionResponse<FeatureDecision> getVariationFromExperiment(@Nonnull ProjectCon
getVariationFromExperimentRule(projectConfig, featureFlag.getKey(), experiment, user, options, userProfileTracker, decisionPath);
reasons.merge(decisionVariation.getReasons());
Variation variation = decisionVariation.getResult();
String cmabUUID = decisionVariation.getCmabUUID();
String cmabUuid = decisionVariation.getCmabUuid();
boolean error = decisionVariation.isError();
if (error) {
return new DecisionResponse(
new FeatureDecision(experiment, variation, FeatureDecision.DecisionSource.FEATURE_TEST, cmabUUID),
new FeatureDecision(experiment, variation, FeatureDecision.DecisionSource.FEATURE_TEST, cmabUuid),
reasons,
decisionVariation.isError(),
cmabUUID);
cmabUuid);
}
if (variation != null) {
return new DecisionResponse(
new FeatureDecision(experiment, variation, FeatureDecision.DecisionSource.FEATURE_TEST, cmabUUID),
new FeatureDecision(experiment, variation, FeatureDecision.DecisionSource.FEATURE_TEST, cmabUuid),
reasons,
decisionVariation.isError(),
cmabUUID);
cmabUuid);
}
}
} else {
Expand Down Expand Up @@ -844,7 +844,7 @@ private DecisionResponse<Variation> getVariationFromExperimentRule(@Nonnull Proj

variation = decisionResponse.getResult();

return new DecisionResponse<>(variation, reasons, decisionResponse.isError(), decisionResponse.getCmabUUID());
return new DecisionResponse<>(variation, reasons, decisionResponse.isError(), decisionResponse.getCmabUuid());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class FeatureDecision {
* The CMAB UUID for Contextual Multi-Armed Bandit experiments.
*/
@Nullable
public String cmabUUID;
public String cmabUuid;

public enum DecisionSource {
FEATURE_TEST("feature-test"),
Expand Down Expand Up @@ -74,7 +74,7 @@ public FeatureDecision(@Nullable ExperimentCore experiment, @Nullable Variation
this.experiment = experiment;
this.variation = variation;
this.decisionSource = decisionSource;
this.cmabUUID = null;
this.cmabUuid = null;
}

/**
Expand All @@ -83,14 +83,14 @@ public FeatureDecision(@Nullable ExperimentCore experiment, @Nullable Variation
* @param experiment The {@link ExperimentCore} the Feature is associated with.
* @param variation The {@link Variation} the user was bucketed into.
* @param decisionSource The source of the variation.
* @param cmabUUID The CMAB UUID for Contextual Multi-Armed Bandit experiments.
* @param cmabUuid The CMAB UUID for Contextual Multi-Armed Bandit experiments.
*/
public FeatureDecision(@Nullable ExperimentCore experiment, @Nullable Variation variation,
@Nullable DecisionSource decisionSource, @Nullable String cmabUUID) {
@Nullable DecisionSource decisionSource, @Nullable String cmabUuid) {
this.experiment = experiment;
this.variation = variation;
this.decisionSource = decisionSource;
this.cmabUUID = cmabUUID;
this.cmabUuid = cmabUuid;
}

@Override
Expand All @@ -103,14 +103,14 @@ public boolean equals(Object o) {
if (variation != null ? !variation.equals(that.variation) : that.variation != null)
return false;
if (decisionSource != that.decisionSource) return false;
return cmabUUID != null ? cmabUUID.equals(that.cmabUUID) : that.cmabUUID == null;
return cmabUuid != null ? cmabUuid.equals(that.cmabUuid) : that.cmabUuid == null;
}

@Override
public int hashCode() {
int result = variation != null ? variation.hashCode() : 0;
result = 31 * result + (decisionSource != null ? decisionSource.hashCode() : 0);
result = 31 * result + (cmabUUID != null ? cmabUUID.hashCode() : 0);
result = 31 * result + (cmabUuid != null ? cmabUuid.hashCode() : 0);
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public interface CmabClient {
* @param ruleId The rule/experiment ID
* @param userId The user ID
* @param attributes User attributes
* @param cmabUUID The CMAB UUID
* @param cmabUuid The CMAB UUID
* @return CompletableFuture containing the variation ID as a String
*/
String fetchDecision(String ruleId, String userId, Map<String, Object> attributes, String cmabUUID);
String fetchDecision(String ruleId, String userId, Map<String, Object> attributes, String cmabUuid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
public class CmabCacheValue {
private final String attributesHash;
private final String variationId;
private final String cmabUUID;
private final String cmabUuid;

public CmabCacheValue(String attributesHash, String variationId, String cmabUUID) {
public CmabCacheValue(String attributesHash, String variationId, String cmabUuid) {
this.attributesHash = attributesHash;
this.variationId = variationId;
this.cmabUUID = cmabUUID;
this.cmabUuid = cmabUuid;
}

public String getAttributesHash() {
Expand All @@ -37,15 +37,15 @@ public String getVariationId() {
}

public String getCmabUuid() {
return cmabUUID;
return cmabUuid;
}

@Override
public String toString() {
return "CmabCacheValue{" +
"attributesHash='" + attributesHash + '\'' +
", variationId='" + variationId + '\'' +
", cmabUuid='" + cmabUUID + '\'' +
", cmabUuid='" + cmabUuid + '\'' +
'}';
}

Expand All @@ -56,11 +56,11 @@ public boolean equals(Object o) {
CmabCacheValue that = (CmabCacheValue) o;
return Objects.equals(attributesHash, that.attributesHash) &&
Objects.equals(variationId, that.variationId) &&
Objects.equals(cmabUUID, that.cmabUUID);
Objects.equals(cmabUuid, that.cmabUuid);
}

@Override
public int hashCode() {
return Objects.hash(attributesHash, variationId, cmabUUID);
return Objects.hash(attributesHash, variationId, cmabUuid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@

public class CmabDecision {
private final String variationId;
private final String cmabUUID;
private final String cmabUuid;

public CmabDecision(String variationId, String cmabUUID) {
public CmabDecision(String variationId, String cmabUuid) {
this.variationId = variationId;
this.cmabUUID = cmabUUID;
this.cmabUuid = cmabUuid;
}

public String getVariationId() {
return variationId;
}

public String getCmabUUID() {
return cmabUUID;
public String getCmabUuid() {
return cmabUuid;
}

@Override
public String toString() {
return "CmabDecision{" +
"variationId='" + variationId + '\'' +
", cmabUUID='" + cmabUUID + '\'' +
", cmabUuid='" + cmabUuid + '\'' +
'}';
}

Expand All @@ -48,11 +48,11 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
CmabDecision that = (CmabDecision) o;
return Objects.equals(variationId, that.variationId) &&
Objects.equals(cmabUUID, that.cmabUUID);
Objects.equals(cmabUuid, that.cmabUuid);
}

@Override
public int hashCode() {
return Objects.hash(variationId, cmabUUID);
return Objects.hash(variationId, cmabUuid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.TreeMap;
import java.util.concurrent.locks.ReentrantLock;

import com.optimizely.ab.event.internal.ClientEngineInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -32,6 +31,7 @@
import com.optimizely.ab.config.Attribute;
import com.optimizely.ab.config.Experiment;
import com.optimizely.ab.config.ProjectConfig;
import com.optimizely.ab.event.internal.ClientEngineInfo;
import com.optimizely.ab.internal.Cache;
import com.optimizely.ab.internal.DefaultLRUCache;
import com.optimizely.ab.optimizelydecision.OptimizelyDecideOption;
Expand Down Expand Up @@ -107,7 +107,7 @@ public CmabDecision getDecision(ProjectConfig projectConfig, OptimizelyUserConte
CmabDecision cmabDecision = fetchDecision(ruleId, userId, filteredAttributes);
logger.debug("CMAB decision is {}", cmabDecision);

cmabCache.save(cacheKey, new CmabCacheValue(attributesHash, cmabDecision.getVariationId(), cmabDecision.getCmabUUID()));
cmabCache.save(cacheKey, new CmabCacheValue(attributesHash, cmabDecision.getVariationId(), cmabDecision.getCmabUuid()));

return cmabDecision;
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static ImpressionEvent createImpressionEvent(@Nonnull ProjectConfig proje
@Nonnull String flagKey,
@Nonnull String ruleType,
@Nonnull boolean enabled,
@Nullable String cmabUUID) {
@Nullable String cmabUuid) {

if ((FeatureDecision.DecisionSource.ROLLOUT.toString().equals(ruleType) || variation == null) && !projectConfig.getSendFlagDecisions())
{
Expand Down Expand Up @@ -76,8 +76,8 @@ public static ImpressionEvent createImpressionEvent(@Nonnull ProjectConfig proje
.setVariationKey(variationKey)
.setEnabled(enabled);

if (cmabUUID != null) {
metadataBuilder.setCmabUUID(cmabUUID);
if (cmabUuid != null) {
metadataBuilder.setCmabUuid(cmabUuid);
}

DecisionMetadata metadata = metadataBuilder.build();
Expand Down
Loading
Loading