Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make lookup table/periodicals startup less noisy. #14655

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -106,7 +106,7 @@ public void add(LookupDataAdapter dataAdapter) {
// ConcurrentMap#computeIfAbsent() does not work here because scheduling a job is not idempotent.
synchronized (futures) {
if (!futures.containsKey(instanceId)) {
LOG.info("Adding job for <{}/{}/@{}> [interval={}ms]", dataAdapter.name(), dataAdapter.id(), instanceId, interval.getMillis());
LOG.debug("Adding job for <{}/{}/@{}> [interval={}ms]", dataAdapter.name(), dataAdapter.id(), instanceId, interval.getMillis());
futures.put(instanceId, schedule(dataAdapter, interval));
} else {
LOG.warn("Job for <{}/{}/@{}> already exists, not adding it again.", dataAdapter.name(), dataAdapter.id(), instanceId);
Expand All @@ -128,7 +128,7 @@ public void remove(LookupDataAdapter dataAdapter) {
// Using the adapter object ID here to make it possible to have multiple jobs for the same adapter
final String instanceId = objectId(dataAdapter);
if (futures.containsKey(instanceId)) {
LOG.info("Removing job for <{}/{}/@{}>", dataAdapter.name(), dataAdapter.id(), instanceId);
LOG.debug("Removing job for <{}/{}/@{}>", dataAdapter.name(), dataAdapter.id(), instanceId);
}
// Try to cancel the job even if the check above fails to avoid race conditions
cancel(futures.remove(instanceId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,13 @@ protected LookupDataAdapter createAdapter(DataAdapterDto dto) {
}

protected void addListeners(LookupDataAdapter adapter, DataAdapterDto dto) {

adapter.addListener(new LoggingServiceListener(
"Data Adapter",
String.format(Locale.ENGLISH, "%s/%s [@%s]", dto.name(), dto.id(), objectId(adapter)),
LOG),
scheduler);
if (LOG.isDebugEnabled()) {
adapter.addListener(new LoggingServiceListener(
"Data Adapter",
String.format(Locale.ENGLISH, "%s/%s [@%s]", dto.name(), dto.id(), objectId(adapter)),
LOG),
scheduler);
}
// Each adapter needs to be added to the refresh scheduler
adapter.addListener(adapterRefreshService.newServiceListener(adapter), scheduler);
}
Expand Down Expand Up @@ -455,11 +456,13 @@ private LookupCache createCache(CacheDto dto) {
return null;
}
final LookupCache cache = factory.create(dto.id(), dto.name(), dto.config());
cache.addListener(new LoggingServiceListener(
"Cache",
String.format(Locale.ENGLISH, "%s/%s [@%s]", dto.name(), dto.id(), objectId(cache)),
LOG),
scheduler);
if (LOG.isDebugEnabled()) {
cache.addListener(new LoggingServiceListener(
"Cache",
String.format(Locale.ENGLISH, "%s/%s [@%s]", dto.name(), dto.id(), objectId(cache)),
LOG),
scheduler);
}
return cache;
} catch (Exception e) {
LOG.error("Couldn't create cache <{}/{}>", dto.name(), dto.id(), e);
Expand Down Expand Up @@ -522,13 +525,13 @@ private LookupTable createLookupTable(LookupTableDto dto) {
.build();
final LookupCache newCache = table.cache();
final LookupDataAdapter newAdapter = table.dataAdapter();
LOG.info("Starting lookup table {}/{} [@{}] using cache {}/{} [@{}], data adapter {}/{} [@{}]",
LOG.debug("Starting lookup table {}/{} [@{}] using cache {}/{} [@{}], data adapter {}/{} [@{}]",
table.name(), table.id(), objectId(table),
newCache.name(), newCache.id(), objectId(newCache),
newAdapter.name(), newAdapter.id(), objectId(newAdapter));
final LookupTable previous = liveTables.put(dto.name(), table);
if (previous != null) {
LOG.info("Replaced previous lookup table {} [@{}]", previous.name(), objectId(previous));
LOG.debug("Replaced previous lookup table {} [@{}]", previous.name(), objectId(previous));
}
return table;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public synchronized void registerAndStart(Periodical periodical) {
t.start();
}
} else {
LOG.info(
LOG.debug(
"Starting [{}] periodical in [{}s], polling every [{}s].",
periodical.getClass().getCanonicalName(),
periodical.getInitialDelaySeconds(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,27 @@ private synchronized void startPeriodicals(Set<Periodical> periodicalsToStart) {
LOG.warn("Skipping start of {} periodicals which have already been started.", numOfPeriodicalsToSkip);
}

int successes = 0;
int failures = 0;
for (Periodical periodical : notYetStartedPeriodicals) {
try {
periodical.initialize();

if (!periodical.startOnThisNode()) {
LOG.info("Not starting [{}] periodical. Not configured to run on this node.", periodical.getClass().getCanonicalName());
LOG.debug("Not starting [{}] periodical. Not configured to run on this node.", periodical.getClass().getCanonicalName());
successes++;
continue;
}

// Register and start.
periodicals.registerAndStart(periodical);
successes++;
} catch (Exception e) {
LOG.error("Could not initialize periodical.", e);
failures++;
}
}
LOG.info("Started [{}/{}] periodicals successfully, {} failed.", successes, notYetStartedPeriodicals.size(), failures);
}

private synchronized void stopPeriodicals(Collection<Periodical> periodicalsToStop) {
Expand Down