Java Code Examples for java.util.concurrent.atomic.AtomicInteger#set()

The following examples show how to use java.util.concurrent.atomic.AtomicInteger#set() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Dolphin   File: MessageBusTest.java    License: Apache License 2.0 6 votes vote down vote up
private MessageCallBack<ResponsePayload> newMessageCallBack(final AtomicInteger flag) {
    return new MessageCallBack<ResponsePayload>(ResponsePayload.class) {

        @Override
        public void success(ResponsePayload responsePayload) {
            flag.set(FLAG_NOT_TIMEOUT);
        }

        @Override
        public void error(Throwable throwable) {
            flag.set(FLAG_ERROR);
        }

        @Override
        public void timeout() {
            flag.set(FLAG_TIMEOUT);
        }

    };
}
 
Example 2
Source Project: interview   File: RedBlackTree.java    License: Apache License 2.0 6 votes vote down vote up
private boolean checkBlackNodesCount(Node root, AtomicInteger blackCount, int currentCount) {

        if(root.color == Color.BLACK) {
            currentCount++;
        }

        if(root.left == null && root.right == null) {
            if(blackCount.get() == 0) {
                blackCount.set(currentCount);
                return true;
            } else {
                return currentCount == blackCount.get();
            }
        }
        return checkBlackNodesCount(root.left, blackCount, currentCount) && checkBlackNodesCount(root.right, blackCount, currentCount);
    }
 
Example 3
@Test
public void testNotifyVmWasDeletedByHand() throws Exception {

	AtomicInteger vmCount = this.autonomicMngr.autonomicVmCount;
	Assert.assertEquals( 0, vmCount.get());

	vmCount.set( 5 );
	Instance rootInstance = new Instance( "inst" );;
	this.autonomicMngr.notifyVmWasDeletedByHand( rootInstance );
	Assert.assertEquals( 5, vmCount.get());

	rootInstance.data.put( AutonomicMngrImpl.AUTONOMIC_MARKER, "whatever" );
	this.autonomicMngr.notifyVmWasDeletedByHand( rootInstance );
	Assert.assertEquals( 4, vmCount.get());

	// The marker was already removed
	this.autonomicMngr.notifyVmWasDeletedByHand( rootInstance );
	Assert.assertEquals( 4, vmCount.get());
}
 
Example 4
public <T> CuboidResult buildBaseCuboid(RecordConsumeBlockingQueueController<T> input,
        final ICuboidResultListener listener) throws IOException {
    completedTaskQueue = new LinkedBlockingQueue<CuboidTask>();
    taskCuboidCompleted = new AtomicInteger(0);

    resultCollector = new DefaultCuboidCollectorWithCallBack(listener);

    MemoryBudgetController.MemoryWaterLevel baseCuboidMemTracker = new MemoryWaterLevel();
    baseCuboidMemTracker.markLow();
    baseResult = createBaseCuboid(input, baseCuboidMemTracker);

    if (baseResult.nRows == 0) {
        taskCuboidCompleted.set(cuboidScheduler.getCuboidCount());
        return baseResult;
    }

    baseCuboidMemTracker.markLow();
    baseResult.aggrCacheMB = Math.max(baseCuboidMemTracker.getEstimateMB(), 10); // 10 MB at minimal

    makeMemoryBudget();
    return baseResult;
}
 
Example 5
@Test
public void testLongOpsShortCircuit() {
    AtomicInteger count = new AtomicInteger();
    LongStream.of(0).flatMap(i -> LongStream.range(0, 100)).
            peek(i -> count.incrementAndGet()).
            limit(10).toArray();
    assertEquals(count.get(), 10);

    count.set(0);
    Stream.of(0).flatMapToLong(i -> LongStream.range(0, 100)).
            peek(i -> count.incrementAndGet()).
            limit(10).toArray();
    assertEquals(count.get(), 10);
}
 
