Source:
<code>public AggregationPolicy<TelemetryMessage, TelemetryProtos.TelemetryMessageLog, TelemetryProtos.TelemetryMessageLog.Builder> getAggregationPolicy() { final String systemId = distPollerDao.whoami().getId(); final String systemLocation = distPollerDao.whoami().getLocation(); return new AggregationPolicy<TelemetryMessage, TelemetryProtos.TelemetryMessageLog, TelemetryProtos.TelemetryMessageLog.Builder>() { @Override public int getCompletionSize() { return TelemetrySinkModule.this.queueConfig.getBatchSize().orElse(DEFAULT_BATCH_SIZE); } @Override public int getCompletionIntervalMs() { return TelemetrySinkModule.this.queueConfig.getBatchIntervalMs().orElse(DEFAULT_BATCH_INTERVAL_MS); } @Override public Object key(TelemetryMessage telemetryMessage) { <START> if (telemetryMessage.getSource() != null) { <END> return telemetryMessage.getSource(); } else { return telemetryMessage; } } @Override public TelemetryProtos.TelemetryMessageLog.Builder aggregate(TelemetryProtos.TelemetryMessageLog.Builder accumulator, TelemetryMessage message) { if (accumulator == null) { accumulator = TelemetryProtos.TelemetryMessageLog.newBuilder() .setLocation(systemLocation) .setSystemId(systemId); if (message.getSource() != null) { accumulator.setSourceAddress(message.getSource().getHostString()) .setSourcePort(message.getSource().getPort()); } } final TelemetryProtos.TelemetryMessage messageDto = TelemetryProtos.TelemetryMessage.newBuilder() .setTimestamp(message.getReceivedAt().getTime()) .setBytes(ByteString.copyFrom(message.getBuffer())) .build(); accumulator.addMessage(messageDto); return accumulator; } @Override public TelemetryProtos.TelemetryMessageLog build(TelemetryProtos.TelemetryMessageLog.Builder accumulator) { return accumulator.build(); } }; }</code><technical_language>set a fake source keeping null? thinking host=0.0.0.0 port=0</technical_language>

Target:
public AggregationPolicy<TelemetryMessage, TelemetryProtos.TelemetryMessageLog, TelemetryProtos.TelemetryMessageLog.Builder> getAggregationPolicy() { final String systemId = distPollerDao.whoami().getId(); final String systemLocation = distPollerDao.whoami().getLocation(); return new AggregationPolicy<TelemetryMessage, TelemetryProtos.TelemetryMessageLog, TelemetryProtos.TelemetryMessageLog.Builder>() { @Override public int getCompletionSize() { return TelemetrySinkModule.this.queueConfig.getBatchSize().orElse(DEFAULT_BATCH_SIZE); } @Override public int getCompletionIntervalMs() { return TelemetrySinkModule.this.queueConfig.getBatchIntervalMs().orElse(DEFAULT_BATCH_INTERVAL_MS); } @Override public Object key(TelemetryMessage telemetryMessage) { return telemetryMessage.getSource(); } @Override public TelemetryProtos.TelemetryMessageLog.Builder aggregate(TelemetryProtos.TelemetryMessageLog.Builder accumulator, TelemetryMessage message) { if (accumulator == null) { accumulator = TelemetryProtos.TelemetryMessageLog.newBuilder() .setLocation(systemLocation) .setSystemId(systemId) .setSourceAddress(message.getSource().getHostString()) .setSourcePort(message.getSource().getPort()); } final TelemetryProtos.TelemetryMessage messageDto = TelemetryProtos.TelemetryMessage.newBuilder() .setTimestamp(message.getReceivedAt().getTime()) .setBytes(ByteString.copyFrom(message.getBuffer())) .build(); accumulator.addMessage(messageDto); return accumulator; } @Override public TelemetryProtos.TelemetryMessageLog build(TelemetryProtos.TelemetryMessageLog.Builder accumulator) { return accumulator.build(); } }; }