Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #808 from zalando/ARUHA-1419-kpi-toggling-fix
Browse files Browse the repository at this point in the history
ARUHA-1419: removed feature-toggle check when re-submitting publishin…
  • Loading branch information
v-stepanov authored Dec 18, 2017
2 parents 5f4c18d + 0f166e0 commit c2b93a3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [2.4.1] - 2017-12-18

### Fixed
- Fixed sending of KPI events after feature toggling

## [2.4.0] - 2017-12-18

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.zalando.nakadi.util.FeatureToggleService;
import org.zalando.nakadi.util.FlowIdUtils;
import org.zalando.nakadi.util.UUIDGenerator;

Expand All @@ -28,7 +27,6 @@ public class EventsProcessor {
private final Map<String, BlockingQueue<JSONObject>> eventTypeEvents;
private final ExecutorService executorService;
private final UUIDGenerator uuidGenerator;
private final FeatureToggleService featureToggleService;

private final long batchCollectionTimeout;
private final int batchSize;
Expand All @@ -38,15 +36,13 @@ public class EventsProcessor {
@Autowired
public EventsProcessor(final EventPublisher eventPublisher,
final UUIDGenerator uuidGenerator,
final FeatureToggleService featureToggleService,
@Value("${nakadi.kpi.config.batch-collection-timeout}") final long batchCollectionTimeout,
@Value("${nakadi.kpi.config.batch-size}") final int batchSize,
@Value("${nakadi.kpi.config.workers}") final int workers,
@Value("${nakadi.kpi.config.poll-timeout}") final long pollTimeout,
@Value("${nakadi.kpi.config.events-queue-size}") final int eventsQueueSize) {
this.eventPublisher = eventPublisher;
this.uuidGenerator = uuidGenerator;
this.featureToggleService = featureToggleService;
this.batchCollectionTimeout = batchCollectionTimeout;
this.batchSize = batchSize;
this.pollTimeout = pollTimeout;
Expand Down Expand Up @@ -91,9 +87,7 @@ private void sendEventBatch(final String etName) {
LOG.error("Error occurred while publishing events to {}, {}", etName, e.getMessage(), e);
}
} finally {
if (featureToggleService.isFeatureEnabled(FeatureToggleService.Feature.KPI_COLLECTION)) {
executorService.submit(() -> sendEventBatch(etName));
}
executorService.submit(() -> sendEventBatch(etName));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,18 @@
import org.json.JSONObject;
import org.junit.Test;
import org.mockito.Mockito;
import org.zalando.nakadi.util.FeatureToggleService;
import org.zalando.nakadi.util.UUIDGenerator;
import org.zalando.nakadi.utils.TestUtils;

public class EventsProcessorTest {

private final EventPublisher eventPublisher = Mockito.mock(EventPublisher.class);
private final UUIDGenerator uuidGenerator = Mockito.mock(UUIDGenerator.class);
private final FeatureToggleService featureToggleService = Mockito.mock(FeatureToggleService.class);

@Test
public void shouldSendEventWhenSubmitted() {
final EventsProcessor eventsProcessor = new EventsProcessor(eventPublisher, uuidGenerator,
featureToggleService, 100, 1, 1, 100, 10);
final EventsProcessor eventsProcessor = new EventsProcessor(eventPublisher, uuidGenerator, 100, 1, 1, 100, 10);
final JSONObject event = new JSONObject().put("path", "/path/to/event").put("user", "adyachkov");
Mockito.when(featureToggleService.isFeatureEnabled(FeatureToggleService.Feature.KPI_COLLECTION))
.thenReturn(true);

eventsProcessor.enrichAndSubmit("test_et_name", event);
TestUtils.waitFor(() -> {
Expand Down

0 comments on commit c2b93a3

Please sign in to comment.