Skip to content

Commit

Permalink
fix: separate database accessor to metadata-jdbc module (#540)
Browse files Browse the repository at this point in the history
Signed-off-by: Li Zhanhui <[email protected]>
  • Loading branch information
lizhanhui authored Nov 1, 2023
1 parent aadbbb4 commit 0192e88
Show file tree
Hide file tree
Showing 119 changed files with 746 additions and 481 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import com.automq.rocketmq.common.api.DataStore;
import com.automq.rocketmq.common.config.BrokerConfig;
import com.automq.rocketmq.common.util.Lifecycle;
import com.automq.rocketmq.controller.ControllerServiceImpl;
import com.automq.rocketmq.controller.MetadataStoreBuilder;
import com.automq.rocketmq.controller.metadata.MetadataStore;
import com.automq.rocketmq.controller.server.ControllerServiceImpl;
import com.automq.rocketmq.controller.server.MetadataStoreBuilder;
import com.automq.rocketmq.controller.MetadataStore;
import com.automq.rocketmq.metadata.DefaultProxyMetadataService;
import com.automq.rocketmq.metadata.DefaultStoreMetadataService;
import com.automq.rocketmq.metadata.api.ProxyMetadataService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.automq.rocketmq.cli.tools.CliUtils;
import com.automq.rocketmq.common.PrefixThreadFactory;
import com.automq.rocketmq.controller.exception.ControllerException;
import com.automq.rocketmq.controller.metadata.GrpcControllerClient;
import com.automq.rocketmq.controller.client.GrpcControllerClient;
import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.Meter;
import com.codahale.metrics.MetricRegistry;
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main/java/com/automq/rocketmq/cli/CreateGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import apache.rocketmq.controller.v1.CreateGroupRequest;
import apache.rocketmq.controller.v1.GroupType;
import apache.rocketmq.controller.v1.SubscriptionMode;
import com.automq.rocketmq.controller.metadata.ControllerClient;
import com.automq.rocketmq.controller.metadata.GrpcControllerClient;
import com.automq.rocketmq.controller.ControllerClient;
import com.automq.rocketmq.controller.client.GrpcControllerClient;
import java.util.concurrent.Callable;
import picocli.CommandLine;

Expand Down
2 changes: 1 addition & 1 deletion cli/src/main/java/com/automq/rocketmq/cli/CreateTopic.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import apache.rocketmq.controller.v1.CreateTopicRequest;
import apache.rocketmq.controller.v1.MessageType;
import com.automq.rocketmq.common.util.DurationUtil;
import com.automq.rocketmq.controller.metadata.GrpcControllerClient;
import com.automq.rocketmq.controller.client.GrpcControllerClient;
import java.util.concurrent.Callable;
import picocli.CommandLine;

Expand Down
4 changes: 2 additions & 2 deletions cli/src/main/java/com/automq/rocketmq/cli/DeleteGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package com.automq.rocketmq.cli;

import com.automq.rocketmq.controller.metadata.ControllerClient;
import com.automq.rocketmq.controller.metadata.GrpcControllerClient;
import com.automq.rocketmq.controller.ControllerClient;
import com.automq.rocketmq.controller.client.GrpcControllerClient;
import java.util.concurrent.Callable;
import picocli.CommandLine;

Expand Down
4 changes: 2 additions & 2 deletions cli/src/main/java/com/automq/rocketmq/cli/DeleteTopic.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package com.automq.rocketmq.cli;

import com.automq.rocketmq.controller.metadata.ControllerClient;
import com.automq.rocketmq.controller.metadata.GrpcControllerClient;
import com.automq.rocketmq.controller.ControllerClient;
import com.automq.rocketmq.controller.client.GrpcControllerClient;
import java.util.concurrent.Callable;
import picocli.CommandLine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import apache.rocketmq.controller.v1.Cluster;
import apache.rocketmq.controller.v1.DescribeClusterRequest;
import com.automq.rocketmq.controller.metadata.ControllerClient;
import com.automq.rocketmq.controller.metadata.GrpcControllerClient;
import com.automq.rocketmq.controller.ControllerClient;
import com.automq.rocketmq.controller.client.GrpcControllerClient;
import java.util.concurrent.Callable;
import picocli.CommandLine;

Expand Down
4 changes: 2 additions & 2 deletions cli/src/main/java/com/automq/rocketmq/cli/DescribeGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package com.automq.rocketmq.cli;

import apache.rocketmq.controller.v1.ConsumerGroup;
import com.automq.rocketmq.controller.metadata.ControllerClient;
import com.automq.rocketmq.controller.metadata.GrpcControllerClient;
import com.automq.rocketmq.controller.ControllerClient;
import com.automq.rocketmq.controller.client.GrpcControllerClient;
import de.vandermeer.asciitable.AT_Row;
import de.vandermeer.asciitable.AsciiTable;
import de.vandermeer.asciitable.CWC_LongestLine;
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main/java/com/automq/rocketmq/cli/DescribeTopic.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package com.automq.rocketmq.cli;

import apache.rocketmq.controller.v1.Topic;
import com.automq.rocketmq.controller.metadata.ControllerClient;
import com.automq.rocketmq.controller.metadata.GrpcControllerClient;
import com.automq.rocketmq.controller.ControllerClient;
import com.automq.rocketmq.controller.client.GrpcControllerClient;
import java.util.concurrent.Callable;
import picocli.CommandLine;

Expand Down
4 changes: 2 additions & 2 deletions cli/src/main/java/com/automq/rocketmq/cli/ListGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import apache.rocketmq.controller.v1.ConsumerGroup;
import apache.rocketmq.controller.v1.ListGroupReply;
import apache.rocketmq.controller.v1.ListGroupRequest;
import com.automq.rocketmq.controller.metadata.ControllerClient;
import com.automq.rocketmq.controller.metadata.GrpcControllerClient;
import com.automq.rocketmq.controller.ControllerClient;
import com.automq.rocketmq.controller.client.GrpcControllerClient;
import de.vandermeer.asciitable.AT_Row;
import de.vandermeer.asciitable.AsciiTable;
import de.vandermeer.asciitable.CWC_LongestLine;
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main/java/com/automq/rocketmq/cli/ListTopic.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import apache.rocketmq.controller.v1.ListTopicsRequest;
import apache.rocketmq.controller.v1.MessageType;
import apache.rocketmq.controller.v1.Topic;
import com.automq.rocketmq.controller.metadata.ControllerClient;
import com.automq.rocketmq.controller.metadata.GrpcControllerClient;
import com.automq.rocketmq.controller.ControllerClient;
import com.automq.rocketmq.controller.client.GrpcControllerClient;
import de.vandermeer.asciitable.AT_Row;
import de.vandermeer.asciitable.AsciiTable;
import de.vandermeer.asciitable.CWC_LongestLine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.automq.rocketmq.cli.tools.CliUtils;
import com.automq.rocketmq.common.PrefixThreadFactory;
import com.automq.rocketmq.controller.exception.ControllerException;
import com.automq.rocketmq.controller.metadata.GrpcControllerClient;
import com.automq.rocketmq.controller.client.GrpcControllerClient;
import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main/java/com/automq/rocketmq/cli/TerminateNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import apache.rocketmq.controller.v1.TerminateNodeReply;
import apache.rocketmq.controller.v1.TerminateNodeRequest;
import com.automq.rocketmq.controller.metadata.ControllerClient;
import com.automq.rocketmq.controller.metadata.GrpcControllerClient;
import com.automq.rocketmq.controller.ControllerClient;
import com.automq.rocketmq.controller.client.GrpcControllerClient;
import io.grpc.stub.StreamObserver;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main/java/com/automq/rocketmq/cli/UpdateGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import apache.rocketmq.controller.v1.GroupType;
import apache.rocketmq.controller.v1.UpdateGroupRequest;
import com.automq.rocketmq.controller.metadata.ControllerClient;
import com.automq.rocketmq.controller.metadata.GrpcControllerClient;
import com.automq.rocketmq.controller.ControllerClient;
import com.automq.rocketmq.controller.client.GrpcControllerClient;
import com.google.common.base.Strings;
import java.util.concurrent.Callable;
import picocli.CommandLine;
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main/java/com/automq/rocketmq/cli/UpdateTopic.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import apache.rocketmq.controller.v1.Topic;
import apache.rocketmq.controller.v1.UpdateTopicRequest;
import com.automq.rocketmq.controller.metadata.ControllerClient;
import com.automq.rocketmq.controller.metadata.GrpcControllerClient;
import com.automq.rocketmq.controller.ControllerClient;
import com.automq.rocketmq.controller.client.GrpcControllerClient;
import com.google.common.base.Strings;
import java.util.concurrent.Callable;
import picocli.CommandLine;
Expand Down
30 changes: 3 additions & 27 deletions controller/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,40 +29,16 @@
<artifactId>rocketmq-controller</artifactId>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>rocketmq-proto</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>rocketmq-common</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>5.0.1</version>
</dependency>

<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.13</version>
</dependency>

<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.1.0</version>
<exclusions>
<exclusion>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</exclusion>
</exclusions>
<groupId>com.automq.rocketmq</groupId>
<artifactId>metadata-jdbc</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.automq.rocketmq.controller.metadata;
package com.automq.rocketmq.controller;

import apache.rocketmq.controller.v1.CloseStreamReply;
import apache.rocketmq.controller.v1.CloseStreamRequest;
Expand Down Expand Up @@ -47,7 +47,7 @@
import apache.rocketmq.controller.v1.UpdateGroupRequest;
import apache.rocketmq.controller.v1.UpdateTopicRequest;
import com.automq.rocketmq.controller.exception.ControllerException;
import com.automq.rocketmq.controller.metadata.database.dao.Node;
import com.automq.rocketmq.metadata.dao.Node;

import io.grpc.stub.StreamObserver;
import java.io.Closeable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.automq.rocketmq.controller.metadata;
package com.automq.rocketmq.controller;

import apache.rocketmq.controller.v1.AssignmentStatus;
import apache.rocketmq.controller.v1.Cluster;
Expand All @@ -34,11 +34,13 @@
import com.automq.rocketmq.common.api.DataStore;
import com.automq.rocketmq.common.config.ControllerConfig;
import com.automq.rocketmq.controller.exception.ControllerException;
import com.automq.rocketmq.controller.metadata.database.dao.Group;
import com.automq.rocketmq.controller.metadata.database.dao.Lease;
import com.automq.rocketmq.controller.metadata.database.dao.Node;
import com.automq.rocketmq.controller.metadata.database.dao.QueueAssignment;
import com.automq.rocketmq.controller.metadata.database.dao.Stream;
import com.automq.rocketmq.controller.server.store.BrokerNode;
import com.automq.rocketmq.controller.server.store.Role;
import com.automq.rocketmq.metadata.dao.Group;
import com.automq.rocketmq.metadata.dao.Lease;
import com.automq.rocketmq.metadata.dao.Node;
import com.automq.rocketmq.metadata.dao.QueueAssignment;
import com.automq.rocketmq.metadata.dao.Stream;
import java.io.Closeable;
import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -207,7 +209,7 @@ CompletableFuture<Pair<List<S3StreamObject>, List<S3WALObject>>> listObjects(lon

boolean maintainLeadershipWithSharedLock(SqlSession session);

void applyTopicChange(List<com.automq.rocketmq.controller.metadata.database.dao.Topic> topics);
void applyTopicChange(List<com.automq.rocketmq.metadata.dao.Topic> topics);

void applyAssignmentChange(List<QueueAssignment> assignments);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.automq.rocketmq.controller.metadata;
package com.automq.rocketmq.controller.client;

import apache.rocketmq.controller.v1.CloseStreamReply;
import apache.rocketmq.controller.v1.CloseStreamRequest;
Expand Down Expand Up @@ -72,8 +72,9 @@
import apache.rocketmq.controller.v1.UpdateTopicReply;
import apache.rocketmq.controller.v1.UpdateTopicRequest;
import com.automq.rocketmq.common.config.GrpcClientConfig;
import com.automq.rocketmq.controller.ControllerClient;
import com.automq.rocketmq.controller.exception.ControllerException;
import com.automq.rocketmq.controller.metadata.database.dao.Node;
import com.automq.rocketmq.metadata.dao.Node;
import com.google.common.base.Strings;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.automq.rocketmq.controller;
package com.automq.rocketmq.controller.server;

import apache.rocketmq.controller.v1.CloseStreamReply;
import apache.rocketmq.controller.v1.CloseStreamRequest;
Expand Down Expand Up @@ -78,9 +78,9 @@
import apache.rocketmq.controller.v1.UpdateTopicReply;
import apache.rocketmq.controller.v1.UpdateTopicRequest;
import com.automq.rocketmq.common.PrefixThreadFactory;
import com.automq.rocketmq.controller.MetadataStore;
import com.automq.rocketmq.controller.exception.ControllerException;
import com.automq.rocketmq.controller.metadata.MetadataStore;
import com.automq.rocketmq.controller.tasks.TerminationStageTask;
import com.automq.rocketmq.controller.server.tasks.TerminationStageTask;
import com.google.protobuf.TextFormat;
import io.grpc.Context;
import io.grpc.stub.StreamObserver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* limitations under the License.
*/

package com.automq.rocketmq.controller;
package com.automq.rocketmq.controller.server;

import com.automq.rocketmq.common.config.ControllerConfig;
import com.automq.rocketmq.controller.metadata.GrpcControllerClient;
import com.automq.rocketmq.controller.metadata.MetadataStore;
import com.automq.rocketmq.controller.metadata.database.DefaultMetadataStore;
import com.automq.rocketmq.controller.MetadataStore;
import com.automq.rocketmq.controller.client.GrpcControllerClient;
import com.automq.rocketmq.controller.server.store.DefaultMetadataStore;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* limitations under the License.
*/

package com.automq.rocketmq.controller.metadata;
package com.automq.rocketmq.controller.server.store;

import com.automq.rocketmq.common.config.ControllerConfig;
import com.automq.rocketmq.controller.metadata.database.dao.Node;
import com.automq.rocketmq.metadata.dao.Node;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.TimeUnit;
Expand Down
Loading

0 comments on commit 0192e88

Please sign in to comment.