All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.joekerouac.async.task.starter.config.AsyncServiceConfigModel Maven / Gradle / Ivy

// Generated by delombok at Sat Aug 05 14:40:14 CST 2023
/*
 * 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 com.github.joekerouac.async.task.starter.config;

import java.util.Map;
import java.util.Set;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import com.github.joekerouac.async.task.model.AsyncThreadPoolConfig;

/**
 * @author JoeKerouac
 * @date 2022-10-14 14:37:00
 * @since 1.0.0
 */
@Configuration
@ConfigurationProperties(prefix = "async.service")
public class AsyncServiceConfigModel {
    /**
     * 数据源名称,如果系统没有提供{@link com.github.joekerouac.async.task.spi.AsyncTransactionManager
     * AsyncTransactionManager}这个bean,则需要提供数据源的名称,该数据源中需要包含我们系统所必须的表
     */
    private String dataSource;
    /**
     * 默认配置
     */
    @NotNull
    private Config defaultExecutorConfig = new Config();
    /**
     * 特定processor配置
     */
    private Map, Config> executorConfigs;


    public static class Config {
        /**
         * 任务缓存队列大小,0表示队列无限长,队列设置太小可能会影响性能;
         */
        @Min(value = 0, message = "缓存队列长度不能小于0")
        private int cacheQueueSize = 100;
        /**
         * 触发捞取任务的队列长度阈值,当任务缓存队列的实际长度小于等于该值时会触发任务捞取,应该小于{@link #cacheQueueSize};
         */
        @Min(value = 0, message = "触发捞取任务的队列长度阈值不能小于0")
        private int loadThreshold = 30;
        /**
         * 当上次任务捞取为空时下次任务捞取的最小时间间隔,当系统从repository中没有获取到任务后必须等待该时间间隔后才能再次捞取,单位毫秒
         */
        @Min(value = 0, message = "上次任务捞取为空时下次任务捞取的最小时间间隔不能小于0")
        private long loadInterval = 1000 * 5;
        /**
         * 触发定时监控的时间间隔,单位毫秒
         */
        @Min(value = 500, message = "监控间隔不能小于500")
        private long monitorInterval = 1000 * 5;
        /**
         * 实际执行任务的线程池配置
         */
        @NotNull(message = "实际执行任务的线程池配置不能为null")
        @Valid
        private AsyncThreadPoolConfig threadPoolConfig = new AsyncThreadPoolConfig();

        @java.lang.SuppressWarnings("all")
        public Config() {
        }

        @java.lang.SuppressWarnings("all")
        public int getCacheQueueSize() {
            return this.cacheQueueSize;
        }

        @java.lang.SuppressWarnings("all")
        public int getLoadThreshold() {
            return this.loadThreshold;
        }

        @java.lang.SuppressWarnings("all")
        public long getLoadInterval() {
            return this.loadInterval;
        }

        @java.lang.SuppressWarnings("all")
        public long getMonitorInterval() {
            return this.monitorInterval;
        }

        @java.lang.SuppressWarnings("all")
        public AsyncThreadPoolConfig getThreadPoolConfig() {
            return this.threadPoolConfig;
        }

        @java.lang.SuppressWarnings("all")
        public void setCacheQueueSize(final int cacheQueueSize) {
            this.cacheQueueSize = cacheQueueSize;
        }

        @java.lang.SuppressWarnings("all")
        public void setLoadThreshold(final int loadThreshold) {
            this.loadThreshold = loadThreshold;
        }

        @java.lang.SuppressWarnings("all")
        public void setLoadInterval(final long loadInterval) {
            this.loadInterval = loadInterval;
        }

        @java.lang.SuppressWarnings("all")
        public void setMonitorInterval(final long monitorInterval) {
            this.monitorInterval = monitorInterval;
        }

        @java.lang.SuppressWarnings("all")
        public void setThreadPoolConfig(final AsyncThreadPoolConfig threadPoolConfig) {
            this.threadPoolConfig = threadPoolConfig;
        }

        @java.lang.Override
        @java.lang.SuppressWarnings("all")
        public boolean equals(final java.lang.Object o) {
            if (o == this) return true;
            if (!(o instanceof AsyncServiceConfigModel.Config)) return false;
            final AsyncServiceConfigModel.Config other = (AsyncServiceConfigModel.Config) o;
            if (!other.canEqual((java.lang.Object) this)) return false;
            if (this.getCacheQueueSize() != other.getCacheQueueSize()) return false;
            if (this.getLoadThreshold() != other.getLoadThreshold()) return false;
            if (this.getLoadInterval() != other.getLoadInterval()) return false;
            if (this.getMonitorInterval() != other.getMonitorInterval()) return false;
            final java.lang.Object this$threadPoolConfig = this.getThreadPoolConfig();
            final java.lang.Object other$threadPoolConfig = other.getThreadPoolConfig();
            if (this$threadPoolConfig == null ? other$threadPoolConfig != null : !this$threadPoolConfig.equals(other$threadPoolConfig)) return false;
            return true;
        }

        @java.lang.SuppressWarnings("all")
        protected boolean canEqual(final java.lang.Object other) {
            return other instanceof AsyncServiceConfigModel.Config;
        }

