use of org.agrona.io.DirectBufferInputStream in project zeebe by zeebe-io.
the class BufferingServerOutput method getAsControlMessageData.
public Map<String, Object> getAsControlMessageData(int index) {
final ControlMessageResponseDecoder decoder = getAs(index, new ControlMessageResponseDecoder());
final UnsafeBuffer dataBuf = new UnsafeBuffer(new byte[decoder.dataLength()]);
decoder.getData(dataBuf, 0, dataBuf.capacity());
return msgPackDecoder.readMsgPack(new DirectBufferInputStream(dataBuf));
}
use of org.agrona.io.DirectBufferInputStream in project zeebe by zeebe-io.
the class ExecuteCommandResponse method wrap.
@Override
public void wrap(DirectBuffer responseBuffer, int offset, int length) {
messageHeaderDecoder.wrap(responseBuffer, offset);
if (messageHeaderDecoder.templateId() != responseDecoder.sbeTemplateId()) {
if (messageHeaderDecoder.templateId() == ErrorResponseDecoder.TEMPLATE_ID) {
errorResponse.wrap(responseBuffer, offset + messageHeaderDecoder.encodedLength(), length);
throw new RuntimeException("Unexpected error response from broker: " + errorResponse.getErrorCode() + " - " + errorResponse.getErrorData());
} else {
throw new RuntimeException("Unexpected response from broker. Template id " + messageHeaderDecoder.templateId());
}
}
responseDecoder.wrap(responseBuffer, offset + messageHeaderDecoder.encodedLength(), messageHeaderDecoder.blockLength(), messageHeaderDecoder.version());
final int eventLength = responseDecoder.eventLength();
final int eventOffset = responseDecoder.limit() + eventHeaderLength();
try (InputStream is = new DirectBufferInputStream(responseBuffer, eventOffset, eventLength)) {
event = msgPackHelper.readMsgPack(is);
} catch (IOException e) {
LangUtil.rethrowUnchecked(e);
}
}
Aggregations