Example 6
@Test
void test() {
    AtomicInteger assertSize = new AtomicInteger();
    BufferTrigger<Integer> bufferTrigger = SimpleBufferTrigger
            .<Integer, Set<Interner>> newGenericBuilder()
            .triggerStrategy(new MultiIntervalTriggerStrategy()
                    .on(10, SECONDS, 1)
                    .on(5, SECONDS, 10)
                    .on(1, SECONDS, 100)
            )
            .consumer(set -> {
                System.out.println("size:" + set.size());
                assertEquals(set.size(), assertSize.get());
            })
            .build();

    enqueue(bufferTrigger, 100);
    assertSize.set(100);
    sleep(2);
    enqueue(bufferTrigger, 10);
    assertSize.set(10);
    sleep(6);
    enqueue(bufferTrigger, 1);
    assertSize.set(1);
    sleep(11);

    sleepUninterruptibly(10, SECONDS);
}
 
Example 7
/**
 * get returns the last value set
 */
public void testGetSet() {
    AtomicInteger ai = new AtomicInteger(1);
    assertEquals(1, ai.get());
    ai.set(2);
    assertEquals(2, ai.get());
    ai.set(-3);
    assertEquals(-3, ai.get());
}
 
Example 8
@Test
public void runAsyncRetryToSuccess() {
    try (FDBDatabaseRunner runner = database.newRunner()) {
        AtomicInteger count = new AtomicInteger(0);
        String value = runner.runAsync(context -> {
            if (count.getAndIncrement() == 0) {
                throw new RecordCoreRetriableTransactionException("Have to try again!", new FDBException("not_committed", 1020));
            } else {
                return CompletableFuture.completedFuture("Success!");
            }
        }).join();
        assertEquals("Success!", value);
        assertEquals(2, count.get(), "Should only take one try");

        count.set(0);
        value = runner.runAsync(context -> {
            if (count.getAndIncrement() == 0) {
                throw new FDBException("not_committed", 1020);
            } else {
                return CompletableFuture.completedFuture("Success!");
            }
        }).join();
        assertEquals("Success!", value);
        assertEquals(2, count.get(), "Should only take one try");

        count.set(0);
        value = runner.runAsync(context -> {
            if (count.getAndIncrement() == 0) {
                throw new RecordCoreRetriableTransactionException("Something non-standard");
            } else {
                return CompletableFuture.completedFuture("Success!");
            }
        }).join();
        assertEquals("Success!", value);
        assertEquals(2, count.get(), "Should only take one try");

        value = runner.runAsync(context -> CompletableFuture.completedFuture("Success!")).join();
        assertEquals("Success!", value);
    }
}
 
Example 9
private int count(String repoUrl) {
	AtomicInteger ownerFollowerOrSubscriberCount = new AtomicInteger();
	ownerFollowerOrSubscriberCount.set(-1);
	
	IGitHubApi client = GitHubUtils.getOAuthClient();
	IData<User> repoOwner = client.getUsersUserByUsername(CloneUtils.extractGhRepoOwner(repoUrl));
	
	repoOwner.observe()
       .doOnNext(o -> {
       	if ( o.getType().equals("User") ) {
       		ownerFollowerOrSubscriberCount.set( o.getFollowers() );   
       		
       	} else if ( o.getType().equals("Organization") ){
       		IData<Repo> repo = client.getReposRepoByRepo(CloneUtils.extractGhRepoOwner(repoUrl), CloneUtils.extractGhRepoName(repoUrl));
       		repo.observe()
	              .doOnNext(r -> {
	            	  ownerFollowerOrSubscriberCount.set(r.getSubscribersCount());
	              })
	              .blockingSubscribe();
       		
       	}
       		
       })
       .blockingSubscribe();
	
	return ownerFollowerOrSubscriberCount.intValue();
}
 
Example 10
Source Project: Dragonfly   File: ProgressServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
private void processPeerSucInfo(String srcCid, String dstCid) {
    if (!needDoPeerInfo(srcCid, dstCid)) {
        return;
    }
    AtomicInteger clientErrorCount = progressRepo.getClientErrorInfo(srcCid);
    if (clientErrorCount != null) {
        clientErrorCount.set(0);
    }
    AtomicInteger serviceErrorCount = progressRepo.getServiceErrorInfo(dstCid);
    if (serviceErrorCount != null) {
        serviceErrorCount.set(0);
    }
}
 
Example 11
private void throwOnNonContinuous(AtomicInteger counter, String x) {
  int curValue = Integer.parseInt(x);
  int prevValue = counter.get();
  if (prevValue >= 0) {
    int dif = curValue - prevValue;
    if (dif != 1) {
      throw new IllegalStateException(
          String.format(
              "Payload values are expected to be continuous numbers: %d %d",
              prevValue, curValue));
    }
  }
  counter.set(curValue);
}
 
