Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/3.8' into 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Jun 1, 2017
2 parents e0a6954 + 7bc3516 commit f853bdf
Showing 1 changed file with 22 additions and 14 deletions.
Expand Up @@ -91,6 +91,12 @@ public class DataGapFastDetector extends DataGapDetector implements ISqlRowMappe
protected boolean detectInvalidGaps;

protected boolean useInMemoryGaps;

protected long routingStartTime;

protected long earliestTransactionTime = 0;

protected boolean supportsTransactionViews;

public DataGapFastDetector(IDataService dataService, IParameterService parameterService, IContextService contextService,
ISymmetricDialect symmetricDialect, IRouterService routerService, IStatisticManager statisticManager, INodeService nodeService) {
Expand All @@ -107,7 +113,7 @@ 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));
Expand Down Expand Up @@ -142,6 +148,18 @@ protected void reset() {
gapsAll = new HashSet<DataGap>();
gapsAdded = new HashSet<DataGap>();
gapsDeleted = new HashSet<DataGap>();

routingStartTime = System.currentTimeMillis();
supportsTransactionViews = symmetricDialect.supportsTransactionViews();
earliestTransactionTime = 0;
if (supportsTransactionViews) {
Date date = symmetricDialect.getEarliestTransactionStartTime();
if (date != null) {
earliestTransactionTime = date.getTime() - parameterService.getLong(
ParameterConstants.DBDIALECT_ORACLE_TRANSACTION_VIEW_CLOCK_SYNC_THRESHOLD_MS, 60000);
}
routingStartTime = symmetricDialect.getDatabaseTime();
}
}

/**
Expand All @@ -157,19 +175,9 @@ public void afterRouting() {
long gapTimoutInMs = parameterService.getLong(ParameterConstants.ROUTING_STALE_DATA_ID_GAP_TIME);
final int dataIdIncrementBy = parameterService.getInt(ParameterConstants.DATA_ID_INCREMENT_BY);

long currentTime = System.currentTimeMillis();
boolean supportsTransactionViews = symmetricDialect.supportsTransactionViews();
long earliestTransactionTime = 0;
if (supportsTransactionViews) {
Date date = symmetricDialect.getEarliestTransactionStartTime();
if (date != null) {
earliestTransactionTime = date.getTime() - parameterService.getLong(
ParameterConstants.DBDIALECT_ORACLE_TRANSACTION_VIEW_CLOCK_SYNC_THRESHOLD_MS, 60000);
}
currentTime = symmetricDialect.getDatabaseTime();
}

Date currentDate = new Date(currentTime);

Date currentDate = new Date(routingStartTime);
boolean isBusyExpire = false;
long lastBusyExpireRunTime = getLastBusyExpireRunTime();
if (!isAllDataRead) {
Expand Down Expand Up @@ -217,7 +225,7 @@ public void afterRouting() {
if (supportsTransactionViews) {
isExpired = createTime != null && (createTime.getTime() < earliestTransactionTime || earliestTransactionTime == 0);
} else {
isExpired = createTime != null && currentTime - createTime.getTime() > gapTimoutInMs;
isExpired = createTime != null && routingStartTime - createTime.getTime() > gapTimoutInMs;
}

if (isExpired) {
Expand Down

0 comments on commit f853bdf

Please sign in to comment.