Skip to content

Commit

Permalink
管理端分组和策略优化
Browse files Browse the repository at this point in the history
  • Loading branch information
iamazy committed Aug 25, 2020
1 parent 0d8befd commit 38c3edb
Showing 1 changed file with 5 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.joyqueue.nsr.TopicNameServerService;
import org.joyqueue.nsr.model.TopicQuery;
import org.joyqueue.service.BrokerGroupService;
import org.joyqueue.toolkit.util.ConvertUtils;
import org.joyqueue.util.NullUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -97,32 +98,10 @@ public String addTopic(Topic topic, List<TopicPartitionGroup> partitionGroups) {
try {
Field field = topicPolicy.getClass().getDeclaredField(entry.getKey());
field.setAccessible(true);
switch (field.getType().getTypeName()) {
case "java.lang.Integer": {
field.set(topicPolicy, Integer.parseInt(entry.getValue()));
break;
}
case "java.lang.Boolean": {
field.set(topicPolicy, Boolean.parseBoolean(entry.getValue()));
break;
}
case "java.lang.Long": {
field.set(topicPolicy, Long.parseLong(entry.getValue()));
break;
}
case "java.lang.Double": {
field.set(topicPolicy, Double.parseDouble(entry.getValue()));
break;
}
case "java.lang.Float": {
field.set(topicPolicy, Float.parseFloat(entry.getValue()));
break;
}
default: {
field.set(topicPolicy, entry.getValue());
}
}
} catch (NoSuchFieldException | IllegalAccessException ignore) { }
field.set(topicPolicy, ConvertUtils.convert(entry.getValue(), field.getType()));
} catch (NoSuchFieldException | IllegalAccessException | UnsupportedOperationException e) {
logger.error("", e);
}
}
}
nsrTopic.setPolicy(topicPolicy);
Expand Down

0 comments on commit 38c3edb

Please sign in to comment.