From 5ca21aacc3e460ce5bdba5b8743c03b445df026f Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Mon, 10 Jul 2023 15:52:30 -0300 Subject: [PATCH 01/16] Linter config --- .github/linter/google-java-style.xml | 364 +++++++++++++++++++++++++++ 1 file changed, 364 insertions(+) create mode 100644 .github/linter/google-java-style.xml diff --git a/.github/linter/google-java-style.xml b/.github/linter/google-java-style.xml new file mode 100644 index 000000000..e3b8db836 --- /dev/null +++ b/.github/linter/google-java-style.xml @@ -0,0 +1,364 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 19468ee70a888efcc899764ddbdd06b9b5b742a2 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Tue, 11 Jul 2023 16:12:05 -0300 Subject: [PATCH 02/16] [SDKS-7280] Add google-java-style and linter workflows --- .github/linter/google-java-style.xml | 42 +++++++++++++++++++--------- .github/workflows/linter.yml | 33 ++++++++++++++++++++++ 2 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/linter.yml diff --git a/.github/linter/google-java-style.xml b/.github/linter/google-java-style.xml index e3b8db836..2987676a6 100644 --- a/.github/linter/google-java-style.xml +++ b/.github/linter/google-java-style.xml @@ -6,25 +6,28 @@ - + - + - + @@ -32,14 +35,14 @@ - + - + @@ -65,7 +68,7 @@ + value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE"/> @@ -103,8 +106,8 @@ + LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_CATCH, LAMBDA, + LITERAL_YIELD, LITERAL_CASE"/> @@ -117,7 +120,7 @@ value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, DO_WHILE, EQUAL, GE, GT, LAMBDA, LAND, LCURLY, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, - LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, + LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN, LITERAL_ASSERT, TYPE_EXTENSION_AND"/> @@ -285,7 +288,7 @@ @@ -343,7 +346,7 @@ - + @@ -354,11 +357,24 @@ - + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 000000000..1d302fc6b --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,33 @@ +name: Lint Code Base +on: + push: + branches: + - '**' + pull_request: + branches: + - master + - development + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + build: + name: Lint Code Base + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Lint Code Base + uses: github/super-linter@v4 + env: + VALIDATE_ALL_CODEBASE: false + VALIDATE_NATURAL_LANGUAGE: false + DEFAULT_BRANCH: main + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LINTER_RULES_PATH: .github/linter + JAVA_FILE_NAME: google-java-style.xml \ No newline at end of file From 2842cd68e64209fa30e382c5780e3f33847c9854 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Tue, 11 Jul 2023 16:18:45 -0300 Subject: [PATCH 03/16] [SDKS-7280] Update ci for linter --- .github/workflows/linter.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 1d302fc6b..ba21abf64 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -1,12 +1,13 @@ name: Lint Code Base + on: push: branches: - '**' - pull_request: - branches: - - master - - development + pull_request: + branches: + - master + - development concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number }} From 0f02617d1e7aa90c2dcf5c4081fae97c362451e3 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Tue, 11 Jul 2023 17:37:02 -0300 Subject: [PATCH 04/16] [SDKS-7280] Update linter --- .github/workflows/linter.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index ba21abf64..d03afc62b 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -29,6 +29,7 @@ jobs: VALIDATE_ALL_CODEBASE: false VALIDATE_NATURAL_LANGUAGE: false DEFAULT_BRANCH: main + LOG_LEVEL: WARN GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} LINTER_RULES_PATH: .github/linter JAVA_FILE_NAME: google-java-style.xml \ No newline at end of file From e07503a77c9c8fa9e1b5fa0be079e93477ed0831 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Tue, 11 Jul 2023 17:40:23 -0300 Subject: [PATCH 05/16] [SDKS-7280] Update Linter --- .github/workflows/linter.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index d03afc62b..88325bc8d 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -19,12 +19,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Lint Code Base - uses: github/super-linter@v4 + uses: github/super-linter/slim@v5 env: VALIDATE_ALL_CODEBASE: false VALIDATE_NATURAL_LANGUAGE: false From f4015457e28cb0c95326f4cd7303045a8a274f43 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Wed, 12 Jul 2023 12:25:16 -0300 Subject: [PATCH 06/16] Update linter --- .github/workflows/linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 88325bc8d..5b21f4976 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -28,7 +28,7 @@ jobs: env: VALIDATE_ALL_CODEBASE: false VALIDATE_NATURAL_LANGUAGE: false - DEFAULT_BRANCH: main + DEFAULT_BRANCH: master LOG_LEVEL: WARN GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} LINTER_RULES_PATH: .github/linter From 7ac703fdf9b9d36317903e65dbfb35fe27079953 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Wed, 12 Jul 2023 17:58:14 -0300 Subject: [PATCH 07/16] Update linter --- .github/workflows/linter.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 5b21f4976..71e623ca2 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -14,7 +14,7 @@ concurrency: cancel-in-progress: true jobs: - build: + lint: name: Lint Code Base runs-on: ubuntu-latest steps: @@ -26,8 +26,8 @@ jobs: - name: Lint Code Base uses: github/super-linter/slim@v5 env: - VALIDATE_ALL_CODEBASE: false VALIDATE_NATURAL_LANGUAGE: false + VALIDATE_ALL_CODEBASE: true DEFAULT_BRANCH: master LOG_LEVEL: WARN GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 0bcd59b8fbc97f7b1e9888dca1d9697f5545e93a Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Thu, 13 Jul 2023 17:51:17 -0300 Subject: [PATCH 08/16] [SDKS-7283] Update google-java-style, add supressions and apply style --- .github/linter/checkstyle-suppressions.xml | 9 + .github/linter/google-java-style.xml | 242 +++++++++--------- .../client/HttpSegmentChangeFetcher.java | 6 +- .../split/client/HttpSplitChangeFetcher.java | 3 +- .../JsonLocalhostSplitChangeFetcher.java | 3 +- .../java/io/split/client/SplitClient.java | 4 +- .../java/io/split/client/SplitClientImpl.java | 32 ++- .../io/split/client/SplitFactoryImpl.java | 27 +- .../YamlLocalhostSplitChangeFetcher.java | 8 +- .../io/split/client/events/EventsSender.java | 3 +- .../io/split/client/events/EventsTask.java | 3 +- .../impressions/HttpImpressionsSender.java | 6 +- .../split/client/impressions/Impression.java | 3 +- .../impressions/ImpressionsManagerImpl.java | 12 +- .../impressions/UniqueKeysTrackerImp.java | 6 +- .../strategy/ProcessImpressionOptimized.java | 6 +- .../io/split/client/jmx/SplitJmxMonitor.java | 3 +- .../split/engine/common/PushManagerImp.java | 6 +- .../split/engine/common/SyncManagerImp.java | 12 +- .../io/split/engine/evaluator/Evaluator.java | 6 +- .../split/engine/evaluator/EvaluatorImp.java | 18 +- .../engine/experiments/SplitFetcherImp.java | 6 +- .../split/engine/experiments/SplitParser.java | 3 +- .../experiments/SplitSynchronizationTask.java | 3 +- .../engine/segments/SegmentFetcherImp.java | 3 +- .../SegmentSynchronizationTaskImp.java | 5 +- .../engine/sse/NotificationProcessorImp.java | 3 +- .../engine/sse/PushStatusTrackerImp.java | 18 +- .../io/split/engine/sse/client/SSEClient.java | 15 +- .../sse/dtos/SegmentChangeNotification.java | 3 +- .../sse/dtos/SplitKillNotification.java | 3 +- .../UserCustomSplitAdapterConsumer.java | 3 +- .../HttpTelemetryMemorySender.java | 6 +- .../TelemetryInMemorySubmitter.java | 5 +- .../AChangePerCallSplitChangeFetcher.java | 3 +- .../src/main/java/redis/RedisInstance.java | 3 +- 36 files changed, 292 insertions(+), 208 deletions(-) create mode 100644 .github/linter/checkstyle-suppressions.xml diff --git a/.github/linter/checkstyle-suppressions.xml b/.github/linter/checkstyle-suppressions.xml new file mode 100644 index 000000000..a071036d1 --- /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 index 2987676a6..e885305ed 100644 --- a/.github/linter/google-java-style.xml +++ b/.github/linter/google-java-style.xml @@ -42,74 +42,74 @@ - + - + + + + + + + + + + --> + + + + + + + + --> + + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + <!– $1 refers to the first match group in the regex defined in commentFormat –> - + <!– The check is suppressed in the next line of code after the comment –> - + --> \ No newline at end of file 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/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 c0c2c0dbb..669a66fac 100644 --- a/client/src/main/java/io/split/client/SplitFactoryImpl.java +++ b/client/src/main/java/io/split/client/SplitFactoryImpl.java @@ -188,7 +188,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); @@ -203,7 +204,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); @@ -271,8 +273,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(); @@ -547,7 +551,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, @@ -566,7 +571,8 @@ private SplitFetcher buildSplitFetcher(SplitCacheConsumer splitCacheConsumer, Sp return new SplitFetcherImp(splitChangeFetcher, splitParser, splitCacheConsumer, 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() @@ -596,7 +602,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) { @@ -627,7 +634,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<>()); }); } @@ -635,7 +643,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 052d726ad..f7cfc7a6d 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 61fff9a1e..cfc46843c 100644 --- a/client/src/main/java/io/split/engine/common/PushManagerImp.java +++ b/client/src/main/java/io/split/engine/common/PushManagerImp.java @@ -75,7 +75,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, splitsWorker, segmentWorker, pushStatusTracker, splitAPI.getSseHttpClient(), telemetryRuntimeProducer, threadFactory), + EventSourceClientImp.build(streamingUrl, splitsWorker, segmentWorker, pushStatusTracker, splitAPI.getSseHttpClient(), + telemetryRuntimeProducer, threadFactory), splitsWorker, segmentWorker, pushStatusTracker, @@ -89,7 +90,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 d739d40ab..a7a1881b0 100644 --- a/client/src/main/java/io/split/engine/common/SyncManagerImp.java +++ b/client/src/main/java/io/split/engine/common/SyncManagerImp.java @@ -142,7 +142,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<>()); }); } @@ -171,13 +172,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 @@ -193,7 +196,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/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 0afef5cc1..f20ef2f2c 100644 --- a/client/src/main/java/io/split/engine/experiments/SplitFetcherImp.java +++ b/client/src/main/java/io/split/engine/experiments/SplitFetcherImp.java @@ -44,7 +44,8 @@ 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, SplitCacheConsumer splitCacheConsumer, SplitCacheProducer splitCacheProducer, TelemetryRuntimeProducer telemetryRuntimeProducer) { + public SplitFetcherImp(SplitChangeFetcher splitChangeFetcher, SplitParser parser, SplitCacheConsumer splitCacheConsumer, + SplitCacheProducer splitCacheProducer, TelemetryRuntimeProducer telemetryRuntimeProducer) { _splitChangeFetcher = checkNotNull(splitChangeFetcher); _parser = checkNotNull(parser); _splitCacheConsumer = checkNotNull(splitCacheConsumer); @@ -133,7 +134,8 @@ private Set runWithoutExceptionHandling(FetchOptions options) throws Int ParsedSplit parsedSplit = _parser.parse(split); if (parsedSplit == null) { - _log.info(String.format("We could not parse the experiment definition for: %s so we are removing it completely to be careful", split.name)); + _log.info(String.format("We could not parse the experiment definition for: %s so we are removing it completely " + + "to be careful", split.name)); _splitCacheProducer.remove(split.name); _log.debug("Deleted feature: " + split.name); 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 7b521175e..5fa662536 100644 --- a/client/src/main/java/io/split/engine/experiments/SplitParser.java +++ b/client/src/main/java/io/split/engine/experiments/SplitParser.java @@ -68,7 +68,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 1f9d5f91e..375e8168c 100644 --- a/client/src/main/java/io/split/engine/segments/SegmentFetcherImp.java +++ b/client/src/main/java/io/split/engine/segments/SegmentFetcherImp.java @@ -24,7 +24,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 c8271c9ec..ead8acfc1 100644 --- a/client/src/main/java/io/split/engine/sse/NotificationProcessorImp.java +++ b/client/src/main/java/io/split/engine/sse/NotificationProcessorImp.java @@ -23,7 +23,8 @@ public class NotificationProcessorImp implements NotificationProcessor { _pushStatusTracker = checkNotNull(pushStatusTracker); } - public static NotificationProcessorImp build(SplitsWorker splitsWorker, Worker segmentWorker, PushStatusTracker pushStatusTracker) { + public static NotificationProcessorImp build(SplitsWorker splitsWorker, Worker segmentWorker, + PushStatusTracker pushStatusTracker) { return new NotificationProcessorImp(splitsWorker, 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 ed4700352..da3ee058a 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()); } } 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 5666e1258..d53917b89 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/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); From d9fd4e293bb2e093d9235bfcbd89eb53dc47d1e8 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Thu, 13 Jul 2023 18:41:00 -0300 Subject: [PATCH 09/16] [SDKS-7283] Update linter.yml --- .github/workflows/linter.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 71e623ca2..2b7053098 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -32,4 +32,5 @@ jobs: LOG_LEVEL: WARN GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} LINTER_RULES_PATH: .github/linter - JAVA_FILE_NAME: google-java-style.xml \ No newline at end of file + JAVA_FILE_NAME: google-java-style.xml + FILTER_REGEX_EXCLUDE: .*test/.* \ No newline at end of file From 17ef5dde176545e84b2a7adbfedcdeb39eca4f3c Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Fri, 14 Jul 2023 13:37:29 -0300 Subject: [PATCH 10/16] [SDKS-7283] Update linter file --- .github/workflows/linter.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 2b7053098..7f557afa5 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -33,4 +33,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} LINTER_RULES_PATH: .github/linter JAVA_FILE_NAME: google-java-style.xml - FILTER_REGEX_EXCLUDE: .*test/.* \ No newline at end of file + VALIDATE_XML: false + VALIDATE_YAML: false + VALIDATE_JSON: false + FILTER_REGEX_EXCLUDE: /**/src/test/** \ No newline at end of file From 66ccc828eadbfa71e0b2df6c4ad51e21eaf75339 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Fri, 14 Jul 2023 13:56:56 -0300 Subject: [PATCH 11/16] [SDKS-7283] Update linter to check only the changed files --- .github/workflows/linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 7f557afa5..cffb6abcd 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -27,7 +27,7 @@ jobs: uses: github/super-linter/slim@v5 env: VALIDATE_NATURAL_LANGUAGE: false - VALIDATE_ALL_CODEBASE: true + VALIDATE_ALL_CODEBASE: false DEFAULT_BRANCH: master LOG_LEVEL: WARN GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From ab42858da7b36eede1131dfc3aea30d1d55a8112 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Fri, 14 Jul 2023 15:22:30 -0300 Subject: [PATCH 12/16] Update linter.yml --- .github/workflows/linter.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index cffb6abcd..66d87a0b1 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -7,7 +7,6 @@ on: pull_request: branches: - master - - development concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number }} From f4a51776123acc5572afbd25149e1b807cc90531 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Thu, 20 Jul 2023 17:13:55 -0300 Subject: [PATCH 13/16] [SDKS-7283] Update pom file to use check-style pluging --- .github/linter/checkstyle-suppressions.xml | 4 +- .github/workflows/ci.yml | 4 ++ .github/workflows/linter.yml | 38 ---------------- .../io/split/client/SplitFactoryImpl.java | 3 +- .../split/engine/common/PushManagerImp.java | 3 +- .../split/engine/common/SynchronizerImp.java | 3 +- .../engine/experiments/SplitFetcherImp.java | 3 +- .../engine/sse/NotificationProcessorImp.java | 3 +- .../sse/workers/FeatureFlagWorkerImp.java | 10 +++-- pom.xml | 45 +++++++++++++++++++ 10 files changed, 67 insertions(+), 49 deletions(-) delete mode 100644 .github/workflows/linter.yml diff --git a/.github/linter/checkstyle-suppressions.xml b/.github/linter/checkstyle-suppressions.xml index a071036d1..81d235392 100644 --- a/.github/linter/checkstyle-suppressions.xml +++ b/.github/linter/checkstyle-suppressions.xml @@ -1,8 +1,8 @@ + "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" + "https://checkstyle.org/dtds/suppressions_1_2.dtd"> 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/.github/workflows/linter.yml b/.github/workflows/linter.yml deleted file mode 100644 index 66d87a0b1..000000000 --- a/.github/workflows/linter.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Lint Code Base - -on: - push: - branches: - - '**' - pull_request: - branches: - - master - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number }} - cancel-in-progress: true - -jobs: - lint: - name: Lint Code Base - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Lint Code Base - uses: github/super-linter/slim@v5 - env: - VALIDATE_NATURAL_LANGUAGE: false - VALIDATE_ALL_CODEBASE: false - DEFAULT_BRANCH: master - LOG_LEVEL: WARN - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - LINTER_RULES_PATH: .github/linter - JAVA_FILE_NAME: google-java-style.xml - VALIDATE_XML: false - VALIDATE_YAML: false - VALIDATE_JSON: false - FILTER_REGEX_EXCLUDE: /**/src/test/** \ No newline at end of file diff --git a/client/src/main/java/io/split/client/SplitFactoryImpl.java b/client/src/main/java/io/split/client/SplitFactoryImpl.java index 7aebcf858..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); 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 4c6007d78..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, 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/experiments/SplitFetcherImp.java b/client/src/main/java/io/split/engine/experiments/SplitFetcherImp.java index 7dfd91a22..1043ccfcf 100644 --- a/client/src/main/java/io/split/engine/experiments/SplitFetcherImp.java +++ b/client/src/main/java/io/split/engine/experiments/SplitFetcherImp.java @@ -41,7 +41,8 @@ public class SplitFetcherImp implements SplitFetcher { */ - 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); 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/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/pom.xml b/pom.xml index 502fdce4b..6a2888062 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 + + @@ -225,5 +244,31 @@ + + linter + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.3.0 + + + checkstyle + validate + + check + + + + + .github/linter/google-java-style.xml + warning + true + + + + + From f7b90222d82cb2ef99eed4fa1f89f2935f7ab245 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Thu, 20 Jul 2023 17:24:53 -0300 Subject: [PATCH 14/16] Update pom file --- pom.xml | 64 +++++++++++++++++---------------------------------------- 1 file changed, 19 insertions(+), 45 deletions(-) diff --git a/pom.xml b/pom.xml index 6a2888062..dd0b5614e 100644 --- a/pom.xml +++ b/pom.xml @@ -129,25 +129,25 @@ - - org.apache.maven.plugins - maven-checkstyle-plugin - 3.3.0 - - - checkstyle - validate - - check - - - - - .github/linter/google-java-style.xml - warning - true - - + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.3.0 + + + checkstyle + validate + + check + + + + + .github/linter/google-java-style.xml + warning + true + + @@ -244,31 +244,5 @@ - - linter - - - - org.apache.maven.plugins - maven-checkstyle-plugin - 3.3.0 - - - checkstyle - validate - - check - - - - - .github/linter/google-java-style.xml - warning - true - - - - - From a2c1e4d600c8e5c167bf56c41c8707fde0c11a31 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Fri, 21 Jul 2023 13:26:16 -0300 Subject: [PATCH 15/16] Add reason to fail linter --- .../java/io/split/engine/sse/NotificationProcessorImp.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 b21a7344a..5b8e705b3 100644 --- a/client/src/main/java/io/split/engine/sse/NotificationProcessorImp.java +++ b/client/src/main/java/io/split/engine/sse/NotificationProcessorImp.java @@ -26,8 +26,7 @@ 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); } From aa36c6c226f96aedddcda56ee6d1606477aea961 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Fri, 21 Jul 2023 13:57:06 -0300 Subject: [PATCH 16/16] Update NotficationProcessorImp --- .../java/io/split/engine/sse/NotificationProcessorImp.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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); }