Example 12
Source Project: micrometer   File: GaugeTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@DisplayName("gauges attached to a number are updated when their values are observed")
default void numericGauge(MeterRegistry registry) {
    AtomicInteger n = registry.gauge("my.gauge", new AtomicInteger(0));
    n.set(1);

    Gauge g = registry.get("my.gauge").gauge();
    assertThat(g.value()).isEqualTo(1);

    n.set(2);
    assertThat(g.value()).isEqualTo(2);
}
 
Example 13
/**
 * We need to insert the system properties as a list of -Dkey=value entries instead of
 * just pasting the String that contains these values.
 */
private String[] substituteSystemProps(ReleaserProperties properties,
		String... commands) {
	String systemProperties = new CommandPicker(properties).systemProperties();
	String systemPropertiesPlaceholder = new CommandPicker(properties)
			.systemPropertiesPlaceholder();
	boolean containsSystemProps = systemProperties.contains("-D");
	String[] splitSystemProps = StringUtils
			.delimitedListToStringArray(systemProperties, "-D");
	// first element might be empty even though the second one contains values
	if (splitSystemProps.length > 1) {
		splitSystemProps = StringUtils.isEmpty(splitSystemProps[0])
				? Arrays.copyOfRange(splitSystemProps, 1, splitSystemProps.length)
				: splitSystemProps;
	}
	String[] systemPropsWithPrefix = containsSystemProps ? Arrays
			.stream(splitSystemProps).map(s -> "-D" + s.trim())
			.collect(Collectors.toList()).toArray(new String[splitSystemProps.length])
			: splitSystemProps;
	final AtomicInteger index = new AtomicInteger(-1);
	for (int i = 0; i < commands.length; i++) {
		if (commands[i].contains(systemPropertiesPlaceholder)) {
			index.set(i);
			break;
		}
	}
	return toCommandList(systemPropsWithPrefix, index, commands);
}
 
Example 14
/**
 * Unit test for correct layering of filters on top of the
 * {@link FusedTupleIterator}. Note that the filters must be layered on top
 * of the {@link FusedTupleIterator} rather than being passed into the
 * per-index source {@link ITupleIterator}s so that the filters will see a
 * fused iterator. This test is designed to verify that the filters are in
 * fact applied to the {@link FusedTupleIterator} rather than to the source
 * iterators.
 */
public void test_filter() {
    
    final byte[] k3 = i2k(3);
    final byte[] k5 = i2k(5);
    final byte[] k7 = i2k(7);
    final byte[] k9 = i2k(9);

    final byte[] v3a = new byte[]{3};
    final byte[] v5a = new byte[]{5};
    final byte[] v5b = new byte[]{5,1};
    final byte[] v7a = new byte[]{7};
    final byte[] v9a = new byte[]{9};
    
    final IRawStore store = new SimpleMemoryRawStore();
    
    // two btrees with the same index UUID.
    final BTree btree1, btree2;
    {

        final IndexMetadata md = new IndexMetadata(UUID.randomUUID());
        
        md.setBranchingFactor(3);
        
        md.setDeleteMarkers(true);

        md.setTupleSerializer(NOPTupleSerializer.INSTANCE);

        btree1 = BTree.create(store, md);
        
        btree2 = BTree.create(store, md.clone());
        
    }
    
    /*
     * Create an ordered view onto {btree1, btree2}. Keys found in btree1
     * will cause the search to halt. If the key is not in btree1 then
     * btree2 will also be searched. A miss is reported if the key is not
     * found in either btree.
     * 
     * Note: Since delete markers are enabled keys will be recognized when
     * the index entry has been marked as deleted.
     */
    final FusedView view = new FusedView(new AbstractBTree[] { btree1,
            btree2 });
    
    /*
     * Setup the view.
     * 
     * Note: [k5] is found in both source B+Trees.
     */
    btree2.insert(k3, v3a);
    btree1.insert(k5, v5a);
    btree2.insert(k5, v5b);
    btree1.insert(k7, v7a);
    btree2.insert(k9, v9a);

    /*
     * Setup a filter that counts the #of tuples _examined_ by the iterator
     * (not just those that it visits). If this filter is applied to the
     * source iterators then it would examine (2) tuples for btree1 and (3)
     * tuples for btree2 for a total of (5). However, if it is applied to
     * the fused tuple iterator, then it will only examine (4) tuples since
     * there is a tuple with [k5] in both btree1 and btree2 and therefore
     * the [k5] tuple from btree2 is dropped from the fused tuple iterator.
     */
    final AtomicInteger count = new AtomicInteger(0);
    final IFilter filter = new TupleFilter(){
        private static final long serialVersionUID = 1L;
        @Override
        protected boolean isValid(ITuple tuple) {
            count.incrementAndGet();
            return true;
        }};
    
    // forward : counts four distinct tuples.
    count.set(0);
    assertSameIterator(new byte[][] { v3a, v5a, v7a, v9a }, view
            .rangeIterator(null, null,0/*capacity*/,IRangeQuery.DEFAULT,filter));
    assertEquals(4,count.get());

    // reverse : counts four distinct tuples.
    count.set(0);
    assertSameIterator(new byte[][] { v9a, v7a, v5a, v3a }, view.rangeIterator(null,
            null, 0/* capacity */,
            IRangeQuery.DEFAULT | IRangeQuery.REVERSE, filter));
    assertEquals(4,count.get());

}
 
