Skip to content

Commit 2a6e934

Browse files
authored
Merge pull request #170 from SpineEventEngine/release-1.8.0
Release 1.8.0
2 parents 044aa16 + b2d4bed commit 2a6e934

7 files changed

Lines changed: 78 additions & 74 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ Gradle:
1616
```kotlin
1717
dependencies {
1818
// Datastore Storage support library.
19-
implementation("io.spine.gcloud:spine-datastore:1.7.0")
19+
implementation("io.spine.gcloud:spine-datastore:1.8.0")
2020

2121
// Pub/Sub messaging support library.
22-
implementation("io.spine.gcloud:spine-pubsub:1.7.0")
22+
implementation("io.spine.gcloud:spine-pubsub:1.8.0")
2323

2424
// Stackdriver Trace support library.
25-
implementation("io.spine.gcloud:spine-stackdriver-trace:1.7.0")
25+
implementation("io.spine.gcloud:spine-stackdriver-trace:1.8.0")
2626

2727
// Datastore-related test utilities (if needed).
28-
implementation("io.spine.gcloud:testutil-gcloud:1.7.0")
28+
implementation("io.spine.gcloud:testutil-gcloud:1.8.0")
2929
}
3030
```
3131

datastore/src/main/java/io/spine/server/storage/datastore/DsSessionStorage.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.google.cloud.datastore.TimestampValue;
3535
import io.spine.server.delivery.ShardIndex;
3636
import io.spine.server.delivery.ShardSessionRecord;
37+
import io.spine.server.delivery.WorkerId;
3738
import org.checkerframework.checker.nullness.qual.Nullable;
3839

3940
import java.util.Iterator;
@@ -165,9 +166,11 @@ private enum Column implements MessageColumn<ShardSessionRecord> {
165166
.getOfTotal());
166167
}),
167168

