Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,41 @@ public void setLastActivationTimeInMillis(long lastActivationTimeInMillis) {
}

public void startRefresher() {
loadRoles();
loadPolicy();

super.start();
try {
loadRoles();
} catch (Exception e) {
LOG.error("Initial roles load failed for serviceName={}: {}, will retry in {}ms via scheduled refresh", serviceName, e, pollingIntervalMs);
}
try {
loadPolicy();
} catch (Exception e) {
LOG.error("Initial policy load failed for serviceName={}: {}, will retry in {}ms via scheduled refresh", serviceName, e, pollingIntervalMs);
}
initRefresher();
}

private void initRefresher() {
LOG.debug("==> PolicyRefresher(serviceName={}).initRefresher()", serviceName);
try {
super.start();
} catch (IllegalStateException e) {
LOG.error("Failed to start PolicyRefresher thread for serviceName={}", serviceName, e);
throw e;
}
policyDownloadTimer = new Timer("policyDownloadTimer", true);

try {
policyDownloadTimer.schedule(new DownloaderTask(policyDownloadQueue), pollingIntervalMs, pollingIntervalMs);

LOG.debug("Scheduled policyDownloadRefresher to download policies every {} milliseconds", pollingIntervalMs);
} catch (IllegalStateException exception) {
LOG.error("Error scheduling policyDownloadTimer:", exception);
} catch (IllegalArgumentException | IllegalStateException | NullPointerException e) {
LOG.error("Error scheduling policyDownloadTimer:", e);
LOG.error("*** Policies will NOT be downloaded every {} milliseconds ***", pollingIntervalMs);

policyDownloadTimer = null;
if (policyDownloadTimer != null) {
policyDownloadTimer.cancel();
policyDownloadTimer = null;
}
throw e;
}
LOG.debug("<== PolicyRefresher(serviceName={}).initRefresher()", serviceName);
}

public void stopRefresher() {
Expand Down
Loading