@Test public void testCalculateParamAmountExceedsMaxSize() { final int maxSize = 10; ParamFlowRequestDataWriter writer = new ParamFlowRequestDataWriter(maxSize); assertEquals(1, writer.calculateParamAmount(new ArrayList<Object>() {{ add(1); }})); assertEquals(2, writer.calculateParamAmount(new ArrayList<Object>() {{ add(1); add(64); }})); assertEquals(2, writer.calculateParamAmount(new ArrayList<Object>() {{ add(1); add(64); add(3); }})); }
int calculateParamAmount( Collection<Object> params) { int size = 0; int length = 0; for (Object param : params) { int s = calculateParamTransportSize(param); if (s <= 0) { RecordLog.warn("[ParamFlowRequestDataWriter] WARN: Non-primitive type detected in params of " + "cluster parameter flow control, which is not supported: " + param); continue; } if (size + s > maxParamByteSize) { break; } size += s; length++; } return length; }
ParamFlowRequestDataWriter implements EntityWriter<ParamFlowRequestData, ByteBuf> { int calculateParamAmount( Collection<Object> params) { int size = 0; int length = 0; for (Object param : params) { int s = calculateParamTransportSize(param); if (s <= 0) { RecordLog.warn("[ParamFlowRequestDataWriter] WARN: Non-primitive type detected in params of " + "cluster parameter flow control, which is not supported: " + param); continue; } if (size + s > maxParamByteSize) { break; } size += s; length++; } return length; } }
ParamFlowRequestDataWriter implements EntityWriter<ParamFlowRequestData, ByteBuf> { int calculateParamAmount( Collection<Object> params) { int size = 0; int length = 0; for (Object param : params) { int s = calculateParamTransportSize(param); if (s <= 0) { RecordLog.warn("[ParamFlowRequestDataWriter] WARN: Non-primitive type detected in params of " + "cluster parameter flow control, which is not supported: " + param); continue; } if (size + s > maxParamByteSize) { break; } size += s; length++; } return length; } ParamFlowRequestDataWriter();  ParamFlowRequestDataWriter(int maxParamByteSize); }
ParamFlowRequestDataWriter implements EntityWriter<ParamFlowRequestData, ByteBuf> { int calculateParamAmount( Collection<Object> params) { int size = 0; int length = 0; for (Object param : params) { int s = calculateParamTransportSize(param); if (s <= 0) { RecordLog.warn("[ParamFlowRequestDataWriter] WARN: Non-primitive type detected in params of " + "cluster parameter flow control, which is not supported: " + param); continue; } if (size + s > maxParamByteSize) { break; } size += s; length++; } return length; } ParamFlowRequestDataWriter();  ParamFlowRequestDataWriter(int maxParamByteSize); @Override void writeTo(ParamFlowRequestData entity, ByteBuf target); }
ParamFlowRequestDataWriter implements EntityWriter<ParamFlowRequestData, ByteBuf> { int calculateParamAmount( Collection<Object> params) { int size = 0; int length = 0; for (Object param : params) { int s = calculateParamTransportSize(param); if (s <= 0) { RecordLog.warn("[ParamFlowRequestDataWriter] WARN: Non-primitive type detected in params of " + "cluster parameter flow control, which is not supported: " + param); continue; } if (size + s > maxParamByteSize) { break; } size += s; length++; } return length; } ParamFlowRequestDataWriter();  ParamFlowRequestDataWriter(int maxParamByteSize); @Override void writeTo(ParamFlowRequestData entity, ByteBuf target);  }