Example 15
@Test
public void testSSEApplication() throws
        InterruptedException, MalformedURLException, TimeoutException {

    AtomicInteger atomicInteger = new AtomicInteger();

    registerApplication(
        new TestSSEApplication(), JAX_RS_APPLICATION_BASE, "/sse");
    registerAddon(
        new SSEResource(), JAX_RS_APPLICATION_SELECT,
        "(" + JAX_RS_APPLICATION_BASE + "=/sse)");
    registerExtension(
        ContainerResponseFilter.class,
        (req, res) -> atomicInteger.incrementAndGet(), "Filter",
        JAX_RS_APPLICATION_SELECT,
        "(" + JAX_RS_APPLICATION_BASE + "=/sse)");

    SseEventSourceFactory sseFactory = createSseFactory();

    SseEventSource source1 = sseFactory.newSource(
        createDefaultTarget().path("/sse").path("/subscribe"));

    SseEventSource source2 = sseFactory.newSource(
        createDefaultTarget().path("/sse").path("/subscribe"));

    ArrayList<String> source1Events = new ArrayList<>();
    ArrayList<String> source2Events = new ArrayList<>();

    Phaser phaser = new Phaser(2);

    source1.register(
        event -> {source1Events.add(event.readData(String.class));phaser.arrive(); });
    source2.register(
        event -> {source2Events.add(event.readData(String.class));phaser.arrive(); });

    source1.open();
    source2.open();

    phaser.awaitAdvanceInterruptibly(0, 10, TimeUnit.SECONDS);

    //The filter IS invoked on the subscribe method
    assertEquals(2, atomicInteger.get());

    WebTarget broadcast = createDefaultTarget().path("/sse").path(
        "/broadcast");

    broadcast.request().post(
        Entity.entity("message", MediaType.TEXT_PLAIN_TYPE));

    phaser.awaitAdvanceInterruptibly(1, 10, TimeUnit.SECONDS);

    assertEquals(Arrays.asList("welcome", "message"), source1Events);
    assertEquals(Arrays.asList("welcome", "message"), source2Events);

    source2.close();
    phaser.arrive();

    atomicInteger.set(0);

    broadcast.request().post(
        Entity.entity("another message", MediaType.TEXT_PLAIN_TYPE));

    phaser.awaitAdvanceInterruptibly(2, 10, TimeUnit.SECONDS);

    assertEquals(
        Arrays.asList("welcome", "message", "another message"),
        source1Events);
    assertEquals(Arrays.asList("welcome", "message"), source2Events);

    source1.close();

    //The filter IS invoked when broadcasting events
    assertEquals(1, atomicInteger.get());
}
 
