Skip to content

Commit 9eeea9b

Browse files
committed
Add worker heartbeat support
Implements periodic worker heartbeat RPC that reports worker status, slot usage, poller info, host metrics, and sticky cache counters to the Temporal server. Includes HeartbeatManager, PollerTracker, and integration tests covering all heartbeat fields.
1 parent ef19423 commit 9eeea9b

File tree

105 files changed

+6951
-850
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+6951
-850
lines changed

.github/workflows/ci.yml

Lines changed: 170 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -13,178 +13,195 @@ jobs:
1313
runs-on: ubuntu-latest-16-cores
1414
timeout-minutes: 30
1515
steps:
16-
- name: Checkout repo
17-
uses: actions/checkout@v5
18-
with:
19-
fetch-depth: 0
20-
submodules: recursive
21-
ref: ${{ github.event.pull_request.head.sha }}
22-
23-
- name: Set up Java
24-
uses: actions/setup-java@v5
25-
with:
26-
java-version: "23"
27-
distribution: "temurin"
28-
29-
- name: Set up Gradle
30-
uses: gradle/actions/setup-gradle@v5
31-
32-
- name: Run unit tests
33-
env:
34-
USER: unittest
35-
USE_DOCKER_SERVICE: false
36-
run: ./gradlew --no-daemon test -x spotlessCheck -x spotlessApply -x spotlessJava -P edgeDepsTest
37-
38-
- name: Run independent resource tuner test
39-
env:
40-
USER: unittest
41-
USE_DOCKER_SERVICE: false
42-
run: ./gradlew --no-daemon temporal-sdk:testResourceIndependent -x spotlessCheck -x spotlessApply -x spotlessJava -P edgeDepsTest
43-
44-
- name: Publish Test Report
45-
uses: mikepenz/action-junit-report@v6
46-
if: success() || failure() # always run even if the previous step fails
47-
with:
48-
report_paths: '**/build/test-results/test/TEST-*.xml'
16+
- name: Checkout repo
17+
uses: actions/checkout@v5
18+
with:
19+
fetch-depth: 0
20+
submodules: recursive
21+
ref: ${{ github.event.pull_request.head.sha }}
22+
23+
- name: Set up Java
24+
uses: actions/setup-java@v5
25+
with:
26+
java-version: "23"
27+
distribution: "temurin"
28+
29+
- name: Set up Gradle
30+
uses: gradle/actions/setup-gradle@v5
31+
32+
- name: Run unit tests
33+
env:
34+
USER: unittest
35+
USE_DOCKER_SERVICE: false
36+
run: ./gradlew --no-daemon test -x spotlessCheck -x spotlessApply -x spotlessJava -P edgeDepsTest
37+
38+
- name: Run independent resource tuner test
39+
env:
40+
USER: unittest
41+
USE_DOCKER_SERVICE: false
42+
run: ./gradlew --no-daemon temporal-sdk:testResourceIndependent -x spotlessCheck -x spotlessApply -x spotlessJava -P edgeDepsTest
43+
44+
- name: Run Spring Boot 3 compatibility tests
45+
env:
46+
USER: unittest
47+
USE_DOCKER_SERVICE: false
48+
run: ./gradlew --no-daemon :temporal-spring-boot-autoconfigure:test -x spotlessCheck -x spotlessApply -x spotlessJava -P edgeDepsTest -P springBoot3Test
49+
50+
- name: Run Spring Boot 4 compatibility tests
51+
env:
52+
USER: unittest
53+
USE_DOCKER_SERVICE: false
54+
run: ./gradlew --no-daemon :temporal-spring-boot-autoconfigure:test -x spotlessCheck -x spotlessApply -x spotlessJava -P edgeDepsTest -P springBoot4Test
55+
56+
- name: Publish Test Report
57+
uses: mikepenz/action-junit-report@v6
58+
if: success() || failure() # always run even if the previous step fails
59+
with:
60+
report_paths: "**/build/test-results/test/TEST-*.xml"
4961

