Skip to content

Commit

Permalink
[ISSUE apache#7943] Add bazel config for auth module and fix bazel te…
Browse files Browse the repository at this point in the history
…st (apache#7944)
  • Loading branch information
dingshuangxi888 authored Mar 20, 2024
1 parent c727f3a commit f2dd5b0
Show file tree
Hide file tree
Showing 15 changed files with 107 additions and 58 deletions.
77 changes: 77 additions & 0 deletions auth/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
load("//bazel:GenTestRules.bzl", "GenTestRules")

java_library(
name = "auth",
srcs = glob(["src/main/java/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//acl",
"//common",
"//remoting",
"//srvutil",
"@maven//:commons_codec_commons_codec",
"@maven//:org_apache_commons_commons_lang3",
"@maven//:commons_collections_commons_collections",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:org_apache_rocketmq_rocketmq_proto",
"@maven//:org_slf4j_slf4j_api",
"@maven//:com_github_ben_manes_caffeine_caffeine",
"@maven//:io_grpc_grpc_api",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:com_google_protobuf_protobuf_java_util",
"@maven//:io_netty_netty_all",
"@maven//:com_google_guava_guava",
"@maven//:org_apache_rocketmq_rocketmq_rocksdb",
],
)

java_library(
name = "tests",
srcs = glob(["src/test/java/**/*.java"]),
resources = glob(["src/test/resources/**/*.yml"]),
visibility = ["//visibility:public"],
deps = [
":auth",
"//acl",
"//:test_deps",
"//common",
"//remoting",
"@maven//:commons_codec_commons_codec",
"@maven//:org_apache_commons_commons_lang3",
"@maven//:commons_collections_commons_collections",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:org_apache_rocketmq_rocketmq_proto",
"@maven//:org_slf4j_slf4j_api",
"@maven//:com_github_ben_manes_caffeine_caffeine",
"@maven//:io_grpc_grpc_api",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:com_google_protobuf_protobuf_java_util",
"@maven//:io_netty_netty_all",
"@maven//:com_google_guava_guava",
"@maven//:org_apache_rocketmq_rocketmq_rocksdb",
],
)

GenTestRules(
name = "GeneratedTestRules",
test_files = glob(["src/test/java/**/*Test.java"]),
deps = [
":tests",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.rocketmq.auth.authentication.manager;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSON;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.apache.commons.lang3.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.rocketmq.auth.config.AuthConfig;
import org.apache.rocketmq.common.config.ConfigRocksDBStorage;
import org.apache.rocketmq.common.thread.ThreadPoolMonitor;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.rocksdb.RocksIterator;

public class LocalAuthenticationMetadataProvider implements AuthenticationMetadataProvider {
Expand Down Expand Up @@ -152,7 +151,7 @@ public UserCacheLoader(ConfigRocksDBStorage storage) {
}

@Override
public User load(@NonNull String username) {
public User load(String username) {
try {
byte[] keyBytes = username.getBytes(StandardCharsets.UTF_8);
byte[] valueBytes = storage.get(keyBytes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.apache.rocketmq.auth.config.AuthConfig;
import org.apache.rocketmq.common.config.ConfigRocksDBStorage;
import org.apache.rocketmq.common.thread.ThreadPoolMonitor;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.rocksdb.RocksIterator;

public class LocalAuthorizationMetadataProvider implements AuthorizationMetadataProvider {
Expand Down Expand Up @@ -181,7 +180,7 @@ public AclCacheLoader(ConfigRocksDBStorage storage) {
}

@Override
public Acl load(@NonNull String subjectKey) {
public Acl load(String subjectKey) {
try {
byte[] keyBytes = subjectKey.getBytes(StandardCharsets.UTF_8);
Subject subject = Subject.of(subjectKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.common.resource.ResourcePattern;
import org.apache.rocketmq.common.resource.ResourceType;
import org.apache.rocketmq.logging.org.slf4j.Logger;
import org.apache.rocketmq.logging.org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AuthMigrator {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.apache.rocketmq.remoting.protocol.RequestCode;
import org.apache.rocketmq.remoting.protocol.header.SendMessageRequestHeader;
import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -110,7 +109,7 @@ public String asLongText() {
}

@Override
public int compareTo(@NotNull ChannelId o) {
public int compareTo(ChannelId o) {
return 0;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
import org.apache.rocketmq.remoting.protocol.heartbeat.ConsumerData;
import org.apache.rocketmq.remoting.protocol.heartbeat.HeartbeatData;
import org.apache.rocketmq.remoting.protocol.heartbeat.SubscriptionData;
import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -499,7 +498,7 @@ public String asLongText() {
}

@Override
public int compareTo(@NotNull ChannelId o) {
public int compareTo(ChannelId o) {
return 0;
}
};
Expand Down
4 changes: 4 additions & 0 deletions broker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ java_library(
visibility = ["//visibility:public"],
deps = [
"//acl",
"//auth",
"//client",
"//common",
"//filter",
Expand All @@ -30,6 +31,7 @@ java_library(
"//store",
"@maven//:ch_qos_logback_logback_classic",
"@maven//:com_alibaba_fastjson",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:com_github_luben_zstd_jni",
"@maven//:com_google_guava_guava",
"@maven//:com_googlecode_concurrentlinkedhashmap_concurrentlinkedhashmap_lru",
Expand Down Expand Up @@ -73,12 +75,14 @@ java_library(
":broker",
"//:test_deps",
"//acl",
"//auth",
"//client",
"//common",
"//filter",
"//remoting",
"//store",
"@maven//:com_alibaba_fastjson",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:com_google_guava_guava",
"@maven//:io_netty_netty_all",
"@maven//:org_apache_commons_commons_lang3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,11 @@ public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException {

public MessageExt viewMessage(String topic, String msgId)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
MessageId messageId = null;
MessageId messageId;
try {
messageId = MessageDecoder.decodeMessageId(msgId);
return this.mQClientFactory.getMQAdminImpl().viewMessage(topic, msgId);
} catch (Exception ignored) {
} catch (Exception e) {
throw new MQClientException(ResponseCode.NO_MESSAGE, "query message by id finished, but no message.");
}
return this.mQClientFactory.getMQClientAPIImpl().viewMessage(NetworkUtil.socketAddress2String(messageId.getAddress()),
topic, messageId.getOffset(), timeoutMillis);
Expand Down
6 changes: 6 additions & 0 deletions common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ java_library(
visibility = ["//visibility:public"],
deps = [
"@maven//:com_alibaba_fastjson",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:com_github_luben_zstd_jni",
"@maven//:com_google_guava_guava",
"@maven//:commons_collections_commons_collections",
Expand All @@ -36,6 +37,8 @@ java_library(
"@maven//:io_opentelemetry_opentelemetry_sdk_common",
"@maven//:io_opentelemetry_opentelemetry_sdk_metrics",
"@maven//:io_opentelemetry_opentelemetry_exporter_logging_otlp",
"@maven//:io_grpc_grpc_api",
"@maven//:io_grpc_grpc_context",
"@maven//:org_apache_commons_commons_lang3",
"@maven//:org_lz4_lz4_java",
"@maven//:io_github_aliyunmq_rocketmq_slf4j_api",
Expand All @@ -53,6 +56,7 @@ java_library(
"//:test_deps",
"@maven//:com_google_guava_guava",
"@maven//:com_alibaba_fastjson",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:io_netty_netty_all",
"@maven//:io_opentelemetry_opentelemetry_api",
"@maven//:io_opentelemetry_opentelemetry_context",
Expand All @@ -61,6 +65,8 @@ java_library(
"@maven//:io_opentelemetry_opentelemetry_sdk",
"@maven//:io_opentelemetry_opentelemetry_sdk_common",
"@maven//:io_opentelemetry_opentelemetry_sdk_metrics",
"@maven//:io_grpc_grpc_api",
"@maven//:io_grpc_grpc_context",
"@maven//:org_apache_commons_commons_lang3",
],
resources = glob(["src/test/resources/certs/*.pem"]) + glob(["src/test/resources/certs/*.key"])
Expand Down
6 changes: 5 additions & 1 deletion proxy/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ java_library(
visibility = ["//visibility:public"],
deps = [
"//acl",
"//auth",
"//broker",
"//client",
"//common",
Expand All @@ -30,6 +31,7 @@ java_library(
"@maven//:ch_qos_logback_logback_classic",
"@maven//:ch_qos_logback_logback_core",
"@maven//:com_alibaba_fastjson",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:com_github_ben_manes_caffeine_caffeine",
"@maven//:com_github_luben_zstd_jni",
"@maven//:com_google_code_findbugs_jsr305",
Expand Down Expand Up @@ -78,7 +80,8 @@ java_library(
],
visibility = ["//visibility:public"],
deps = [
"//acl",
"//acl",
"//auth",
":proxy",
"//:test_deps",
"//broker",
Expand All @@ -87,6 +90,7 @@ java_library(
"//remoting",
"@maven//:ch_qos_logback_logback_core",
"@maven//:com_alibaba_fastjson",
"@maven//:com_alibaba_fastjson2_fastjson2",
"@maven//:com_github_ben_manes_caffeine_caffeine",
"@maven//:com_google_guava_guava",
"@maven//:com_google_protobuf_protobuf_java",
Expand Down
2 changes: 2 additions & 0 deletions remoting/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ java_library(
"@maven//:io_github_aliyunmq_rocketmq_slf4j_api",
"@maven//:io_github_aliyunmq_rocketmq_logback_classic",
"@maven//:commons_collections_commons_collections",
"@maven//:org_reflections_reflections",
],
)

Expand Down Expand Up @@ -66,6 +67,7 @@ java_library(
"@maven//:org_apache_tomcat_annotations_api",
"@maven//:org_apache_commons_commons_lang3",
"@maven//:org_jetbrains_annotations",
"@maven//:org_reflections_reflections",
],
resources = glob(["src/test/resources/certs/*.pem"]) + glob(["src/test/resources/certs/*.key"])
)
Expand Down
4 changes: 3 additions & 1 deletion tieredstore/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ java_library(
"@maven//:com_alibaba_fastjson",
"@maven//:org_apache_rocketmq_rocketmq_rocksdb",
"@maven//:commons_collections_commons_collections",
"@maven//:org_slf4j_slf4j_api",
],
)

Expand All @@ -68,8 +69,9 @@ java_library(
"@maven//:org_apache_commons_commons_lang3",
"@maven//:com_google_guava_guava",
"@maven//:io_github_aliyunmq_rocketmq_slf4j_api",
"@maven//:io_github_aliyunmq_rocketmq_shaded_slf4j_api_bridge",
"@maven//:io_github_aliyunmq_rocketmq_logback_classic",
"@maven//:net_java_dev_jna_jna",
"@maven//:org_slf4j_slf4j_api",
],
)

Expand Down

This file was deleted.

This file was deleted.

0 comments on commit f2dd5b0

Please sign in to comment.