Enable Custom Partitioning
In addition to URL-based or HTTP-header-based partitioning, users can implement their own partitioning logic. This can be done by creating a custom partitioning interceptor class with the desired logic and registering it with the Healthcare Data Repository FHIR Server.
Use the following property in the hdr_fhir.yaml file to configure the custom
interceptor:
custom-interceptor-classes:
<Fully Qualified Custom interceptor class name>
To enable custom partitioning defined by the user, perform the
following:
- Ensure partitioning is enabled and disable default URL-based
partitioning. In the hdr_fhir.yaml file, configure the following
settings:
partitioning:
allow_references_across_partitions: false
partitioning_include_in_search_hashes: false
allow_default_tenant_partition_interceptor: false
- Create a custom partition interceptor class. Implement
your own partitioning logic in a custom interceptor class and ensure the
custom class is compiled and included in a JAR file.
Example using resource contents:
@Interceptor public class ResourceTypePartitionInterceptor { @Hook(Pointcut.STORAGE_PARTITION_IDENTIFY_CREATE) public RequestPartitionId PartitionIdentifyCreate(IBaseResource theResource) { if (theResource instanceof Patient) { return RequestPartitionId.fromPartitionName("PATIENT"); } else if (theResource instanceof Observation) { return RequestPartitionId.fromPartitionName("OBSERVATION"); } else { return RequestPartitionId.fromPartitionName("OTHER"); } } }
Example Always Read All Partitions:
This is an example of a simple interceptor that ensures read requests always use all partitions. This will be achieved using RequestPartitionId.allPartitions() method.@Interceptor public class PartitionInterceptorReadAllPartitions { @Hook(Pointcut.STORAGE_PARTITION_IDENTIFY_READ) public RequestPartitionId readPartition() { return RequestPartitionId.allPartitions(); } }
- Add the JAR to the Healthcare Data Repository FHIR application WAR classpath. Place the JAR file in the WEB-INF/lib directory of the HDR FHIR WAR application.
- Enable the custom-interceptor-classes property. In the
hdr_fhir.yaml file, configure the fully qualified name of the custom
interceptor class to this property:
custom-interceptor-classes: <Fully Qualified Custom Interceptor Class Name>
Parent topic: Partitioning Features