Example 16
Source Project: lucene-solr   File: TestPolicy.java    License: Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({"unchecked"})
public void testReplicaZonesPercentage() {
  String autoScalingjson = "  { cluster-policy:[" +
      "    { replica :'33%', shard: '#EACH', sysprop.az : east}," +
      "    { replica :'67%', shard: '#EACH', sysprop.az : west}" +
      "    ]," +
      "  cluster-preferences :[{ minimize : cores }]}";

  String COLL_NAME = "percentColl";
  AutoScalingConfig autoScalingConfig = new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString(autoScalingjson));

  Policy.Transaction txn = new Policy.Transaction(autoScalingConfig.getPolicy());
  txn.open(cloudManagerWithData((Map<String, Object>) loadFromResource("testReplicaZonesPercentage.json")));

  List<String> nodes = new ArrayList<>();

  int westCount = 0, eastCount = 0;
  for (int i = 0; i < 12; i++) {
    @SuppressWarnings({"rawtypes"})
    SolrRequest suggestion = txn.getCurrentSession()
        .getSuggester(ADDREPLICA)
        .hint(Hint.COLL_SHARD, new Pair<>(COLL_NAME, "shard1"))
        .getSuggestion();
    assertNotNull(suggestion);
    String node = suggestion.getParams().get("node");
    nodes.add(node);
    if ("10.0.0.6:8983_solr".equals(node)) eastCount++;
    if ("10.0.0.6:7574_solr".equals(node)) westCount++;
    if (i % 3 == 1) assertEquals("10.0.0.6:8983_solr", node);
    else assertEquals("10.0.0.6:7574_solr", node);
  }
  assertEquals(8, westCount);
  assertEquals(4, eastCount);

  List<Violation> violations = txn.close();
  assertTrue(violations.isEmpty());
  Policy.Session latestSession = txn.getCurrentSession();
  assertEquals("10.0.0.6:7574_solr", latestSession.matrix.get(0).node);
  AtomicInteger count = new AtomicInteger();
  latestSession.matrix.get(0).forEachReplica(replicaInfo -> count.incrementAndGet());
  assertEquals(8, count.get());

  assertEquals("10.0.0.6:8983_solr", latestSession.matrix.get(1).node);
  count.set(0);
  latestSession.matrix.get(1).forEachReplica(replicaInfo -> count.incrementAndGet());
  assertEquals(4, count.get());

}
 
Example 17
public void testWeakCollection() throws Exception
{
    final int max = 1 << 18;
    final String[] toKeep = new String[1 << 14];
    final StringIndex index = createStringPool();
    final AtomicInteger done = new AtomicInteger(0);
    ExceptionCatchingThread putter = new ExceptionCatchingThread(new Runnable()
    {
        public void run()
        {
            for(int i=0;i<max;i++)
            {
                String data = createData(i);
                String result = index.getIfAbsentPut(data, false);
                if (i % ((1 << 4)-1) == 0) toKeep[i >> 4] = result;
            }
            done.set(1);
        }
    });
    ExceptionCatchingThread evictor = new ExceptionCatchingThread(new Runnable()
    {
        public void run()
        {
            while(done.get() == 0)
                index.evictCollectedReferences();
            index.evictCollectedReferences();
        }
    });
    evictor.start();
    putter.start();
    putter.joinWithExceptionHandling();
    evictor.joinWithExceptionHandling();
    System.gc();
    Thread.yield();
    System.gc();
    Thread.yield();
    assertTrue(index.size() >= toKeep.length);
    for(int i=0;i<toKeep.length;i++)
    {
        assertSame(toKeep[i], index.getIfAbsentPut(toKeep[i], false));
    }
}
 