5062
unit_test_jdk8:
5163
name: Unit test with docker service [JDK8]
5264
runs-on: ubuntu-latest-16-cores
5365
timeout-minutes: 30
5466
steps:
55-
- name: Checkout repo
56-
uses: actions/checkout@v5
57-
with:
58-
fetch-depth: 0
59-
submodules: recursive
60-
ref: ${{ github.event.pull_request.head.sha }}
61-
62-
- name: Set up Java
63-
uses: actions/setup-java@v5
64-
with:
65-
java-version: |
66-
23
67-
11
68-
distribution: "temurin"
69-
70-
- name: Set up Gradle
71-
uses: gradle/actions/setup-gradle@v5
72-
73-
- name: Start containerized server and dependencies
74-
env:
75-
TEMPORAL_CLI_VERSION: 1.4.1-cloud-v1-29-0-139-2.0
76-
run: |
77-
wget -O temporal_cli.tar.gz https://github.com/temporalio/cli/releases/download/v${TEMPORAL_CLI_VERSION}/temporal_cli_${TEMPORAL_CLI_VERSION}_linux_amd64.tar.gz
78-
tar -xzf temporal_cli.tar.gz
79-
chmod +x temporal
80-
./temporal server start-dev \
81-
--headless \
82-
--port 7233 \
83-
--http-port 7243 \
84-
--namespace UnitTest \
85-
--db-filename temporal.sqlite \
86-
--sqlite-pragma journal_mode=WAL \
87-
--sqlite-pragma synchronous=OFF \
88-
--search-attribute CustomKeywordField=Keyword \
89-
--search-attribute CustomStringField=Text \
90-
--search-attribute CustomTextField=Text \
91-
--search-attribute CustomIntField=Int \
92-
--search-attribute CustomDatetimeField=Datetime \
93-
--search-attribute CustomDoubleField=Double \
94-
--search-attribute CustomBoolField=Bool \
95-
--dynamic-config-value system.enableActivityEagerExecution=true \
96-
--dynamic-config-value history.MaxBufferedQueryCount=10000 \
97-
--dynamic-config-value frontend.workerVersioningDataAPIs=true \
98-
--dynamic-config-value component.nexusoperations.recordCancelRequestCompletionEvents=true \
99-
--dynamic-config-value component.callbacks.allowedAddresses='[{"Pattern":"*","AllowInsecure":true}]' \
100-
--dynamic-config-value history.enableRequestIdRefLinks=true &
101-
sleep 10s
102-
103-
- name: Run unit tests
104-
env:
105-
USER: unittest
106-
TEMPORAL_SERVICE_ADDRESS: localhost:7233
107-
USE_DOCKER_SERVICE: true
108-
run: ./gradlew --no-daemon test -x spotlessCheck -x spotlessApply -x spotlessJava
109-
110-
- name: Run virtual thread tests
111-
env:
112-
USER: unittest
113-
TEMPORAL_SERVICE_ADDRESS: localhost:7233
114-
USE_DOCKER_SERVICE: true
115-
run: ./gradlew --no-daemon :temporal-sdk:virtualThreadTests -x spotlessCheck -x spotlessApply -x spotlessJava
116-
117-
- name: Publish Test Report
118-
uses: mikepenz/action-junit-report@v6
119-
if: success() || failure() # always run even if the previous step fails
120-
with:
121-
report_paths: '**/build/test-results/test/TEST-*.xml'
67+
- name: Checkout repo
68+
uses: actions/checkout@v5
69+
with:
70+
fetch-depth: 0
71+
submodules: recursive
72+
ref: ${{ github.event.pull_request.head.sha }}
73+
74+
- name: Set up Java
75+
uses: actions/setup-java@v5
76+
with:
77+
java-version: |
78+
23
79+
11
80+
distribution: "temurin"
81+
82+
- name: Set up Gradle
83+
uses: gradle/actions/setup-gradle@v5
84+
85+
- name: Start containerized server and dependencies
86+
env:
87+
TEMPORAL_CLI_VERSION: 1.6.1-server-1.31.0-151.0
88+
run: |
89+
wget -O temporal_cli.tar.gz https://github.com/temporalio/cli/releases/download/v${TEMPORAL_CLI_VERSION}/temporal_cli_${TEMPORAL_CLI_VERSION}_linux_amd64.tar.gz
90+
tar -xzf temporal_cli.tar.gz
91+
chmod +x temporal
92+
./temporal server start-dev \
93+
--headless \
94+
--port 7233 \
95+
--http-port 7243 \
96+
--namespace UnitTest \
97+
--db-filename temporal.sqlite \
98+
--sqlite-pragma journal_mode=WAL \
99+
--sqlite-pragma synchronous=OFF \
100+
--search-attribute CustomKeywordField=Keyword \
101+
--search-attribute CustomStringField=Text \
102+
--search-attribute CustomTextField=Text \
103+
--search-attribute CustomIntField=Int \
104+
--search-attribute CustomDatetimeField=Datetime \
105+
--search-attribute CustomDoubleField=Double \
106+
--search-attribute CustomBoolField=Bool \
107+
--dynamic-config-value system.enableActivityEagerExecution=true \
108+
--dynamic-config-value history.MaxBufferedQueryCount=10000 \
109+
--dynamic-config-value frontend.workerVersioningDataAPIs=true \
110+
--dynamic-config-value history.enableRequestIdRefLinks=true \
111+
--dynamic-config-value 'component.callbacks.allowedAddresses=[{"Pattern":"localhost:7243","AllowInsecure":true}]' &
112+
sleep 10s
113+
114+
- name: Run unit tests
115+
env:
116+
USER: unittest
117+
TEMPORAL_SERVICE_ADDRESS: localhost:7233
118+
USE_DOCKER_SERVICE: true
119+
run: ./gradlew --no-daemon test -x spotlessCheck -x spotlessApply -x spotlessJava
120+
121+
- name: Run Jackson 3 converter tests
122+
env:
123+
USER: unittest
124+
USE_DOCKER_SERVICE: false
125+
run: ./gradlew --no-daemon :temporal-sdk:jackson3Tests -x spotlessCheck -x spotlessApply -x spotlessJava
126+
127+
- name: Run virtual thread tests
128+
env:
129+
USER: unittest
130+
TEMPORAL_SERVICE_ADDRESS: localhost:7233
131+
USE_DOCKER_SERVICE: true
132+
run: ./gradlew --no-daemon :temporal-sdk:virtualThreadTests -x spotlessCheck -x spotlessApply -x spotlessJava
133+
134+
- name: Publish Test Report
135+
uses: mikepenz/action-junit-report@v6
136+
if: success() || failure() # always run even if the previous step fails
137+
with:
138+
report_paths: "**/build/test-results/test/TEST-*.xml"
122139