        @java.lang.Override
        @java.lang.SuppressWarnings("all")
        public int hashCode() {
            final int PRIME = 59;
            int result = 1;
            result = result * PRIME + this.getCacheQueueSize();
            result = result * PRIME + this.getLoadThreshold();
            final long $loadInterval = this.getLoadInterval();
            result = result * PRIME + (int) ($loadInterval >>> 32 ^ $loadInterval);
            final long $monitorInterval = this.getMonitorInterval();
            result = result * PRIME + (int) ($monitorInterval >>> 32 ^ $monitorInterval);
            final java.lang.Object $threadPoolConfig = this.getThreadPoolConfig();
            result = result * PRIME + ($threadPoolConfig == null ? 43 : $threadPoolConfig.hashCode());
            return result;
        }

        @java.lang.Override
        @java.lang.SuppressWarnings("all")
        public java.lang.String toString() {
            return "AsyncServiceConfigModel.Config(cacheQueueSize=" + this.getCacheQueueSize() + ", loadThreshold=" + this.getLoadThreshold() + ", loadInterval=" + this.getLoadInterval() + ", monitorInterval=" + this.getMonitorInterval() + ", threadPoolConfig=" + this.getThreadPoolConfig() + ")";
        }
    }

    @java.lang.SuppressWarnings("all")
    public AsyncServiceConfigModel() {
    }

    /**
     * 数据源名称,如果系统没有提供{@link com.github.joekerouac.async.task.spi.AsyncTransactionManager
     * AsyncTransactionManager}这个bean,则需要提供数据源的名称,该数据源中需要包含我们系统所必须的表
     */
    @java.lang.SuppressWarnings("all")
    public String getDataSource() {
        return this.dataSource;
    }

    /**
     * 默认配置
     */
    @java.lang.SuppressWarnings("all")
    public Config getDefaultExecutorConfig() {
        return this.defaultExecutorConfig;
    }

    /**
     * 特定processor配置
     */
    @java.lang.SuppressWarnings("all")
    public Map, Config> getExecutorConfigs() {
        return this.executorConfigs;
    }

    /**
     * 数据源名称,如果系统没有提供{@link com.github.joekerouac.async.task.spi.AsyncTransactionManager
     * AsyncTransactionManager}这个bean,则需要提供数据源的名称,该数据源中需要包含我们系统所必须的表
     */
    @java.lang.SuppressWarnings("all")
    public void setDataSource(final String dataSource) {
        this.dataSource = dataSource;
    }

    /**
     * 默认配置
     */
    @java.lang.SuppressWarnings("all")
    public void setDefaultExecutorConfig(final Config defaultExecutorConfig) {
        this.defaultExecutorConfig = defaultExecutorConfig;
    }

    /**
     * 特定processor配置
     */
    @java.lang.SuppressWarnings("all")
    public void setExecutorConfigs(final Map, Config> executorConfigs) {
        this.executorConfigs = executorConfigs;
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("all")
    public boolean equals(final java.lang.Object o) {
        if (o == this) return true;
        if (!(o instanceof AsyncServiceConfigModel)) return false;
        final AsyncServiceConfigModel other = (AsyncServiceConfigModel) o;
        if (!other.canEqual((java.lang.Object) this)) return false;
        final java.lang.Object this$dataSource = this.getDataSource();
        final java.lang.Object other$dataSource = other.getDataSource();
        if (this$dataSource == null ? other$dataSource != null : !this$dataSource.equals(other$dataSource)) return false;
        final java.lang.Object this$defaultExecutorConfig = this.getDefaultExecutorConfig();
        final java.lang.Object other$defaultExecutorConfig = other.getDefaultExecutorConfig();
        if (this$defaultExecutorConfig == null ? other$defaultExecutorConfig != null : !this$defaultExecutorConfig.equals(other$defaultExecutorConfig)) return false;
        final java.lang.Object this$executorConfigs = this.getExecutorConfigs();
        final java.lang.Object other$executorConfigs = other.getExecutorConfigs();
        if (this$executorConfigs == null ? other$executorConfigs != null : !this$executorConfigs.equals(other$executorConfigs)) return false;
        return true;
    }

    @java.lang.SuppressWarnings("all")
    protected boolean canEqual(final java.lang.Object other) {
        return other instanceof AsyncServiceConfigModel;
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("all")
    public int hashCode() {
        final int PRIME = 59;
        int result = 1;
        final java.lang.Object $dataSource = this.getDataSource();
        result = result * PRIME + ($dataSource == null ? 43 : $dataSource.hashCode());
        final java.lang.Object $defaultExecutorConfig = this.getDefaultExecutorConfig();
        result = result * PRIME + ($defaultExecutorConfig == null ? 43 : $defaultExecutorConfig.hashCode());
        final java.lang.Object $executorConfigs = this.getExecutorConfigs();
        result = result * PRIME + ($executorConfigs == null ? 43 : $executorConfigs.hashCode());
        return result;
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("all")
    public java.lang.String toString() {
        return "AsyncServiceConfigModel(dataSource=" + this.getDataSource() + ", defaultExecutorConfig=" + this.getDefaultExecutorConfig() + ", executorConfigs=" + this.getExecutorConfigs() + ")";
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy