Commit fce01550 authored by chiaming2000's avatar chiaming2000
Browse files

Fix statics byte counter calculation to include "value" length (bytes).

The calculation became inaccurate when the "value" field was removed
from protocol definition.
parent 8d9f27b6
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import com.seagate.kinetic.heartbeat.message.OperationCounter;
import com.seagate.kinetic.proto.Kinetic.Message;
import com.seagate.kinetic.proto.Kinetic.Message.MessageType;
import com.seagate.kinetic.proto.Kinetic.Message.Security.ACL;
import com.seagate.kinetic.proto.Kinetic.MessageOrBuilder;
import com.seagate.kinetic.simulator.heartbeat.Heartbeat;
import com.seagate.kinetic.simulator.internal.p2p.P2POperationHandler;
import com.seagate.kinetic.simulator.io.provider.nio.NioEventLoopGroupManager;
@@ -475,15 +476,20 @@ public class SimulatorEngine implements MessageService {
                logger.log(Level.WARNING, e2.getMessage(), e2);
            }
            
            this.addStatisticCounter(request, response.build());
            this.addStatisticCounter(kmreq, kmresp);
        }

        return kmresp;
    }

    private void addStatisticCounter(Message request, Message response) {
    private void addStatisticCounter(KineticMessage kmreq, KineticMessage kmresp) {

        try {
            
            Message request = (Message) kmreq.getMessage();
            
            Message response = ((Message.Builder) kmresp.getMessage()).build();
            
            MessageType mtype = request.getCommand().getHeader()
                    .getMessageType();

@@ -493,10 +499,18 @@ public class SimulatorEngine implements MessageService {

            if (request != null) {
                inCount = request.getSerializedSize();
                //add in-bound value byte count
                if (kmreq.getValue() != null) {
                    inCount = inCount + kmreq.getValue().length;
                }
            }
            
            if (response != null) {
                outCount = response.getSerializedSize();
              //add out-bound value byte count
                if (kmresp.getValue() != null) {
                    outCount = outCount + kmresp.getValue().length;
                }
            }
            
            switch (mtype) {