-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MODFQMMGR-331: Retry materialized view refresh on failure
- Loading branch information
Showing
7 changed files
with
188 additions
and
40 deletions.
There are no files selected for viewing
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
33 changes: 30 additions & 3 deletions
33
src/main/java/org/folio/fqm/service/DataRefreshService.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 |
---|---|---|
@@ -1,16 +1,43 @@ | ||
package org.folio.fqm.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.folio.fqm.domain.dto.DataRefreshResponse; | ||
import org.folio.fqm.repository.DataRefreshRepository; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.folio.fqm.repository.DataRefreshRepository.EXCHANGE_RATE_TABLE; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class DataRefreshService { | ||
private final DataRefreshRepository dataRefreshRepository; | ||
|
||
public void refreshData(String tenantId) { | ||
dataRefreshRepository.refreshMaterializedViews(tenantId); | ||
dataRefreshRepository.refreshExchangeRates(tenantId); | ||
static final List<String> MATERIALIZED_VIEW_NAMES = List.of( | ||
"drv_circulation_loan_status", | ||
"drv_inventory_item_status", | ||
"drv_pol_payment_status", | ||
"drv_pol_receipt_status", | ||
"drv_inventory_statistical_code_full", | ||
"drv_languages" | ||
); | ||
|
||
public DataRefreshResponse refreshData(String tenantId) { | ||
List<String> failedConcurrentRefreshes = dataRefreshRepository.refreshMaterializedViews(tenantId, MATERIALIZED_VIEW_NAMES, true); | ||
List<String> failedRefreshes = dataRefreshRepository.refreshMaterializedViews(tenantId, failedConcurrentRefreshes, false); | ||
List<String> successRefreshes = new ArrayList<>(MATERIALIZED_VIEW_NAMES | ||
.stream() | ||
.filter(matView -> !failedRefreshes.contains(matView)) | ||
.toList()); | ||
if (dataRefreshRepository.refreshExchangeRates(tenantId)) { | ||
successRefreshes.add(EXCHANGE_RATE_TABLE); | ||
} else { | ||
failedRefreshes.add(EXCHANGE_RATE_TABLE); | ||
} | ||
return new DataRefreshResponse() | ||
.successfulRefresh(successRefreshes) | ||
.failedRefresh(failedRefreshes); | ||
} | ||
} |
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
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