<commit_before>/*
 * 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.sling.event.jobs.consumer;

import aQute.bnd.annotation.ProviderType;




/**
 *
 * @since 1.1
 */
@ProviderType
public interface JobExecutionContext {

    interface AsyncHandler {

        void failed();

        void ok();

        void cancel();
    }

    AsyncHandler getAsyncHandler();

    void log(final String message);

    void start(final int steps);

    void start(final int steps, final long eta);

    void setProgress(final int step);
}<commit_msg>SLING-3028 :  Support for progress tracking of jobs  - prototype of an API<commit_after>/*
 * 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.sling.event.jobs.consumer;

import aQute.bnd.annotation.ProviderType;

/**
 *
 * @since 1.1
 */
@ProviderType
public interface JobExecutionContext {

    /**
     * Report an async result.
     * @throws IllegalStateException If the job is not processed asynchronously
     */
    void asyncProcessingFinished(final JobStatus status);

    /**
     * Indicate that the job executor is able to report the progress
     * by providing a step count.
     * This method should only be called once, consecutive calls
     * or a call to {@link #startProgress(long)} have no effect.
     * @param steps Number of total steps or -1 if the number of
     *              steps is unknown.
     */
    void startProgress(final int steps);

    /**
     * Indicate that the job executor is able to report the progress
     * by providing an ETA.
     * This method should only be called once, consecutive calls
     * or a call to {@link #startProgress(int)} have no effect.
     * @param eta Number of seconds the process should take or
     *        -1 of it's not known now.
     */
    void startProgress(final long eta);

    /**
     * Update the progress to the current finished step.
     * This method has only effect if {@link #startProgress(int)}
     * has been called first.
     * @param step The current step.
     */
    void setProgress(final int step);

    /**
     * Update the progress to the new ETA.
     * This method has only effect if {@link #startProgress(long)}
     * has been called first.
     * @param eta The new ETA
     */
    void update(final long eta);

    /**
     * Log a message.
     * The message might contain place holders for additional arguments.
     * @param message A message
     * @param args Additional arguments
     */
    void log(final String message, final Object...args);
}
{'fraction_non_alphanumeric': 0.07515451174289246, 'fraction_numerical': 0.004449938195302843, 'mean_word_length': 2.962781586679726, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5568605', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1019, 'n_words': 491}