package com.its.pis.global;

import com.its.pis.entity.TbVdsCtlr;
import io.netty.channel.Channel;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ConcurrentHashMap;

@Slf4j
@Getter
@Setter
public class AppRepository {
    private static AppRepository _instance = null;

    public ConcurrentHashMap<String, TbVdsCtlr> ctlrMap = null;
    public ConcurrentHashMap<String, TbVdsCtlr> ctlrIpMap = null;
    public ConcurrentHashMap<Channel, TbVdsCtlr> ctlrChannelMap = null;
    // TODO
    //public ConcurrentHashMap<String, TbVdsCtlr> ctlrKeyMap = null;

    public static AppRepository getInstance() {
        if (_instance == null) {
            synchronized (AppRepository.class) {
                if (_instance == null)
                    _instance = new AppRepository();
            }
        }
        return _instance;
    }

    public AppRepository() {
        this.ctlrMap = new ConcurrentHashMap<>();
        this.ctlrIpMap = new ConcurrentHashMap<>();
        this.ctlrChannelMap = new ConcurrentHashMap<>();
        // TODO
        //this.ctlrKeyMap = new ConcurrentHashMap<>();
    }

}
