Skip to content

Commit

Permalink
0003300: Run fix data gaps by default the first time routing runs after
Browse files Browse the repository at this point in the history
a restart
  • Loading branch information
chenson42 committed Nov 4, 2017
1 parent 128a681 commit 831ae99
Showing 1 changed file with 33 additions and 27 deletions.
Expand Up @@ -97,6 +97,8 @@ public class DataGapFastDetector extends DataGapDetector implements ISqlRowMappe
protected long earliestTransactionTime = 0;

protected boolean supportsTransactionViews;

protected static Map<String, Boolean> firstTime = Collections.synchronizedMap(new HashMap<String, Boolean>());

public DataGapFastDetector(IDataService dataService, IParameterService parameterService, IContextService contextService,
ISymmetricDialect symmetricDialect, IRouterService routerService, IStatisticManager statisticManager, INodeService nodeService) {
Expand All @@ -110,35 +112,39 @@ public DataGapFastDetector(IDataService dataService, IParameterService parameter
}

public void beforeRouting() {
maxDataToSelect = parameterService.getLong(ParameterConstants.ROUTING_LARGEST_GAP_SIZE);
detectInvalidGaps = parameterService.is(ParameterConstants.ROUTING_DETECT_INVALID_GAPS);
reset();

if (isFullGapAnalysis()) {
ProcessInfo processInfo = this.statisticManager.newProcessInfo(new ProcessInfoKey(
nodeService.findIdentityNodeId(), null, ProcessType.GAP_DETECT));
processInfo.setStatus(Status.QUERYING);
log.info("Full gap analysis is running");
long ts = System.currentTimeMillis();
gaps = dataService.findDataGaps();
if (detectInvalidGaps) {
fixOverlappingGaps(gaps, processInfo);
}
queryDataIdMap();
processInfo.setStatus(Status.OK);
log.info("Querying data in gaps from database took {} ms", System.currentTimeMillis() - ts);
afterRouting();
try {
maxDataToSelect = parameterService.getLong(ParameterConstants.ROUTING_LARGEST_GAP_SIZE);
detectInvalidGaps = parameterService.is(ParameterConstants.ROUTING_DETECT_INVALID_GAPS) || firstTime.get(parameterService.getEngineName()) == null;
reset();
log.info("Full gap analysis is done after {} ms", System.currentTimeMillis() - ts);
} else if (gaps == null || parameterService.is(ParameterConstants.CLUSTER_LOCKING_ENABLED)) {
ProcessInfo processInfo = this.statisticManager.newProcessInfo(new ProcessInfoKey(
nodeService.findIdentityNodeId(), null, ProcessType.GAP_DETECT));
processInfo.setStatus(Status.QUERYING);
gaps = dataService.findDataGaps();
if (detectInvalidGaps) {
fixOverlappingGaps(gaps, processInfo);

if (isFullGapAnalysis()) {
ProcessInfo processInfo = this.statisticManager
.newProcessInfo(new ProcessInfoKey(nodeService.findIdentityNodeId(), null, ProcessType.GAP_DETECT));
processInfo.setStatus(Status.QUERYING);
log.info("Full gap analysis is running");
long ts = System.currentTimeMillis();
gaps = dataService.findDataGaps();
if (detectInvalidGaps) {
fixOverlappingGaps(gaps, processInfo);
}
queryDataIdMap();
processInfo.setStatus(Status.OK);
log.info("Querying data in gaps from database took {} ms", System.currentTimeMillis() - ts);
afterRouting();
reset();
log.info("Full gap analysis is done after {} ms", System.currentTimeMillis() - ts);
} else if (gaps == null || parameterService.is(ParameterConstants.CLUSTER_LOCKING_ENABLED)) {
ProcessInfo processInfo = this.statisticManager
.newProcessInfo(new ProcessInfoKey(nodeService.findIdentityNodeId(), null, ProcessType.GAP_DETECT));
processInfo.setStatus(Status.QUERYING);
gaps = dataService.findDataGaps();
if (detectInvalidGaps) {
fixOverlappingGaps(gaps, processInfo);
}
processInfo.setStatus(Status.OK);
}
processInfo.setStatus(Status.OK);
} finally {
firstTime.put(parameterService.getEngineName(), true);
}
}

Expand Down

0 comments on commit 831ae99

Please sign in to comment.