Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -390,6 +390,7 @@ public String getStatusCode(StatusCode sc) {
public static final String CHUNK_DATA_SIZE = "dataSize";
public static final String NOT_AVAILABLE = "notAvailable";
public static final String NOT_ACTIVE = "notActive";
public static final String WRONG_KEY_RETURNED = "wrongKeyReturned";

public static final String INITIAL = "initial";
public static final String SECOND = "second";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ private void incrementFailure(String metric, EVCache.Call call, String host) {
counter.increment();
}

public void reportWrongKeyReturned(String hostName) {
incrementFailure(EVCacheMetricsFactory.WRONG_KEY_RETURNED, null, hostName);
}

private boolean ensureWriteQueueSize(MemcachedNode node, String key, EVCache.Call call) throws EVCacheException {
if (node instanceof EVCacheNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ public void receivedStatus(OperationStatus status) {
public void gotData(String k, int flags, byte[] data) {

if (!key.equals(k)) {
log.error("Wrong key returned. Key - " + key + "; Returned Key " + k);
// If they keys don't match, log the error along with the key owning host information.
final String host = getHostNameByKey(k);
log.error("Wrong key returned. Key - " + key + "; Returned Key " + k + "; Host" + host);
client.reportWrongKeyReturned(host);
return;
}
if (log.isDebugEnabled() && client.getPool().getEVCacheClientPoolManager().shouldLog(appName)) log.debug("Read data : key " + key + "; flags : " + flags + "; data : " + data);
Expand Down Expand Up @@ -255,7 +258,12 @@ public void complete() {
}

public void gotData(String k, int flags, long cas, byte[] data) {
if (!key.equals(k)) log.warn("Wrong key returned. Key - " + key + "; Returned Key " + k);
if (!key.equals(k)) {
Comment thread
smukil marked this conversation as resolved.
Outdated
// If they keys don't match, log the error along with the key owning host information.
final String host = getHostNameByKey(k);
log.error("Wrong key returned. Key - " + key + "; Returned Key " + k + "; Host" + host);
client.reportWrongKeyReturned(host);
}
if (data != null) getDataSizeDistributionSummary(EVCacheMetricsFactory.GET_AND_TOUCH_OPERATION, EVCacheMetricsFactory.READ, EVCacheMetricsFactory.IPC_SIZE_INBOUND).record(data.length);
val = new CASValue<T>(cas, tc.decode(new CachedData(flags, data, tc.getMaxSize())));
}
Expand Down Expand Up @@ -602,6 +610,11 @@ public int getReadMetricMaxValue() {
return maxReadDuration.get().intValue();
}

private String getHostNameByKey(String key) {
EVCacheNode evcNode = (EVCacheNode)getEVCacheNode(key);
Comment thread
smukil marked this conversation as resolved.
Outdated
return getHostName(evcNode.getSocketAddress());
}

private String getHostName(SocketAddress sa) {
if (sa == null) return null;
if(sa instanceof InetSocketAddress) {
Expand Down Expand Up @@ -723,7 +736,10 @@ public void receivedStatus(OperationStatus status) {
public void gotMetaData(String k, char flag, String fVal) {
if (log.isDebugEnabled()) log.debug("key " + k + "; val : " + fVal + "; flag : " + flag);
if (!key.equals(k)) {
log.error("Wrong key returned. Expected Key - " + key + "; Returned Key " + k);
// If they keys don't match, log the error along with the key owning host information.
final String host = getHostNameByKey(k);
log.error("Wrong key returned. Key - " + key + "; Returned Key " + k + "; Host" + host);
client.reportWrongKeyReturned(host);
return;
}
switch (flag) {
Expand Down Expand Up @@ -766,7 +782,10 @@ public void gotMetaData(String k, char flag, String fVal) {
public void gotData(String k, int flag, byte[] data) {
if (log.isDebugEnabled() && client.getPool().getEVCacheClientPoolManager().shouldLog(appName)) log.debug("Read data : key " + k + "; flags : " + flag + "; data : " + data);
if (!key.equals(k)) {
log.error("Wrong key returned. Expected Key - " + key + "; Returned Key " + k);
// If they keys don't match, log the error along with the key owning host information.
final String host = getHostNameByKey(k);
log.error("Wrong key returned. Key - " + key + "; Returned Key " + k + "; Host" + host);
client.reportWrongKeyReturned(host);
return;
}
if (data != null) {
Expand Down