|
1 | 1 | /* |
2 | | - * (C) Copyright IBM Corp. 2021 |
| 2 | + * (C) Copyright IBM Corp. 2021, 2022 |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: Apache-2.0 |
5 | 5 | */ |
@@ -44,6 +44,7 @@ public class ClientDrivenReindexOperation extends DriveReindexOperation { |
44 | 44 | private static final String NOT_MODIFIED_AFTER_PARAM = "notModifiedAfter"; |
45 | 45 | private static final String AFTER_INDEX_ID_PARAM = "afterIndexId"; |
46 | 46 | private static final String INDEX_IDS_PARAM = "indexIds"; |
| 47 | + private static final String FORCE_PARAM = "force"; |
47 | 48 | private static final int MAX_RETRIEVE_COUNT = 1000; |
48 | 49 | private static final int OFFER_TIMEOUT_IN_SEC = 30; |
49 | 50 | private static final int POLL_TIMEOUT_IN_SEC = 5; |
@@ -88,21 +89,26 @@ public class ClientDrivenReindexOperation extends DriveReindexOperation { |
88 | 89 | // Number of threads currently running |
89 | 90 | private AtomicInteger currentlyRunning = new AtomicInteger(); |
90 | 91 |
|
| 92 | + // Include the force parameter in the reindex operation request |
| 93 | + private final boolean force; |
| 94 | + |
91 | 95 | /** |
92 | 96 | * Public constructor. |
93 | 97 | * @param fhirClient the FHIR client |
94 | 98 | * @param maxConcurrentRequests the number of threads to spin up |
95 | 99 | * @param reindexTimestamp timestamp the reindex began |
96 | 100 | * @param maxResourceCount resources processed per request per thread |
97 | 101 | * @param startWithIndexId index ID from which to start, or null |
| 102 | + * @param force force the reindex even if the parameter hash matches |
98 | 103 | */ |
99 | | - public ClientDrivenReindexOperation(FHIRBucketClient fhirClient, int maxConcurrentRequests, String reindexTimestamp, int maxResourceCount, String startWithIndexId) { |
| 104 | + public ClientDrivenReindexOperation(FHIRBucketClient fhirClient, int maxConcurrentRequests, String reindexTimestamp, int maxResourceCount, String startWithIndexId, boolean force) { |
100 | 105 | this.fhirClient = fhirClient; |
101 | 106 | this.maxConcurrentRequests = maxConcurrentRequests; |
102 | 107 | this.reindexTimestamp = reindexTimestamp; |
103 | 108 | this.maxResourceCount = maxResourceCount; |
104 | 109 | this.blockingQueue = new LinkedBlockingDeque<>(MAX_RETRIEVE_COUNT + (maxResourceCount * maxConcurrentRequests)); |
105 | 110 | this.inProgressIndexIds = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(maxResourceCount * maxConcurrentRequests)); |
| 111 | + this.force = force; |
106 | 112 | if (startWithIndexId != null) { |
107 | 113 | // Subtract 1 since the $retrieve-index operation retrieves index IDs after a specified index ID |
108 | 114 | this.lastIndexId = String.valueOf(Long.parseLong(startWithIndexId) - 1); |
@@ -427,6 +433,7 @@ private boolean callReindexOperation(String indexIds) { |
427 | 433 |
|
428 | 434 | Builder builder = Parameters.builder(); |
429 | 435 | builder.parameter(Parameter.builder().name(str(INDEX_IDS_PARAM)).value(str(indexIds)).build()); |
| 436 | + builder.parameter(Parameter.builder().name(str(FORCE_PARAM)).value(true).build()); |
430 | 437 | Parameters parameters = builder.build(); |
431 | 438 | String requestBody = FHIRBucketClientUtil.resourceToString(parameters); |
432 | 439 |
|
|
0 commit comments