Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小五666\n哈哈
Rocketmq
提交
10d84bbe
R
Rocketmq
项目概览
小五666\n哈哈
/
Rocketmq
与 Fork 源项目一致
Fork自
Apache RocketMQ / Rocketmq
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rocketmq
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
10d84bbe
编写于
12月 29, 2018
作者:
D
dongeforever
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish the watch test
上级
be83a9a3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
69 addition
and
8 deletion
+69
-8
acl/pom.xml
acl/pom.xml
+17
-0
acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionLoader.java
.../org/apache/rocketmq/acl/plain/PlainPermissionLoader.java
+4
-2
acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java
...ache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java
+1
-1
acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionLoaderTest.java
.../apache/rocketmq/acl/plain/PlainPermissionLoaderTest.java
+4
-5
acl/src/test/resources/conf/watch/plain_acl_watch.yml
acl/src/test/resources/conf/watch/plain_acl_watch.yml
+9
-0
acl/src/test/resources/logback-test.xml
acl/src/test/resources/logback-test.xml
+34
-0
未找到文件。
acl/pom.xml
浏览文件 @
10d84bbe
...
...
@@ -49,5 +49,22 @@
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-classic
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-core
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
</project>
acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionLoader.java
浏览文件 @
10d84bbe
...
...
@@ -44,7 +44,7 @@ import org.apache.rocketmq.logging.InternalLoggerFactory;
public
class
PlainPermissionLoader
{
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
BROKER
_LOGGER_NAME
);
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
COMMON
_LOGGER_NAME
);
private
static
final
String
DEFAULT_PLAIN_ACL_FILE
=
"/conf/plain_acl.yml"
;
...
...
@@ -102,7 +102,7 @@ public class PlainPermissionLoader {
int
fileIndex
=
fileName
.
lastIndexOf
(
"/"
)
+
1
;
String
watchDirectory
=
fileName
.
substring
(
0
,
fileIndex
);
final
String
watchFileName
=
fileName
.
substring
(
fileIndex
);
log
.
info
(
"watch directory is {} , watch
directory
file name is {} "
,
fileHome
+
File
.
separator
+
watchDirectory
,
watchFileName
);
log
.
info
(
"watch directory is {} , watch file name is {} "
,
fileHome
+
File
.
separator
+
watchDirectory
,
watchFileName
);
final
WatchService
watcher
=
FileSystems
.
getDefault
().
newWatchService
();
Path
p
=
Paths
.
get
(
fileHome
+
File
.
separator
+
watchDirectory
);
...
...
@@ -119,6 +119,8 @@ public class PlainPermissionLoader {
&&
(
StandardWatchEventKinds
.
ENTRY_MODIFY
.
equals
(
event
.
kind
())
||
StandardWatchEventKinds
.
ENTRY_CREATE
.
equals
(
event
.
kind
())))
{
log
.
info
(
"{} make a difference change is : {}"
,
watchFileName
,
event
.
toString
());
//TODO do a retain
//Clearing the info, may result in a non-available time
PlainPermissionLoader
.
this
.
clearPermissionInfo
();
initialize
();
}
...
...
acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java
浏览文件 @
10d84bbe
...
...
@@ -27,7 +27,7 @@ import org.apache.rocketmq.logging.InternalLoggerFactory;
public
class
RemoteAddressStrategyFactory
{
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
BROKER
_LOGGER_NAME
);
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
COMMON
_LOGGER_NAME
);
public
static
final
NullRemoteAddressStrategy
NULL_NET_ADDRESS_STRATEGY
=
new
NullRemoteAddressStrategy
();
...
...
acl/src/test/java/org/apache/rocketmq/acl/plain/PlainPermissionLoaderTest.java
浏览文件 @
10d84bbe
...
...
@@ -223,20 +223,19 @@ public class PlainPermissionLoaderTest {
FileWriter
writer
=
new
FileWriter
(
transport
);
writer
.
write
(
"accounts:\r\n"
);
writer
.
write
(
"- accessKey: rocketmq\r\n"
);
writer
.
write
(
"- accessKey:
watch
rocketmq\r\n"
);
writer
.
write
(
" secretKey: 12345678\r\n"
);
writer
.
write
(
" whiteRemoteAddress: 127.0.0.1\r\n"
);
writer
.
write
(
" admin: true\r\n"
);
writer
.
flush
();
writer
.
close
();
System
.
out
.
println
(
System
.
getProperty
(
"rocketmq.acl.plain.file"
));
PlainPermissionLoader
plainPermissionLoader
=
new
PlainPermissionLoader
();
Assert
.
assertTrue
(
plainPermissionLoader
.
isWatchStart
());
{
Map
<
String
,
PlainAccessResource
>
plainAccessResourceMap
=
(
Map
<
String
,
PlainAccessResource
>)
FieldUtils
.
readDeclaredField
(
plainPermissionLoader
,
"plainAccessResourceMap"
,
true
);
PlainAccessResource
accessResource
=
plainAccessResourceMap
.
get
(
"rocketmq"
);
PlainAccessResource
accessResource
=
plainAccessResourceMap
.
get
(
"
watch
rocketmq"
);
Assert
.
assertNotNull
(
accessResource
);
Assert
.
assertEquals
(
accessResource
.
getSecretKey
(),
"12345678"
);
Assert
.
assertTrue
(
accessResource
.
isAdmin
());
...
...
@@ -244,7 +243,7 @@ public class PlainPermissionLoaderTest {
}
writer
=
new
FileWriter
(
new
File
(
fileName
),
true
);
writer
.
write
(
"- accessKey: rocketmq1\r\n"
);
writer
.
write
(
"- accessKey:
watch
rocketmq1\r\n"
);
writer
.
write
(
" secretKey: 88888888\r\n"
);
writer
.
write
(
" whiteRemoteAddress: 127.0.0.1\r\n"
);
writer
.
write
(
" admin: false\r\n"
);
...
...
@@ -254,7 +253,7 @@ public class PlainPermissionLoaderTest {
UtilAll
.
sleep
(
1000
);
{
Map
<
String
,
PlainAccessResource
>
plainAccessResourceMap
=
(
Map
<
String
,
PlainAccessResource
>)
FieldUtils
.
readDeclaredField
(
plainPermissionLoader
,
"plainAccessResourceMap"
,
true
);
PlainAccessResource
accessResource
=
plainAccessResourceMap
.
get
(
"rocketmq1"
);
PlainAccessResource
accessResource
=
plainAccessResourceMap
.
get
(
"
watch
rocketmq1"
);
Assert
.
assertNotNull
(
accessResource
);
Assert
.
assertEquals
(
accessResource
.
getSecretKey
(),
"88888888"
);
Assert
.
assertFalse
(
accessResource
.
isAdmin
());
...
...
acl/src/test/resources/conf/watch/plain_acl_watch.yml
0 → 100644
浏览文件 @
10d84bbe
accounts
:
-
accessKey
:
watchrocketmq
secretKey
:
12345678
whiteRemoteAddress
:
127.0.0.1
admin
:
true
-
accessKey
:
watchrocketmq1
secretKey
:
88888888
whiteRemoteAddress
:
127.0.0.1
admin
:
false
acl/src/test/resources/logback-test.xml
0 → 100644
浏览文件 @
10d84bbe
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<configuration>
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder>
<pattern>
%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n
</pattern>
<charset
class=
"java.nio.charset.Charset"
>
UTF-8
</charset>
</encoder>
</appender>
<logger
name=
"RocketmqCommon"
level=
"INFO"
additivity=
"false"
>
<appender-ref
ref=
"STDOUT"
/>
</logger>
<root
level=
"INFO"
>
<appender-ref
ref=
"STDOUT"
/>
</root>
</configuration>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录