improved logging of replication operations received from replicas

This commit is contained in:
Axel Uhl
2025-05-14 14:53:50 +02:00
parent 3f6d268512
commit c556013a82
4 changed files with 22 additions and 2 deletions
@@ -28,6 +28,8 @@
<li>The Riot server listening for WindBot data now properly implements connection closing upon not having
received device heartbeat messages for more than 30s.</li>
<li>Fixed parsing of X-Forwarded-For header, now reporting the correct client IP in case of multiple proxies along the way.</li>
<li>Improved logging in case operations received from replicas are being applied. The log entry now shows the name of the server
where the operation originated from.</li>
</ul>
<h2 class="articleSubheadline">March 2025</h2>
<ul class="bulletList">
@@ -3,6 +3,7 @@ package com.sap.sse.replication;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import com.sap.sse.ServerInfo;
import com.sap.sse.operationaltransformation.Operation;
/**
@@ -82,4 +83,12 @@ public interface OperationWithResult<S, R> extends Operation<S>, Serializable {
}
}
/**
* Returns {@code null} by default; however, operations that originated on a different server and were sent
* to their primary will return their {@link ServerInfo#getName() server name}. This can be used, e.g., for
* debug output.
*/
default String getOriginServerName() {
return null;
}
}
@@ -3,6 +3,7 @@ package com.sap.sse.replication;
import java.io.Serializable;
import java.util.UUID;
import com.sap.sse.ServerInfo;
import com.sap.sse.common.WithID;
/**
@@ -19,6 +20,7 @@ public class OperationWithResultWithIdWrapper<S, R> implements OperationWithResu
private static final long serialVersionUID = -5435955633510008283L;
private final Serializable id;
private final OperationWithResult<S, R> delegate;
private final String originServerName;
/**
* Creates a new UUID for this wrapper operation
@@ -34,6 +36,7 @@ public class OperationWithResultWithIdWrapper<S, R> implements OperationWithResu
super();
this.id = id;
this.delegate = delegate;
this.originServerName = delegate.getOriginServerName() == null ? ServerInfo.getName() : delegate.getOriginServerName();
}
/**
@@ -41,7 +44,7 @@ public class OperationWithResultWithIdWrapper<S, R> implements OperationWithResu
*/
@Override
public Class<?> getClassForLogging() {
return delegate.getClass();
return delegate.getClassForLogging();
}
@Override
@@ -94,8 +97,13 @@ public class OperationWithResultWithIdWrapper<S, R> implements OperationWithResu
return id;
}
@Override
public String getOriginServerName() {
return originServerName;
}
@Override
public String toString() {
return ""+delegate+" with ID "+getId();
return ""+delegate+" with ID "+getId()+(originServerName==null?"":(" from server \""+getOriginServerName()+"\""));
}
}
@@ -300,6 +300,7 @@ public class ReplicationServlet extends AbstractHttpServlet {
}
Thread.currentThread().setContextClassLoader(oldContextClassLoader);
logger.info("Applying operation of type " + operation.getClassForLogging().getName()
+ (operation.getOriginServerName() == null ? "" : (" originating from server \""+operation.getOriginServerName()+"\""))
+ " received from replica to replicable " + replicable.toString());
try {
replicable.apply(operation);