123140
unit_test_cloud:
124141
name: Unit test with cloud
125142
runs-on: ubuntu-latest
126143
timeout-minutes: 30
127144
steps:
128-
- name: Checkout repo
129-
uses: actions/checkout@v5
130-
with:
131-
fetch-depth: 0
132-
submodules: recursive
133-
ref: ${{ github.event.pull_request.head.sha }}
134-
135-
- name: Set up Java
136-
uses: actions/setup-java@v5
137-
with:
138-
java-version: "11"
139-
distribution: "temurin"
140-
141-
- name: Set up Gradle
142-
uses: gradle/actions/setup-gradle@v5
143-
144-
- name: Run cloud test
145-
# Only supported in non-fork runs, since secrets are not available in forks. We intentionally
146-
# are only doing this check on the step instead of the job so we require job passing in CI
147-
# even for those that can't run this step.
148-
if: ${{ github.event.pull_request.head.repo.full_name == '' || github.event.pull_request.head.repo.full_name == 'temporalio/sdk-java' }}
149-
env:
150-
USER: unittest
151-
TEMPORAL_CLIENT_CLOUD_NAMESPACE: sdk-ci.a2dd6
152-
TEMPORAL_CLIENT_CLOUD_API_KEY: ${{ secrets.TEMPORAL_CLIENT_CLOUD_API_KEY }}
153-
TEMPORAL_CLIENT_CLOUD_API_VERSION: 2024-05-13-00
154-
run: ./gradlew --no-daemon :temporal-sdk:test --tests '*CloudOperationsClientTest'
155-
156-
- name: Publish Test Report
157-
uses: mikepenz/action-junit-report@v6
158-
if: success() || failure() # always run even if the previous step fails
159-
with:
160-
report_paths: '**/build/test-results/test/TEST-*.xml'
145+
- name: Checkout repo
146+
uses: actions/checkout@v5
147+
with:
148+
fetch-depth: 0
149+
submodules: recursive
150+
ref: ${{ github.event.pull_request.head.sha }}
151+
152+
- name: Set up Java
153+
uses: actions/setup-java@v5
154+
with:
155+
java-version: "11"
156+
distribution: "temurin"
157+
158+
- name: Set up Gradle
159+
uses: gradle/actions/setup-gradle@v5
160+
161+
- name: Run cloud test
162+
# Only supported in non-fork runs, since secrets are not available in forks. We intentionally
163+
# are only doing this check on the step instead of the job so we require job passing in CI
164+
# even for those that can't run this step.
165+
if: ${{ github.event.pull_request.head.repo.full_name == '' || github.event.pull_request.head.repo.full_name == 'temporalio/sdk-java' }}
166+
env:
167+
USER: unittest
168+
TEMPORAL_CLIENT_CLOUD_NAMESPACE: sdk-ci.a2dd6
169+
TEMPORAL_CLIENT_CLOUD_API_KEY: ${{ secrets.TEMPORAL_CLIENT_CLOUD_API_KEY }}
170+
TEMPORAL_CLIENT_CLOUD_API_VERSION: 2024-05-13-00
171+
run: ./gradlew --no-daemon :temporal-sdk:test --tests '*CloudOperationsClientTest'
172+
173+
- name: Publish Test Report
174+
uses: mikepenz/action-junit-report@v6
175+
if: success() || failure() # always run even if the previous step fails
176+
with:
177+
report_paths: "**/build/test-results/test/TEST-*.xml"
161178

