zoukankan      html  css  js  c++  java
  • GetProperties

    package com.hgx.test.common;

    import java.util.HashMap;
    import java.util.Map;
    import java.util.Properties;

    import com.hgx.test.common.ReadProperties;

    /**
    * GetProperties
    *
    * @author sasou <admin@php-gene.com> web:http://www.php-gene.com/
    * @version 1.0.0
    */

    public class GetProperties {
    // debug
    public static int system_debug = 0;
    // canal
    public static CanalData canal = new CanalData();

    // target
    public static Map<String, TargetData> target = new HashMap<String, TargetData>();

    public GetProperties() {
    // read config
    ReadProperties readProperties = new ReadProperties();
    Properties p = readProperties.readProperties();
    String tmp = "";

    // debug
    tmp = String.valueOf(p.get("system.debug"));
    if (!"".equals(tmp)) {
    system_debug = Integer.parseInt(tmp);
    }

    // canal
    tmp = String.valueOf(p.get("canal.ip"));
    if (!"".equals(tmp)) {
    canal.setIp(tmp);
    }

    tmp = String.valueOf(p.get("canal.port"));
    if (!"".equals(tmp)) {
    canal.setPort(Integer.parseInt(tmp));
    }
    canal.setDestination(String.valueOf(p.get("canal.destination")));
    canal.setUsername(String.valueOf(p.get("canal.username")));
    canal.setPassword(String.valueOf(p.get("canal.password")));

    tmp = String.valueOf(p.get("canal.filter"));
    if (!"".equals(tmp)) {
    canal.setFilter(tmp);
    }

    // target
    if (canal.destination != null) {
    int num = canal.destination.length;
    if (num > 0) {
    for (int i = 0; i < num; i++) {
    TargetData target_tmp = new TargetData();

    tmp = String.valueOf(p.get(canal.destination[i] + ".target_type"));
    if (!"".equals(tmp)) {
    target_tmp.setType(tmp);
    }
    tmp = String.valueOf(p.get(canal.destination[i] + ".target_ip"));
    if (!"".equals(tmp)) {
    target_tmp.setIp(tmp);
    }
    if ("kafka".equals(target_tmp.type)) {
    target_tmp.setPort(9092);
    }
    if ("redis".equals(target_tmp.type)) {
    target_tmp.setPort(6379);
    }
    if ("elasticsearch".equals(target_tmp.type)) {
    target_tmp.setPort(9200);
    }
    tmp = String.valueOf(p.get(canal.destination[i] + ".target_port"));
    if (!"".equals(tmp)) {
    target_tmp.setPort(Integer.parseInt(tmp));
    }
    target.put(canal.destination[i], target_tmp);
    }
    }
    }
    }
    }
  • 相关阅读:
    经典isset,empty,is_null三个的用法与区别,最详细的讲解
    TP框架分页bootstrap冲突问题
    TP框架右下角运行时间
    TP6的跳转坑 和cmd报错 php版本和composer扩展坑
    TP5.1模板继承
    TP5.1模型关联
    Oracle语句
    ajaxform和ajaxgrid获取数据源、添加数据
    confirm和alert弹窗
    UEP-弹窗
  • 原文地址:https://www.cnblogs.com/heguoxiu/p/10135327.html
Copyright © 2011-2022 走看看