File tree Expand file tree Collapse file tree 6 files changed +22
-20
lines changed
eventmesh-storage-api/src/main/java/org/apache/eventmesh/api/admin
eventmesh-storage-rocketmq/src/main/java/org/apache/eventmesh/storage/rocketmq/admin
eventmesh-storage-standalone/src
main/java/org/apache/eventmesh/storage/standalone/admin
test/java/org/apache/eventmesh/storage/standalone/admin Expand file tree Collapse file tree 6 files changed +22
-20
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public interface Admin extends LifeCycle {
3737 /**
3838 * Initializes admin api service.
3939 */
40- void init (Properties keyValue ) throws Exception ;
40+ void init (Properties properties ) throws Exception ;
4141
4242 /**
4343 * Get the list of topics.
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ public class RocketMQAdmin implements Admin {
5959 private int numOfQueue = 4 ;
6060 private int queuePermission = 6 ;
6161
62- public RocketMQAdmin (Properties properties ) {
62+ public RocketMQAdmin () {
6363 isStarted = new AtomicBoolean (false );
6464
6565 ConfigService configService = ConfigService .getInstance ();
@@ -98,7 +98,8 @@ public void shutdown() {
9898 }
9999
100100 @ Override
101- public void init (Properties keyValue ) throws Exception {
101+ public void init (Properties properties ) {
102+
102103 }
103104
104105 @ Override
@@ -163,11 +164,11 @@ public void deleteTopic(String topicName) throws Exception {
163164 }
164165
165166 @ Override
166- public List <CloudEvent > getEvent (String topicName , int offset , int length ) throws Exception {
167+ public List <CloudEvent > getEvent (String topicName , int offset , int length ) {
167168 return null ;
168169 }
169170
170171 @ Override
171- public void publish (CloudEvent cloudEvent ) throws Exception {
172+ public void publish (CloudEvent cloudEvent ) {
172173 }
173174}
Original file line number Diff line number Diff line change 2929
3030public class RocketMQAdminAdaptor implements Admin {
3131
32- private RocketMQAdmin admin ;
32+ private final RocketMQAdmin admin ;
3333
3434 public RocketMQAdminAdaptor () {
35+ admin = new RocketMQAdmin ();
3536 }
3637
3738 @ Override
@@ -55,8 +56,8 @@ public void shutdown() {
5556 }
5657
5758 @ Override
58- public void init (Properties keyValue ) throws Exception {
59- admin = new RocketMQAdmin ( keyValue );
59+ public void init (Properties properties ) throws Exception {
60+ admin . init ( properties );
6061 }
6162
6263 @ Override
@@ -75,12 +76,12 @@ public void deleteTopic(String topicName) throws Exception {
7576 }
7677
7778 @ Override
78- public List <CloudEvent > getEvent (String topicName , int offset , int length ) throws Exception {
79+ public List <CloudEvent > getEvent (String topicName , int offset , int length ) {
7980 return admin .getEvent (topicName , offset , length );
8081 }
8182
8283 @ Override
83- public void publish (CloudEvent cloudEvent ) throws Exception {
84+ public void publish (CloudEvent cloudEvent ) {
8485 admin .publish (cloudEvent );
8586 }
8687}
Original file line number Diff line number Diff line change 3737public class StandaloneAdmin implements Admin {
3838
3939 private final AtomicBoolean isStarted ;
40-
4140 private final StandaloneBroker standaloneBroker ;
4241
43- public StandaloneAdmin (Properties properties ) {
42+ public StandaloneAdmin () {
4443 this .standaloneBroker = StandaloneBroker .getInstance ();
4544 this .isStarted = new AtomicBoolean (false );
4645 }
@@ -66,20 +65,21 @@ public void shutdown() {
6665 }
6766
6867 @ Override
69- public void init (Properties keyValue ) throws Exception {
68+ public void init (Properties properties ) throws Exception {
69+
7070 }
7171
7272 @ Override
7373 public List <TopicProperties > getTopic () throws Exception {
7474 ConcurrentHashMap <TopicMetadata , MessageQueue > messageContainer = this .standaloneBroker .getMessageContainer ();
7575 List <TopicProperties > topicList = new ArrayList <>();
76- for ( TopicMetadata topicMetadata : messageContainer .keySet ()) {
76+ messageContainer .keySet (). forEach ( topicMetadata -> {
7777 MessageQueue messageQueue = messageContainer .get (topicMetadata );
7878 topicList .add (new TopicProperties (
7979 topicMetadata .getTopicName (),
8080 messageQueue .getPutIndex () - messageQueue .getTakeIndex ()
8181 ));
82- }
82+ });
8383 topicList .sort (Comparator .comparing (t -> t .name ));
8484 return topicList ;
8585 }
Original file line number Diff line number Diff line change 2929
3030public class StandaloneAdminAdaptor implements Admin {
3131
32- private StandaloneAdmin admin ;
32+ private final StandaloneAdmin admin ;
3333
3434 public StandaloneAdminAdaptor () {
35+ admin = new StandaloneAdmin ();
3536 }
3637
3738 @ Override
@@ -55,8 +56,8 @@ public void shutdown() {
5556 }
5657
5758 @ Override
58- public void init (Properties keyValue ) throws Exception {
59- admin = new StandaloneAdmin ( keyValue );
59+ public void init (Properties properties ) throws Exception {
60+ admin . init ( properties );
6061 }
6162
6263 @ Override
Original file line number Diff line number Diff line change 3030import org .apache .eventmesh .storage .standalone .broker .model .MessageEntity ;
3131
3232import java .util .List ;
33- import java .util .Properties ;
3433
3534import org .junit .Assert ;
3635import org .junit .Before ;
@@ -115,7 +114,7 @@ private void initStaticInstance() {
115114 try (MockedStatic <StandaloneBroker > standaloneBrokerMockedStatic = Mockito .mockStatic (StandaloneBroker .class )) {
116115 standaloneBrokerMockedStatic .when (StandaloneBroker ::getInstance ).thenReturn (standaloneBroker );
117116 Mockito .when (standaloneBroker .getMessageContainer ()).thenReturn (createDefaultMessageContainer ());
118- standaloneAdmin = new StandaloneAdmin (new Properties () );
117+ standaloneAdmin = new StandaloneAdmin ();
119118 }
120119 }
121120}
You can’t perform that action at this time.
0 commit comments