162179
code_format:
163180
name: Code format
164181
runs-on: ubuntu-latest
165182
timeout-minutes: 20
166183
steps:
167-
- name: Checkout repo
168-
uses: actions/checkout@v5
169-
with:
170-
fetch-depth: 0
171-
submodules: recursive
172-
ref: ${{ github.event.pull_request.head.sha }}
173-
174-
- name: Set up Java
175-
uses: actions/setup-java@v5
176-
with:
177-
java-version: "11"
178-
distribution: "temurin"
179-
180-
- name: Set up Gradle
181-
uses: gradle/actions/setup-gradle@v5
182-
183-
- name: Run copyright and code format checks
184-
run: ./gradlew --no-daemon spotlessCheck
185-
184+
- name: Checkout repo
185+
uses: actions/checkout@v5
186+
with:
187+
fetch-depth: 0
188+
submodules: recursive
189+
ref: ${{ github.event.pull_request.head.sha }}
190+
191+
- name: Set up Java
192+
uses: actions/setup-java@v5
193+
with:
194+
java-version: "11"
195+
distribution: "temurin"
196+
197+
- name: Set up Gradle
198+
uses: gradle/actions/setup-gradle@v5
199+
200+
- name: Run copyright and code format checks
201+
run: ./gradlew --no-daemon spotlessCheck
202+
186203
build_native_images:
187204
name: Build native test server
188205
uses: ./.github/workflows/build-native-image.yml
189206
with:
190-
ref: ${{ github.event.pull_request.head.sha }}
207+
ref: ${{ github.event.pull_request.head.sha }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ src/main/idls/*
1717
.project
1818
.settings
1919
.vscode/
20-
*/bin
20+
*/bin
21+
/.claude

CONTRIBUTING.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ the main repo.
4141

4242
## Test and Build
4343

44-
Testing and building `sdk-java` requires running temporal docker locally, execute:
44+
Run a local temporal server with the [temporal CLI](https://docs.temporal.io/cli#installation):
4545

4646
```bash
47-
curl -O https://raw.githubusercontent.com/temporalio/temporal/master/docker/docker-compose.yml
48-
docker-compose up
47+
temporal server start-dev
4948
```
5049

5150
(If this does not work, see instructions for running the Temporal Server at https://github.com/temporalio/temporal/blob/master/README.md.)
@@ -61,3 +60,20 @@ Build with:
6160
```bash
6261
./gradlew build
6362
```
63+
64+
## Note on Rosetta
65+
Newer Apple Silicon macs do not ship with Rosetta by default, and the version of `protoc-gen-rpc-java` we use (1.34.1) does not ship Apple Silicon binaries.
66+
67+
So Gradle is set to hardcode the download of the x86_64 binaries on MacOS, but this depends on Rosetta to function. Make sure Rosetta is installed with
68+
69+
```bash
70+
/usr/bin/pgrep oahd
71+
```
72+
73+
which should return a PID of the Rosetta process. If it doesn't, you'll need to run
74+
75+
```bash
76+
softwareupdate --install-rosetta
77+
```
78+
79+
for builds to complete successfully.

0 commit comments

Comments
 (0)