diff --git a/.github/linter/checkstyle-suppressions.xml b/.github/linter/checkstyle-suppressions.xml new file mode 100644 index 000000000..81d235392 --- /dev/null +++ b/.github/linter/checkstyle-suppressions.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/.github/linter/google-java-style.xml b/.github/linter/google-java-style.xml new file mode 100644 index 000000000..e885305ed --- /dev/null +++ b/.github/linter/google-java-style.xml @@ -0,0 +1,380 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 378a3a2e3..f258689cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,10 @@ jobs: if: matrix.jdk == '8' && github.event_name == 'pull_request' && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/development' run: mvn --batch-mode clean install + - name: Linter + if: matrix.jdk == '8' && github.event_name == 'pull_request' && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/development' + run: mvn checkstyle::check + - name: Deploy if: matrix.jdk == '8' && github.event_name == 'push' && github.ref != 'refs/heads/master' && github.ref != 'refs/heads/development' run: mvn --batch-mode deploy -P test diff --git a/client/src/main/java/io/split/client/HttpSegmentChangeFetcher.java b/client/src/main/java/io/split/client/HttpSegmentChangeFetcher.java index 31157d513..ef676de6e 100644 --- a/client/src/main/java/io/split/client/HttpSegmentChangeFetcher.java +++ b/client/src/main/java/io/split/client/HttpSegmentChangeFetcher.java @@ -47,7 +47,8 @@ public final class HttpSegmentChangeFetcher implements SegmentChangeFetcher { private final URI _target; private final TelemetryRuntimeProducer _telemetryRuntimeProducer; - public static HttpSegmentChangeFetcher create(CloseableHttpClient client, URI root, TelemetryRuntimeProducer telemetryRuntimeProducer) throws URISyntaxException { + public static HttpSegmentChangeFetcher create(CloseableHttpClient client, URI root, TelemetryRuntimeProducer telemetryRuntimeProducer) + throws URISyntaxException { return new HttpSegmentChangeFetcher(client, Utils.appendPath(root, "api/segmentChanges"), telemetryRuntimeProducer); } @@ -102,7 +103,8 @@ public SegmentChange fetch(String segmentName, long since, FetchOptions options) _log.error("factory instantiation: you passed a client side type sdkKey, " + "please grab an sdk key from the Split user interface that is of type server side"); } - throw new IllegalStateException(String.format("Could not retrieve segment changes for %s, since %s; http return code %s", segmentName, since, statusCode)); + throw new IllegalStateException(String.format("Could not retrieve segment changes for %s, since %s; http return code %s", + segmentName, since, statusCode)); } _telemetryRuntimeProducer.recordSuccessfulSync(LastSynchronizationRecordsEnum.SEGMENTS, System.currentTimeMillis()); diff --git a/client/src/main/java/io/split/client/HttpSplitChangeFetcher.java b/client/src/main/java/io/split/client/HttpSplitChangeFetcher.java index 431aa12d7..0400d8a6d 100644 --- a/client/src/main/java/io/split/client/HttpSplitChangeFetcher.java +++ b/client/src/main/java/io/split/client/HttpSplitChangeFetcher.java @@ -46,7 +46,8 @@ public final class HttpSplitChangeFetcher implements SplitChangeFetcher { private final URI _target; private final TelemetryRuntimeProducer _telemetryRuntimeProducer; - public static HttpSplitChangeFetcher create(CloseableHttpClient client, URI root, TelemetryRuntimeProducer telemetryRuntimeProducer) throws URISyntaxException { + public static HttpSplitChangeFetcher create(CloseableHttpClient client, URI root, TelemetryRuntimeProducer telemetryRuntimeProducer) + throws URISyntaxException { return new HttpSplitChangeFetcher(client, Utils.appendPath(root, "api/splitChanges"), telemetryRuntimeProducer); } diff --git a/client/src/main/java/io/split/client/JsonLocalhostSplitChangeFetcher.java b/client/src/main/java/io/split/client/JsonLocalhostSplitChangeFetcher.java index 1c65021df..9b42fa4f2 100644 --- a/client/src/main/java/io/split/client/JsonLocalhostSplitChangeFetcher.java +++ b/client/src/main/java/io/split/client/JsonLocalhostSplitChangeFetcher.java @@ -39,7 +39,8 @@ public SplitChange fetch(long since, FetchOptions options) { _log.warn(String.format("There was no file named %s found. " + "We created a split client that returns default treatments for all feature flags for all of your users. " + "If you wish to return a specific treatment for a feature flag, enter the name of that feature flag name and " + - "treatment name separated by whitespace in %s; one pair per line. Empty lines or lines starting with '#' are considered comments", + "treatment name separated by whitespace in %s; one pair per line. Empty lines or lines starting with '#' are " + + "considered comments", _file.getPath(), _file.getPath()), f); throw new IllegalStateException("Problem fetching splitChanges: " + f.getMessage(), f); } catch (Exception e) { diff --git a/client/src/main/java/io/split/client/SplitClient.java b/client/src/main/java/io/split/client/SplitClient.java index ca51c0ae9..e4945c8ea 100644 --- a/client/src/main/java/io/split/client/SplitClient.java +++ b/client/src/main/java/io/split/client/SplitClient.java @@ -233,8 +233,8 @@ public interface SplitClient { * * @param key a unique key of your customer (e.g. user_id, user_email, account_id, etc.) MUST not be null. * @param featureFlagNames the names of the feature flags we want to evaluate. MUST NOT be null. - * @return Map containing for each feature flag the evaluated treatment (the default treatment of this feature flag, or 'control') and - * a configuration associated to this treatment if set. + * @return Map containing for each feature flag the evaluated treatment (the default treatment of + * this feature flag, or 'control') and a configuration associated to this treatment if set. */ Map getTreatmentsWithConfig(String key, List featureFlagNames); diff --git a/client/src/main/java/io/split/client/SplitClientConfig.java b/client/src/main/java/io/split/client/SplitClientConfig.java index f5f2341ed..b362a2de4 100644 --- a/client/src/main/java/io/split/client/SplitClientConfig.java +++ b/client/src/main/java/io/split/client/SplitClientConfig.java @@ -402,7 +402,7 @@ public static final class Builder { private String _authServiceURL = AUTH_ENDPOINT; private String _streamingServiceURL = STREAMING_ENDPOINT; private String _telemetryURl = TELEMETRY_ENDPOINT; - private int _telemetryRefreshRate = 3600; + private int _telemetryRefreshRate = 600; private final int _uniqueKeysRefreshRateInMemory = 900; private final int _uniqueKeysRefreshRateRedis = 300; private final int _filterUniqueKeysRefreshRate = 86400; diff --git a/client/src/main/java/io/split/client/SplitClientImpl.java b/client/src/main/java/io/split/client/SplitClientImpl.java index 6cc0e96a6..35839cc2e 100644 --- a/client/src/main/java/io/split/client/SplitClientImpl.java +++ b/client/src/main/java/io/split/client/SplitClientImpl.java @@ -125,7 +125,8 @@ public Map getTreatments(Key key, List featureFlagNames, @Override public Map getTreatmentsWithConfig(String key, List featureFlagNames) { - return getTreatmentsWithConfigInternal(key, null, featureFlagNames, Collections.emptyMap(), MethodEnum.TREATMENTS_WITH_CONFIG); + return getTreatmentsWithConfigInternal(key, null, featureFlagNames, Collections.emptyMap(), + MethodEnum.TREATMENTS_WITH_CONFIG); } @Override @@ -135,7 +136,8 @@ public Map getTreatmentsWithConfig(String key, List @Override public Map getTreatmentsWithConfig(Key key, List featureFlagNames, Map attributes) { - return getTreatmentsWithConfigInternal(key.matchingKey(), key.bucketingKey(), featureFlagNames, attributes, MethodEnum.TREATMENTS_WITH_CONFIG); + return getTreatmentsWithConfigInternal(key.matchingKey(), key.bucketingKey(), featureFlagNames, attributes, + MethodEnum.TREATMENTS_WITH_CONFIG); } @Override @@ -220,7 +222,8 @@ private boolean track(Event event) { return _eventsStorageProducer.track(event, propertiesResult.getEventSize()); } - private SplitResult getTreatmentWithConfigInternal(String matchingKey, String bucketingKey, String featureFlag, Map attributes, MethodEnum methodEnum) { + private SplitResult getTreatmentWithConfigInternal(String matchingKey, String bucketingKey, String featureFlag, Map attributes, MethodEnum methodEnum) { long initTime = System.currentTimeMillis(); try { checkSDKReady(methodEnum); @@ -279,7 +282,8 @@ private SplitResult getTreatmentWithConfigInternal(String matchingKey, String bu } } - private Map getTreatmentsWithConfigInternal(String matchingKey, String bucketingKey, List featureFlagNames, Map attributes, MethodEnum methodEnum) { + private Map getTreatmentsWithConfigInternal(String matchingKey, String bucketingKey, List featureFlagNames, + Map attributes, MethodEnum methodEnum) { long initTime = System.currentTimeMillis(); if (featureFlagNames == null) { _log.error(String.format("%s: featureFlagNames must be a non-empty array", methodEnum.getMethod())); @@ -303,17 +307,20 @@ private Map getTreatmentsWithConfigInternal(String matching return new HashMap<>(); } featureFlagNames = SplitNameValidator.areValid(featureFlagNames, methodEnum.getMethod()); - Map evaluatorResult = _evaluator.evaluateFeatures(matchingKey, bucketingKey, featureFlagNames, attributes); + Map evaluatorResult = _evaluator.evaluateFeatures(matchingKey, + bucketingKey, featureFlagNames, attributes); List impressions = new ArrayList<>(); Map result = new HashMap<>(); evaluatorResult.keySet().forEach(t -> { - if (evaluatorResult.get(t).treatment.equals(Treatments.CONTROL) && evaluatorResult.get(t).label.equals(Labels.DEFINITION_NOT_FOUND) && _gates.isSDKReady()) { - _log.warn(String.format( - "%s: you passed \"%s\" that does not exist in this environment please double check what feature flags exist in the Split user interface.", methodEnum.getMethod(), t)); + if (evaluatorResult.get(t).treatment.equals(Treatments.CONTROL) && evaluatorResult.get(t).label. + equals(Labels.DEFINITION_NOT_FOUND) && _gates.isSDKReady()) { + _log.warn(String.format("%s: you passed \"%s\" that does not exist in this environment please double check " + + "what feature flags exist in the Split user interface.", methodEnum.getMethod(), t)); result.put(t, SPLIT_RESULT_CONTROL); } else { result.put(t, new SplitResult(evaluatorResult.get(t).treatment, evaluatorResult.get(t).configurations)); - impressions.add(new Impression(matchingKey, bucketingKey, t, evaluatorResult.get(t).treatment, System.currentTimeMillis(), evaluatorResult.get(t).label, evaluatorResult.get(t).changeNumber, attributes)); + impressions.add(new Impression(matchingKey, bucketingKey, t, evaluatorResult.get(t).treatment, System.currentTimeMillis(), + evaluatorResult.get(t).label, evaluatorResult.get(t).changeNumber, attributes)); } }); @@ -337,7 +344,8 @@ private Map getTreatmentsWithConfigInternal(String matching private void recordStats(String matchingKey, String bucketingKey, String featureFlagName, long start, String result, String operation, String label, Long changeNumber, Map attributes) { try { - _impressionManager.track(Stream.of(new Impression(matchingKey, bucketingKey, featureFlagName, result, System.currentTimeMillis(), label, changeNumber, attributes)).collect(Collectors.toList())); + _impressionManager.track(Stream.of(new Impression(matchingKey, bucketingKey, featureFlagName, result, System.currentTimeMillis(), + label, changeNumber, attributes)).collect(Collectors.toList())); } catch (Throwable t) { _log.error("Exception", t); } @@ -354,8 +362,8 @@ private Event createEvent(String key, String trafficType, String eventType) { private void checkSDKReady(MethodEnum methodEnum) { if (!_gates.isSDKReady()) { - _log.warn(String.format( - "%s: the SDK is not ready, results may be incorrect. Make sure to wait for SDK readiness before using this method", methodEnum.getMethod())); + _log.warn(String.format("%s: the SDK is not ready, results may be incorrect. Make sure to wait for SDK readiness " + + "before using this method", methodEnum.getMethod())); _telemetryConfigProducer.recordNonReadyUsage(); } } diff --git a/client/src/main/java/io/split/client/SplitFactoryImpl.java b/client/src/main/java/io/split/client/SplitFactoryImpl.java index ab83f8e82..3c46ff7fd 100644 --- a/client/src/main/java/io/split/client/SplitFactoryImpl.java +++ b/client/src/main/java/io/split/client/SplitFactoryImpl.java @@ -184,7 +184,8 @@ public SplitFactoryImpl(String apiToken, SplitClientConfig config) throws URISyn ImpressionsStorage impressionsStorage = new InMemoryImpressionsStorage(config.impressionsQueueSize()); _splitCache = splitCache; _segmentCache = segmentCache; - _telemetrySynchronizer = new TelemetryInMemorySubmitter(_httpclient, URI.create(config.telemetryURL()), telemetryStorage, splitCache, _segmentCache, telemetryStorage, _startTime); + _telemetrySynchronizer = new TelemetryInMemorySubmitter(_httpclient, URI.create(config.telemetryURL()), telemetryStorage, + splitCache, _segmentCache, telemetryStorage, _startTime); // Segments _segmentSynchronizationTaskImp = buildSegments(config, segmentCache, splitCache); @@ -200,7 +201,8 @@ public SplitFactoryImpl(String apiToken, SplitClientConfig config) throws URISyn config.getThreadFactory()); //ImpressionSender - _impressionsSender = HttpImpressionsSender.create(_httpclient, URI.create(config.eventsEndpoint()), config.impressionsMode(), _telemetryStorageProducer); + _impressionsSender = HttpImpressionsSender.create(_httpclient, URI.create(config.eventsEndpoint()), config.impressionsMode(), + _telemetryStorageProducer); //UniqueKeysTracker _uniqueKeysTracker = createUniqueKeysTracker(config); @@ -267,8 +269,10 @@ protected SplitFactoryImpl(String apiToken, SplitClientConfig config, CustomStor _userStorageWrapper = new UserStorageWrapper(customStorageWrapper); UserCustomSegmentAdapterConsumer userCustomSegmentAdapterConsumer= new UserCustomSegmentAdapterConsumer(customStorageWrapper); UserCustomSplitAdapterConsumer userCustomSplitAdapterConsumer = new UserCustomSplitAdapterConsumer(customStorageWrapper); - UserCustomImpressionAdapterConsumer userCustomImpressionAdapterConsumer = new UserCustomImpressionAdapterConsumer(); // TODO migrate impressions sender to Task instead manager and not instantiate Producer here. - UserCustomImpressionAdapterProducer userCustomImpressionAdapterProducer = new UserCustomImpressionAdapterProducer(customStorageWrapper, metadata); + // TODO migrate impressions sender to Task instead manager and not instantiate Producer here. + UserCustomImpressionAdapterConsumer userCustomImpressionAdapterConsumer = new UserCustomImpressionAdapterConsumer(); + UserCustomImpressionAdapterProducer userCustomImpressionAdapterProducer = new UserCustomImpressionAdapterProducer(customStorageWrapper, + metadata); UserCustomEventAdapterProducer userCustomEventAdapterProducer = new UserCustomEventAdapterProducer(customStorageWrapper, metadata); _operationMode = config.operationMode(); @@ -543,7 +547,8 @@ private static HttpClientBuilder setupProxy(HttpClientBuilder httpClientbuilder, return httpClientbuilder; } - private SegmentSynchronizationTaskImp buildSegments(SplitClientConfig config, SegmentCacheProducer segmentCacheProducer, SplitCacheConsumer splitCacheConsumer) throws URISyntaxException { + private SegmentSynchronizationTaskImp buildSegments(SplitClientConfig config, SegmentCacheProducer segmentCacheProducer, + SplitCacheConsumer splitCacheConsumer) throws URISyntaxException { SegmentChangeFetcher segmentChangeFetcher = HttpSegmentChangeFetcher.create(_httpclient, _rootTarget, _telemetryStorageProducer); return new SegmentSynchronizationTaskImp(segmentChangeFetcher, @@ -561,7 +566,8 @@ private SplitFetcher buildSplitFetcher(SplitCacheProducer splitCacheProducer, Sp return new SplitFetcherImp(splitChangeFetcher, splitParser, splitCacheProducer, _telemetryStorageProducer); } - private ImpressionsManagerImpl buildImpressionsManager(SplitClientConfig config, ImpressionsStorageConsumer impressionsStorageConsumer, ImpressionsStorageProducer impressionsStorageProducer) throws URISyntaxException { + private ImpressionsManagerImpl buildImpressionsManager(SplitClientConfig config, ImpressionsStorageConsumer impressionsStorageConsumer, + ImpressionsStorageProducer impressionsStorageProducer) throws URISyntaxException { List impressionListeners = new ArrayList<>(); if (config.integrationsConfig() != null) { config.integrationsConfig().getImpressionsListeners(IntegrationsConfig.Execution.ASYNC).stream() @@ -591,7 +597,8 @@ private ImpressionsManagerImpl buildImpressionsManager(SplitClientConfig config, processImpressionStrategy = new ProcessImpressionNone(listener != null, _uniqueKeysTracker, counter); break; } - return ImpressionsManagerImpl.instance(config, _telemetryStorageProducer, impressionsStorageConsumer, impressionsStorageProducer, _impressionsSender, processImpressionStrategy, counter, listener); + return ImpressionsManagerImpl.instance(config, _telemetryStorageProducer, impressionsStorageConsumer, impressionsStorageProducer, + _impressionsSender, processImpressionStrategy, counter, listener); } private SDKMetadata createSdkMetadata(boolean ipAddressEnabled, String splitSdkVersion) { @@ -622,7 +629,8 @@ private void manageSdkReady(SplitClientConfig config) { } } _gates.sdkInternalReady(); - _telemetrySynchronizer.synchronizeConfig(config, System.currentTimeMillis(), ApiKeyCounter.getApiKeyCounterInstance().getFactoryInstances(), new ArrayList<>()); + _telemetrySynchronizer.synchronizeConfig(config, System.currentTimeMillis(), ApiKeyCounter.getApiKeyCounterInstance(). + getFactoryInstances(), new ArrayList<>()); }); } @@ -630,7 +638,8 @@ private UniqueKeysTracker createUniqueKeysTracker(SplitClientConfig config){ if (config.impressionsMode().equals(ImpressionsManager.Mode.NONE)){ int uniqueKeysRefreshRate = config.operationMode().equals(OperationMode.STANDALONE) ? config.uniqueKeysRefreshRateInMemory() : config.uniqueKeysRefreshRateRedis(); - return new UniqueKeysTrackerImp(_telemetrySynchronizer, uniqueKeysRefreshRate, config.filterUniqueKeysRefreshRate(), config.getThreadFactory()); + return new UniqueKeysTrackerImp(_telemetrySynchronizer, uniqueKeysRefreshRate, config.filterUniqueKeysRefreshRate(), + config.getThreadFactory()); } return null; } diff --git a/client/src/main/java/io/split/client/YamlLocalhostSplitChangeFetcher.java b/client/src/main/java/io/split/client/YamlLocalhostSplitChangeFetcher.java index 514545c3b..abde47d73 100644 --- a/client/src/main/java/io/split/client/YamlLocalhostSplitChangeFetcher.java +++ b/client/src/main/java/io/split/client/YamlLocalhostSplitChangeFetcher.java @@ -77,10 +77,10 @@ public SplitChange fetch(long since, FetchOptions options) { splitChange.since = since; return splitChange; } catch (FileNotFoundException f) { - _log.warn(String.format("There was no file named %s found. " + - "We created a split client that returns default treatments for all feature flags for all of your users. " + - "If you wish to return a specific treatment for a feature flag, enter the name of that feature flag name and " + - "treatment name separated by whitespace in %s; one pair per line. Empty lines or lines starting with '#' are considered comments", + _log.warn(String.format("There was no file named %s found. We created a split client that returns default treatments " + + "for all feature flags for all of your users. If you wish to return a specific treatment for a feature flag, " + + "enter the name of that feature flag name and treatment name separated by whitespace in %s; one pair per line. " + + "Empty lines or lines starting with '#' are considered comments", _splitFile.getPath(), _splitFile.getPath()), f); throw new IllegalStateException("Problem fetching splitChanges: " + f.getMessage(), f); } catch (Exception e) { diff --git a/client/src/main/java/io/split/client/events/EventsSender.java b/client/src/main/java/io/split/client/events/EventsSender.java index ae71dfa78..64ab3e90c 100644 --- a/client/src/main/java/io/split/client/events/EventsSender.java +++ b/client/src/main/java/io/split/client/events/EventsSender.java @@ -22,7 +22,8 @@ public class EventsSender { private final TelemetryRuntimeProducer _telemetryRuntimeProducer; private final HttpPostImp _httpPostImp; - public static EventsSender create(CloseableHttpClient httpclient, URI eventsTarget, TelemetryRuntimeProducer telemetryRuntimeProducer) throws URISyntaxException { + public static EventsSender create(CloseableHttpClient httpclient, URI eventsTarget, TelemetryRuntimeProducer telemetryRuntimeProducer) + throws URISyntaxException { return new EventsSender(httpclient, Utils.appendPath(eventsTarget, BULK_ENDPOINT_PATH), telemetryRuntimeProducer); } diff --git a/client/src/main/java/io/split/client/events/EventsTask.java b/client/src/main/java/io/split/client/events/EventsTask.java index 628be6cf4..fb71a7241 100644 --- a/client/src/main/java/io/split/client/events/EventsTask.java +++ b/client/src/main/java/io/split/client/events/EventsTask.java @@ -27,7 +27,8 @@ public class EventsTask{ private final ScheduledExecutorService _senderScheduledExecutorService; private static final Logger _log = LoggerFactory.getLogger(EventsTask.class); - public static EventsTask create(long sendIntervalMillis, EventsStorageConsumer eventsStorageConsumer, EventsSender eventsSender, ThreadFactory threadFactory) throws URISyntaxException { + public static EventsTask create(long sendIntervalMillis, EventsStorageConsumer eventsStorageConsumer, EventsSender eventsSender, + ThreadFactory threadFactory) throws URISyntaxException { return new EventsTask(eventsStorageConsumer, sendIntervalMillis, eventsSender, diff --git a/client/src/main/java/io/split/client/impressions/HttpImpressionsSender.java b/client/src/main/java/io/split/client/impressions/HttpImpressionsSender.java index 112a56817..0a08e5dad 100644 --- a/client/src/main/java/io/split/client/impressions/HttpImpressionsSender.java +++ b/client/src/main/java/io/split/client/impressions/HttpImpressionsSender.java @@ -42,7 +42,8 @@ public class HttpImpressionsSender implements ImpressionsSender { private final ImpressionsManager.Mode _mode; private final TelemetryRuntimeProducer _telemetryRuntimeProducer; - public static HttpImpressionsSender create(CloseableHttpClient client, URI eventsRootEndpoint, ImpressionsManager.Mode mode, TelemetryRuntimeProducer telemetryRuntimeProducer) throws URISyntaxException { + public static HttpImpressionsSender create(CloseableHttpClient client, URI eventsRootEndpoint, ImpressionsManager.Mode mode, + TelemetryRuntimeProducer telemetryRuntimeProducer) throws URISyntaxException { return new HttpImpressionsSender(client, Utils.appendPath(eventsRootEndpoint, BULK_ENDPOINT_PATH), Utils.appendPath(eventsRootEndpoint, COUNT_ENDPOINT_PATH), @@ -50,7 +51,8 @@ public static HttpImpressionsSender create(CloseableHttpClient client, URI event telemetryRuntimeProducer); } - private HttpImpressionsSender(CloseableHttpClient client, URI impressionBulkTarget, URI impressionCountTarget, ImpressionsManager.Mode mode, TelemetryRuntimeProducer telemetryRuntimeProducer) { + private HttpImpressionsSender(CloseableHttpClient client, URI impressionBulkTarget, URI impressionCountTarget, ImpressionsManager.Mode mode, + TelemetryRuntimeProducer telemetryRuntimeProducer) { _client = client; _mode = mode; _impressionBulkTarget = impressionBulkTarget; diff --git a/client/src/main/java/io/split/client/impressions/Impression.java b/client/src/main/java/io/split/client/impressions/Impression.java index dc273326f..31678f2bd 100644 --- a/client/src/main/java/io/split/client/impressions/Impression.java +++ b/client/src/main/java/io/split/client/impressions/Impression.java @@ -18,7 +18,8 @@ public class Impression { private final Map _attributes; - public Impression(String key, String bucketingKey, String featureFlag, String treatment, long time, String appliedRule, Long changeNumber, Map atributes) { + public Impression(String key, String bucketingKey, String featureFlag, String treatment, long time, String appliedRule, + Long changeNumber, Map atributes) { _key = key; _bucketingKey = bucketingKey; _split = featureFlag; diff --git a/client/src/main/java/io/split/client/impressions/ImpressionsManagerImpl.java b/client/src/main/java/io/split/client/impressions/ImpressionsManagerImpl.java index e6b19289f..07ef85605 100644 --- a/client/src/main/java/io/split/client/impressions/ImpressionsManagerImpl.java +++ b/client/src/main/java/io/split/client/impressions/ImpressionsManagerImpl.java @@ -50,7 +50,8 @@ public static ImpressionsManagerImpl instance(SplitClientConfig config, ProcessImpressionStrategy processImpressionStrategy, ImpressionCounter counter, ImpressionListener listener) throws URISyntaxException { - return new ImpressionsManagerImpl(config, impressionsSender, telemetryRuntimeProducer, impressionsStorageConsumer, impressionsStorageProducer, processImpressionStrategy, counter, listener); + return new ImpressionsManagerImpl(config, impressionsSender, telemetryRuntimeProducer, impressionsStorageConsumer, + impressionsStorageProducer, processImpressionStrategy, counter, listener); } public static ImpressionsManagerImpl instanceForTest(SplitClientConfig config, @@ -61,7 +62,8 @@ public static ImpressionsManagerImpl instanceForTest(SplitClientConfig config, ProcessImpressionStrategy processImpressionStrategy, ImpressionCounter counter, ImpressionListener listener) throws URISyntaxException { - return new ImpressionsManagerImpl(config, impressionsSender, telemetryRuntimeProducer, impressionsStorageConsumer, impressionsStorageProducer, processImpressionStrategy, counter, listener); + return new ImpressionsManagerImpl(config, impressionsSender, telemetryRuntimeProducer, impressionsStorageConsumer, + impressionsStorageProducer, processImpressionStrategy, counter, listener); } private ImpressionsManagerImpl(SplitClientConfig config, @@ -93,14 +95,16 @@ private ImpressionsManagerImpl(SplitClientConfig config, public void start(){ switch (_impressionsMode){ case OPTIMIZED: - _scheduler.scheduleAtFixedRate(this::sendImpressionCounters, COUNT_INITIAL_DELAY_SECONDS, COUNT_REFRESH_RATE_SECONDS, TimeUnit.SECONDS); + _scheduler.scheduleAtFixedRate(this::sendImpressionCounters, COUNT_INITIAL_DELAY_SECONDS, COUNT_REFRESH_RATE_SECONDS, + TimeUnit.SECONDS); _scheduler.scheduleAtFixedRate(this::sendImpressions, BULK_INITIAL_DELAY_SECONDS, _impressionsRefreshRate, TimeUnit.SECONDS); break; case DEBUG: _scheduler.scheduleAtFixedRate(this::sendImpressions, BULK_INITIAL_DELAY_SECONDS, _impressionsRefreshRate, TimeUnit.SECONDS); break; case NONE: - _scheduler.scheduleAtFixedRate(this::sendImpressionCounters, COUNT_INITIAL_DELAY_SECONDS, COUNT_REFRESH_RATE_SECONDS, TimeUnit.SECONDS); + _scheduler.scheduleAtFixedRate(this::sendImpressionCounters, COUNT_INITIAL_DELAY_SECONDS, COUNT_REFRESH_RATE_SECONDS, + TimeUnit.SECONDS); break; } } diff --git a/client/src/main/java/io/split/client/impressions/UniqueKeysTrackerImp.java b/client/src/main/java/io/split/client/impressions/UniqueKeysTrackerImp.java index 97629245f..7097699e0 100644 --- a/client/src/main/java/io/split/client/impressions/UniqueKeysTrackerImp.java +++ b/client/src/main/java/io/split/client/impressions/UniqueKeysTrackerImp.java @@ -33,7 +33,8 @@ public class UniqueKeysTrackerImp implements UniqueKeysTracker{ private final int _filterRefreshRate; private static final Logger _logger = LoggerFactory.getLogger(UniqueKeysTrackerImp.class); - public UniqueKeysTrackerImp(TelemetrySynchronizer telemetrySynchronizer, int uniqueKeysRefreshRate, int filterRefreshRate, ThreadFactory threadFactory) { + public UniqueKeysTrackerImp(TelemetrySynchronizer telemetrySynchronizer, int uniqueKeysRefreshRate, int filterRefreshRate, + ThreadFactory threadFactory) { Filter bloomFilter = new BloomFilterImp(MAX_AMOUNT_OF_KEYS, MARGIN_ERROR); this.filterAdapter = new FilterAdapterImpl(bloomFilter); uniqueKeysTracker = new ConcurrentHashMap<>(); @@ -74,7 +75,8 @@ public void start() { scheduleWithFixedDelay(_cleanFilterScheduledExecutorService, _filterRefreshRate, new ExecuteCleanFilter()); } - private void scheduleWithFixedDelay(ScheduledExecutorService scheduledExecutorService, int refreshRate, ExecuteUniqueKeysAction executeUniqueKeysAction) { + private void scheduleWithFixedDelay(ScheduledExecutorService scheduledExecutorService, int refreshRate, + ExecuteUniqueKeysAction executeUniqueKeysAction) { scheduledExecutorService.scheduleWithFixedDelay(() -> { try { executeUniqueKeysAction.execute(); diff --git a/client/src/main/java/io/split/client/impressions/strategy/ProcessImpressionOptimized.java b/client/src/main/java/io/split/client/impressions/strategy/ProcessImpressionOptimized.java index ece5e0308..1af51a209 100644 --- a/client/src/main/java/io/split/client/impressions/strategy/ProcessImpressionOptimized.java +++ b/client/src/main/java/io/split/client/impressions/strategy/ProcessImpressionOptimized.java @@ -20,7 +20,8 @@ public class ProcessImpressionOptimized implements ProcessImpressionStrategy{ private final boolean _listenerEnabled; - public ProcessImpressionOptimized(boolean listenerEnabled, ImpressionObserver impressionObserver, ImpressionCounter impressionCounter, TelemetryRuntimeProducer telemetryRuntimeProducer) { + public ProcessImpressionOptimized(boolean listenerEnabled, ImpressionObserver impressionObserver, ImpressionCounter impressionCounter, + TelemetryRuntimeProducer telemetryRuntimeProducer) { _telemetryRuntimeProducer = telemetryRuntimeProducer; _listenerEnabled = listenerEnabled; _impressionObserver = impressionObserver; @@ -42,7 +43,8 @@ public ImpressionsResult process(List impressions) { } List impressionForListener = this._listenerEnabled ? impressions : null; - _telemetryRuntimeProducer.recordImpressionStats(ImpressionsDataTypeEnum.IMPRESSIONS_DEDUPED, impressions.size()- (long)impressionsToQueue.size()); + _telemetryRuntimeProducer.recordImpressionStats(ImpressionsDataTypeEnum.IMPRESSIONS_DEDUPED, impressions.size()- + (long)impressionsToQueue.size()); return new ImpressionsResult(impressionsToQueue, impressionForListener); } diff --git a/client/src/main/java/io/split/client/jmx/SplitJmxMonitor.java b/client/src/main/java/io/split/client/jmx/SplitJmxMonitor.java index 6f4e0522c..fa5ad58ac 100644 --- a/client/src/main/java/io/split/client/jmx/SplitJmxMonitor.java +++ b/client/src/main/java/io/split/client/jmx/SplitJmxMonitor.java @@ -25,7 +25,8 @@ public class SplitJmxMonitor implements SplitJmxMonitorMBean { private final SegmentSynchronizationTask _segmentSynchronizationTask; private SegmentCacheConsumer segmentCacheConsumer; - public SplitJmxMonitor(SplitClient splitClient, SplitFetcher featureFetcher, SplitCacheConsumer splitCacheConsumer, SegmentSynchronizationTask segmentSynchronizationTask, SegmentCacheConsumer segmentCacheConsumer) { + public SplitJmxMonitor(SplitClient splitClient, SplitFetcher featureFetcher, SplitCacheConsumer splitCacheConsumer, + SegmentSynchronizationTask segmentSynchronizationTask, SegmentCacheConsumer segmentCacheConsumer) { _client = checkNotNull(splitClient); _featureFetcher = checkNotNull(featureFetcher); _splitCacheConsumer = checkNotNull(splitCacheConsumer); diff --git a/client/src/main/java/io/split/engine/common/PushManagerImp.java b/client/src/main/java/io/split/engine/common/PushManagerImp.java index 5fb423f0a..42343b9b4 100644 --- a/client/src/main/java/io/split/engine/common/PushManagerImp.java +++ b/client/src/main/java/io/split/engine/common/PushManagerImp.java @@ -79,7 +79,8 @@ public static PushManagerImp build(Synchronizer synchronizer, Worker segmentWorker = new SegmentsWorkerImp(synchronizer); PushStatusTracker pushStatusTracker = new PushStatusTrackerImp(statusMessages, telemetryRuntimeProducer); return new PushManagerImp(new AuthApiClientImp(authUrl, splitAPI.getHttpClient(), telemetryRuntimeProducer), - EventSourceClientImp.build(streamingUrl, featureFlagsWorker, segmentWorker, pushStatusTracker, splitAPI.getSseHttpClient(), telemetryRuntimeProducer, threadFactory), + EventSourceClientImp.build(streamingUrl, featureFlagsWorker, segmentWorker, pushStatusTracker, splitAPI.getSseHttpClient(), + telemetryRuntimeProducer, threadFactory), featureFlagsWorker, segmentWorker, pushStatusTracker, @@ -93,7 +94,8 @@ public synchronized void start() { _log.debug(String.format("Auth service response pushEnabled: %s", response.isPushEnabled())); if (response.isPushEnabled() && startSse(response.getToken(), response.getChannels())) { _expirationTime.set(response.getExpiration()); - _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.TOKEN_REFRESH.getType(), response.getExpiration(), System.currentTimeMillis())); + _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.TOKEN_REFRESH.getType(), + response.getExpiration(), System.currentTimeMillis())); return; } diff --git a/client/src/main/java/io/split/engine/common/SyncManagerImp.java b/client/src/main/java/io/split/engine/common/SyncManagerImp.java index bc23c96b1..89d826cba 100644 --- a/client/src/main/java/io/split/engine/common/SyncManagerImp.java +++ b/client/src/main/java/io/split/engine/common/SyncManagerImp.java @@ -146,7 +146,8 @@ public void start() { startPollingMode(); } _synchronizer.startPeriodicDataRecording(); - _telemetrySynchronizer.synchronizeConfig(_config, System.currentTimeMillis(), ApiKeyCounter.getApiKeyCounterInstance().getFactoryInstances(), new ArrayList<>()); + _telemetrySynchronizer.synchronizeConfig(_config, System.currentTimeMillis(), ApiKeyCounter.getApiKeyCounterInstance(). + getFactoryInstances(), new ArrayList<>()); }); } @@ -175,13 +176,15 @@ private void startStreamingMode() { _pushStatusMonitorTask = _pushMonitorExecutorService.submit(this::incomingPushStatusHandler); } _pushManager.start(); - _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.SYNC_MODE_UPDATE.getType(), StreamEventsEnum.SyncModeUpdateValues.STREAMING_EVENT.getValue(), System.currentTimeMillis())); + _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.SYNC_MODE_UPDATE.getType(), + StreamEventsEnum.SyncModeUpdateValues.STREAMING_EVENT.getValue(), System.currentTimeMillis())); } private void startPollingMode() { _log.debug("Starting in polling mode ..."); _synchronizer.startPeriodicFetching(); - _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.SYNC_MODE_UPDATE.getType(), StreamEventsEnum.SyncModeUpdateValues.POLLING_EVENT.getValue(), System.currentTimeMillis())); + _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.SYNC_MODE_UPDATE.getType(), + StreamEventsEnum.SyncModeUpdateValues.POLLING_EVENT.getValue(), System.currentTimeMillis())); } @VisibleForTesting @@ -197,7 +200,8 @@ private void startPollingMode() { _pushManager.startWorkers(); _pushManager.scheduleConnectionReset(); _backoff.reset(); - _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.STREAMING_STATUS.getType(), StreamEventsEnum.StreamingStatusValues.STREAMING_ENABLED.getValue(), System.currentTimeMillis())); + _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.STREAMING_STATUS.getType(), + StreamEventsEnum.StreamingStatusValues.STREAMING_ENABLED.getValue(), System.currentTimeMillis())); _log.info("Streaming up and running."); break; case STREAMING_DOWN: diff --git a/client/src/main/java/io/split/engine/common/SynchronizerImp.java b/client/src/main/java/io/split/engine/common/SynchronizerImp.java index 1e308dccd..933851d10 100644 --- a/client/src/main/java/io/split/engine/common/SynchronizerImp.java +++ b/client/src/main/java/io/split/engine/common/SynchronizerImp.java @@ -186,7 +186,8 @@ public void refreshSplits(Long targetChangeNumber) { @Override public void localKillSplit(SplitKillNotification splitKillNotification) { if (splitKillNotification.getChangeNumber() > _splitCacheProducer.getChangeNumber()) { - _splitCacheProducer.kill(splitKillNotification.getSplitName(), splitKillNotification.getDefaultTreatment(), splitKillNotification.getChangeNumber()); + _splitCacheProducer.kill(splitKillNotification.getSplitName(), splitKillNotification.getDefaultTreatment(), + splitKillNotification.getChangeNumber()); refreshSplits(splitKillNotification.getChangeNumber()); } } diff --git a/client/src/main/java/io/split/engine/evaluator/Evaluator.java b/client/src/main/java/io/split/engine/evaluator/Evaluator.java index 2d91df318..bd7ced732 100644 --- a/client/src/main/java/io/split/engine/evaluator/Evaluator.java +++ b/client/src/main/java/io/split/engine/evaluator/Evaluator.java @@ -4,6 +4,8 @@ import java.util.Map; public interface Evaluator { - EvaluatorImp.TreatmentLabelAndChangeNumber evaluateFeature(String matchingKey, String bucketingKey, String featureFlag, Map attributes); - Map evaluateFeatures(String matchingKey, String bucketingKey, List featureFlags, Map attributes); + EvaluatorImp.TreatmentLabelAndChangeNumber evaluateFeature(String matchingKey, String bucketingKey, String featureFlag, + Map attributes); + Map evaluateFeatures(String matchingKey, String bucketingKey, + List featureFlags, Map attributes); } diff --git a/client/src/main/java/io/split/engine/evaluator/EvaluatorImp.java b/client/src/main/java/io/split/engine/evaluator/EvaluatorImp.java index ae6adea93..ac5bc3081 100644 --- a/client/src/main/java/io/split/engine/evaluator/EvaluatorImp.java +++ b/client/src/main/java/io/split/engine/evaluator/EvaluatorImp.java @@ -33,13 +33,15 @@ public EvaluatorImp(SplitCacheConsumer splitCacheConsumer, SegmentCacheConsumer } @Override - public TreatmentLabelAndChangeNumber evaluateFeature(String matchingKey, String bucketingKey, String featureFlag, Map attributes) { + public TreatmentLabelAndChangeNumber evaluateFeature(String matchingKey, String bucketingKey, String featureFlag, Map attributes) { ParsedSplit parsedSplit = _splitCacheConsumer.get(featureFlag); return evaluateParsedSplit(matchingKey, bucketingKey, attributes, parsedSplit); } @Override - public Map evaluateFeatures(String matchingKey, String bucketingKey, List featureFlags, Map attributes) { + public Map evaluateFeatures(String matchingKey, String bucketingKey, List featureFlags, + Map attributes) { Map results = new HashMap<>(); Map parsedSplits = _splitCacheConsumer.fetchMany(featureFlags); if (parsedSplits == null) { @@ -57,7 +59,8 @@ public Map evaluateFeatures(String matchi * @return * @throws ChangeNumberExceptionWrapper */ - private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bucketingKey, ParsedSplit parsedSplit, Map attributes) throws ChangeNumberExceptionWrapper { + private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bucketingKey, ParsedSplit parsedSplit, Map attributes) throws ChangeNumberExceptionWrapper { try { if (parsedSplit.killed()) { String config = parsedSplit.configurations() != null ? parsedSplit.configurations().get(parsedSplit.defaultTreatment()) : null; @@ -84,8 +87,10 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu if (bucket > parsedSplit.trafficAllocation()) { // out of split - String config = parsedSplit.configurations() != null ? parsedSplit.configurations().get(parsedSplit.defaultTreatment()) : null; - return new TreatmentLabelAndChangeNumber(parsedSplit.defaultTreatment(), Labels.NOT_IN_SPLIT, parsedSplit.changeNumber(), config); + String config = parsedSplit.configurations() != null ? + parsedSplit.configurations().get(parsedSplit.defaultTreatment()) : null; + return new TreatmentLabelAndChangeNumber(parsedSplit.defaultTreatment(), Labels.NOT_IN_SPLIT, + parsedSplit.changeNumber(), config); } } @@ -106,7 +111,8 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu } } - private TreatmentLabelAndChangeNumber evaluateParsedSplit(String matchingKey, String bucketingKey, Map attributes, ParsedSplit parsedSplit) { + private TreatmentLabelAndChangeNumber evaluateParsedSplit(String matchingKey, String bucketingKey, Map attributes, + ParsedSplit parsedSplit) { try { if (parsedSplit == null) { return new TreatmentLabelAndChangeNumber(Treatments.CONTROL, Labels.DEFINITION_NOT_FOUND); diff --git a/client/src/main/java/io/split/engine/experiments/SplitFetcherImp.java b/client/src/main/java/io/split/engine/experiments/SplitFetcherImp.java index 5eb81bda8..1043ccfcf 100644 --- a/client/src/main/java/io/split/engine/experiments/SplitFetcherImp.java +++ b/client/src/main/java/io/split/engine/experiments/SplitFetcherImp.java @@ -40,7 +40,9 @@ public class SplitFetcherImp implements SplitFetcher { * an ARCHIVED split is received, we know if we need to remove a traffic type from the multiset. */ - public SplitFetcherImp(SplitChangeFetcher splitChangeFetcher, SplitParser parser, SplitCacheProducer splitCacheProducer, TelemetryRuntimeProducer telemetryRuntimeProducer) { + + public SplitFetcherImp(SplitChangeFetcher splitChangeFetcher, SplitParser parser, SplitCacheProducer splitCacheProducer, + TelemetryRuntimeProducer telemetryRuntimeProducer) { _splitChangeFetcher = checkNotNull(splitChangeFetcher); _parser = checkNotNull(parser); _splitCacheProducer = checkNotNull(splitCacheProducer); @@ -113,7 +115,6 @@ private Set runWithoutExceptionHandling(FetchOptions options) throws Int // some other thread may have updated the shared state. exit return segments; } - FeatureFlagsToUpdate featureFlagsToUpdate = processFeatureFlagChanges(_parser, change.splits); segments = featureFlagsToUpdate.getSegments(); _splitCacheProducer.update(featureFlagsToUpdate.getToAdd(), featureFlagsToUpdate.getToRemove(), change.till); diff --git a/client/src/main/java/io/split/engine/experiments/SplitParser.java b/client/src/main/java/io/split/engine/experiments/SplitParser.java index eab521212..78ed2e0f4 100644 --- a/client/src/main/java/io/split/engine/experiments/SplitParser.java +++ b/client/src/main/java/io/split/engine/experiments/SplitParser.java @@ -63,7 +63,8 @@ private ParsedSplit parseWithoutExceptionHandling(Split split) { parsedConditionList.add(new ParsedCondition(condition.conditionType, matcher, partitions, condition.label)); } - return new ParsedSplit(split.name, split.seed, split.killed, split.defaultTreatment, parsedConditionList, split.trafficTypeName, split.changeNumber, split.trafficAllocation, split.trafficAllocationSeed, split.algo, split.configurations); + return new ParsedSplit(split.name, split.seed, split.killed, split.defaultTreatment, parsedConditionList, split.trafficTypeName, + split.changeNumber, split.trafficAllocation, split.trafficAllocationSeed, split.algo, split.configurations); } private CombiningMatcher toMatcher(MatcherGroup matcherGroup) { diff --git a/client/src/main/java/io/split/engine/experiments/SplitSynchronizationTask.java b/client/src/main/java/io/split/engine/experiments/SplitSynchronizationTask.java index 10b5d2fde..6f4f99ab7 100644 --- a/client/src/main/java/io/split/engine/experiments/SplitSynchronizationTask.java +++ b/client/src/main/java/io/split/engine/experiments/SplitSynchronizationTask.java @@ -36,7 +36,8 @@ public class SplitSynchronizationTask implements SyncTask, Closeable { private ScheduledFuture _scheduledFuture; - public SplitSynchronizationTask(SplitFetcher splitFetcher, SplitCacheProducer splitCachesplitCacheProducer, long refreshEveryNSeconds, ThreadFactory threadFactory) { + public SplitSynchronizationTask(SplitFetcher splitFetcher, SplitCacheProducer splitCachesplitCacheProducer, long refreshEveryNSeconds, + ThreadFactory threadFactory) { _splitFetcher.set(checkNotNull(splitFetcher)); _splitCacheProducer.set(checkNotNull(splitCachesplitCacheProducer)); checkArgument(refreshEveryNSeconds >= 0L); diff --git a/client/src/main/java/io/split/engine/segments/SegmentFetcherImp.java b/client/src/main/java/io/split/engine/segments/SegmentFetcherImp.java index 466a529a7..526ca02d1 100644 --- a/client/src/main/java/io/split/engine/segments/SegmentFetcherImp.java +++ b/client/src/main/java/io/split/engine/segments/SegmentFetcherImp.java @@ -23,7 +23,8 @@ public class SegmentFetcherImp implements SegmentFetcher { private final Object _lock = new Object(); - public SegmentFetcherImp(String segmentName, SegmentChangeFetcher segmentChangeFetcher, SegmentCacheProducer segmentCacheProducer, TelemetryRuntimeProducer telemetryRuntimeProducer) { + public SegmentFetcherImp(String segmentName, SegmentChangeFetcher segmentChangeFetcher, SegmentCacheProducer segmentCacheProducer, + TelemetryRuntimeProducer telemetryRuntimeProducer) { _segmentName = checkNotNull(segmentName); _segmentChangeFetcher = checkNotNull(segmentChangeFetcher); _segmentCacheProducer = checkNotNull(segmentCacheProducer); diff --git a/client/src/main/java/io/split/engine/segments/SegmentSynchronizationTaskImp.java b/client/src/main/java/io/split/engine/segments/SegmentSynchronizationTaskImp.java index 08f35e813..fc7db7a98 100644 --- a/client/src/main/java/io/split/engine/segments/SegmentSynchronizationTaskImp.java +++ b/client/src/main/java/io/split/engine/segments/SegmentSynchronizationTaskImp.java @@ -41,8 +41,9 @@ public class SegmentSynchronizationTaskImp implements SegmentSynchronizationTask private ScheduledFuture _scheduledFuture; - public SegmentSynchronizationTaskImp(SegmentChangeFetcher segmentChangeFetcher, long refreshEveryNSeconds, int numThreads, SegmentCacheProducer segmentCacheProducer, - TelemetryRuntimeProducer telemetryRuntimeProducer, SplitCacheConsumer splitCacheConsumer, ThreadFactory threadFactory) { + public SegmentSynchronizationTaskImp(SegmentChangeFetcher segmentChangeFetcher, long refreshEveryNSeconds, int numThreads, + SegmentCacheProducer segmentCacheProducer, TelemetryRuntimeProducer telemetryRuntimeProducer, + SplitCacheConsumer splitCacheConsumer, ThreadFactory threadFactory) { _segmentChangeFetcher = checkNotNull(segmentChangeFetcher); checkArgument(refreshEveryNSeconds >= 0L); diff --git a/client/src/main/java/io/split/engine/sse/NotificationProcessorImp.java b/client/src/main/java/io/split/engine/sse/NotificationProcessorImp.java index 5b8e705b3..b21a7344a 100644 --- a/client/src/main/java/io/split/engine/sse/NotificationProcessorImp.java +++ b/client/src/main/java/io/split/engine/sse/NotificationProcessorImp.java @@ -26,7 +26,8 @@ public class NotificationProcessorImp implements NotificationProcessor { _pushStatusTracker = checkNotNull(pushStatusTracker); } - public static NotificationProcessorImp build(FeatureFlagsWorker featureFlagsWorker, Worker segmentWorker, PushStatusTracker pushStatusTracker) { + public static NotificationProcessorImp build(FeatureFlagsWorker featureFlagsWorker, Worker segmentWorker, + PushStatusTracker pushStatusTracker) { return new NotificationProcessorImp(featureFlagsWorker, segmentWorker, pushStatusTracker); } diff --git a/client/src/main/java/io/split/engine/sse/PushStatusTrackerImp.java b/client/src/main/java/io/split/engine/sse/PushStatusTrackerImp.java index cee18333c..083fc0d37 100644 --- a/client/src/main/java/io/split/engine/sse/PushStatusTrackerImp.java +++ b/client/src/main/java/io/split/engine/sse/PushStatusTrackerImp.java @@ -52,7 +52,8 @@ public void handleSseStatus(SSEClient.StatusMessage newStatus) { case FIRST_EVENT: if (SSEClient.StatusMessage.CONNECTED.equals(_sseStatus.get())) { _statusMessages.offer(PushManager.Status.STREAMING_READY); - _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.CONNECTION_ESTABLISHED.getType(),0l, System.currentTimeMillis())); + _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.CONNECTION_ESTABLISHED.getType(), + 0l, System.currentTimeMillis())); } case CONNECTED: _sseStatus.compareAndSet(SSEClient.StatusMessage.INITIALIZATION_IN_PROGRESS, SSEClient.StatusMessage.CONNECTED); @@ -98,14 +99,16 @@ public void handleIncomingControlEvent(ControlNotification controlNotification) } break; case STREAMING_PAUSED: - _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.STREAMING_STATUS.getType(), StreamEventsEnum.StreamingStatusValues.STREAMING_PAUSED.getValue(), System.currentTimeMillis())); + _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.STREAMING_STATUS.getType(), + StreamEventsEnum.StreamingStatusValues.STREAMING_PAUSED.getValue(), System.currentTimeMillis())); if (_backendStatus.compareAndSet(ControlType.STREAMING_RESUMED, ControlType.STREAMING_PAUSED) && _publishersOnline.get()) { // If there are no publishers online, the STREAMING_DOWN message should have already been sent _statusMessages.offer(PushManager.Status.STREAMING_DOWN); } break; case STREAMING_DISABLED: - _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.STREAMING_STATUS.getType(), StreamEventsEnum.StreamingStatusValues.STREAMING_DISABLED.getValue(), System.currentTimeMillis())); + _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.STREAMING_STATUS.getType(), + StreamEventsEnum.StreamingStatusValues.STREAMING_DISABLED.getValue(), System.currentTimeMillis())); _backendStatus.set(ControlType.STREAMING_DISABLED); _statusMessages.offer(PushManager.Status.STREAMING_OFF); break; @@ -130,7 +133,8 @@ public void handleIncomingOccupancyEvent(OccupancyNotification occupancyNotifica @Override public void handleIncomingAblyError(ErrorNotification notification) { _log.debug(String.format("handleIncomingAblyError: %s", notification.getMessage())); - _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.ABLY_ERROR.getType(), notification.getCode(), System.currentTimeMillis())); + _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.ABLY_ERROR.getType(), notification.getCode(), + System.currentTimeMillis())); if (_backendStatus.get().equals(ControlType.STREAMING_DISABLED)) { return; // Ignore } @@ -164,10 +168,12 @@ private boolean isPublishers() { private void recordTelemetryOcuppancy(OccupancyNotification occupancyNotification, int publishers) { if (CONTROL_PRI_CHANNEL.equals(occupancyNotification.getChannel())) { - _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.OCCUPANCY_PRI.getType(), publishers, System.currentTimeMillis())); + _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.OCCUPANCY_PRI.getType(), + publishers, System.currentTimeMillis())); } else if (CONTROL_SEC_CHANNEL.equals(occupancyNotification.getChannel())){ - _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.OCCUPANCY_SEC.getType(), publishers, System.currentTimeMillis())); + _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.OCCUPANCY_SEC.getType(), + publishers, System.currentTimeMillis())); } } diff --git a/client/src/main/java/io/split/engine/sse/client/SSEClient.java b/client/src/main/java/io/split/engine/sse/client/SSEClient.java index 805c7cb13..30dd16f20 100644 --- a/client/src/main/java/io/split/engine/sse/client/SSEClient.java +++ b/client/src/main/java/io/split/engine/sse/client/SSEClient.java @@ -136,26 +136,31 @@ private void connectAndLoop(URI uri, CountDownLatch signal) { _log.debug(exc.getMessage()); if (SOCKET_CLOSED_MESSAGE.equals(exc.getMessage())) { // Connection closed by us _statusCallback.apply(StatusMessage.FORCED_STOP); - _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.SSE_CONNECTION_ERROR.getType(), StreamEventsEnum.SseConnectionErrorValues.REQUESTED_CONNECTION_ERROR.getValue(), System.currentTimeMillis())); + _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.SSE_CONNECTION_ERROR.getType(), + StreamEventsEnum.SseConnectionErrorValues.REQUESTED_CONNECTION_ERROR.getValue(), System.currentTimeMillis())); return; } // Connection closed by server _statusCallback.apply(StatusMessage.RETRYABLE_ERROR); - _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.SSE_CONNECTION_ERROR.getType(), StreamEventsEnum.SseConnectionErrorValues.NON_REQUESTED_CONNECTION_ERROR.getValue(), System.currentTimeMillis())); + _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.SSE_CONNECTION_ERROR.getType(), + StreamEventsEnum.SseConnectionErrorValues.NON_REQUESTED_CONNECTION_ERROR.getValue(), System.currentTimeMillis())); return; } catch (IOException exc) { // Other type of connection error if(!_forcedStop.get()) { _log.debug(String.format("SSE connection ended abruptly: %s. Retying", exc.getMessage())); - _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.SSE_CONNECTION_ERROR.getType(), StreamEventsEnum.SseConnectionErrorValues.REQUESTED_CONNECTION_ERROR.getValue(), System.currentTimeMillis())); + _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.SSE_CONNECTION_ERROR.getType(), + StreamEventsEnum.SseConnectionErrorValues.REQUESTED_CONNECTION_ERROR.getValue(), System.currentTimeMillis())); _statusCallback.apply(StatusMessage.RETRYABLE_ERROR); return; } - _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.SSE_CONNECTION_ERROR.getType(), StreamEventsEnum.SseConnectionErrorValues.NON_REQUESTED_CONNECTION_ERROR.getValue(), System.currentTimeMillis())); + _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.SSE_CONNECTION_ERROR.getType(), + StreamEventsEnum.SseConnectionErrorValues.NON_REQUESTED_CONNECTION_ERROR.getValue(), System.currentTimeMillis())); } } } catch (Exception e) { // Any other error non related to the connection disables streaming altogether - _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.SSE_CONNECTION_ERROR.getType(), StreamEventsEnum.SseConnectionErrorValues.NON_REQUESTED_CONNECTION_ERROR.getValue(), System.currentTimeMillis())); + _telemetryRuntimeProducer.recordStreamingEvents(new StreamingEvent(StreamEventsEnum.SSE_CONNECTION_ERROR.getType(), + StreamEventsEnum.SseConnectionErrorValues.NON_REQUESTED_CONNECTION_ERROR.getValue(), System.currentTimeMillis())); _log.warn(e.getMessage(), e); _statusCallback.apply(StatusMessage.NONRETRYABLE_ERROR); } finally { diff --git a/client/src/main/java/io/split/engine/sse/dtos/SegmentChangeNotification.java b/client/src/main/java/io/split/engine/sse/dtos/SegmentChangeNotification.java index de542cfda..7eb2f9122 100644 --- a/client/src/main/java/io/split/engine/sse/dtos/SegmentChangeNotification.java +++ b/client/src/main/java/io/split/engine/sse/dtos/SegmentChangeNotification.java @@ -27,6 +27,7 @@ public void handler(NotificationProcessor notificationProcessor) { @Override public String toString() { - return String.format("Type: %s; Channel: %s; ChangeNumber: %s; SegmentName: %s", getType(), getChannel(), getChangeNumber(), getSegmentName()); + return String.format("Type: %s; Channel: %s; ChangeNumber: %s; SegmentName: %s", getType(), getChannel(), getChangeNumber(), + getSegmentName()); } } diff --git a/client/src/main/java/io/split/engine/sse/dtos/SplitKillNotification.java b/client/src/main/java/io/split/engine/sse/dtos/SplitKillNotification.java index 4d47e758b..c5a02a662 100644 --- a/client/src/main/java/io/split/engine/sse/dtos/SplitKillNotification.java +++ b/client/src/main/java/io/split/engine/sse/dtos/SplitKillNotification.java @@ -33,6 +33,7 @@ public void handler(NotificationProcessor notificationProcessor) { @Override public String toString() { - return String.format("Type: %s; Channel: %s; ChangeNumber: %s; DefaultTreatment: %s; SplitName: %s", getType(), getChannel(), getChangeNumber(), getDefaultTreatment(), getSplitName()); + return String.format("Type: %s; Channel: %s; ChangeNumber: %s; DefaultTreatment: %s; SplitName: %s", getType(), getChannel(), + getChangeNumber(), getDefaultTreatment(), getSplitName()); } } \ No newline at end of file diff --git a/client/src/main/java/io/split/engine/sse/workers/FeatureFlagWorkerImp.java b/client/src/main/java/io/split/engine/sse/workers/FeatureFlagWorkerImp.java index 455986689..938963cec 100644 --- a/client/src/main/java/io/split/engine/sse/workers/FeatureFlagWorkerImp.java +++ b/client/src/main/java/io/split/engine/sse/workers/FeatureFlagWorkerImp.java @@ -25,7 +25,8 @@ public class FeatureFlagWorkerImp extends Worker private final SplitCacheProducer _splitCacheProducer; private final TelemetryRuntimeProducer _telemetryRuntimeProducer; - public FeatureFlagWorkerImp(Synchronizer synchronizer, SplitParser splitParser, SplitCacheProducer splitCacheProducer, TelemetryRuntimeProducer telemetryRuntimeProducer) { + public FeatureFlagWorkerImp(Synchronizer synchronizer, SplitParser splitParser, SplitCacheProducer splitCacheProducer, + TelemetryRuntimeProducer telemetryRuntimeProducer) { super("Feature flags"); _synchronizer = checkNotNull(synchronizer); _splitParser = splitParser; @@ -37,8 +38,8 @@ public FeatureFlagWorkerImp(Synchronizer synchronizer, SplitParser splitParser, public void kill(SplitKillNotification splitKillNotification) { try { _synchronizer.localKillSplit(splitKillNotification); - _log.debug(String.format("Kill feature flag: %s, changeNumber: %s, defaultTreatment: %s", splitKillNotification.getSplitName(), splitKillNotification.getChangeNumber(), - splitKillNotification.getDefaultTreatment())); + _log.debug(String.format("Kill feature flag: %s, changeNumber: %s, defaultTreatment: %s", splitKillNotification.getSplitName(), + splitKillNotification.getChangeNumber(), splitKillNotification.getDefaultTreatment())); } catch (Exception ex) { _log.warn(String.format("Exception on FeatureFlagWorker kill: %s", ex.getMessage())); } @@ -61,7 +62,8 @@ private boolean addOrUpdateFeatureFlag(FeatureFlagChangeNotification featureFlag featureFlagChangeNotification.getPreviousChangeNumber() == _splitCacheProducer.getChangeNumber()) { Split featureFlag = featureFlagChangeNotification.getFeatureFlagDefinition(); FeatureFlagsToUpdate featureFlagsToUpdate = processFeatureFlagChanges(_splitParser, Collections.singletonList(featureFlag)); - _splitCacheProducer.update(featureFlagsToUpdate.getToAdd(), featureFlagsToUpdate.getToRemove(), featureFlagChangeNotification.getChangeNumber()); + _splitCacheProducer.update(featureFlagsToUpdate.getToAdd(), featureFlagsToUpdate.getToRemove(), + featureFlagChangeNotification.getChangeNumber()); Set segments = featureFlagsToUpdate.getSegments(); for (String segmentName: segments) { _synchronizer.forceRefreshSegment(segmentName); diff --git a/client/src/main/java/io/split/storages/pluggable/adapters/UserCustomSplitAdapterConsumer.java b/client/src/main/java/io/split/storages/pluggable/adapters/UserCustomSplitAdapterConsumer.java index 0bc1addb2..e47dfd9fd 100644 --- a/client/src/main/java/io/split/storages/pluggable/adapters/UserCustomSplitAdapterConsumer.java +++ b/client/src/main/java/io/split/storages/pluggable/adapters/UserCustomSplitAdapterConsumer.java @@ -87,7 +87,8 @@ public boolean trafficTypeExists(String trafficTypeName) { @Override public List splitNames() { Set splitNamesWithPrefix = _userStorageWrapper.getKeysByPrefix(PrefixAdapter.buildGetAllSplit()); - splitNamesWithPrefix = splitNamesWithPrefix.stream().map(key -> key.replace(PrefixAdapter.buildSplitsPrefix(), "")).collect(Collectors.toSet()); + splitNamesWithPrefix = splitNamesWithPrefix.stream().map(key -> key.replace(PrefixAdapter.buildSplitsPrefix(), "")). + collect(Collectors.toSet()); return new ArrayList<>(splitNamesWithPrefix); } diff --git a/client/src/main/java/io/split/telemetry/synchronizer/HttpTelemetryMemorySender.java b/client/src/main/java/io/split/telemetry/synchronizer/HttpTelemetryMemorySender.java index 7e5204337..503b99cda 100644 --- a/client/src/main/java/io/split/telemetry/synchronizer/HttpTelemetryMemorySender.java +++ b/client/src/main/java/io/split/telemetry/synchronizer/HttpTelemetryMemorySender.java @@ -32,7 +32,8 @@ public class HttpTelemetryMemorySender{ private final URI _uniqueKeysTarget; private final HttpPostImp _httpPost; - public static HttpTelemetryMemorySender create(CloseableHttpClient client, URI telemetryRootEndpoint, TelemetryRuntimeProducer telemetryRuntimeProducer) throws URISyntaxException { + public static HttpTelemetryMemorySender create(CloseableHttpClient client, URI telemetryRootEndpoint, + TelemetryRuntimeProducer telemetryRuntimeProducer) throws URISyntaxException { return new HttpTelemetryMemorySender(client, Utils.appendPath(telemetryRootEndpoint,CONFIG_ENDPOINT_PATH), Utils.appendPath(telemetryRootEndpoint, STATS_ENDPOINT_PATH), @@ -42,7 +43,8 @@ public static HttpTelemetryMemorySender create(CloseableHttpClient client, URI t } @VisibleForTesting - HttpTelemetryMemorySender(CloseableHttpClient client, URI impressionConfigTarget, URI impressionStatsTarget, URI uniqueKeysTarget,TelemetryRuntimeProducer telemetryRuntimeProducer) { + HttpTelemetryMemorySender(CloseableHttpClient client, URI impressionConfigTarget, URI impressionStatsTarget, + URI uniqueKeysTarget,TelemetryRuntimeProducer telemetryRuntimeProducer) { _httpPost = new HttpPostImp(client, telemetryRuntimeProducer); _impressionConfigTarget = impressionConfigTarget; _impressionStatsTarget = impressionStatsTarget; diff --git a/client/src/main/java/io/split/telemetry/synchronizer/TelemetryInMemorySubmitter.java b/client/src/main/java/io/split/telemetry/synchronizer/TelemetryInMemorySubmitter.java index c58ed1380..a4e6b92bd 100644 --- a/client/src/main/java/io/split/telemetry/synchronizer/TelemetryInMemorySubmitter.java +++ b/client/src/main/java/io/split/telemetry/synchronizer/TelemetryInMemorySubmitter.java @@ -38,8 +38,9 @@ public class TelemetryInMemorySubmitter implements TelemetrySynchronizer{ private SegmentCacheConsumer _segmentCacheConsumer; private final long _initStartTime; - public TelemetryInMemorySubmitter(CloseableHttpClient client, URI telemetryRootEndpoint, TelemetryStorageConsumer telemetryStorageConsumer, SplitCacheConsumer splitCacheConsumer, - SegmentCacheConsumer segmentCacheConsumer, TelemetryRuntimeProducer telemetryRuntimeProducer, long initStartTime) throws URISyntaxException { + public TelemetryInMemorySubmitter(CloseableHttpClient client, URI telemetryRootEndpoint, TelemetryStorageConsumer telemetryStorageConsumer, + SplitCacheConsumer splitCacheConsumer, SegmentCacheConsumer segmentCacheConsumer, + TelemetryRuntimeProducer telemetryRuntimeProducer, long initStartTime) throws URISyntaxException { _httpHttpTelemetryMemorySender = HttpTelemetryMemorySender.create(client, telemetryRootEndpoint, telemetryRuntimeProducer); _teleTelemetryStorageConsumer = checkNotNull(telemetryStorageConsumer); _splitCacheConsumer = checkNotNull(splitCacheConsumer); diff --git a/client/src/test/java/io/split/engine/experiments/AChangePerCallSplitChangeFetcher.java b/client/src/test/java/io/split/engine/experiments/AChangePerCallSplitChangeFetcher.java index 64495e112..63fbf1e26 100644 --- a/client/src/test/java/io/split/engine/experiments/AChangePerCallSplitChangeFetcher.java +++ b/client/src/test/java/io/split/engine/experiments/AChangePerCallSplitChangeFetcher.java @@ -37,7 +37,8 @@ public SplitChange fetch(long since, FetchOptions options) { Condition condition = null; if (_segmentName != null) { - condition = ConditionsTestUtil.makeUserDefinedSegmentCondition(ConditionType.ROLLOUT, _segmentName, Lists.newArrayList(ConditionsTestUtil.partition("on", 10))); + condition = ConditionsTestUtil.makeUserDefinedSegmentCondition(ConditionType.ROLLOUT, _segmentName, + Lists.newArrayList(ConditionsTestUtil.partition("on", 10))); } else { condition = ConditionsTestUtil.makeAllKeysCondition(Lists.newArrayList(ConditionsTestUtil.partition("on", 10))); } diff --git a/pom.xml b/pom.xml index 502fdce4b..dd0b5614e 100644 --- a/pom.xml +++ b/pom.xml @@ -129,6 +129,25 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.3.0 + + + checkstyle + validate + + check + + + + + .github/linter/google-java-style.xml + warning + true + + diff --git a/redis-wrapper/src/main/java/redis/RedisInstance.java b/redis-wrapper/src/main/java/redis/RedisInstance.java index 2d9331ce8..bc3eb2786 100644 --- a/redis-wrapper/src/main/java/redis/RedisInstance.java +++ b/redis-wrapper/src/main/java/redis/RedisInstance.java @@ -18,7 +18,8 @@ public static Builder builder() { return new Builder(); } - private static CustomStorageWrapper getRedisInstance(String host, int port, int timeout, String password, int database, String prefix, int maxTotal) { + private static CustomStorageWrapper getRedisInstance(String host, int port, int timeout, String password, int database, + String prefix, int maxTotal) { JedisPoolConfig poolConfig = new JedisPoolConfig(); poolConfig.setMaxTotal(maxTotal); JedisPool jedisPool = new JedisPool(poolConfig, host, port, timeout, password, database);