{
ObjectMapper mapper = new ObjectMapper();
boolean pretty = request.getParams().getProperty("pretty") != null;
// create pretty or regular writer
ObjectWriter writer = pretty ? mapper.defaultPrettyPrintingWriter() : mapper.writer();
StringWriter out = new StringWriter(10240);
DbusEventBufferMult multBuf = _relay.getEventBuffer();
Set<PhysicalPartitionKey> keys = multBuf.getAllPhysicalPartitionKeys();
// creat map to output partId=>PhysicalSources...
Map<PhysicalPartition, Set<PhysicalSource>> map =
new HashMap<PhysicalPartition, Set<PhysicalSource>>(keys.size());
for(PhysicalPartitionKey key: keys) {
Set<PhysicalSource> set = multBuf.getPhysicalSourcesForPartition(key.getPhysicalPartition());
map.put(key.getPhysicalPartition(), set);
}
if(keys.isEmpty()) {
writer.writeValue(out, new HashSet<PhysicalPartition>());
} else {
writer.writeValue(out,map);
}
byte[] resultBytes = out.toString().getBytes(Charset.defaultCharset());
request.getResponseContent().write(ByteBuffer.wrap(resultBytes));