168-
node((m) -> {
169-
return StringValue.of(m.getPickedBy()
170-
.getValue());
169+
worker((m) -> {
170+
WorkerId worker = m.getWorker();
171+
String value = worker.getNodeId().getValue() + '-' + worker.getValue();
172+
return StringValue.of(value);
173+
171174
}),
172175

173176
when_last_picked((m) -> {

datastore/src/main/java/io/spine/server/storage/datastore/DsShardedWorkRegistry.java

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import io.spine.server.delivery.ShardIndex;
3434
import io.spine.server.delivery.ShardProcessingSession;
3535
import io.spine.server.delivery.ShardSessionRecord;
36+
import io.spine.server.delivery.WorkerId;
3637
import org.checkerframework.checker.nullness.qual.Nullable;
3738

3839
import java.util.Iterator;
@@ -79,11 +80,26 @@ public DsShardedWorkRegistry(DatastoreStorageFactory factory) {
7980
public synchronized Optional<ShardProcessingSession> pickUp(ShardIndex index, NodeId nodeId) {
8081
checkNotNull(index);
8182
checkNotNull(nodeId);
83+
84+
WorkerId worker = currentWorkerFor(nodeId);
8285
Optional<ShardSessionRecord> result =
83-
storage.updateTransactionally(index, new UpdateNodeIfAbsent(index, nodeId));
86+
storage.updateTransactionally(index, new UpdateWorkerIfAbsent(index, worker));
8487
return result.map(this::asSession);
8588
}
8689

90+
/**
91+
* Creates a worker ID by combining the given node ID with the ID of the current Java thread,
92+
* in which the execution in performed.
93+
*/
94+
@Override
95+
protected WorkerId currentWorkerFor(NodeId id) {
96+
long threadId = Thread.currentThread().getId();
97+
return WorkerId.newBuilder()
98+
.setNodeId(id)
99+
.setValue(Long.toString(threadId))
100+
.vBuild();
101+
}
102+
87103
@Override
88104
public synchronized Iterable<ShardIndex> releaseExpiredSessions(Duration inactivityPeriod) {
89105
return super.releaseExpiredSessions(inactivityPeriod);
@@ -123,24 +139,24 @@ protected DsSessionStorage storage() {
123139
}
124140

125141
/**
126-
* Updates the {@code nodeId} for the {@link ShardSessionRecord} with the specified
142+
* Updates the {@code workerId} for the {@link ShardSessionRecord} with the specified
127143
* {@link ShardIndex} if the record has not been picked by anyone.
128144
*
129145
* <p>If there is no such a record, creates a new record.
130146
*/
131-
private static class UpdateNodeIfAbsent implements DsSessionStorage.RecordUpdate {
147+
private static class UpdateWorkerIfAbsent implements DsSessionStorage.RecordUpdate {
132148

133149
private final ShardIndex index;
134-
private final NodeId nodeToSet;
150+
private final WorkerId workerToSet;
135151

136-
private UpdateNodeIfAbsent(ShardIndex index, NodeId set) {
152+
private UpdateWorkerIfAbsent(ShardIndex index, WorkerId worker) {
137153
this.index = index;
138-
nodeToSet = set;
154+
workerToSet = worker;
139155
}
140156

141157
@Override
142158
public Optional<ShardSessionRecord> createOrUpdate(@Nullable ShardSessionRecord previous) {
143-
if (previous != null && previous.hasPickedBy()) {
159+
if (previous != null && previous.hasWorker()) {
144160
return Optional.empty();
145161
}
146162
ShardSessionRecord.Builder builder =
@@ -150,7 +166,7 @@ public Optional<ShardSessionRecord> createOrUpdate(@Nullable ShardSessionRecord
150166
: previous.toBuilder();
151167

152168
ShardSessionRecord updated =
153-
builder.setPickedBy(nodeToSet)
169+
builder.setWorker(workerToSet)
154170
.setWhenLastPicked(currentTime())
155171
.vBuild();
156172
return Optional.of(updated);

datastore/src/test/java/io/spine/server/storage/datastore/DsShardedWorkRegistryTest.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import io.spine.server.delivery.ShardSessionRecord;
3737
import io.spine.server.delivery.ShardedWorkRegistry;
3838
import io.spine.server.delivery.ShardedWorkRegistryTest;
39+
import io.spine.server.delivery.WorkerId;
3940
import io.spine.testing.server.storage.datastore.TestDatastoreStorageFactory;
4041
import org.junit.jupiter.api.AfterEach;
4142
import org.junit.jupiter.api.BeforeEach;
@@ -47,8 +48,6 @@
4748
import static com.google.common.truth.Truth.assertThat;
4849
import static com.google.common.truth.Truth8.assertThat;
4950
import static io.spine.server.storage.datastore.given.TestShardIndex.newIndex;
50-
import static org.junit.Assert.assertFalse;
51-
import static org.junit.Assert.assertTrue;
5251

5352
@DisplayName("`DsShardedWorkRegistry` should")
5453
class DsShardedWorkRegistryTest extends ShardedWorkRegistryTest {
@@ -82,60 +81,62 @@ protected ShardedWorkRegistry registry() {
8281
@DisplayName("pick up the shard and write a corresponding record to the storage")
8382
void pickUp() {
8483
Optional<ShardProcessingSession> session = registry.pickUp(index, nodeId);
85-
assertTrue(session.isPresent());
84+
WorkerId expectedWorker = registry.currentWorkerFor(nodeId);
85+
assertThat(session).isPresent();
8686
assertThat(session.get()
8787
.shardIndex()).isEqualTo(index);
8888

8989
ShardSessionRecord record = readSingleRecord(index);
9090
assertThat(record.getIndex()).isEqualTo(index);
91-
assertThat(record.getPickedBy()).isEqualTo(nodeId);
91+
assertThat(record.getWorker()).isEqualTo(expectedWorker);
9292
}
9393

9494
@Test
9595
@DisplayName("not be able to pick up the shard if it's already picked up")
9696
void cannotPickUpIfTaken() {
9797

9898
Optional<ShardProcessingSession> session = registry.pickUp(index, nodeId);
99-
assertTrue(session.isPresent());
99+
assertThat(session).isPresent();
100100

101101
Optional<ShardProcessingSession> sameIdxSameNode = registry.pickUp(index, nodeId);
102-
assertFalse(sameIdxSameNode.isPresent());
102+
assertThat(sameIdxSameNode).isEmpty();
103103

104104
Optional<ShardProcessingSession> sameIdxAnotherNode = registry.pickUp(index, newNode());
105-
assertFalse(sameIdxAnotherNode.isPresent());
105+
assertThat(sameIdxAnotherNode).isEmpty();
106106

107107
ShardIndex anotherIdx = newIndex(24, 100);
108108
Optional<ShardProcessingSession> anotherIdxSameNode = registry.pickUp(anotherIdx, nodeId);
109-
assertTrue(anotherIdxSameNode.isPresent());
109+
assertThat(anotherIdxSameNode).isPresent();
110110

111111
Optional<ShardProcessingSession> anotherIdxAnotherNode =
112112
registry.pickUp(anotherIdx, newNode());
113-
assertFalse(anotherIdxAnotherNode.isPresent());
113+
assertThat(anotherIdxAnotherNode).isEmpty();
114114
}
115115

116116
@Test
117117
@DisplayName("complete the shard session (once picked up) and make it available for picking up")
118118
void completeSessionAndMakeItAvailable() {
119119
Optional<ShardProcessingSession> optional = registry.pickUp(index, nodeId);
120-
assertTrue(optional.isPresent());
120+
assertThat(optional).isPresent();
121121

122122
Timestamp whenPickedFirst = readSingleRecord(index).getWhenLastPicked();
123123

124124
DsShardProcessingSession session = (DsShardProcessingSession) optional.get();
125125
session.complete();
126126

127127
ShardSessionRecord completedRecord = readSingleRecord(index);
128-
assertFalse(completedRecord.hasPickedBy());
128+
assertThat(completedRecord.hasWorker()).isFalse();
129129

130130
NodeId anotherNode = newNode();
131+
WorkerId anotherWorker = registry.currentWorkerFor(anotherNode);
131132
Optional<ShardProcessingSession> anotherOptional = registry.pickUp(index, anotherNode);
132-
assertTrue(anotherOptional.isPresent());
133+
assertThat(anotherOptional).isPresent();
133134

134135
ShardSessionRecord secondSessionRecord = readSingleRecord(index);
135-
assertThat(secondSessionRecord.getPickedBy()).isEqualTo(anotherNode);
136+
assertThat(secondSessionRecord.getWorker()).isEqualTo(anotherWorker);
136137

137138
Timestamp whenPickedSecond = secondSessionRecord.getWhenLastPicked();
138-
assertTrue(Timestamps.compare(whenPickedFirst, whenPickedSecond) < 0);
139+
assertThat(Timestamps.compare(whenPickedFirst, whenPickedSecond) < 0).isTrue();
139140
}
140141

141142
@Test

license-report.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
# Dependencies of `io.spine.gcloud:spine-datastore:1.7.0`
3+
# Dependencies of `io.spine.gcloud:spine-datastore:1.8.0`
44

55
## Runtime
66
1. **Group:** com.fasterxml.jackson **Name:** jackson-bom **Version:** 2.12.0 **No license information found**
@@ -592,12 +592,12 @@
592592
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
593593

594594

595-
This report was generated on **Tue Dec 15 12:20:09 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
595+
This report was generated on **Thu Dec 16 16:38:53 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
596596

597597

598598

599599

600-
# Dependencies of `io.spine.gcloud:spine-pubsub:1.7.0`
600+
# Dependencies of `io.spine.gcloud:spine-pubsub:1.8.0`
601601

602602
## Runtime
603603
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
@@ -1003,12 +1003,12 @@ This report was generated on **Tue Dec 15 12:20:09 EET 2020** using [Gradle-Lice
10031003
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
10041004

10051005

1006-
This report was generated on **Tue Dec 15 12:20:20 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
1006+
This report was generated on **Thu Dec 16 16:38:57 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
10071007

10081008

10091009

10101010

1011-
# Dependencies of `io.spine.gcloud:spine-stackdriver-trace:1.7.0`
1011+
# Dependencies of `io.spine.gcloud:spine-stackdriver-trace:1.8.0`
10121012

10131013
## Runtime
10141014
1. **Group:** com.fasterxml.jackson **Name:** jackson-bom **Version:** 2.12.0 **No license information found**
@@ -1594,12 +1594,12 @@ This report was generated on **Tue Dec 15 12:20:20 EET 2020** using [Gradle-Lice
15941594
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
15951595

15961596

1597-
This report was generated on **Tue Dec 15 12:20:43 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
1597+
This report was generated on **Thu Dec 16 16:39:04 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
15981598

15991599

16001600

16011601

1602-
# Dependencies of `io.spine.gcloud:spine-testutil-gcloud:1.7.0`
1602+
# Dependencies of `io.spine.gcloud:spine-testutil-gcloud:1.8.0`
16031603

16041604
## Runtime
16051605
1. **Group:** com.fasterxml.jackson **Name:** jackson-bom **Version:** 2.12.0 **No license information found**
@@ -2191,4 +2191,4 @@ This report was generated on **Tue Dec 15 12:20:43 EET 2020** using [Gradle-Lice
21912191
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
21922192

21932193

2194-
This report was generated on **Tue Dec 15 12:20:48 EET 2020** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
2194+
This report was generated on **Thu Dec 16 16:39:07 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).

pom.xml

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject.
1212

1313
<groupId>io.spine.gcloud</groupId>
1414
<artifactId>spine-gcloud-java</artifactId>
15-
<version>1.7.0</version>
15+
<version>1.8.0</version>
1616

1717
<inceptionYear>2015</inceptionYear>
1818

@@ -46,7 +46,7 @@ all modules and does not describe the project structure per-subproject.
4646
<dependency>
4747
<groupId>io.spine</groupId>
4848
<artifactId>spine-server</artifactId>
49-
<version>1.7.0</version>
49+
<version>1.8.0</version>
5050
<scope>compile</scope>
5151
</dependency>
5252
<dependency>
@@ -70,7 +70,7 @@ all modules and does not describe the project structure per-subproject.
7070
<dependency>
7171
<groupId>io.spine</groupId>
7272
<artifactId>spine-testutil-server</artifactId>
73-
<version>1.7.0</version>
73+
<version>1.8.0</version>
7474
<scope>test</scope>
7575
</dependency>
7676
<dependency>
@@ -98,44 +98,28 @@ all modules and does not describe the project structure per-subproject.
9898
<scope>test</scope>
9999
</dependency>
100100
<dependency>
101-
<groupId>com.google.errorprone</groupId>
102-
<artifactId>error_prone_core</artifactId>
103-
<version>2.4.0</version>
101+
<groupId>com.google.code.findbugs</groupId>
102+
<artifactId>jsr305</artifactId>
103+
<version>3.0.2</version>
104+
<scope>provided</scope>
104105
</dependency>
105106
<dependency>
106107
<groupId>com.google.errorprone</groupId>
107-
<artifactId>javac</artifactId>
108-
<version>9+181-r4173-1</version>
109-
</dependency>
110-
<dependency>
111-
<groupId>com.google.protobuf</groupId>
112-
<artifactId>protoc</artifactId>
113-
<version>3.13.0</version>
114-
</dependency>
115-
<dependency>
116-
<groupId>io.grpc</groupId>
117-
<artifactId>protoc-gen-grpc-java</artifactId>
118-
<version>1.28.1</version>
119-
</dependency>
120-
<dependency>
121-
<groupId>io.spine.tools</groupId>
122-
<artifactId>spine-protoc-plugin</artifactId>
123-
<version>1.7.0</version>
124-
</dependency>
125-
<dependency>
126-
<groupId>net.sourceforge.pmd</groupId>
127-
<artifactId>pmd-java</artifactId>
128-
<version>6.24.0</version>
108+
<artifactId>error_prone_annotations</artifactId>
109+
<version>2.4.0</version>
110+
<scope>provided</scope>
129111
</dependency>
130112
<dependency>
131-
<groupId>org.jacoco</groupId>
132-
<artifactId>org.jacoco.agent</artifactId>
133-
<version>0.8.5</version>
113+
<groupId>com.google.errorprone</groupId>
114+
<artifactId>error_prone_type_annotations</artifactId>
115+
<version>2.4.0</version>
116+
<scope>provided</scope>
134117
</dependency>
135118
<dependency>
136-
<groupId>org.jacoco</groupId>
137-
<artifactId>org.jacoco.ant</artifactId>
138-
<version>0.8.5</version>
119+
<groupId>org.checkerframework</groupId>
120+
<artifactId>checker-qual</artifactId>
121+
<version>3.7.1</version>
122+
<scope>provided</scope>
139123
</dependency>
140124
</dependencies>
141125
</project>

version.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
* `.config/gradle/dependencies.gradle`.
3232
*/
3333

34-
val spineBaseVersion: String by extra("1.7.0")
35-
val spineCoreVersion: String by extra("1.7.0")
36-
val versionToPublish: String by extra("1.7.0")
34+
val spineBaseVersion: String by extra("1.8.0")
35+
val spineCoreVersion: String by extra("1.8.0")
36+
val versionToPublish: String by extra("1.8.0")

0 commit comments

Comments
 (0)