Alachisoft.NCache.Sessions.MetricsSessions.SessionIdManager Maven / Gradle / Ivy
The newest version!
package Alachisoft.NCache.Sessions.MetricsSessions;
import Alachisoft.NCache.Common.Monitoring.MetricsServer.BridgeCacheMetaData;
import Alachisoft.NCache.Common.Monitoring.MetricsServer.BridgeMetaData;
import Alachisoft.NCache.Common.Monitoring.MetricsServer.CacheMetaData;
import com.alachisoft.ncache.common.monitoring.ClientMetaData;
import com.alachisoft.ncache.common.monitoring.CounterDataCollection;
import com.alachisoft.ncache.common.monitoring.CounterMetadataCollection;
public class SessionIdManager {
private String replica = "replica";
public String getSessionId(String sessionId, CounterMetadataCollection counterMeta) {
String sessionIdCopy = sessionId;
switch (counterMeta.getCategory()) {
case NCachePersistence:
case NCacheLucene:
case NCache:
if (counterMeta.getFromReplica()) {
sessionIdCopy = sessionId + ":" + replica;
}
break;
case NCacheClient:
case Bridge:
case BridgedCache:
sessionIdCopy = sessionId + ":" + counterMeta.getInstanceName().toLowerCase();
break;
}
return sessionIdCopy;
}
public String getSessionId(String sessionId, CounterDataCollection counterData) {
String sessionIdCopy = sessionId;
switch (counterData.getCategory()) {
case NCachePersistence:
case NCacheLucene:
case NCache:
if (counterData.getFromReplica()) {
sessionIdCopy = sessionId + ":" + replica;
}
break;
case NCacheClient:
case Bridge:
case BridgedCache:
sessionIdCopy = sessionId + ":" + counterData.getInstanceName().toLowerCase();
break;
}
return sessionIdCopy;
}
public String getSessionId(String sessionId, CacheMetaData cacheMeta) {
String sessionIdCopy = sessionId;
if (cacheMeta.isFromReplica()) {
sessionIdCopy = sessionId + ":replica";
}
return sessionIdCopy;
}
public String getSessionId(String sessionId, BridgeCacheMetaData bridgeCache) {
String sessionIdCopy = sessionId + ":" + bridgeCache.getCacheId().toLowerCase();
return sessionIdCopy;
}
public String getSessionId(String sessionId, BridgeMetaData bridge) {
String sessionIdCopy = sessionId + ":" + bridge.getBridgeName().toLowerCase();
return sessionIdCopy;
}
public String getSessionId(String sessionId, ClientMetaData client) {
String sessionIdCopy = sessionId + ":" + client.getBindIP().toLowerCase();
return sessionIdCopy;
}
public String getSessionId(String sessionId, String nodeIP) {
String sessionIdCopy = sessionId + ":" + nodeIP;
return sessionIdCopy;
}
public String getSessionId(String bridgeId, String sessionId, String cacheId) {
if (cacheId == null) {
return sessionId + ":" + bridgeId.toLowerCase();
} else {
return sessionId + ":" + cacheId.toLowerCase();
}
}
}