use of com.alibaba.csp.sentinel.cluster.response.data.FlowTokenResponseData in project Sentinel by alibaba.
the class DefaultClusterTokenClient method sendTokenRequest.
private TokenResult sendTokenRequest(ClusterRequest request) throws Exception {
if (transportClient == null) {
RecordLog.warn("[DefaultClusterTokenClient] Client not created, please check your config for cluster client");
return clientFail();
}
ClusterResponse response = transportClient.sendRequest(request);
TokenResult result = new TokenResult(response.getStatus());
if (response.getData() != null) {
FlowTokenResponseData responseData = (FlowTokenResponseData) response.getData();
result.setRemaining(responseData.getRemainingCount()).setWaitInMs(responseData.getWaitInMs());
}
return result;
}
use of com.alibaba.csp.sentinel.cluster.response.data.FlowTokenResponseData in project Sentinel by alibaba.
the class FlowResponseDataDecoderTest method testDecode.
@Test
public void testDecode() {
ByteBuf buf = Unpooled.buffer();
FlowResponseDataDecoder decoder = new FlowResponseDataDecoder();
FlowTokenResponseData data = new FlowTokenResponseData();
data.setRemainingCount(12);
data.setWaitInMs(13);
buf.writeInt(12);
buf.writeInt(13);
Assert.assertEquals(decoder.decode(buf), data);
}
use of com.alibaba.csp.sentinel.cluster.response.data.FlowTokenResponseData in project Sentinel by alibaba.
the class FlowResponseDataDecoder method decode.
@Override
public FlowTokenResponseData decode(ByteBuf source) {
FlowTokenResponseData data = new FlowTokenResponseData();
if (source.readableBytes() == 8) {
data.setRemainingCount(source.readInt());
data.setWaitInMs(source.readInt());
}
return data;
}
Aggregations