本文整理汇总了Java中com.hazelcast.nio.ObjectDataOutput.toByteArray方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectDataOutput.toByteArray方法的具体用法?Java ObjectDataOutput.toByteArray怎么用?Java ObjectDataOutput.toByteArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hazelcast.nio.ObjectDataOutput
的用法示例。
在下文中一共展示了ObjectDataOutput.toByteArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFlowControlPacket
import com.hazelcast.nio.ObjectDataOutput; //导入方法依赖的package包/类
private byte[] createFlowControlPacket(Address member) throws IOException {
final ObjectDataOutput out = createObjectDataOutput(nodeEngine);
final boolean[] hasData = {false};
Map<Long, ExecutionContext> executionContexts = jobExecutionService.getExecutionContexts();
out.writeInt(executionContexts.size());
executionContexts.forEach((execId, exeCtx) -> uncheckRun(() -> {
if (!exeCtx.hasParticipant(member)) {
return;
}
out.writeLong(execId);
out.writeInt(exeCtx.receiverMap().values().stream().mapToInt(Map::size).sum());
exeCtx.receiverMap().forEach((vertexId, ordinalToSenderToTasklet) ->
ordinalToSenderToTasklet.forEach((ordinal, senderToTasklet) -> uncheckRun(() -> {
out.writeInt(vertexId);
out.writeInt(ordinal);
out.writeInt(senderToTasklet.get(member).updateAndGetSendSeqLimitCompressed());
hasData[0] = true;
})));
}));
return hasData[0] ? out.toByteArray() : EMPTY_BYTES;
}
示例2: createStreamPacketHeader
import com.hazelcast.nio.ObjectDataOutput; //导入方法依赖的package包/类
public static byte[] createStreamPacketHeader(NodeEngine nodeEngine, long executionId,
int destinationVertexId, int ordinal) {
ObjectDataOutput out = createObjectDataOutput(nodeEngine);
try {
out.writeLong(executionId);
out.writeInt(destinationVertexId);
out.writeInt(ordinal);
return out.toByteArray();
} catch (IOException e) {
throw sneakyThrow(e);
}
}
示例3: convertToJson
import com.hazelcast.nio.ObjectDataOutput; //导入方法依赖的package包/类
private <T extends Serializable> JsonElement convertToJson(DolphinEvent<T> event) throws IOException {
final EventStreamSerializer streamSerializer = new EventStreamSerializer();
final ObjectDataOutput output = new ByteObjectDataOutput();
streamSerializer.write(output, event);
final byte[] rawOutputData = output.toByteArray();
final String outputData = new String(rawOutputData);
return new JsonParser().parse(outputData);
}
示例4: writeData
import com.hazelcast.nio.ObjectDataOutput; //导入方法依赖的package包/类
@Override
public void writeData(ObjectDataOutput out) throws IOException {
InternalSerializationService ss = getSerializationService();
ObjectDataOutput tmp = ss.createObjectDataOutput();
super.writeData(tmp);
byte[] data = tmp.toByteArray();
byte[] data2 = IOUtil.compress(data);
//logger.info("writeData; original size: {}; compressed size: {}", data.length, data2.length);
out.writeByteArray(data2);
}