@@ -55,10 +55,17 @@ public class AggClientConnection extends AbstractActor {
55
55
* @param connection Reference to the client connection actor.
56
56
* @param remote The address of the client socket.
57
57
* @param maxConnectionAge The maximum duration to keep a connection open before cycling it.
58
+ * @param calculateAggregates True to compute cluster aggregations, false to only publish host aggregations
58
59
* @return A new <code>Props</code>.
59
60
*/
60
- public static Props props (final ActorRef connection , final InetSocketAddress remote , final FiniteDuration maxConnectionAge ) {
61
- return Props .create (AggClientConnection .class , connection , remote , maxConnectionAge );
61
+ public static Props props (
62
+ final ActorRef connection ,
63
+ final InetSocketAddress remote ,
64
+ final FiniteDuration maxConnectionAge ,
65
+ final boolean calculateAggregates ) {
66
+ return Props .create (
67
+ AggClientConnection .class ,
68
+ () -> new AggClientConnection (connection , remote , maxConnectionAge , calculateAggregates ));
62
69
}
63
70
64
71
/**
@@ -67,13 +74,16 @@ public static Props props(final ActorRef connection, final InetSocketAddress rem
67
74
* @param connection Reference to the client connection actor.
68
75
* @param remote The address of the client socket.
69
76
* @param maxConnectionAge The maximum duration to keep a connection open before cycling it.
77
+ * @param calculateAggregates True to compute cluster aggregations, false to only publish host aggregations
70
78
*/
71
79
public AggClientConnection (
72
80
final ActorRef connection ,
73
81
final InetSocketAddress remote ,
74
- final FiniteDuration maxConnectionAge ) {
82
+ final FiniteDuration maxConnectionAge ,
83
+ final boolean calculateAggregates ) {
75
84
_connection = connection ;
76
85
_remoteAddress = remote ;
86
+ _calculateAggregates = calculateAggregates ;
77
87
78
88
getContext ().watch (connection );
79
89
@@ -150,7 +160,11 @@ private void processMessages() {
150
160
.addData ("aggregation" , setRecord )
151
161
.addContext ("actor" , self ())
152
162
.log ();
153
- getContext ().parent ().tell (setRecord , getSelf ());
163
+ // StatisticSetRecords get forwarded to the parent, who then forwards them to the shard for cluster aggregating
164
+ // If we aren't doing shard aggregating, don't forward it
165
+ if (_calculateAggregates ) {
166
+ getContext ().parent ().tell (setRecord , getSelf ());
167
+ }
154
168
if (setRecord .getStatisticsCount () > 0 ) {
155
169
final Optional <PeriodicData > periodicData = buildPeriodicData (setRecord );
156
170
if (periodicData .isPresent ()) {
@@ -268,6 +282,7 @@ private Optional<PeriodicData> buildPeriodicData(final Messages.StatisticSetReco
268
282
private ByteString _buffer = ByteString .empty ();
269
283
private final ActorRef _connection ;
270
284
private final InetSocketAddress _remoteAddress ;
285
+ private final boolean _calculateAggregates ;
271
286
private static final Logger LOGGER = LoggerFactory .getLogger (AggClientConnection .class );
272
287
private static final Logger INCOMPLETE_RECORD_LOGGER = LoggerFactory .getRateLimitLogger (
273
288
AggClientConnection .class ,
0 commit comments