/**
 * 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
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * 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.camel.component.file.springboot.cluster;

import java.util.Map;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "camel.cluster.file")
public class FileLockClusterServiceConfiguration {
    /**
     * Sets if the file cluster service should be enabled or not, default is true.
     */
    private boolean enabled = true;

    /**
     * Cluster Service ID
     */
    private String id;

    /**
     * The root path.
     */
    private String root;

    /**
     * The time to wait before starting to try to acquire the cluster lock. Note that if FileLockClusterService
     * determines no cluster members are running or cannot reliably determine the cluster state, the initial delay is
     * computed from the acquireLockInterval.
     */
    private String acquireLockDelay;

    /**
     * The time to wait between attempts to try to acquire the cluster lock evaluated using wall-clock time. All cluster
     * members must use the same value so leadership checks and leader liveness detection remain consistent.
     */
    private String acquireLockInterval;

    /**
     * Custom service attributes.
     */
    private Map<String, Object> attributes;

    /**
     * Multiplier applied to the cluster leader acquireLockInterval to determine how long followers should wait
     * before considering the leader "stale".
     * For example, if the leader updates its heartbeat every 2 seconds and the heartbeatTimeoutMultiplier is 3,
     * followers will tolerate up to  2s * 3 = 6s of silence before declaring the leader unavailable.
     */
    private Integer heartbeatTimeoutMultiplier;

    /**
     * The number of times a cluster data task will run, counting both the first execution and subsequent retries in
     * case of failure or timeout.
     * <p>
     * This can be useful when the cluster data root is on network based file storage, where I/O operations may
     * occasionally block for long or unpredictable periods.
     */
    private Integer clusterDataTaskMaxAttempts;

    /**
     * The timeout for a cluster data task (reading or writing cluster data).
     * <p>
     * Timeouts are useful when the cluster data root is on network storage, where I/O operations may occasionally block
     * for long or unpredictable periods.
     */
    private Long clusterDataTaskTimeout;

    /**
     * Service lookup order/priority.
     */
    private Integer order;

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getRoot() {
        return root;
    }

    public void setRoot(String root) {
        this.root = root;
    }

    public String getAcquireLockDelay() {
        return acquireLockDelay;
    }

    public void setAcquireLockDelay(String acquireLockDelay) {
        this.acquireLockDelay = acquireLockDelay;
    }

    public String getAcquireLockInterval() {
        return acquireLockInterval;
    }

    public void setAcquireLockInterval(String acquireLockInterval) {
        this.acquireLockInterval = acquireLockInterval;
    }

    public Map<String, Object> getAttributes() {
        return attributes;
    }

    public void setAttributes(Map<String, Object> attributes) {
        this.attributes = attributes;
    }

    public Integer getOrder() {
        return order;
    }

    public void setOrder(Integer order) {
        this.order = order;
    }

    public Integer getHeartbeatTimeoutMultiplier() {
        return heartbeatTimeoutMultiplier;
    }

    public void setHeartbeatTimeoutMultiplier(Integer heartbeatTimeoutMultiplier) {
        this.heartbeatTimeoutMultiplier = heartbeatTimeoutMultiplier;
    }

    public Integer getClusterDataTaskMaxAttempts() {
        return clusterDataTaskMaxAttempts;
    }

    public void setClusterDataTaskMaxAttempts(Integer clusterDataTaskMaxAttempts) {
        this.clusterDataTaskMaxAttempts = clusterDataTaskMaxAttempts;
    }

    public Long getClusterDataTaskTimeout() {
        return clusterDataTaskTimeout;
    }

    public void setClusterDataTaskTimeout(Long clusterDataTaskTimeout) {
        this.clusterDataTaskTimeout = clusterDataTaskTimeout;
    }
}
