Skip to content

Commit

Permalink
TEIID-5425 simplifying the code so that polling also has an initial load
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Sep 1, 2018
1 parent e89d5e2 commit 1043b37
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,27 +148,24 @@ public void process(final Table table) {

long ttl = 0;
String ttlStr = table.getProperty(MaterializationMetadataRepository.MATVIEW_TTL, false);
if (ttlStr == null) {
ttlStr = String.valueOf(Long.MAX_VALUE);
}
if (ttlStr != null) {
ttl = Long.parseLong(ttlStr);
if (ttl > 0) {
scheduleSnapshotJob(cvdb, table, ttl, 0L, JobType.TTL);
}
}

if (ttl > 0) {
scheduleSnapshotJob(cvdb, table, ttl, 0L, JobType.TTL);
} else {
scheduleSnapshotJob(cvdb, table, 0l, 0L, JobType.ONCE);
}

String stalenessString = table.getProperty(MaterializationMetadataRepository.MATVIEW_MAX_STALENESS_PCT, false);
String pollingExpression = table.getProperty(MaterializationMetadataRepository.MATVIEW_POLLING_QUERY, false);
String pollingInterval = table.getProperty(MaterializationMetadataRepository.MATVIEW_POLLING_INTERVAL, false);

if (pollingExpression != null || stalenessString != null) {
// schedule a check every minute
long interval = WAITTIME;
if (ttl <= 0 && pollingExpression == null) {
// run first time like, SNAPSHOT
scheduleSnapshotJob(cvdb, table, 0L, 0L, JobType.ONCE);
} else {
if (ttl > 0) {
interval = Math.min(interval, Math.max(1, ttl>>1));
}

Expand Down Expand Up @@ -208,7 +205,7 @@ public void run() {
}
}

if (ttl <= 0 && pollingQuery == null) {
if (ttl <= 0) {
//just a one time load
try {
//we use a count so that the load can cascade
Expand Down

0 comments on commit 1043b37

Please sign in to comment.