Example 18
Source Project: pravega   File: FuturesTests.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testDoWhileLoopWithCondition() {
    final int maxLoops = 10;
    final int expectedResult = maxLoops * (maxLoops - 1) / 2;
    AtomicInteger loopCounter = new AtomicInteger();
    AtomicInteger accumulator = new AtomicInteger();

    // 1. Verify this is actually a do-while loop vs a regular while loop.
    Futures.doWhileLoop(
            () -> {
                accumulator.incrementAndGet();
                return CompletableFuture.completedFuture(0);
            },
            x -> false, // Only one iteration.
            ForkJoinPool.commonPool()
    ).join();
    Assert.assertEquals("Unexpected result for loop without a specific accumulator.", 1, accumulator.get());

    // 2. Successful execution.
    loopCounter.set(0);
    accumulator.set(0);
    Futures.doWhileLoop(
            () -> {
                int i = loopCounter.get();
                accumulator.addAndGet(i);
                return CompletableFuture.completedFuture(loopCounter.incrementAndGet());
            },
            x -> x < maxLoops,
            ForkJoinPool.commonPool()
    ).join();

    Assert.assertEquals("Unexpected result for loop without a specific accumulator.", expectedResult, accumulator.get());

    // 3. With exceptions.
    loopCounter.set(0);
    accumulator.set(0);
    CompletableFuture<Void> loopFuture = Futures.doWhileLoop(
            () -> {
                if (loopCounter.incrementAndGet() % 3 == 0) {
                    throw new IntentionalException();
                } else {
                    accumulator.addAndGet(loopCounter.get());
                    return CompletableFuture.completedFuture(loopCounter.get());
                }
            },
            x -> x < maxLoops, ForkJoinPool.commonPool());

    AssertExtensions.assertThrows(
            "doWhileLoop() did not return a failed Future when one of the loopBody calls returned a failed Future.",
            loopFuture::join,
            ex -> ex instanceof IntentionalException);
    Assert.assertEquals("Unexpected value accumulated until loop was interrupted.", 3, accumulator.get());
}
 
Example 19
Source Project: ignite   File: IgniteWalReaderTest.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Tests WAL iterator which uses shared cache context of currently started Ignite node.
 */
@Test
public void testIteratorWithCurrentKernelContext() throws Exception {
    IgniteEx ignite = startGrid(0);

    ignite.cluster().active(true);

    int cntEntries = 100;

    putDummyRecords(ignite, cntEntries);

    String workDir = U.defaultWorkDirectory();

    IgniteWalIteratorFactory factory = new IgniteWalIteratorFactory(log);

    IteratorParametersBuilder iterParametersBuilder =
        createIteratorParametersBuilder(workDir, genDbSubfolderName(ignite, 0))
            .filesOrDirs(workDir)
            .binaryMetadataFileStoreDir(null)
            .marshallerMappingFileStoreDir(null)
            .sharedContext(ignite.context().cache().context());

    AtomicInteger cnt = new AtomicInteger();

    IgniteBiInClosure<Object, Object> objConsumer = (key, val) -> {
        if (val instanceof IndexedObject) {
            assertEquals(key, ((IndexedObject)val).iVal);
            assertEquals(key, cnt.getAndIncrement());
        }
    };

    iterateAndCountDataRecord(factory.iterator(iterParametersBuilder.copy()), objConsumer, null);

    assertEquals(cntEntries, cnt.get());

    // Test without converting non primary types.
    iterParametersBuilder.keepBinary(true);

    cnt.set(0);

    IgniteBiInClosure<Object, Object> binObjConsumer = (key, val) -> {
        if (val instanceof BinaryObject) {
            assertEquals(key, ((BinaryObject)val).field("iVal"));
            assertEquals(key, cnt.getAndIncrement());
        }
    };

    iterateAndCountDataRecord(factory.iterator(iterParametersBuilder.copy()), binObjConsumer, null);

    assertEquals(cntEntries, cnt.get());
}
 
Example 20
@Override
protected int execute() throws ToolException
{
    // Used for ability to be final and have a set
    final AtomicInteger status = new AtomicInteger(0);

    BatchProcessWorker<User> worker = new BatchProcessWorkerAdaptor<User>()
    {
        public void process(final User user) throws Throwable
        {
            RunAsWork<Void> runAsWork = new RunAsWork<Void>()
            {
                @Override
                public Void doWork() throws Exception
                {
                    try
                    {
                        renameUser(user.getOldUsername(), user.getNewUsername());
                    }
                    catch (Throwable t)
                    {
                        status.set(handleError(t));
                    }
                    return null;
                }
            };
            AuthenticationUtil.runAs(runAsWork, context.getUsername());
        }
    };
    
    // Use 2 threads, 20 User objects per transaction. Log every 100 entries.
    BatchProcessor<User> processor = new BatchProcessor<User>(
            "HomeFolderProviderSynchronizer",
            getServiceRegistry().getTransactionService().getRetryingTransactionHelper(),
            new WorkProvider(context),
            2, 20,
            null,
            logger, 100);
    processor.process(worker, true);

    return status.get();
}