コード例 #1
0
 private Map<String, Properties> getSlaveProperties() throws IOException {
   final Map<String, Properties> ret = new HashMap<String, Properties>();
   final Properties properties =
       com.taobao.metamorphosis.utils.Utils.getResourceAsProperties(
           "gregor_slave.properties", "GBK");
   ret.put("gregor", properties);
   return ret;
 }
コード例 #2
0
 private Map<String, Properties> getMasterProperties() throws IOException {
   final Map<String, Properties> ret = new HashMap<String, Properties>();
   final Properties properties =
       com.taobao.metamorphosis.utils.Utils.getResourceAsProperties(
           "samsa_master.properties", "GBK");
   ret.put("samsa", properties);
   return ret;
 }
コード例 #3
0
  // 单元测试要是通不过,请修改resources/zk.properties里的zk地址
  private ZKConfig loadZkConfigFromDiamond() {
    // 尝试从diamond获取
    // this.diamondManager =
    // new DefaultDiamondManager(this.metaClientConfig.getDiamondZKGroup(),
    // this.metaClientConfig.getDiamondZKDataId(), new ManagerListener() {
    // @Override
    // public void receiveConfigInfo(final String configInfo) {
    // log.info("Receiving new diamond zk config:" + configInfo);
    // log.info("Closing zk client");
    // MetaMessageSessionFactory.this.zkClient.close();
    // final Properties properties = new Properties();
    // try {
    // properties.load(new StringReader(configInfo));
    // final ZKConfig zkConfig = DiamondUtils.getZkConfig(properties);
    // MetaMessageSessionFactory.this.zkClient.close();
    // Thread.sleep(zkConfig.zkSyncTimeMs);
    // log.info("Initialize zk client...");
    // final ZkClient newClient =
    // new ZkClient(zkConfig.zkConnect, zkConfig.zkSessionTimeoutMs,
    // zkConfig.zkConnectionTimeoutMs, new ZkUtils.StringSerializer());
    // log.info("Begin to notify zkClient has been changed...");
    // MetaMessageSessionFactory.this.metaZookeeper.setZkClient(newClient);
    // MetaMessageSessionFactory.this.notifyZkClientChanged(newClient);
    // MetaMessageSessionFactory.this.zkClient = newClient;
    // log.info("End notifying zkClient has been changed...");
    // }
    // catch (final Exception e) {
    // log.error("从diamond加载zk配置失败", e);
    // }
    // }
    //
    //
    // @Override
    // public Executor getExecutor() {
    // return null;
    // }
    // });
    try {
      final Properties properties = Utils.getResourceAsProperties("zk.properties", "GBK");
      final ZKConfig zkConfig = new ZKConfig();
      if (StringUtils.isNotBlank(properties.getProperty("zk.zkConnect"))) {
        zkConfig.zkConnect = properties.getProperty("zk.zkConnect");
      }

      if (StringUtils.isNotBlank(properties.getProperty("zk.zkSessionTimeoutMs"))) {
        zkConfig.zkSessionTimeoutMs =
            Integer.parseInt(properties.getProperty("zk.zkSessionTimeoutMs"));
      }

      if (StringUtils.isNotBlank(properties.getProperty("zk.zkConnectionTimeoutMs"))) {
        zkConfig.zkConnectionTimeoutMs =
            Integer.parseInt(properties.getProperty("zk.zkConnectionTimeoutMs"));
      }

      if (StringUtils.isNotBlank(properties.getProperty("zk.zkSyncTimeMs"))) {
        zkConfig.zkSyncTimeMs = Integer.parseInt(properties.getProperty("zk.zkSyncTimeMs"));
      }

      return zkConfig; // DiamondUtils.getZkConfig(this.diamondManager,
      // 10000);
    } catch (final IOException e) {
      log.error("zk配置失败", e);
      return null;
    }
  }