@@ -186,8 +186,9 @@ void write() {
186
186
if (this .queue .isEmpty ()) {
187
187
return ;
188
188
}
189
-
190
- Map <String , BatchPoints > databaseToBatchPoints = Maps .newHashMap ();
189
+ //for batch on HTTP.
190
+ Map <String , BatchPoints > batchKeyToBatchPoints = Maps .newHashMap ();
191
+ //for batch on UDP.
191
192
Map <Integer , List <String >> udpPortToBatchPoints = Maps .newHashMap ();
192
193
List <AbstractBatchEntry > batchEntries = new ArrayList <>(this .queue .size ());
193
194
this .queue .drainTo (batchEntries );
@@ -197,12 +198,14 @@ void write() {
197
198
if (batchEntry instanceof HttpBatchEntry ) {
198
199
HttpBatchEntry httpBatchEntry = HttpBatchEntry .class .cast (batchEntry );
199
200
String dbName = httpBatchEntry .getDb ();
200
- if (!databaseToBatchPoints .containsKey (dbName )) {
201
+ String rp = httpBatchEntry .getRp ();
202
+ String batchKey = dbName + "_" + rp ;
203
+ if (!batchKeyToBatchPoints .containsKey (batchKey )) {
201
204
BatchPoints batchPoints = BatchPoints .database (dbName )
202
- .retentionPolicy (httpBatchEntry . getRp () ).build ();
203
- databaseToBatchPoints .put (dbName , batchPoints );
205
+ .retentionPolicy (rp ).build ();
206
+ batchKeyToBatchPoints .put (batchKey , batchPoints );
204
207
}
205
- databaseToBatchPoints .get (dbName ).point (point );
208
+ batchKeyToBatchPoints .get (batchKey ).point (point );
206
209
} else if (batchEntry instanceof UdpBatchEntry ) {
207
210
UdpBatchEntry udpBatchEntry = UdpBatchEntry .class .cast (batchEntry );
208
211
int udpPort = udpBatchEntry .getUdpPort ();
@@ -214,8 +217,8 @@ void write() {
214
217
}
215
218
}
216
219
217
- for (BatchPoints batchPoints : databaseToBatchPoints .values ()) {
218
- BatchProcessor .this .influxDB .write (batchPoints );
220
+ for (BatchPoints batchPoints : batchKeyToBatchPoints .values ()) {
221
+ BatchProcessor .this .influxDB .write (batchPoints );
219
222
}
220
223
for (Entry <Integer , List <String >> entry : udpPortToBatchPoints .entrySet ()) {
221
224
BatchProcessor .this .influxDB .write (entry .getKey (), entry .getValue ());
0 commit comments