Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor DatabaseMetaDataNodePath #34273

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class DatabaseMetaDataNodePath {

private static final String ROOT_NODE = "metadata";
private static final String ROOT_NODE = "/metadata";

private static final String SCHEMAS_NODE = "schemas";

Expand All @@ -48,7 +48,7 @@ public final class DatabaseMetaDataNodePath {
* @return meta data root path
*/
public static String getRootPath() {
return String.join("/", "", ROOT_NODE);
return ROOT_NODE;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class GlobalNodePath {

private static final String RULE_NODE = "rules";
private static final String RULE_NODE = "/rules";

private static final String PROPS_NODE = "props";
private static final String PROPS_NODE = "/props";

private static final String VERSIONS_NODE = "versions";

Expand All @@ -40,7 +40,7 @@ public final class GlobalNodePath {
* @return global rule root path
*/
public static String getRuleRootPath() {
return String.join("/", "", RULE_NODE);
return RULE_NODE;
}

/**
Expand Down Expand Up @@ -90,7 +90,7 @@ public static String getRuleActiveVersionPath(final String ruleName) {
* @return properties path
*/
public static String getPropsRootPath() {
return String.join("/", "", PROPS_NODE);
return PROPS_NODE;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ProcessNodePath {

private static final String ROOT_NODE = "execution_nodes";
private static final String ROOT_NODE = "/execution_nodes";

/**
* Get process ID root path.
Expand All @@ -35,7 +35,7 @@ public final class ProcessNodePath {
* @return process ID root path
*/
public static String getRootPath(final String processId) {
return String.join("/", "", ROOT_NODE, processId);
return String.join("/", ROOT_NODE, processId);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class QualifiedDataSourceNodePath {

private static final String ROOT_NODE = "nodes";
private static final String ROOT_NODE = "/nodes";

private static final String QUALIFIED_DATA_SOURCES_NODE = "qualified_data_sources";

Expand All @@ -43,7 +43,7 @@ public final class QualifiedDataSourceNodePath {
* @return qualified data source root path
*/
public static String getRootPath() {
return String.join("/", "", ROOT_NODE, QUALIFIED_DATA_SOURCES_NODE);
return String.join("/", ROOT_NODE, QUALIFIED_DATA_SOURCES_NODE);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ReservationNodePath {

private static final String ROOT_NODE = "reservation";
private static final String ROOT_NODE = "/reservation";

private static final String WORKER_ID_NODE = "worker_id";

Expand All @@ -37,6 +37,6 @@ public final class ReservationNodePath {
* @return worker id reservation path
*/
public static String getWorkerIdReservationPath(final int workerId) {
return String.join("/", "", ROOT_NODE, WORKER_ID_NODE, String.valueOf(workerId));
return String.join("/", ROOT_NODE, WORKER_ID_NODE, String.valueOf(workerId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ShardingSphereDataNodePath {

private static final String ROOT_NODE = "statistics";
private static final String ROOT_NODE = "/statistics";

private static final String DATABASES_NODE = "databases";

Expand All @@ -46,7 +46,7 @@ public final class ShardingSphereDataNodePath {
* @return database root path
*/
public static String getDatabasesRootPath() {
return String.join("/", "", ROOT_NODE, DATABASES_NODE);
return String.join("/", ROOT_NODE, DATABASES_NODE);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class StatesNodePath {

private static final String ROOT_NODE = "states";
private static final String ROOT_NODE = "/states";

private static final String CLUSTER_STATE_NODE = "cluster_state";

Expand All @@ -42,7 +42,7 @@ public final class StatesNodePath {
* @return cluster state path
*/
public static String getClusterStatePath() {
return String.join("/", "", ROOT_NODE, CLUSTER_STATE_NODE);
return String.join("/", ROOT_NODE, CLUSTER_STATE_NODE);
}

/**
Expand All @@ -51,7 +51,7 @@ public static String getClusterStatePath() {
* @return listener assisted node path
*/
public static String getListenerAssistedNodePath() {
return String.join("/", "", ROOT_NODE, LISTENER_ASSISTED_NODE);
return String.join("/", ROOT_NODE, LISTENER_ASSISTED_NODE);
}

/**
Expand All @@ -73,6 +73,6 @@ public static Optional<String> findDatabaseNameByListenerAssistedNodePath(final
* @return database name listener assisted node path
*/
public static String getDatabaseNameListenerAssistedNodePath(final String databaseName) {
return String.join("/", "", ROOT_NODE, LISTENER_ASSISTED_NODE, databaseName);
return String.join("/", ROOT_NODE, LISTENER_ASSISTED_NODE, databaseName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ void assertGetRowUniqueKeyUniqueKeyNotFoundScenario() {

@Test
void assertGetJobPath() {
assertThat(ShardingSphereDataNodePath.getJobPath(), is("statistics/job"));
assertThat(ShardingSphereDataNodePath.getJobPath(), is("/statistics/job"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void initialize() {

private CoordinatorRegistryCenter createRegistryCenter(final ModeConfiguration modeConfig) {
ClusterPersistRepositoryConfiguration repositoryConfig = (ClusterPersistRepositoryConfiguration) modeConfig.getRepository();
String namespace = String.join("/", repositoryConfig.getNamespace(), ShardingSphereDataNodePath.getJobPath());
String namespace = repositoryConfig.getNamespace() + ShardingSphereDataNodePath.getJobPath();
CoordinatorRegistryCenter result = new ZookeeperRegistryCenter(getZookeeperConfiguration(repositoryConfig, namespace));
result.init();
return result;
Expand Down
Loading