16
16
17
17
package com .basho .riak .client .api .commands .itest ;
18
18
19
+ import com .basho .riak .client .api .ListException ;
19
20
import com .basho .riak .client .api .RiakClient ;
20
21
import com .basho .riak .client .core .RiakFuture ;
21
22
import com .basho .riak .client .api .commands .buckets .StoreBucketProperties ;
42
43
import static org .junit .Assert .assertEquals ;
43
44
import static org .junit .Assert .assertFalse ;
44
45
import static org .junit .Assert .assertTrue ;
46
+ import static org .junit .Assert .fail ;
45
47
46
48
/**
47
49
*
@@ -134,13 +136,21 @@ public void erlangBucketMRTestTypeStreaming() throws InterruptedException, Execu
134
136
private void erlangBucketMR (String bucketType ) throws InterruptedException , ExecutionException
135
137
{
136
138
Namespace ns = new Namespace (bucketType , mrBucketName );
137
- BucketMapReduce bmr =
138
- new BucketMapReduce .Builder ()
139
+ BucketMapReduce bmr = null ;
140
+ try
141
+ {
142
+ bmr = new BucketMapReduce .Builder ()
143
+ .withAllowListing ()
139
144
.withNamespace (ns )
140
145
.withMapPhase (Function .newErlangFunction ("riak_kv_mapreduce" , "map_object_value" ), false )
141
146
.withReducePhase (Function .newErlangFunction ("riak_kv_mapreduce" , "reduce_string_to_integer" ), false )
142
147
.withReducePhase (Function .newErlangFunction ("riak_kv_mapreduce" , "reduce_sort" ), true )
143
148
.build ();
149
+ }
150
+ catch (ListException ex )
151
+ {
152
+ fail (ex .getMessage ());
153
+ }
144
154
145
155
MapReduce .Response response = client .execute (bmr );
146
156
@@ -157,13 +167,21 @@ private void erlangBucketMR(String bucketType) throws InterruptedException, Exec
157
167
private void streamingErlangBucketMR (String bucketType ) throws InterruptedException , ExecutionException
158
168
{
159
169
Namespace ns = new Namespace (bucketType , mrBucketName );
160
- BucketMapReduce bmr =
161
- new BucketMapReduce .Builder ()
162
- .withNamespace (ns )
163
- .withMapPhase (Function .newErlangFunction ("riak_kv_mapreduce" , "map_object_value" ), false )
164
- .withReducePhase (Function .newErlangFunction ("riak_kv_mapreduce" , "reduce_string_to_integer" ), false )
165
- .withReducePhase (Function .newErlangFunction ("riak_kv_mapreduce" , "reduce_sort" ), true )
166
- .build ();
170
+ BucketMapReduce bmr = null ;
171
+ try
172
+ {
173
+ bmr = new BucketMapReduce .Builder ()
174
+ .withAllowListing ()
175
+ .withNamespace (ns )
176
+ .withMapPhase (Function .newErlangFunction ("riak_kv_mapreduce" , "map_object_value" ), false )
177
+ .withReducePhase (Function .newErlangFunction ("riak_kv_mapreduce" , "reduce_string_to_integer" ), false )
178
+ .withReducePhase (Function .newErlangFunction ("riak_kv_mapreduce" , "reduce_sort" ), true )
179
+ .build ();
180
+ }
181
+ catch (ListException ex )
182
+ {
183
+ fail (ex .getMessage ());
184
+ }
167
185
168
186
final RiakFuture <MapReduce .Response , BinaryValue > streamingFuture =
169
187
client .executeAsyncStreaming (bmr , 10 );
@@ -231,12 +249,20 @@ public void JsBucketMRTestType() throws InterruptedException, ExecutionException
231
249
private void JsBucketMR (String bucketType ) throws InterruptedException , ExecutionException
232
250
{
233
251
Namespace ns = new Namespace (bucketType , mrBucketName );
234
- BucketMapReduce bmr =
235
- new BucketMapReduce .Builder ()
252
+ BucketMapReduce bmr = null ;
253
+ try
254
+ {
255
+ bmr = new BucketMapReduce .Builder ()
256
+ .withAllowListing ()
236
257
.withNamespace (ns )
237
258
.withMapPhase (Function .newNamedJsFunction ("Riak.mapValuesJson" ), false )
238
259
.withReducePhase (Function .newNamedJsFunction ("Riak.reduceNumericSort" ), true )
239
260
.build ();
261
+ }
262
+ catch (ListException ex )
263
+ {
264
+ fail (ex .getMessage ());
265
+ }
240
266
241
267
RiakFuture <MapReduce .Response , BinaryValue > future = client .executeAsync (bmr );
242
268
@@ -259,12 +285,20 @@ private void JsBucketMR(String bucketType) throws InterruptedException, Executio
259
285
public void multiPhaseResult () throws InterruptedException , ExecutionException
260
286
{
261
287
Namespace ns = new Namespace (Namespace .DEFAULT_BUCKET_TYPE , mrBucketName );
262
- BucketMapReduce bmr =
263
- new BucketMapReduce .Builder ()
288
+ BucketMapReduce bmr = null ;
289
+ try
290
+ {
291
+ bmr = new BucketMapReduce .Builder ()
292
+ .withAllowListing ()
264
293
.withNamespace (ns )
265
294
.withMapPhase (Function .newNamedJsFunction ("Riak.mapValuesJson" ), true )
266
295
.withReducePhase (Function .newNamedJsFunction ("Riak.reduceNumericSort" ), true )
267
296
.build ();
297
+ }
298
+ catch (ListException ex )
299
+ {
300
+ fail (ex .getMessage ());
301
+ }
268
302
269
303
RiakFuture <MapReduce .Response , BinaryValue > future = client .executeAsync (bmr );
270
304
@@ -288,15 +322,23 @@ public void multiPhaseResult() throws InterruptedException, ExecutionException
288
322
public void keyFilter () throws InterruptedException , ExecutionException
289
323
{
290
324
Namespace ns = new Namespace (Namespace .DEFAULT_BUCKET_TYPE , mrBucketName );
291
- BucketMapReduce bmr =
292
- new BucketMapReduce .Builder ()
325
+ BucketMapReduce bmr = null ;
326
+ try
327
+ {
328
+ bmr = new BucketMapReduce .Builder ()
329
+ .withAllowListing ()
293
330
.withNamespace (ns )
294
331
.withMapPhase (Function .newNamedJsFunction ("Riak.mapValuesJson" ))
295
332
.withReducePhase (Function .newErlangFunction ("riak_kv_mapreduce" , "reduce_sort" ),true )
296
333
.withKeyFilter (new TokenizeFilter ("_" ,3 ))
297
334
.withKeyFilter (new StringToIntFilter ())
298
335
.withKeyFilter (new LogicalAndFilter (new LessThanFilter <>(50 ), new GreaterThanFilter <>(45 )))
299
336
.build ();
337
+ }
338
+ catch (ListException ex )
339
+ {
340
+ fail (ex .getMessage ());
341
+ }
300
342
301
343
RiakFuture <MapReduce .Response , BinaryValue > future = client .executeAsync (bmr );
302
344
@@ -315,8 +357,10 @@ public void differentBucketType() throws InterruptedException, ExecutionExceptio
315
357
Assume .assumeTrue (testBucketType );
316
358
317
359
Namespace ns = new Namespace (mapReduceBucketType .toString (), mrBucketName );
318
- BucketMapReduce bmr =
319
- new BucketMapReduce .Builder ()
360
+ BucketMapReduce bmr = null ;
361
+ try
362
+ {
363
+ bmr = new BucketMapReduce .Builder ()
320
364
.withNamespace (ns )
321
365
.withMapPhase (Function .newAnonymousJsFunction (
322
366
"function(value, keydata, arg) {" +
@@ -327,6 +371,11 @@ public void differentBucketType() throws InterruptedException, ExecutionExceptio
327
371
" return[];" +
328
372
"}" ), true )
329
373
.build ();
374
+ }
375
+ catch (ListException ex )
376
+ {
377
+ fail (ex .getMessage ());
378
+ }
330
379
331
380
MapReduce .Response response = client .execute (bmr );
332
381
@@ -339,8 +388,10 @@ public void differentBucketTypeWithFilter() throws InterruptedException, Executi
339
388
Assume .assumeTrue (testBucketType );
340
389
341
390
Namespace ns = new Namespace (mapReduceBucketType .toString (), mrBucketName );
342
- BucketMapReduce bmr =
343
- new BucketMapReduce .Builder ()
391
+ BucketMapReduce bmr = null ;
392
+ try
393
+ {
394
+ bmr = new BucketMapReduce .Builder ()
344
395
.withNamespace (ns )
345
396
.withKeyFilter (new TokenizeFilter ("_" ,3 ))
346
397
.withKeyFilter (new StringToIntFilter ())
@@ -351,6 +402,11 @@ public void differentBucketTypeWithFilter() throws InterruptedException, Executi
351
402
" return [data];" +
352
403
"}" ), true )
353
404
.build ();
405
+ }
406
+ catch (ListException ex )
407
+ {
408
+ fail (ex .getMessage ());
409
+ }
354
410
355
411
RiakFuture <MapReduce .Response , BinaryValue > future = client .executeAsync (bmr );
356
412
0 commit comments