<commit_before>/**
 * Copyright Pravega Authors.
 *
 * Licensed 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 io.pravega.connectors.flink;

import org.apache.flink.annotation.Internal;
import org.apache.flink.api.common.serialization.SerializationSchema;
import org.apache.flink.api.common.time.Time;
import org.apache.flink.util.Preconditions;

/**
 * An abstract streaming writer builder.
 *
 * The builder is abstracted to act as the base for the {@link FlinkPravegaWriter} builder.
 *
 * @param <T> the element type.
 * @param <B> the builder type.
 */
@Internal
public abstract class AbstractStreamingWriterBuilder<T, B extends AbstractStreamingWriterBuilder> extends AbstractWriterBuilder<B> {

    // the numbers below are picked based on the default max settings in Pravega
    protected static final long DEFAULT_TXN_LEASE_RENEWAL_PERIOD_MILLIS = 120000; // 120 seconds

    public PravegaWriterMode writerMode;
    public boolean enableWatermark;
    public Time txnLeaseRenewalPeriod;

    protected AbstractStreamingWriterBuilder() {
        writerMode = PravegaWriterMode.ATLEAST_ONCE;
        enableWatermark = false;
        txnLeaseRenewalPeriod = Time.milliseconds(DEFAULT_TXN_LEASE_RENEWAL_PERIOD_MILLIS);
    }

    /**
     * Sets the writer mode to provide at-least-once or exactly-once guarantees.
     *
     * @param writerMode The writer mode of {@code BEST_EFFORT}, {@code ATLEAST_ONCE}, or {@code EXACTLY_ONCE}.
     * @return A builder to configure and create a streaming writer.
     */
    public B withWriterMode(PravegaWriterMode writerMode) {
        this.writerMode = writerMode;
        return builder();
    }

    /**
     * Enable watermark.
     *<commit_msg>[issue-617] increase default transaction lease (#618)<commit_after>/**
 * Copyright Pravega Authors.
 *
 * Licensed 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 io.pravega.connectors.flink;

import org.apache.flink.annotation.Internal;
import org.apache.flink.api.common.serialization.SerializationSchema;
import org.apache.flink.api.common.time.Time;
import org.apache.flink.util.Preconditions;

/**
 * An abstract streaming writer builder.
 *
 * The builder is abstracted to act as the base for the {@link FlinkPravegaWriter} builder.
 *
 * @param <T> the element type.
 * @param <B> the builder type.
 */
@Internal
public abstract class AbstractStreamingWriterBuilder<T, B extends AbstractStreamingWriterBuilder> extends AbstractWriterBuilder<B> {

    // the numbers below are picked based on the default max settings in Pravega
    protected static final long DEFAULT_TXN_LEASE_RENEWAL_PERIOD_MILLIS = 600000; // 600 seconds

    public PravegaWriterMode writerMode;
    public boolean enableWatermark;
    public Time txnLeaseRenewalPeriod;

    protected AbstractStreamingWriterBuilder() {
        writerMode = PravegaWriterMode.ATLEAST_ONCE;
        enableWatermark = false;
        txnLeaseRenewalPeriod = Time.milliseconds(DEFAULT_TXN_LEASE_RENEWAL_PERIOD_MILLIS);
    }

    /**
     * Sets the writer mode to provide at-least-once or exactly-once guarantees.
     *
     * @param writerMode The writer mode of {@code BEST_EFFORT}, {@code ATLEAST_ONCE}, or {@code EXACTLY_ONCE}.
     * @return A builder to configure and create a streaming writer.
     */
    public B withWriterMode(PravegaWriterMode writerMode) {
        this.writerMode = writerMode;
        return builder();
    }

    /**
     * Enable watermark.
     *
{'fraction_non_alphanumeric': 0.07858105074090704, 'fraction_numerical': 0.007184553210597216, 'mean_word_length': 3.7444089456869007, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2772524', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1243, 'n_words': 429}