-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from xenit-eu/ALFREDOPS-850
ALFREDOPS-850 re-fetch trackers on each call
- Loading branch information
Showing
6 changed files
with
145 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...n/src/main/java/eu/xenit/alfred/telemetry/solr/monitoring/binder/AbstractSolrMetrics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package eu.xenit.alfred.telemetry.solr.monitoring.binder; | ||
|
||
import io.micrometer.core.instrument.MeterRegistry; | ||
import io.micrometer.core.instrument.binder.MeterBinder; | ||
import org.alfresco.solr.AlfrescoCoreAdminHandler; | ||
import org.alfresco.solr.tracker.TrackerRegistry; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public abstract class AbstractSolrMetrics implements MeterBinder { | ||
private static final Logger logger = LoggerFactory.getLogger(AbstractSolrMetrics.class); | ||
protected final AlfrescoCoreAdminHandler coreAdminHandler; | ||
protected MeterRegistry registry; | ||
|
||
AbstractSolrMetrics(AlfrescoCoreAdminHandler coreAdminHandler) { | ||
this.coreAdminHandler = coreAdminHandler; | ||
} | ||
|
||
protected TrackerRegistry getTrackerRegistryWhenAvailable() { | ||
logger.info("Registering tracker metrics"); | ||
TrackerRegistry trackerRegistry = coreAdminHandler.getTrackerRegistry(); | ||
|
||
while (trackerRegistry.getCoreNames().isEmpty()) { | ||
logger.error("Solr did not start tracking yet, waiting 10sec"); | ||
try { | ||
Thread.currentThread().sleep(10_000); | ||
trackerRegistry = coreAdminHandler.getTrackerRegistry(); | ||
} catch (InterruptedException e) { | ||
logger.error("Fail to wait 10 sec", e); | ||
} | ||
} | ||
return trackerRegistry; | ||
} | ||
|
||
@Override | ||
public void bindTo(MeterRegistry registry) { | ||
this.registry = registry; | ||
registerMetrics(); | ||
} | ||
|
||
protected abstract void registerMetrics(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.