package com.mpush.tools.config;

import java.lang.reflect.Method;

import com.mpush.tools.redis.RedisGroup;
import org.aeonbits.owner.Converter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mpush.tools.redis.RedisNode;

public class RedisGroupConverter implements Converter<RedisGroup>{

	private static final Logger log = LoggerFactory.getLogger(RedisGroupConverter.class);
	
	@Override
	public RedisGroup convert(Method method, String input) {
		
		log.warn("method:"+method.getName()+","+input);
		

        RedisGroup group = new RedisGroup();
		
		String[] chunks = input.split(",");
        for (String chunk : chunks) {
            String[] entry = chunk.split(":");
            String ip = entry[0].trim();
            String port = entry[1].trim();
            String password = null;
            if(entry.length >=3){
            	password = entry[2].trim();
            }
            RedisNode node = new RedisNode(ip, Integer.parseInt(port), password);
            group.addRedisNode(node);
        }
		return group;
	}
	
	

}

@@ -767,32 +767,149 @@
 ntry%5B1%5D.trim();%0A
+            // %E5%A6%82%E6%9E%9C%E9%85%8D%E7%BD%AE%E4%BA%86redis%E5%AF%86%E7%A0%81%EF%BC%88redis_group = 111.1.57.148:6379:ShineMoIpo%EF%BC%89%E6%89%8D%E8%AE%BE%E7%BD%AE%E5%AF%86%E7%A0%81%0A            // %E5%90%A6%E5%88%99%E5%AF%86%E7%A0%81%E4%B8%BA%E7%A9%BA%EF%BC%8CJedisPool%E5%8F%AF%E4%BB%A5%E5%85%BC%E5%AE%B9%E4%B8%A4%E7%A7%8D%E6%83%85%E5%86%B5%0A
             Stri
@@ -927,16 +927,17 @@
  = null;
+ 
 %0A       

add comment