/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.pulsar.functions.api.examples;

import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;

import org.apache.pulsar.functions.api.Context;
import org.apache.pulsar.functions.api.Function;
import org.slf4j.Logger;

/**
 * A function with logging example.
 */
public class LoggingFunction implements Function<String, String> {

    private static final AtomicIntegerFieldUpdater<LoggingFunction> COUNTER_UPDATER =
        AtomicIntegerFieldUpdater.newUpdater(LoggingFunction.class, "counter");

    @Override
    public String process(String input, Context context) {
        Logger LOG = context.getLogger();

        int counterLocal = COUNTER_UPDATER.incrementAndGet(this);
        if ((counterLocal & Integer.MAX_VALUE) % 100000 == 0) {
            LOG.info("Handled {} messages", counterLocal);
        }

        return String.format("%s!", input);
    }

}

@@ -905,22 +905,10 @@
 eger
-FieldUpdater
 ;%0A
+
 %0Aimp
@@ -1155,15 +1155,8 @@
 ate 
-static 
 fina
@@ -1174,133 +1174,38 @@
 eger
-FieldUpdater%3CLoggingFunction%3E COUNTER_UPDATER =%0A        AtomicIntegerFieldUpdater.newUpdater(LoggingFunction.class, %22counter%22
+ counter = new AtomicInteger(0
 );%0A%0A
@@ -1351,23 +1351,15 @@
 l = 
-COUNTER_UPDATER
+counter
 .inc
@@ -1371,20 +1371,16 @@
 tAndGet(
-this
 );%0A     

Use `AtomicInteger` in LoggingFunction (#1558)