1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.allanbank.mongodb.client;
21
22 import java.util.Collection;
23
24 import com.allanbank.mongodb.AsyncMongoCollection;
25 import com.allanbank.mongodb.Callback;
26 import com.allanbank.mongodb.Durability;
27 import com.allanbank.mongodb.LambdaCallback;
28 import com.allanbank.mongodb.ListenableFuture;
29 import com.allanbank.mongodb.LockType;
30 import com.allanbank.mongodb.MongoCollection;
31 import com.allanbank.mongodb.MongoCursorControl;
32 import com.allanbank.mongodb.MongoDatabase;
33 import com.allanbank.mongodb.MongoDbException;
34 import com.allanbank.mongodb.MongoIterator;
35 import com.allanbank.mongodb.ReadPreference;
36 import com.allanbank.mongodb.StreamCallback;
37 import com.allanbank.mongodb.bson.Document;
38 import com.allanbank.mongodb.bson.DocumentAssignable;
39 import com.allanbank.mongodb.bson.Element;
40 import com.allanbank.mongodb.bson.builder.BuilderFactory;
41 import com.allanbank.mongodb.builder.Aggregate;
42 import com.allanbank.mongodb.builder.BatchedWrite;
43 import com.allanbank.mongodb.builder.ConditionBuilder;
44 import com.allanbank.mongodb.builder.Count;
45 import com.allanbank.mongodb.builder.Distinct;
46 import com.allanbank.mongodb.builder.Find;
47 import com.allanbank.mongodb.builder.FindAndModify;
48 import com.allanbank.mongodb.builder.GroupBy;
49 import com.allanbank.mongodb.builder.MapReduce;
50 import com.allanbank.mongodb.builder.ParallelScan;
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65 public abstract class AbstractAsyncMongoCollection extends
66 AbstractMongoOperations implements AsyncMongoCollection {
67
68
69
70
71
72
73
74
75
76
77
78 public AbstractAsyncMongoCollection(final Client client,
79 final MongoDatabase database, final String name) {
80 super(client, database, name);
81 }
82
83
84
85
86
87
88
89
90
91 @Override
92 public ListenableFuture<MongoIterator<Document>> aggregateAsync(
93 final Aggregate command) throws MongoDbException {
94 final FutureCallback<MongoIterator<Document>> future;
95
96 future = new FutureCallback<MongoIterator<Document>>(getLockType());
97
98 aggregateAsync(future, command);
99
100 return future;
101 }
102
103
104
105
106
107
108
109 @Override
110 public ListenableFuture<MongoIterator<Document>> aggregateAsync(
111 final Aggregate.Builder command) throws MongoDbException {
112 return aggregateAsync(command.build());
113 }
114
115
116
117
118
119
120
121 @Override
122 public void aggregateAsync(final Callback<MongoIterator<Document>> results,
123 final Aggregate.Builder command) throws MongoDbException {
124 aggregateAsync(results, command.build());
125 }
126
127
128
129
130
131
132
133
134 @Override
135 public void aggregateAsync(
136 final LambdaCallback<MongoIterator<Document>> results,
137 final Aggregate command) throws MongoDbException {
138 aggregateAsync(new LambdaCallbackAdapter<MongoIterator<Document>>(
139 results), command);
140 }
141
142
143
144
145
146
147
148
149
150 @Override
151 public void aggregateAsync(
152 final LambdaCallback<MongoIterator<Document>> results,
153 final Aggregate.Builder command) throws MongoDbException {
154 aggregateAsync(new LambdaCallbackAdapter<MongoIterator<Document>>(
155 results), command);
156 }
157
158
159
160
161
162
163
164
165
166
167 @Override
168 public ListenableFuture<Long> countAsync() throws MongoDbException {
169 return countAsync(BuilderFactory.start(), getReadPreference());
170 }
171
172
173
174
175
176
177
178
179
180
181 @Override
182 public void countAsync(final Callback<Long> results)
183 throws MongoDbException {
184 countAsync(results, BuilderFactory.start(), getReadPreference());
185 }
186
187
188
189
190
191
192
193
194 @Override
195 public void countAsync(final Callback<Long> results,
196 final Count.Builder count) throws MongoDbException {
197 countAsync(results, count.build());
198 }
199
200
201
202
203
204
205
206
207
208
209 @Override
210 public void countAsync(final Callback<Long> results,
211 final DocumentAssignable query) throws MongoDbException {
212 countAsync(results, query, getReadPreference());
213 }
214
215
216
217
218
219
220
221
222 @Override
223 public void countAsync(final Callback<Long> results,
224 final DocumentAssignable query, final ReadPreference readPreference)
225 throws MongoDbException {
226 countAsync(results,
227 Count.builder().query(query).readPreference(readPreference)
228 .build());
229 }
230
231
232
233
234
235
236
237
238
239 @Override
240 public void countAsync(final Callback<Long> results,
241 final ReadPreference readPreference) throws MongoDbException {
242 countAsync(results, BuilderFactory.start(), readPreference);
243 }
244
245
246
247
248
249
250
251
252 @Override
253 public ListenableFuture<Long> countAsync(final Count count)
254 throws MongoDbException {
255 final FutureCallback<Long> future = new FutureCallback<Long>(
256 getLockType());
257
258 countAsync(future, count);
259
260 return future;
261 }
262
263
264
265
266
267
268
269
270 @Override
271 public ListenableFuture<Long> countAsync(final Count.Builder count)
272 throws MongoDbException {
273 return countAsync(count.build());
274 }
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292 @Override
293 public ListenableFuture<Long> countAsync(final DocumentAssignable query)
294 throws MongoDbException {
295 final FutureCallback<Long> future = new FutureCallback<Long>(
296 getLockType());
297
298 countAsync(future, query, getReadPreference());
299
300 return future;
301 }
302
303
304
305
306
307
308
309
310 @Override
311 public ListenableFuture<Long> countAsync(final DocumentAssignable query,
312 final ReadPreference readPreference) throws MongoDbException {
313 final FutureCallback<Long> future = new FutureCallback<Long>(
314 getLockType());
315
316 countAsync(future, query, readPreference);
317
318 return future;
319 }
320
321
322
323
324
325
326
327
328 @Override
329 public void countAsync(final LambdaCallback<Long> results)
330 throws MongoDbException {
331 countAsync(new LambdaCallbackAdapter<Long>(results));
332 }
333
334
335
336
337
338
339
340
341 @Override
342 public void countAsync(final LambdaCallback<Long> results, final Count count)
343 throws MongoDbException {
344 countAsync(new LambdaCallbackAdapter<Long>(results), count);
345 }
346
347
348
349
350
351
352
353
354 @Override
355 public void countAsync(final LambdaCallback<Long> results,
356 final Count.Builder count) throws MongoDbException {
357 countAsync(new LambdaCallbackAdapter<Long>(results), count);
358 }
359
360
361
362
363
364
365
366
367 @Override
368 public void countAsync(final LambdaCallback<Long> results,
369 final DocumentAssignable query) throws MongoDbException {
370 countAsync(new LambdaCallbackAdapter<Long>(results), query);
371
372 }
373
374
375
376
377
378
379
380
381
382 @Override
383 public void countAsync(final LambdaCallback<Long> results,
384 final DocumentAssignable query, final ReadPreference readPreference)
385 throws MongoDbException {
386 countAsync(new LambdaCallbackAdapter<Long>(results), query,
387 readPreference);
388 }
389
390
391
392
393
394
395
396
397 @Override
398 public void countAsync(final LambdaCallback<Long> results,
399 final ReadPreference readPreference) throws MongoDbException {
400 countAsync(new LambdaCallbackAdapter<Long>(results), readPreference);
401 }
402
403
404
405
406
407
408
409
410
411 @Override
412 public ListenableFuture<Long> countAsync(final ReadPreference readPreference)
413 throws MongoDbException {
414 return countAsync(BuilderFactory.start(), readPreference);
415 }
416
417
418
419
420
421
422
423
424
425
426
427
428 @Override
429 public void deleteAsync(final Callback<Long> results,
430 final DocumentAssignable query) throws MongoDbException {
431 deleteAsync(results, query, DELETE_SINGLE_DELETE_DEFAULT,
432 getDurability());
433 }
434
435
436
437
438
439
440
441
442
443
444
445 @Override
446 public void deleteAsync(final Callback<Long> results,
447 final DocumentAssignable query, final boolean singleDelete)
448 throws MongoDbException {
449 deleteAsync(results, query, singleDelete, getDurability());
450 }
451
452
453
454
455
456
457
458
459
460
461
462 @Override
463 public void deleteAsync(final Callback<Long> results,
464 final DocumentAssignable query, final Durability durability)
465 throws MongoDbException {
466 deleteAsync(results, query, DELETE_SINGLE_DELETE_DEFAULT, durability);
467 }
468
469
470
471
472
473
474
475
476
477
478
479
480 @Override
481 public ListenableFuture<Long> deleteAsync(final DocumentAssignable query)
482 throws MongoDbException {
483 final FutureCallback<Long> future = new FutureCallback<Long>(
484 getLockType());
485
486 deleteAsync(future, query, DELETE_SINGLE_DELETE_DEFAULT,
487 getDurability());
488
489 return future;
490 }
491
492
493
494
495
496
497
498
499
500
501
502 @Override
503 public ListenableFuture<Long> deleteAsync(final DocumentAssignable query,
504 final boolean singleDelete) throws MongoDbException {
505 final FutureCallback<Long> future = new FutureCallback<Long>(
506 getLockType());
507
508 deleteAsync(future, query, singleDelete, getDurability());
509
510 return future;
511 }
512
513
514
515
516
517
518
519
520
521
522 @Override
523 public ListenableFuture<Long> deleteAsync(final DocumentAssignable query,
524 final boolean singleDelete, final Durability durability)
525 throws MongoDbException {
526 final FutureCallback<Long> future = new FutureCallback<Long>(
527 getLockType());
528
529 deleteAsync(future, query, singleDelete, durability);
530
531 return future;
532 }
533
534
535
536
537
538
539
540
541
542
543 @Override
544 public ListenableFuture<Long> deleteAsync(final DocumentAssignable query,
545 final Durability durability) throws MongoDbException {
546 final FutureCallback<Long> future = new FutureCallback<Long>(
547 getLockType());
548
549 deleteAsync(future, query, DELETE_SINGLE_DELETE_DEFAULT, durability);
550
551 return future;
552 }
553
554
555
556
557
558
559
560
561 @Override
562 public void deleteAsync(final LambdaCallback<Long> results,
563 final DocumentAssignable query) throws MongoDbException {
564 deleteAsync(new LambdaCallbackAdapter<Long>(results), query);
565 }
566
567
568
569
570
571
572
573
574
575 @Override
576 public void deleteAsync(final LambdaCallback<Long> results,
577 final DocumentAssignable query, final boolean singleDelete)
578 throws MongoDbException {
579 deleteAsync(new LambdaCallbackAdapter<Long>(results), query,
580 singleDelete);
581 }
582
583
584
585
586
587
588
589
590
591 @Override
592 public void deleteAsync(final LambdaCallback<Long> results,
593 final DocumentAssignable query, final boolean singleDelete,
594 final Durability durability) throws MongoDbException {
595 deleteAsync(new LambdaCallbackAdapter<Long>(results), query,
596 singleDelete, durability);
597 }
598
599
600
601
602
603
604
605
606
607 @Override
608 public void deleteAsync(final LambdaCallback<Long> results,
609 final DocumentAssignable query, final Durability durability)
610 throws MongoDbException {
611 deleteAsync(new LambdaCallbackAdapter<Long>(results), query, durability);
612 }
613
614
615
616
617
618
619
620 @Override
621 public void distinctAsync(final Callback<MongoIterator<Element>> results,
622 final Distinct.Builder command) throws MongoDbException {
623 distinctAsync(results, command.build());
624 }
625
626
627
628
629
630
631
632 @Override
633 public ListenableFuture<MongoIterator<Element>> distinctAsync(
634 final Distinct command) throws MongoDbException {
635 final FutureCallback<MongoIterator<Element>> future = new FutureCallback<MongoIterator<Element>>(
636 getLockType());
637
638 distinctAsync(future, command);
639
640 return future;
641 }
642
643
644
645
646
647
648
649 @Override
650 public ListenableFuture<MongoIterator<Element>> distinctAsync(
651 final Distinct.Builder command) throws MongoDbException {
652 return distinctAsync(command.build());
653 }
654
655
656
657
658
659
660
661
662 @Override
663 public void distinctAsync(
664 final LambdaCallback<MongoIterator<Element>> results,
665 final Distinct command) throws MongoDbException {
666 distinctAsync(
667 new LambdaCallbackAdapter<MongoIterator<Element>>(results),
668 command);
669 }
670
671
672
673
674
675
676
677
678 @Override
679 public void distinctAsync(
680 final LambdaCallback<MongoIterator<Element>> results,
681 final Distinct.Builder command) throws MongoDbException {
682 distinctAsync(
683 new LambdaCallbackAdapter<MongoIterator<Element>>(results),
684 command);
685 }
686
687
688
689
690
691
692
693 @Override
694 public ListenableFuture<Document> explainAsync(final Aggregate aggregation)
695 throws MongoDbException {
696 final FutureCallback<Document> future = new FutureCallback<Document>(
697 getLockType());
698
699 explainAsync(future, aggregation);
700
701 return future;
702
703 }
704
705
706
707
708
709
710
711 @Override
712 public ListenableFuture<Document> explainAsync(
713 final Aggregate.Builder aggregation) throws MongoDbException {
714 final FutureCallback<Document> future = new FutureCallback<Document>(
715 getLockType());
716
717 explainAsync(future, aggregation.build());
718
719 return future;
720 }
721
722
723
724
725
726
727
728 @Override
729 public void explainAsync(final Callback<Document> results,
730 final Aggregate.Builder aggregation) throws MongoDbException {
731 explainAsync(results, aggregation.build());
732 }
733
734
735
736
737
738
739
740 @Override
741 public void explainAsync(final Callback<Document> results,
742 final Find.Builder query) throws MongoDbException {
743 explainAsync(results, query.build());
744 }
745
746
747
748
749
750
751
752
753
754 @Override
755 public ListenableFuture<Document> explainAsync(final Find query)
756 throws MongoDbException {
757 final FutureCallback<Document> future = new FutureCallback<Document>(
758 getLockType());
759
760 explainAsync(future, query);
761
762 return future;
763 }
764
765
766
767
768
769
770
771 @Override
772 public ListenableFuture<Document> explainAsync(final Find.Builder query)
773 throws MongoDbException {
774 return explainAsync(query.build());
775 }
776
777
778
779
780
781
782
783
784 @Override
785 public void explainAsync(final LambdaCallback<Document> results,
786 final Aggregate aggregation) throws MongoDbException {
787 explainAsync(new LambdaCallbackAdapter<Document>(results), aggregation);
788 }
789
790
791
792
793
794
795
796
797 @Override
798 public void explainAsync(final LambdaCallback<Document> results,
799 final Aggregate.Builder aggregation) throws MongoDbException {
800 explainAsync(new LambdaCallbackAdapter<Document>(results), aggregation);
801 }
802
803
804
805
806
807
808
809
810 @Override
811 public void explainAsync(final LambdaCallback<Document> results,
812 final Find query) throws MongoDbException {
813 explainAsync(new LambdaCallbackAdapter<Document>(results), query);
814 }
815
816
817
818
819
820
821
822
823 @Override
824 public void explainAsync(final LambdaCallback<Document> results,
825 final Find.Builder query) throws MongoDbException {
826 explainAsync(new LambdaCallbackAdapter<Document>(results), query);
827 }
828
829
830
831
832
833
834
835
836 @Override
837 public void findAndModifyAsync(final Callback<Document> results,
838 final FindAndModify.Builder command) throws MongoDbException {
839 findAndModifyAsync(results, command.build());
840 }
841
842
843
844
845
846
847
848
849
850
851 @Override
852 public ListenableFuture<Document> findAndModifyAsync(
853 final FindAndModify command) throws MongoDbException {
854 final FutureCallback<Document> future = new FutureCallback<Document>(
855 getLockType());
856
857 findAndModifyAsync(future, command);
858
859 return future;
860 }
861
862
863
864
865
866
867
868 @Override
869 public ListenableFuture<Document> findAndModifyAsync(
870 final FindAndModify.Builder command) throws MongoDbException {
871 return findAndModifyAsync(command.build());
872 }
873
874
875
876
877
878
879
880
881
882 @Override
883 public void findAndModifyAsync(final LambdaCallback<Document> results,
884 final FindAndModify command) throws MongoDbException {
885 findAndModifyAsync(new LambdaCallbackAdapter<Document>(results),
886 command);
887 }
888
889
890
891
892
893
894
895
896
897 @Override
898 public void findAndModifyAsync(final LambdaCallback<Document> results,
899 final FindAndModify.Builder command) throws MongoDbException {
900 findAndModifyAsync(new LambdaCallbackAdapter<Document>(results),
901 command);
902 }
903
904
905
906
907
908
909
910
911
912 @Override
913 public void findAsync(final Callback<MongoIterator<Document>> results,
914 final DocumentAssignable query) throws MongoDbException {
915 findAsync(results, new Find.Builder(query).build());
916 }
917
918
919
920
921
922
923
924 @Override
925 public void findAsync(final Callback<MongoIterator<Document>> results,
926 final Find.Builder query) throws MongoDbException {
927 findAsync(results, query.build());
928 }
929
930
931
932
933
934
935
936
937
938 @Override
939 public ListenableFuture<MongoIterator<Document>> findAsync(
940 final DocumentAssignable query) throws MongoDbException {
941 final FutureCallback<MongoIterator<Document>> future = new FutureCallback<MongoIterator<Document>>(
942 getLockType());
943
944 findAsync(future, query);
945
946 return future;
947 }
948
949
950
951
952
953
954
955
956
957 @Override
958 public ListenableFuture<MongoIterator<Document>> findAsync(final Find query)
959 throws MongoDbException {
960 final FutureCallback<MongoIterator<Document>> future = new FutureCallback<MongoIterator<Document>>(
961 getLockType());
962
963 findAsync(future, query);
964
965 return future;
966 }
967
968
969
970
971
972
973
974 @Override
975 public ListenableFuture<MongoIterator<Document>> findAsync(
976 final Find.Builder query) throws MongoDbException {
977 return findAsync(query.build());
978 }
979
980
981
982
983
984
985
986
987 @Override
988 public void findAsync(
989 final LambdaCallback<MongoIterator<Document>> results,
990 final DocumentAssignable query) throws MongoDbException {
991 findAsync(new LambdaCallbackAdapter<MongoIterator<Document>>(results),
992 query);
993 }
994
995
996
997
998
999
1000
1001
1002 @Override
1003 public void findAsync(
1004 final LambdaCallback<MongoIterator<Document>> results,
1005 final Find query) throws MongoDbException {
1006 findAsync(new LambdaCallbackAdapter<MongoIterator<Document>>(results),
1007 query);
1008 }
1009
1010
1011
1012
1013
1014
1015
1016
1017 @Override
1018 public void findAsync(
1019 final LambdaCallback<MongoIterator<Document>> results,
1020 final Find.Builder query) throws MongoDbException {
1021 findAsync(new LambdaCallbackAdapter<MongoIterator<Document>>(results),
1022 query);
1023 }
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033 @Override
1034 public void findOneAsync(final Callback<Document> results,
1035 final DocumentAssignable query) throws MongoDbException {
1036 findOneAsync(results, new Find.Builder(query).build());
1037 }
1038
1039
1040
1041
1042
1043
1044
1045 @Override
1046 public void findOneAsync(final Callback<Document> results,
1047 final Find.Builder query) throws MongoDbException {
1048 findOneAsync(results, query.build());
1049 }
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060 @Override
1061 public ListenableFuture<Document> findOneAsync(
1062 final DocumentAssignable query) throws MongoDbException {
1063 final FutureCallback<Document> future = new FutureCallback<Document>(
1064 getLockType());
1065
1066 findOneAsync(future, query);
1067
1068 return future;
1069 }
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079 @Override
1080 public ListenableFuture<Document> findOneAsync(final Find query)
1081 throws MongoDbException {
1082 final FutureCallback<Document> future = new FutureCallback<Document>(
1083 getLockType());
1084
1085 findOneAsync(future, query);
1086
1087 return future;
1088 }
1089
1090
1091
1092
1093
1094
1095
1096 @Override
1097 public ListenableFuture<Document> findOneAsync(final Find.Builder query)
1098 throws MongoDbException {
1099 return findOneAsync(query.build());
1100 }
1101
1102
1103
1104
1105
1106
1107
1108
1109 @Override
1110 public void findOneAsync(final LambdaCallback<Document> results,
1111 final DocumentAssignable query) throws MongoDbException {
1112 findOneAsync(new LambdaCallbackAdapter<Document>(results), query);
1113 }
1114
1115
1116
1117
1118
1119
1120
1121
1122 @Override
1123 public void findOneAsync(final LambdaCallback<Document> results,
1124 final Find query) throws MongoDbException {
1125 findOneAsync(new LambdaCallbackAdapter<Document>(results), query);
1126 }
1127
1128
1129
1130
1131
1132
1133
1134
1135 @Override
1136 public void findOneAsync(final LambdaCallback<Document> results,
1137 final Find.Builder query) throws MongoDbException {
1138 findOneAsync(new LambdaCallbackAdapter<Document>(results), query);
1139 }
1140
1141
1142
1143
1144
1145
1146
1147 @Override
1148 public void groupByAsync(final Callback<MongoIterator<Element>> results,
1149 final GroupBy.Builder command) throws MongoDbException {
1150 groupByAsync(results, command.build());
1151 }
1152
1153
1154
1155
1156
1157
1158
1159 @Override
1160 public ListenableFuture<MongoIterator<Element>> groupByAsync(
1161 final GroupBy command) throws MongoDbException {
1162 final FutureCallback<MongoIterator<Element>> future = new FutureCallback<MongoIterator<Element>>(
1163 getLockType());
1164
1165 groupByAsync(future, command);
1166
1167 return future;
1168 }
1169
1170
1171
1172
1173
1174
1175
1176 @Override
1177 public ListenableFuture<MongoIterator<Element>> groupByAsync(
1178 final GroupBy.Builder command) throws MongoDbException {
1179 return groupByAsync(command.build());
1180 }
1181
1182
1183
1184
1185
1186
1187
1188
1189 @Override
1190 public void groupByAsync(
1191 final LambdaCallback<MongoIterator<Element>> results,
1192 final GroupBy command) throws MongoDbException {
1193 groupByAsync(
1194 new LambdaCallbackAdapter<MongoIterator<Element>>(results),
1195 command);
1196 }
1197
1198
1199
1200
1201
1202
1203
1204
1205 @Override
1206 public void groupByAsync(
1207 final LambdaCallback<MongoIterator<Element>> results,
1208 final GroupBy.Builder command) throws MongoDbException {
1209 groupByAsync(
1210 new LambdaCallbackAdapter<MongoIterator<Element>>(results),
1211 command);
1212 }
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225 @Override
1226 public ListenableFuture<Integer> insertAsync(final boolean continueOnError,
1227 final DocumentAssignable... documents) throws MongoDbException {
1228 final FutureCallback<Integer> future = new FutureCallback<Integer>(
1229 getLockType());
1230
1231 insertAsync(future, continueOnError, getDurability(), documents);
1232
1233 return future;
1234 }
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248 @Override
1249 public ListenableFuture<Integer> insertAsync(final boolean continueOnError,
1250 final Durability durability, final DocumentAssignable... documents)
1251 throws MongoDbException {
1252 final FutureCallback<Integer> future = new FutureCallback<Integer>(
1253 getLockType());
1254
1255 insertAsync(future, continueOnError, durability, documents);
1256
1257 return future;
1258 }
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271 @Override
1272 public void insertAsync(final Callback<Integer> results,
1273 final boolean continueOnError,
1274 final DocumentAssignable... documents) throws MongoDbException {
1275 insertAsync(results, continueOnError, getDurability(), documents);
1276 }
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290 @Override
1291 public void insertAsync(final Callback<Integer> results,
1292 final DocumentAssignable... documents) throws MongoDbException {
1293 insertAsync(results, INSERT_CONTINUE_ON_ERROR_DEFAULT, getDurability(),
1294 documents);
1295 }
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308 @Override
1309 public void insertAsync(final Callback<Integer> results,
1310 final Durability durability, final DocumentAssignable... documents)
1311 throws MongoDbException {
1312 insertAsync(results, INSERT_CONTINUE_ON_ERROR_DEFAULT, durability,
1313 documents);
1314 }
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328 @Override
1329 public ListenableFuture<Integer> insertAsync(
1330 final DocumentAssignable... documents) throws MongoDbException {
1331 final FutureCallback<Integer> future = new FutureCallback<Integer>(
1332 getLockType());
1333
1334 insertAsync(future, INSERT_CONTINUE_ON_ERROR_DEFAULT, getDurability(),
1335 documents);
1336
1337 return future;
1338 }
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351 @Override
1352 public ListenableFuture<Integer> insertAsync(final Durability durability,
1353 final DocumentAssignable... documents) throws MongoDbException {
1354 final FutureCallback<Integer> future = new FutureCallback<Integer>(
1355 getLockType());
1356
1357 insertAsync(future, INSERT_CONTINUE_ON_ERROR_DEFAULT, durability,
1358 documents);
1359
1360 return future;
1361 }
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371 @Override
1372 public void insertAsync(final LambdaCallback<Integer> results,
1373 final boolean continueOnError,
1374 final DocumentAssignable... documents) throws MongoDbException {
1375 insertAsync(new LambdaCallbackAdapter<Integer>(results),
1376 continueOnError, documents);
1377 }
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387 @Override
1388 public void insertAsync(final LambdaCallback<Integer> results,
1389 final boolean continueOnError, final Durability durability,
1390 final DocumentAssignable... documents) throws MongoDbException {
1391 insertAsync(new LambdaCallbackAdapter<Integer>(results),
1392 continueOnError, durability, documents);
1393 }
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403 @Override
1404 public void insertAsync(final LambdaCallback<Integer> results,
1405 final DocumentAssignable... documents) throws MongoDbException {
1406 insertAsync(new LambdaCallbackAdapter<Integer>(results), documents);
1407 }
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417 @Override
1418 public void insertAsync(final LambdaCallback<Integer> results,
1419 final Durability durability, final DocumentAssignable... documents)
1420 throws MongoDbException {
1421 insertAsync(new LambdaCallbackAdapter<Integer>(results), durability,
1422 documents);
1423 }
1424
1425
1426
1427
1428
1429
1430
1431 @Override
1432 public void mapReduceAsync(final Callback<MongoIterator<Document>> results,
1433 final MapReduce.Builder command) throws MongoDbException {
1434 mapReduceAsync(results, command.build());
1435 }
1436
1437
1438
1439
1440
1441
1442
1443
1444 @Override
1445 public void mapReduceAsync(
1446 final LambdaCallback<MongoIterator<Document>> results,
1447 final MapReduce command) throws MongoDbException {
1448 mapReduceAsync(new LambdaCallbackAdapter<MongoIterator<Document>>(
1449 results), command);
1450 }
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460 @Override
1461 public void mapReduceAsync(
1462 final LambdaCallback<MongoIterator<Document>> results,
1463 final MapReduce.Builder command) throws MongoDbException {
1464 mapReduceAsync(new LambdaCallbackAdapter<MongoIterator<Document>>(
1465 results), command);
1466 }
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476 @Override
1477 public ListenableFuture<MongoIterator<Document>> mapReduceAsync(
1478 final MapReduce command) throws MongoDbException {
1479 final FutureCallback<MongoIterator<Document>> future = new FutureCallback<MongoIterator<Document>>(
1480 getLockType());
1481
1482 mapReduceAsync(future, command);
1483
1484 return future;
1485 }
1486
1487
1488
1489
1490
1491
1492
1493 @Override
1494 public ListenableFuture<MongoIterator<Document>> mapReduceAsync(
1495 final MapReduce.Builder command) throws MongoDbException {
1496 return mapReduceAsync(command.build());
1497 }
1498
1499
1500
1501
1502
1503
1504
1505
1506 @Override
1507 public void parallelScanAsync(
1508 final Callback<Collection<MongoIterator<Document>>> results,
1509 final ParallelScan.Builder parallelScan) throws MongoDbException {
1510 parallelScanAsync(results, parallelScan.build());
1511 }
1512
1513
1514
1515
1516
1517
1518
1519
1520 @Override
1521 public void parallelScanAsync(
1522 final LambdaCallback<Collection<MongoIterator<Document>>> results,
1523 final ParallelScan parallelScan) throws MongoDbException {
1524 parallelScanAsync(
1525 new LambdaCallbackAdapter<Collection<MongoIterator<Document>>>(
1526 results), parallelScan);
1527
1528 }
1529
1530
1531
1532
1533
1534
1535
1536
1537 @Override
1538 public void parallelScanAsync(
1539 final LambdaCallback<Collection<MongoIterator<Document>>> results,
1540 final ParallelScan.Builder parallelScan) throws MongoDbException {
1541 parallelScanAsync(results, parallelScan.build());
1542
1543 }
1544
1545
1546
1547
1548
1549
1550
1551
1552 @Override
1553 public ListenableFuture<Collection<MongoIterator<Document>>> parallelScanAsync(
1554 final ParallelScan parallelScan) throws MongoDbException {
1555 final FutureCallback<Collection<MongoIterator<Document>>> future;
1556 future = new FutureCallback<Collection<MongoIterator<Document>>>(
1557 getLockType());
1558
1559 parallelScanAsync(future, parallelScan);
1560
1561 return future;
1562 }
1563
1564
1565
1566
1567
1568
1569
1570
1571 @Override
1572 public ListenableFuture<Collection<MongoIterator<Document>>> parallelScanAsync(
1573 final ParallelScan.Builder parallelScan) throws MongoDbException {
1574 return parallelScanAsync(parallelScan.build());
1575 }
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585 @Override
1586 public void saveAsync(final Callback<Integer> results,
1587 final DocumentAssignable document) throws MongoDbException {
1588 saveAsync(results, document, getDurability());
1589 }
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599 @Override
1600 public ListenableFuture<Integer> saveAsync(final DocumentAssignable document)
1601 throws MongoDbException {
1602 final FutureCallback<Integer> future = new FutureCallback<Integer>(
1603 getLockType());
1604
1605 saveAsync(future, document, getDurability());
1606
1607 return future;
1608 }
1609
1610
1611
1612
1613
1614
1615
1616
1617 @Override
1618 public ListenableFuture<Integer> saveAsync(
1619 final DocumentAssignable document, final Durability durability)
1620 throws MongoDbException {
1621 final FutureCallback<Integer> future = new FutureCallback<Integer>(
1622 getLockType());
1623
1624 saveAsync(future, document, durability);
1625
1626 return future;
1627 }
1628
1629
1630
1631
1632
1633
1634
1635
1636 @Override
1637 public void saveAsync(final LambdaCallback<Integer> results,
1638 final DocumentAssignable document) throws MongoDbException {
1639 saveAsync(new LambdaCallbackAdapter<Integer>(results), document);
1640 }
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650 @Override
1651 public void saveAsync(final LambdaCallback<Integer> results,
1652 final DocumentAssignable document, final Durability durability)
1653 throws MongoDbException {
1654 saveAsync(new LambdaCallbackAdapter<Integer>(results), document,
1655 durability);
1656 }
1657
1658
1659
1660
1661
1662
1663
1664
1665 @Override
1666 public MongoCursorControl stream(final LambdaCallback<Document> results,
1667 final Aggregate aggregation) throws MongoDbException {
1668 return stream(new LambdaCallbackAdapter<Document>(results), aggregation);
1669 }
1670
1671
1672
1673
1674
1675
1676
1677
1678 @Override
1679 public MongoCursorControl stream(final LambdaCallback<Document> results,
1680 final Aggregate.Builder aggregation) throws MongoDbException {
1681 return stream(new LambdaCallbackAdapter<Document>(results), aggregation);
1682 }
1683
1684
1685
1686
1687
1688
1689
1690
1691 @Override
1692 public MongoCursorControl stream(final LambdaCallback<Document> results,
1693 final Find query) throws MongoDbException {
1694 return stream(new LambdaCallbackAdapter<Document>(results), query);
1695 }
1696
1697
1698
1699
1700
1701
1702
1703
1704 @Override
1705 public MongoCursorControl stream(final LambdaCallback<Document> results,
1706 final Find.Builder aggregation) throws MongoDbException {
1707 return stream(new LambdaCallbackAdapter<Document>(results), aggregation);
1708 }
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718 @Override
1719 public MongoCursorControl stream(final StreamCallback<Document> results,
1720 final Aggregate.Builder aggregation) throws MongoDbException {
1721 return stream(results, aggregation.build());
1722 }
1723
1724
1725
1726
1727
1728
1729
1730 @Override
1731 public MongoCursorControl stream(final StreamCallback<Document> results,
1732 final Find.Builder query) throws MongoDbException {
1733 return streamingFind(results, query.build());
1734 }
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744 @Deprecated
1745 @Override
1746 public MongoCursorControl streamingFind(final Callback<Document> results,
1747 final DocumentAssignable query) throws MongoDbException {
1748 return streamingFind(results, new Find.Builder(query).build());
1749 }
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759 @Deprecated
1760 @Override
1761 public MongoCursorControl streamingFind(final Callback<Document> results,
1762 final Find query) throws MongoDbException {
1763 return stream(
1764 new com.allanbank.mongodb.client.callback.LegacyStreamCallbackAdapter(
1765 results), query);
1766 }
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776 @Override
1777 public MongoCursorControl streamingFind(
1778 final LambdaCallback<Document> results,
1779 final DocumentAssignable query) throws MongoDbException {
1780 return streamingFind(new LambdaCallbackAdapter<Document>(results),
1781 query);
1782 }
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792 @Override
1793 public MongoCursorControl streamingFind(
1794 final StreamCallback<Document> results,
1795 final DocumentAssignable query) throws MongoDbException {
1796 return stream(results, new Find.Builder(query).build());
1797 }
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807 @Deprecated
1808 @Override
1809 public MongoCursorControl streamingFind(
1810 final StreamCallback<Document> results, final Find query)
1811 throws MongoDbException {
1812 return stream(results, query);
1813 }
1814
1815
1816
1817
1818
1819
1820
1821
1822 @Deprecated
1823 @Override
1824 public MongoCursorControl streamingFind(
1825 final StreamCallback<Document> results, final Find.Builder query)
1826 throws MongoDbException {
1827 return streamingFind(results, query.build());
1828 }
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844 @Deprecated
1845 @Override
1846 public void textSearchAsync(
1847 final Callback<MongoIterator<com.allanbank.mongodb.builder.TextResult>> results,
1848 final com.allanbank.mongodb.builder.Text.Builder command)
1849 throws MongoDbException {
1850 textSearchAsync(results, command.build());
1851 }
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868 @Deprecated
1869 @Override
1870 public ListenableFuture<MongoIterator<com.allanbank.mongodb.builder.TextResult>> textSearchAsync(
1871 final com.allanbank.mongodb.builder.Text command)
1872 throws MongoDbException {
1873 final FutureCallback<MongoIterator<com.allanbank.mongodb.builder.TextResult>> future;
1874 future = new FutureCallback<MongoIterator<com.allanbank.mongodb.builder.TextResult>>(
1875 getLockType());
1876
1877 textSearchAsync(future, command);
1878
1879 return future;
1880 }
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896 @Deprecated
1897 @Override
1898 public ListenableFuture<MongoIterator<com.allanbank.mongodb.builder.TextResult>> textSearchAsync(
1899 final com.allanbank.mongodb.builder.Text.Builder command)
1900 throws MongoDbException {
1901 return textSearchAsync(command.build());
1902 }
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916 @Override
1917 public void updateAsync(final Callback<Long> results,
1918 final DocumentAssignable query, final DocumentAssignable update)
1919 throws MongoDbException {
1920 updateAsync(results, query, update, UPDATE_MULTIUPDATE_DEFAULT,
1921 UPDATE_UPSERT_DEFAULT, getDurability());
1922 }
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935 @Override
1936 public void updateAsync(final Callback<Long> results,
1937 final DocumentAssignable query, final DocumentAssignable update,
1938 final boolean multiUpdate, final boolean upsert)
1939 throws MongoDbException {
1940 updateAsync(results, query, update, multiUpdate, upsert,
1941 getDurability());
1942 }
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955 @Override
1956 public void updateAsync(final Callback<Long> results,
1957 final DocumentAssignable query, final DocumentAssignable update,
1958 final Durability durability) throws MongoDbException {
1959 updateAsync(results, query, update, UPDATE_MULTIUPDATE_DEFAULT,
1960 UPDATE_UPSERT_DEFAULT, durability);
1961 }
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975 @Override
1976 public ListenableFuture<Long> updateAsync(final DocumentAssignable query,
1977 final DocumentAssignable update) throws MongoDbException {
1978 final FutureCallback<Long> future = new FutureCallback<Long>(
1979 getLockType());
1980
1981 updateAsync(future, query, update, UPDATE_MULTIUPDATE_DEFAULT,
1982 UPDATE_UPSERT_DEFAULT, getDurability());
1983
1984 return future;
1985 }
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998 @Override
1999 public ListenableFuture<Long> updateAsync(final DocumentAssignable query,
2000 final DocumentAssignable update, final boolean multiUpdate,
2001 final boolean upsert) throws MongoDbException {
2002 final FutureCallback<Long> future = new FutureCallback<Long>(
2003 getLockType());
2004
2005 updateAsync(future, query, update, multiUpdate, upsert, getDurability());
2006
2007 return future;
2008 }
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021 @Override
2022 public ListenableFuture<Long> updateAsync(final DocumentAssignable query,
2023 final DocumentAssignable update, final boolean multiUpdate,
2024 final boolean upsert, final Durability durability)
2025 throws MongoDbException {
2026 final FutureCallback<Long> future = new FutureCallback<Long>(
2027 getLockType());
2028
2029 updateAsync(future, query, update, multiUpdate, upsert, durability);
2030
2031 return future;
2032 }
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045 @Override
2046 public ListenableFuture<Long> updateAsync(final DocumentAssignable query,
2047 final DocumentAssignable update, final Durability durability)
2048 throws MongoDbException {
2049 final FutureCallback<Long> future = new FutureCallback<Long>(
2050 getLockType());
2051
2052 updateAsync(future, query, update, UPDATE_MULTIUPDATE_DEFAULT,
2053 UPDATE_UPSERT_DEFAULT, durability);
2054
2055 return future;
2056 }
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066 @Override
2067 public void updateAsync(final LambdaCallback<Long> results,
2068 final DocumentAssignable query, final DocumentAssignable update)
2069 throws MongoDbException {
2070 updateAsync(new LambdaCallbackAdapter<Long>(results), query, update);
2071 }
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081 @Override
2082 public void updateAsync(final LambdaCallback<Long> results,
2083 final DocumentAssignable query, final DocumentAssignable update,
2084 final boolean multiUpdate, final boolean upsert)
2085 throws MongoDbException {
2086 updateAsync(new LambdaCallbackAdapter<Long>(results), query, update,
2087 multiUpdate, upsert);
2088 }
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098 @Override
2099 public void updateAsync(final LambdaCallback<Long> results,
2100 final DocumentAssignable query, final DocumentAssignable update,
2101 final boolean multiUpdate, final boolean upsert,
2102 final Durability durability) throws MongoDbException {
2103 updateAsync(new LambdaCallbackAdapter<Long>(results), query, update,
2104 multiUpdate, upsert, durability);
2105 }
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115 @Override
2116 public void updateAsync(final LambdaCallback<Long> results,
2117 final DocumentAssignable query, final DocumentAssignable update,
2118 final Durability durability) throws MongoDbException {
2119 updateAsync(new LambdaCallbackAdapter<Long>(results), query, update,
2120 durability);
2121 }
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132 @Override
2133 public ListenableFuture<Long> writeAsync(final BatchedWrite write)
2134 throws MongoDbException {
2135 final FutureCallback<Long> future = new FutureCallback<Long>(
2136 getLockType());
2137
2138 writeAsync(future, write);
2139
2140 return future;
2141 }
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151 @Override
2152 public ListenableFuture<Long> writeAsync(final BatchedWrite.Builder write)
2153 throws MongoDbException {
2154 return writeAsync(write.build());
2155 }
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166 @Override
2167 public void writeAsync(final Callback<Long> results,
2168 final BatchedWrite.Builder write) throws MongoDbException {
2169 writeAsync(results, write.build());
2170 }
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181 @Override
2182 public void writeAsync(final LambdaCallback<Long> results,
2183 final BatchedWrite write) throws MongoDbException {
2184 writeAsync(new LambdaCallbackAdapter<Long>(results), write);
2185 }
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196 @Override
2197 public void writeAsync(final LambdaCallback<Long> results,
2198 final BatchedWrite.Builder write) throws MongoDbException {
2199 writeAsync(results, write.build());
2200 }
2201
2202
2203
2204
2205
2206
2207 protected LockType getLockType() {
2208 return myClient.getConfig().getLockType();
2209 }
2210
2211 }