All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.icodegarden.commons.lang.metrics.NamesCachedInstanceMetrics Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package io.github.icodegarden.commons.lang.metrics;

import java.io.Closeable;
import java.io.IOException;
import java.util.List;

import io.github.icodegarden.commons.lang.NamesCachedObjectReader;
import io.github.icodegarden.commons.lang.registry.RegisteredInstance;

/**
 *
 * 只关注给定的serviceNames
* * @author Fangfang.Xu * */ public class NamesCachedInstanceMetrics implements InstanceMetrics { private final InstanceMetrics delegator; private final NamesCachedObjectReader namesCachedObjectReader; public NamesCachedInstanceMetrics(List serviceNames, InstanceMetrics delegator, long cacheRefreshIntervalMillis) throws IllegalArgumentException { if (serviceNames == null || serviceNames.isEmpty()) { throw new IllegalArgumentException("serviceNames must not empty"); } if (delegator == null) { throw new IllegalArgumentException("param delegator must not null"); } this.delegator = delegator; namesCachedObjectReader = new NamesCachedObjectReader(serviceNames, delegator, cacheRefreshIntervalMillis); } @Override public List listNamedObjects(String serviceName) { return (List) namesCachedObjectReader.listNamedObjects(serviceName); } @Override public void setMetrics(T instance, Metrics metrics) { delegator.setMetrics(instance, metrics); } @Override public Metrics getMetrics(T instance) { return delegator.getMetrics(instance); } @Override public void removeMetrics(T instance) { delegator.removeMetrics(instance); } /** * 停止调度 */ @Override public void close() throws IOException { namesCachedObjectReader.close(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy