-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
82 changed files
with
3,800 additions
and
1,591 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
hapi-fhir-base/src/main/java/ca/uhn/fhir/util/ProxyUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package ca.uhn.fhir.util; | ||
|
||
/*- | ||
* #%L | ||
* HAPI FHIR - Core Library | ||
* %% | ||
* Copyright (C) 2014 - 2023 Smile CDR, Inc. | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
import org.apache.commons.lang3.Validate; | ||
|
||
import java.lang.reflect.InvocationHandler; | ||
import java.lang.reflect.Method; | ||
import java.lang.reflect.Proxy; | ||
|
||
import static com.google.common.base.Preconditions.checkArgument; | ||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
public class ProxyUtil { | ||
private ProxyUtil() {} | ||
|
||
/** | ||
* Wrap theInstance in a Proxy that synchronizes every method. | ||
* | ||
* @param theClass the target interface | ||
* @param theInstance the instance to wrap | ||
* @return a Proxy implementing theClass interface that syncronizes every call on theInstance | ||
* @param <T> the interface type | ||
*/ | ||
public static <T> T synchronizedProxy(Class<T> theClass, T theInstance) { | ||
Validate.isTrue(theClass.isInterface(), "%s is not an interface", theClass); | ||
InvocationHandler handler = new SynchronizedHandler(theInstance); | ||
Object object = Proxy.newProxyInstance(theClass.getClassLoader(), new Class<?>[] { theClass }, handler); | ||
return theClass.cast(object); | ||
} | ||
|
||
/** | ||
* Simple handler that first synchronizes on the delegate | ||
*/ | ||
static class SynchronizedHandler implements InvocationHandler { | ||
private final Object theDelegate; | ||
|
||
SynchronizedHandler(Object theDelegate) { | ||
this.theDelegate = theDelegate; | ||
} | ||
|
||
@Override | ||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { | ||
synchronized (theDelegate) { | ||
return method.invoke(theDelegate, args); | ||
} | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_4_0/4622-batch2-chunk-io.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
type: perf | ||
issue: 4622 | ||
title: "The batch system now reads less data during the maintenance pass. This avoids slowdowns on large systems." |
4 changes: 4 additions & 0 deletions
4
...fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_6_0/4621-work-chunk-events.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
type: change | ||
issue: 4621 | ||
title: "Batch2 work-chunk processing now aligns transaction boundaries with event transitions." |
5 changes: 5 additions & 0 deletions
5
...ain/resources/ca/uhn/hapi/fhir/changelog/6_6_0/4643-fix-intermittent-in-batch2-tests.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
type: fix | ||
issue: 4643 | ||
title: "There was a transaction boundary issue in the Batch2 storage layer which resulted in the | ||
framework needing more open database connections than necessary. This has been corrected." |
4 changes: 4 additions & 0 deletions
4
...s/src/main/resources/ca/uhn/hapi/fhir/changelog/6_6_0/4647-job-instance-transactions.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
type: fix | ||
issue: 4647 | ||
title: "Batch job state transitions are are now transitionally safe." |
68 changes: 68 additions & 0 deletions
68
...docs/src/main/resources/ca/uhn/hapi/fhir/docs/server_jpa_batch/batch2_states.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
|
||
```mermaid | ||
--- | ||
title: Batch2 Job Instance state transitions | ||
--- | ||
stateDiagram-v2 | ||
[*] --> QUEUED : on db create and queued on kakfa | ||
QUEUED --> IN_PROGRESS : on any work-chunk received by worker | ||
%% and (see ca.uhn.fhir.batch2.progress.InstanceProgress.getNewStatus()) | ||
state first_step_finished <<choice>> | ||
IN_PROGRESS --> first_step_finished : When 1st step finishes | ||
first_step_finished --> COMPLETED: if no chunks produced | ||
first_step_finished --> IN_PROGRESS: chunks produced | ||
IN_PROGRESS --> in_progress_poll : on poll \n(count acomplete/failed/errored chunks) | ||
in_progress_poll --> COMPLETED : 0 failures, errored, or incomplete\n AND at least 1 chunk complete | ||
in_progress_poll --> ERRORED : no failed but errored chunks | ||
in_progress_poll --> FINALIZE : none failed, gated execution\n last step\n queue REDUCER chunk | ||
in_progress_poll --> IN_PROGRESS : still work to do | ||
%% ERRORED is just like IN_PROGRESS, but it is a one-way trip from IN_PROGRESS to ERRORED. | ||
%% FIXME We could probably delete/merge this state with IS_PROCESS, and use the error count in the UI. | ||
note left of ERRORED | ||
Parallel to IS_PROCESS | ||
end note | ||
state in_progress_poll <<choice>> | ||
state error_progress_poll <<choice>> | ||
ERRORED --> error_progress_poll : on poll \n(count acomplete/failed/errored chunks) | ||
error_progress_poll --> FAILED : any failed chunks | ||
error_progress_poll --> ERRORED : no failed but errored chunks | ||
error_progress_poll --> FINALIZE : none failed, gated execution\n last step\n queue REDUCER chunk | ||
error_progress_poll --> COMPLETED : 0 failures, errored, or incomplete AND at least 1 chunk complete | ||
state do_report <<choice>> | ||
FINALIZE --> do_reduction: poll util worker marks REDUCER chunk yes or no. | ||
do_reduction --> COMPLETED : success | ||
do_reduction --> FAILED : fail | ||
in_progress_poll --> FAILED : any failed chunks | ||
``` | ||
|
||
```mermaid | ||
--- | ||
title: Batch2 Job Work Chunk state transitions | ||
--- | ||
stateDiagram-v2 | ||
state QUEUED | ||
state on_receive <<choice>> | ||
state IN_PROGRESS | ||
state ERROR | ||
state execute <<choice>> | ||
state FAILED | ||
state COMPLETED | ||
direction LR | ||
[*] --> QUEUED : on create | ||
%% worker processing states | ||
QUEUED --> on_receive : on deque by worker | ||
on_receive --> IN_PROGRESS : start execution | ||
IN_PROGRESS --> execute: execute | ||
execute --> ERROR : on re-triable error | ||
execute --> COMPLETED : success\n maybe trigger instance first_step_finished | ||
execute --> FAILED : on unrecoverable \n or too many errors | ||
%% temporary error state until retry | ||
ERROR --> on_receive : exception rollback\n triggers redelivery | ||
%% terminal states | ||
COMPLETED --> [*] | ||
FAILED --> [*] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.