Alachisoft.NCache.MetricServer.MetricServer Maven / Gradle / Ivy
The newest version!
package Alachisoft.NCache.MetricServer;
import Alachisoft.NCache.Common.*;
import Alachisoft.NCache.Common.Logger.ILogger;
import Alachisoft.NCache.Common.Logger.JLogger;
import Alachisoft.NCache.Common.Logger.LoggerNames;
import Alachisoft.NCache.Common.Monitoring.IMetricServer;
import Alachisoft.NCache.Common.Monitoring.MetricsServer.*;
import com.alachisoft.ncache.common.monitoring.ClientMetaData;
import com.alachisoft.ncache.common.monitoring.CounterDataCollection;
import com.alachisoft.ncache.common.monitoring.CounterMetadataCollection;
import com.alachisoft.ncache.common.monitoring.PublishCountersDataResult;
public class MetricServer implements IMetricServer {
private SessionManager sessionManager;
private ILogger logger = new JLogger();
public MetricServer() throws Exception {
initialize();
}
public void initialize() throws Exception {
if (sessionManager == null) {
logger.Initialize(LoggerNames.MetricServer);
sessionManager = new SessionManager(logger);
}
}
@Override
public void close() throws Exception {
sessionManager.close();
logger.close();
}
// Publishing - Metadata
public void publishMetadata(String sessionId, String version, CacheMetaData cacheMeta) {
try {
sessionManager.publishCacheMetadata(sessionId, version, cacheMeta);
} catch (Exception e) {
logger.Error("Metric Server", e.toString());
}
}
public void publishMetadata(String sessionId, String version, BridgeMetaData bridgeMetaData) {
try {
sessionManager.publishBridgeMetadata(sessionId, version, bridgeMetaData);
} catch (Exception e) {
logger.Error("Metric Server", e.toString());
}
}
public void publishMetadata(String sessionId, String version, BridgeCacheMetaData bridgeMetaData) {
try {
sessionManager.publishBridgedCacheMetadata(sessionId, version, bridgeMetaData);
} catch (Exception e) {
logger.Error("Metric Server", e.toString());
}
}
public void publishMetadata(String sessionId, String version, ClientMetaData clientMeta) {
try {
sessionManager.publishClientMetadata(sessionId, version, clientMeta);
} catch (Exception e) {
logger.Error("Metric Server", e.toString());
}
}
public void publishMetadata(String sessionId, CounterMetadataCollection counterMeta) {
try {
sessionManager.publishCountersMetadata(sessionId, counterMeta);
} catch (Exception e) {
logger.Error("Metric Server", e.toString());
}
}
// Publishing Data
public void publishData(String sessionId, Object eventsMeta) {
try {
// Implementation for eventsMeta in Java
} catch (Exception e) {
logger.Error("Metric Server", e.toString());
}
}
public PublishCountersDataResult publishData(String session, CounterDataCollection data) {
try {
return sessionManager.publishCountersData(session, data);
} catch (Exception e) {
logger.Error("Metric Server", e.toString());
throw new RuntimeException(e);
}
}
public void publishData(String session, APILogDataCollection data) {
try {
// Implementation for APILogDataCollection in Java
} catch (Exception e) {
logger.Error("Metric Server", e.toString());
}
}
public void publishData(String session, ClusterHealthData data) {
try {
// Implementation for ClusterHealthData in Java
} catch (Exception e) {
logger.Error("Metric Server", e.toString());
}
}
}