Skip to content

Commit

Permalink
Merge pull request #698 from wtt40122/master
Browse files Browse the repository at this point in the history
feat:udate rockemq acl
  • Loading branch information
gaoxh authored Sep 8, 2023
2 parents cfc9260 + c43c3e9 commit 0571378
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@
import com.xiaomi.youpin.docean.plugin.IPlugin;
import com.xiaomi.youpin.docean.plugin.config.Config;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.acl.common.AclClientRPCHook;
import org.apache.rocketmq.acl.common.SessionCredentials;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragely;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.remoting.RPCHook;

import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -62,8 +67,10 @@ public void init(Set<? extends Class<?>> classSet, Ioc ioc) {
}

private DefaultMQProducer initDefaultMQProducer(RocketmqConfig config) {
DefaultMQProducer producer = null;
if (!config.getAk().equals("") && !config.getSk().equals("")) {
DefaultMQProducer producer;
if (StringUtils.isNotEmpty(config.getAk()) && StringUtils.isNotEmpty(config.getSk())) {
RPCHook rpcHook = new AclClientRPCHook(new SessionCredentials(config.getAk(), config.getSk()));
producer = new DefaultMQProducer(config.getProducerGroup(), rpcHook, true, null);
} else {
producer = new DefaultMQProducer(config.getProducerGroup());
}
Expand All @@ -79,8 +86,10 @@ private DefaultMQProducer initDefaultMQProducer(RocketmqConfig config) {
}

private DefaultMQPushConsumer initDefaultMQPushConsumer(RocketmqConfig config) {
DefaultMQPushConsumer defaultMQPushConsumer = new DefaultMQPushConsumer(config.getConsumerGroup());
if (!config.getAk().equals("") && !config.getSk().equals("")) {
DefaultMQPushConsumer defaultMQPushConsumer;
if (StringUtils.isNotEmpty(config.getAk()) && StringUtils.isNotEmpty(config.getSk())) {
RPCHook rpcHook = new AclClientRPCHook(new SessionCredentials(config.getAk(), config.getSk()));
defaultMQPushConsumer = new DefaultMQPushConsumer(config.getConsumerGroup(), rpcHook, new AllocateMessageQueueAveragely());
} else {
defaultMQPushConsumer = new DefaultMQPushConsumer(config.getConsumerGroup());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
@Getter
public enum LogParserEnum {

SEPARATOR_PARSE(2, "Separator"),
CUSTOM_PARSE(5, "Custom scripts");
SEPARATOR_PARSE(2, "分割符"),
CUSTOM_PARSE(5, "自定义脚本");

private final Integer code;
private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@
*/
@Getter
public enum LogTypeEnum {
APP_LOG_MULTI(1, "Multi-line application log",
APP_LOG_MULTI(1, "多行应用日志",
1, 1,
"Logs starting in time format can be collected in multiple lines, such as 2022 or [2022], etc., if they do not start with time, multiple lines will be grouped together"),
NGINX(2, "nginx log", 3, 1, "Single-line acquisition, which is collected into a column by each line of the file"),
OPENTELEMETRY(3, "opentelemetry log", 4, 0, "Multi-line acquisition, collected into a fixed topic"),
DOCKER(4, "docker log", 5, 1, ""),
APP_LOG_SIGNAL(8, "Single-line application log", 2, 1, "Single-line acquisition, which is collected into a column by each line of the file"),
ORIGIN_LOG(9, "Raw format log", 6, 1, "Raw data is written to a fixed topic, and HERA is not consumed"),
FREE(0, "Custom log", 7, 1, "Single-line acquisition, which is collected into a column by each line of the file");
"时间格式开始的日志可以多行采集,例如2022或者[2022]等,如果不是以时间开始,则会多行糅合在一起"),
NGINX(2, "nginx日志", 3, 1, "单行采集,按文件的每一行采集成一列"),
OPENTELEMETRY(3, "opentelemetry日志", 4, 0, "多行采集,采集到固定的topic中"),
DOCKER(4, "docker日志", 5, 1, ""),
APP_LOG_SIGNAL(8, "单行应用日志", 2, 1, "单行采集,按文件的每一行采集成一列"),
ORIGIN_LOG(9, "原始格式日志", 6, 1, "向固定的topic中写入原始数据,hera不消费"),
FREE(0, "自定义日志", 7, 1, "单行采集,按文件的每一行采集成一列");


private final Integer type;
private final String typeName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@Getter
public enum MachineRegionEnum {

CN_MACHINE("cn", "Continental machine", Arrays.asList("c1", "c2", "c3"));
CN_MACHINE("cn", "大陆机房", Arrays.asList("c1", "c2", "c3"));

private final String en;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
@Getter
public enum MachineTypeEnum {

CONTAINER_MACHINE(0, "Container"),
PHYSICAL_MACHINE(1, "Physical Machines");
CONTAINER_MACHINE(0, "容器"),
PHYSICAL_MACHINE(1, "物理机");

private final Integer type;
private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package com.xiaomi.mone.log.manager.service.bind;

import com.xiaomi.mone.log.api.enums.LogTypeEnum;

/**
* @author wtt
* @version 1.0
Expand Down

0 comments on commit 0571378

Please sign in to comment.