Skip to content

Commit 482356f

Browse files
Merge pull request #244 from commercetools/242-fix-concurrency-issue
242 fix statistics concurrency issue
2 parents 5ea07c4 + f4761ef commit 482356f

15 files changed

Lines changed: 442 additions & 201 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Build Status](https://travis-ci.org/commercetools/commercetools-sync-java.svg?branch=master)](https://travis-ci.org/commercetools/commercetools-sync-java)
44
[![codecov](https://codecov.io/gh/commercetools/commercetools-sync-java/branch/master/graph/badge.svg)](https://codecov.io/gh/commercetools/commercetools-sync-java)
55
[![Download](https://api.bintray.com/packages/commercetools/maven/commercetools-sync-java/images/download.svg) ](https://bintray.com/commercetools/maven/commercetools-sync-java/_latestVersion)
6-
[![Javadoc](http://javadoc-badge.appspot.com/com.commercetools/commercetools-sync-java.svg?label=Javadoc)](https://commercetools.github.io/commercetools-sync-java/v/v1.0.0-M9/)
6+
[![Javadoc](http://javadoc-badge.appspot.com/com.commercetools/commercetools-sync-java.svg?label=Javadoc)](https://commercetools.github.io/commercetools-sync-java/v/v1.0.0-M10/)
77
[![Known Vulnerabilities](https://snyk.io/test/github/commercetools/commercetools-sync-java/4b2e26113d591bda158217c5dc1cf80a88665646/badge.svg)](https://snyk.io/test/github/commercetools/commercetools-sync-java/4b2e26113d591bda158217c5dc1cf80a88665646)
88

99
Java API which exposes utilities for building update actions and automatic syncing of CTP data from external sources
@@ -21,7 +21,7 @@ Java API which exposes utilities for building update actions and automatic synci
2121
- [Ivy](#ivy)
2222
- [Roadmap](#roadmap)
2323
- [Release Notes](/docs/RELEASE_NOTES.md)
24-
- [Javadoc](https://commercetools.github.io/commercetools-sync-java/v/v1.0.0-M9/)
24+
- [Javadoc](https://commercetools.github.io/commercetools-sync-java/v/v1.0.0-M10/)
2525

2626
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
2727
## Usage
@@ -56,20 +56,20 @@ most popular ones:
5656
<dependency>
5757
<groupId>com.commercetools</groupId>
5858
<artifactId>commercetools-sync-java</artifactId>
59-
<version>v1.0.0-M9</version>
59+
<version>v1.0.0-M10</version>
6060
</dependency>
6161
````
6262
#### Gradle
6363
````groovy
64-
implementation 'com.commercetools:commercetools-sync-java:v1.0.0-M9'
64+
implementation 'com.commercetools:commercetools-sync-java:v1.0.0-M10'
6565
````
6666
#### SBT
6767
````
68-
libraryDependencies += "com.commercetools" % "commercetools-sync-java" % "v1.0.0-M9"
68+
libraryDependencies += "com.commercetools" % "commercetools-sync-java" % "v1.0.0-M10"
6969
````
7070
#### Ivy
7171
````xml
72-
<dependency org="com.commercetools" name="commercetools-sync-java" rev="v1.0.0-M9"/>
72+
<dependency org="com.commercetools" name="commercetools-sync-java" rev="v1.0.0-M10"/>
7373
````
7474

7575

docs/RELEASE_NOTES.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3434

3535

36+
- [v1.0.0-M10 - Feb 13, 2018](#v100-m10----feb-13-2018)
3637
- [v1.0.0-M9 - Jan 22, 2018](#v100-m9----jan-22-2018)
3738
- [v1.0.0-M8 - Dec 29, 2017](#v100-m8----dec-29-2017)
3839
- [v1.0.0-M7 - Dec 15, 2017](#v100-m7----dec-15-2017)
@@ -47,14 +48,25 @@
4748
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
4849

4950
<!--
50-
### v1.0.0-M10 - Feb 07, 2018
51+
### v1.0.0-M11 - Mar 01, 2018
52+
[Commits](https://github.com/commercetools/commercetools-sync-java/compare/v1.0.0-M10...v1.0.0-M11) |
53+
[Javadoc](https://commercetools.github.io/commercetools-sync-java/v/v1.0.0-M11/) |
54+
[Jar](https://bintray.com/commercetools/maven/commercetools-sync-java/v1.0.0-M11)
55+
-->
56+
57+
58+
### v1.0.0-M10 - Feb 13, 2018
5159
[Commits](https://github.com/commercetools/commercetools-sync-java/compare/v1.0.0-M9...v1.0.0-M10) |
5260
[Javadoc](https://commercetools.github.io/commercetools-sync-java/v/v1.0.0-M10/) |
5361
[Jar](https://bintray.com/commercetools/maven/commercetools-sync-java/v1.0.0-M10)
5462

5563
**New Features** (1)
5664
- **Commons** - Added [benchmarking setup](/docs/BENCHMARKS.md) for the library on every release. [#155](https://github.com/commercetools/commercetools-sync-java/issues/155)
57-
-->
65+
66+
**Changes** (3)
67+
- **Commons** - Statistics counters are now of type `AtomicInteger` instead of int to support conccurency. [#242](https://github.com/commercetools/commercetools-sync-java/issues/242)
68+
- **Category Sync** - `categoryKeysWithMissingParents` in the `CategorySyncStatistics` is now of type `ConcurrentHashMap<String, Set<String>` instead of `Map<String, List<String>`. [#242](https://github.com/commercetools/commercetools-sync-java/issues/242)
69+
- **Category Sync** - `CategorySyncStatistics` now exposes the methods `removeChildCategoryKeyFromMissingParentsMap`, `getMissingParentKey` and `putMissingParentCategoryChildKey` to support manipulating `categoryKeysWithMissingParents` map. [#242](https://github.com/commercetools/commercetools-sync-java/issues/242)
5870

5971
### v1.0.0-M9 - Jan 22, 2018
6072
[Commits](https://github.com/commercetools/commercetools-sync-java/compare/v1.0.0-M8...v1.0.0-M9) |

docs/usage/CATEGORY_SYNC.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ streams, would look as follows:
8383
```java
8484
final Logger logger = LoggerFactory.getLogger(MySync.class);
8585
final CategorySyncOptions categorySyncOptions = CategorySyncOptionsBuilder.of(sphereClient)
86-
.setErrorCallBack(logger::error)
87-
.setWarningCallBack(logger::warn)
86+
.errorCallBack(logger::error)
87+
.warningCallBack(logger::warn)
8888
.build();
8989
```
9090

docs/usage/PRODUCT_SYNC.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ streams, would look as follows:
100100
```java
101101
final Logger logger = LoggerFactory.getLogger(MySync.class);
102102
final ProductSyncOptions productsyncOptions = ProductSyncOptionsBuilder.of(sphereClient)
103-
.setErrorCallBack(logger::error)
104-
.setWarningCallBack(logger::warn)
103+
.errorCallBack(logger::error)
104+
.warningCallBack(logger::warn)
105105
.build();
106106
```
107107

gradle-scripts/dependencies.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
ext{
22
commercetoolsJvmSdkVersion = '1.25.0'
3-
mockitoVersion = '2.8.9'
3+
mockitoVersion = '2.13.0'
44
jUnitVersion = '4.12'
5-
assertjVersion = '3.6.1'
5+
assertjVersion = '3.9.0'
66
checkstyleVersion = '7.7'
77
pmdVersion = '5.6.1'
8-
jacocoVersion = '0.7.9'
8+
jacocoVersion = '0.8.0'
99
findbugsVersion = '3.0.1'
1010
}
1111

src/integration-test/java/com/commercetools/sync/integration/externalsource/categories/CategorySyncIT.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.Locale;
3232
import java.util.Map;
3333
import java.util.Optional;
34+
import java.util.Set;
3435
import java.util.UUID;
3536
import java.util.concurrent.CompletableFuture;
3637
import java.util.concurrent.CompletionStage;
@@ -710,14 +711,14 @@ public void syncDrafts_WithDraftWithAMissingParentKey_ShouldNotSyncIt() {
710711

711712
assertThat(syncStatistics).hasValues(2, 2, 0, 0);
712713

713-
final Map<String, List<String>> categoryKeysWithMissingParents = syncStatistics
714+
final Map<String, Set<String>> categoryKeysWithMissingParents = syncStatistics
714715
.getCategoryKeysWithMissingParents();
715716
assertThat(categoryKeysWithMissingParents).hasSize(1);
716717

717-
final List<String> missingParentsChildren = categoryKeysWithMissingParents.get(nonExistingParentKey);
718+
final Set<String> missingParentsChildren = categoryKeysWithMissingParents.get(nonExistingParentKey);
718719
assertThat(missingParentsChildren).hasSize(1);
719720

720-
final String childrenKeys = missingParentsChildren.get(0);
721-
assertThat(childrenKeys).isEqualTo(categoryDraftWithMissingParent.getKey());
721+
final String childKey = missingParentsChildren.iterator().next();
722+
assertThat(childKey).isEqualTo(categoryDraftWithMissingParent.getKey());
722723
}
723724
}

src/integration-test/java/com/commercetools/sync/integration/externalsource/products/utils/ProductUpdateActionUtilsIT.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import static com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT;
2929
import static com.commercetools.sync.products.ProductSyncMockUtils.PRODUCT_TYPE_RESOURCE_PATH;
3030
import static com.commercetools.tests.utils.CompletionStageUtil.executeBlocking;
31+
import static com.commercetools.sync.commons.asserts.statistics.AssertionsForStatistics.assertThat;
3132
import static org.assertj.core.api.Assertions.assertThat;
3233

3334
public class ProductUpdateActionUtilsIT {
@@ -87,10 +88,7 @@ public void buildVariantsUpdateActions_shouldUpdateVariants() {
8788
assertThat(errors).isEmpty();
8889
assertThat(warnings).isEmpty();
8990

90-
assertThat(sync.getCreated()).isEqualTo(0);
91-
assertThat(sync.getUpdated()).isEqualTo(1);
92-
assertThat(sync.getProcessed()).isEqualTo(1);
93-
assertThat(sync.getFailed()).isEqualTo(0);
91+
assertThat(sync).hasValues(1, 0, 1, 0);
9492

9593
final Product synced = executeBlocking(CTP_TARGET_CLIENT.execute(ProductByKeyGet.of("productToSyncKey")));
9694
final ProductVariant syncedMasterVariant = synced.getMasterData().getStaged().getMasterVariant();

0 commit comments

Comments
 (0)