Skip to content

Commit

Permalink
FIXED REVIEW OPTIONS
Browse files Browse the repository at this point in the history
  • Loading branch information
chengyouling committed Dec 23, 2024
1 parent 3cd3a94 commit 06de347
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
import io.sermant.core.plugin.agent.declarer.InterceptDeclarer;
import io.sermant.core.plugin.agent.matcher.ClassMatcher;
import io.sermant.core.plugin.agent.matcher.MethodMatcher;
import io.sermant.mq.grayscale.rocketmq.interceptor.client51.RocketMq51ConsumerConstructorInterceptor;
import io.sermant.mq.grayscale.rocketmq.interceptor.client51.RocketMqV51ConsumerConstructorInterceptor;

/**
* 5.1.x client lite pull consumer set gray consumer group declarer
*
* @author chengyouling
* @since 2024-09-07
**/
public class RocketMq51LitePullConsumerConstructorDeclarer extends AbstractPluginDeclarer {
public class RocketMqV51LitePullConsumerConstructorDeclarer extends AbstractPluginDeclarer {
private static final String ENHANCE_CLASS = "org.apache.rocketmq.client.consumer.DefaultLitePullConsumer";

private static final String[] METHOD_PARAM_TYPES = {
Expand All @@ -46,7 +46,7 @@ public InterceptDeclarer[] getInterceptDeclarers(ClassLoader classLoader) {
return new InterceptDeclarer[]{
InterceptDeclarer.build(MethodMatcher.isConstructor()
.and(MethodMatcher.paramTypesEqual(METHOD_PARAM_TYPES)),
new RocketMq51ConsumerConstructorInterceptor())
new RocketMqV51ConsumerConstructorInterceptor())
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
import io.sermant.core.plugin.agent.declarer.InterceptDeclarer;
import io.sermant.core.plugin.agent.matcher.ClassMatcher;
import io.sermant.core.plugin.agent.matcher.MethodMatcher;
import io.sermant.mq.grayscale.rocketmq.interceptor.client51.RocketMq51ConsumerConstructorInterceptor;
import io.sermant.mq.grayscale.rocketmq.interceptor.client51.RocketMqV51ConsumerConstructorInterceptor;

/**
* 5.1.x client pull consumer set gray consumer group declarer
*
* @author chengyouling
* @since 2024-09-07
**/
public class RocketMq51PullConsumerConstructorDeclarer extends AbstractPluginDeclarer {
public class RocketMqV51PullConsumerConstructorDeclarer extends AbstractPluginDeclarer {
private static final String ENHANCE_CLASS = "org.apache.rocketmq.client.consumer.DefaultMQPullConsumer";

private static final String[] METHOD_PARAM_TYPES = {
Expand All @@ -46,7 +46,7 @@ public InterceptDeclarer[] getInterceptDeclarers(ClassLoader classLoader) {
return new InterceptDeclarer[]{
InterceptDeclarer.build(MethodMatcher.isConstructor()
.and(MethodMatcher.paramTypesEqual(METHOD_PARAM_TYPES)),
new RocketMq51ConsumerConstructorInterceptor())
new RocketMqV51ConsumerConstructorInterceptor())
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
import io.sermant.core.plugin.agent.declarer.InterceptDeclarer;
import io.sermant.core.plugin.agent.matcher.ClassMatcher;
import io.sermant.core.plugin.agent.matcher.MethodMatcher;
import io.sermant.mq.grayscale.rocketmq.interceptor.client51.RocketMq51ConsumerConstructorInterceptor;
import io.sermant.mq.grayscale.rocketmq.interceptor.client51.RocketMqV51ConsumerConstructorInterceptor;

/**
* 5.1.x client push consumer set gray consumer group declarer
*
* @author chengyouling
* @since 2024-09-07
**/
public class RocketMq51PushConsumerConstructorDeclarer extends AbstractPluginDeclarer {
public class RocketMqV51PushConsumerConstructorDeclarer extends AbstractPluginDeclarer {
private static final String ENHANCE_CLASS = "org.apache.rocketmq.client.consumer.DefaultMQPushConsumer";

private static final String PARAMETER_STRING = "java.lang.String";
Expand All @@ -55,7 +55,7 @@ public InterceptDeclarer[] getInterceptDeclarers(ClassLoader classLoader) {
return new InterceptDeclarer[]{
InterceptDeclarer.build(MethodMatcher.isConstructor()
.and(MethodMatcher.paramTypesEqual(METHOD_PARAM_TYPES)),
new RocketMq51ConsumerConstructorInterceptor())
new RocketMqV51ConsumerConstructorInterceptor())
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @author chengyouling
* @since 2024-05-27
**/
public class RocketMq51ConsumerConstructorInterceptor extends AbstractInterceptor {
public class RocketMqV51ConsumerConstructorInterceptor extends AbstractInterceptor {
@Override
public ExecuteContext before(ExecuteContext context) throws Exception {
if (!MqGrayConfigCache.getCacheConfig().isEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ private RocketMqReflectUtils() {
* @return groupList
*/
public static Set<String> getGroupList(Object groupList) {
Optional<Object> groupSets = ReflectUtils.invokeMethodWithNoneParameter(groupList, "getGroupList");
return groupSets.map(o -> (Set<String>) o).orElseGet(HashSet::new);
Optional<Object> groupSetsOpt = ReflectUtils.invokeMethodWithNoneParameter(groupList, "getGroupList");
return groupSetsOpt.map(groupSets -> (Set<String>) groupSets).orElseGet(HashSet::new);
}

/**
Expand All @@ -56,8 +56,8 @@ public static Set<String> getGroupList(Object groupList) {
* @return brokerDatas
*/
public static List<Object> getBrokerDatas(Object topicRouteData) {
Optional<Object> brokerDatas = ReflectUtils.invokeMethodWithNoneParameter(topicRouteData, "getBrokerDatas");
return brokerDatas.map(o -> (List<Object>) o).orElseGet(ArrayList::new);
Optional<Object> brokerDatasOpt = ReflectUtils.invokeMethodWithNoneParameter(topicRouteData, "getBrokerDatas");
return brokerDatasOpt.map(brokerDatas -> (List<Object>) brokerDatas).orElseGet(ArrayList::new);
}

/**
Expand All @@ -67,8 +67,8 @@ public static List<Object> getBrokerDatas(Object topicRouteData) {
* @return brokerAddrs
*/
public static Map<Long, String> getBrokerAddrs(Object brokerData) {
Optional<Object> brokerAddrs = ReflectUtils.invokeMethodWithNoneParameter(brokerData, "getBrokerAddrs");
return brokerAddrs.map(o -> (Map<Long, String>) o).orElseGet(HashMap::new);
Optional<Object> brokerAddrsOpt = ReflectUtils.invokeMethodWithNoneParameter(brokerData, "getBrokerAddrs");
return brokerAddrsOpt.map(brokerAddrs -> (Map<Long, String>) brokerAddrs).orElseGet(HashMap::new);
}

/**
Expand All @@ -78,9 +78,9 @@ public static Map<Long, String> getBrokerAddrs(Object brokerData) {
* @return expressionType
*/
public static String getExpressionType(Object subscriptionData) {
Optional<Object> expressionType = ReflectUtils.invokeMethodWithNoneParameter(subscriptionData,
Optional<Object> expressionTypeOpt = ReflectUtils.invokeMethodWithNoneParameter(subscriptionData,
"getExpressionType");
return expressionType.map(o -> (String) o).orElse("");
return expressionTypeOpt.map(expressionType -> (String) expressionType).orElse("");
}

/**
Expand All @@ -103,8 +103,8 @@ public static void setSubscriptionDatae(Object subscriptionData, String methodNa
* @return topic
*/
public static String getTopic(Object subscriptionData) {
Optional<Object> topic = ReflectUtils.invokeMethodWithNoneParameter(subscriptionData, "getTopic");
return topic.map(o -> (String) o).orElse("");
Optional<Object> topicOpt = ReflectUtils.invokeMethodWithNoneParameter(subscriptionData, "getTopic");
return topicOpt.map(topic -> (String) topic).orElse("");
}

/**
Expand All @@ -114,8 +114,8 @@ public static String getTopic(Object subscriptionData) {
* @return subString
*/
public static String getSubString(Object subscriptionData) {
Optional<Object> substr = ReflectUtils.invokeMethodWithNoneParameter(subscriptionData, "getSubString");
return substr.map(o -> (String) o).orElse("");
Optional<Object> substrOpt = ReflectUtils.invokeMethodWithNoneParameter(subscriptionData, "getSubString");
return substrOpt.map(substr -> (String) substr).orElse("");
}

/**
Expand All @@ -125,19 +125,19 @@ public static String getSubString(Object subscriptionData) {
* @return tagsSet
*/
public static Set<String> getTagsSet(Object subscriptionData) {
Optional<Object> tagsSet = ReflectUtils.invokeMethodWithNoneParameter(subscriptionData, "getTagsSet");
return tagsSet.map(o -> (Set<String>) o).orElse(new HashSet<>());
Optional<Object> tagsSetOpt = ReflectUtils.invokeMethodWithNoneParameter(subscriptionData, "getTagsSet");
return tagsSetOpt.map(tagsSet -> (Set<String>) tagsSet).orElse(new HashSet<>());
}

/**
* get code set
*
* @param subscriptionData subscriptionData
* @return tagsSet
* @return codeSet
*/
public static Set<Integer> getCodeSet(Object subscriptionData) {
Optional<Object> tagsSet = ReflectUtils.invokeMethodWithNoneParameter(subscriptionData, "getCodeSet");
return tagsSet.map(o -> (Set<Integer>) o).orElse(new HashSet<>());
Optional<Object> codeSetOpt = ReflectUtils.invokeMethodWithNoneParameter(subscriptionData, "getCodeSet");
return codeSetOpt.map(codeSet -> (Set<Integer>) codeSet).orElse(new HashSet<>());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ io.sermant.mq.grayscale.rocketmq.declarer.RocketMqPullConsumerConstructorDeclare
io.sermant.mq.grayscale.rocketmq.declarer.RocketMqPushConsumerConstructorDeclarer

# UPPER 5.1.x client
io.sermant.mq.grayscale.rocketmq.declarer.client51.RocketMq51LitePullConsumerConstructorDeclarer
io.sermant.mq.grayscale.rocketmq.declarer.client51.RocketMq51PullConsumerConstructorDeclarer
io.sermant.mq.grayscale.rocketmq.declarer.client51.RocketMq51PushConsumerConstructorDeclarer
io.sermant.mq.grayscale.rocketmq.declarer.client51.RocketMqV51LitePullConsumerConstructorDeclarer
io.sermant.mq.grayscale.rocketmq.declarer.client51.RocketMqV51PullConsumerConstructorDeclarer
io.sermant.mq.grayscale.rocketmq.declarer.client51.RocketMqV51PushConsumerConstructorDeclarer

0 comments on commit 06de347

Please sign in to comment.