use of com.alibaba.csp.sentinel.cluster.request.data.ParamFlowRequestData in project Sentinel by alibaba.
the class DefaultClusterTokenClient method requestParamToken.
@Override
public TokenResult requestParamToken(Long flowId, int acquireCount, Collection<Object> params) {
if (notValidRequest(flowId, acquireCount) || params == null || params.isEmpty()) {
return badRequest();
}
ParamFlowRequestData data = new ParamFlowRequestData().setCount(acquireCount).setFlowId(flowId).setParams(params);
ClusterRequest<ParamFlowRequestData> request = new ClusterRequest<>(ClusterConstants.MSG_TYPE_PARAM_FLOW, data);
try {
TokenResult result = sendTokenRequest(request);
logForResult(result);
return result;
} catch (Exception ex) {
ClusterClientStatLogUtil.log(ex.getMessage());
return new TokenResult(TokenResultStatus.FAIL);
}
}
use of com.alibaba.csp.sentinel.cluster.request.data.ParamFlowRequestData in project Sentinel by alibaba.
the class ParamFlowRequestDataDecoder method decode.
@Override
public ParamFlowRequestData decode(ByteBuf source) {
if (source.readableBytes() >= 16) {
ParamFlowRequestData requestData = new ParamFlowRequestData().setFlowId(source.readLong()).setCount(source.readInt());
int amount = source.readInt();
if (amount > 0) {
List<Object> params = new ArrayList<>(amount);
for (int i = 0; i < amount; i++) {
decodeParam(source, params);
}
requestData.setParams(params);
return requestData;
}
}
return null;
}
Aggregations