-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix-16903] Fix monitor page cannot display well
- Loading branch information
1 parent
2ae4402
commit 4afbcd4
Showing
16 changed files
with
196 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...egistry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/KeyUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.apache.dolphinscheduler.plugin.registry.jdbc; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import lombok.experimental.UtilityClass; | ||
|
||
@UtilityClass | ||
public class KeyUtils { | ||
|
||
/** | ||
* Whether the path is the parent path of the child | ||
* <p> Only the parentPath is the parent path of the childPath, return true | ||
* <p> If the parentPath is equal to the childPath, return false | ||
*/ | ||
public static boolean isParent(final String parentPath, final String childPath) { | ||
if (StringUtils.isEmpty(parentPath)) { | ||
throw new IllegalArgumentException("Invalid parent path string " + parentPath); | ||
} | ||
if (StringUtils.isEmpty(childPath)) { | ||
throw new IllegalArgumentException("Invalid child path string " + childPath); | ||
} | ||
// 使用"/"分割字符串,判断childPath是否是parentPath的子路径 | ||
final String[] parentSplit = parentPath.split("/"); | ||
final String[] childSplit = childPath.split("/"); | ||
if (parentSplit.length >= childSplit.length) { | ||
return false; | ||
} | ||
for (int i = 0; i < parentSplit.length; i++) { | ||
if (!parentSplit[i].equals(childSplit[i])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
|
||
} | ||
|
||
public static boolean isSamePath(final String path1, final String path2) { | ||
return removeLastSlash(path1).equals(path2); | ||
} | ||
|
||
private static String removeLastSlash(final String path) { | ||
checkNotNull(path, "path is null"); | ||
if (!path.startsWith("/")) { | ||
throw new IllegalArgumentException("Invalid path string " + path); | ||
} | ||
int length = path.length() - 1; | ||
while (length >= 0 && path.charAt(length) == '/') { | ||
length--; | ||
} | ||
if (length == -1) { | ||
return "/"; | ||
} | ||
return path.substring(0, length + 1); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...try-jdbc/src/test/java/org/apache/dolphinscheduler/plugin/registry/jdbc/KeyUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.apache.dolphinscheduler.plugin.registry.jdbc; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class KeyUtilsTest { | ||
|
||
@Test | ||
void isParent() { | ||
assertFalse(KeyUtils.isParent("/a", "/b")); | ||
assertFalse(KeyUtils.isParent("/a", "/a")); | ||
assertFalse(KeyUtils.isParent("/b/c", "/b")); | ||
assertFalse(KeyUtils.isParent("/b/c", "/b/")); | ||
|
||
assertTrue(KeyUtils.isParent("/", "/b")); | ||
assertTrue(KeyUtils.isParent("/b/c", "/b/c/d")); | ||
assertTrue(KeyUtils.isParent("/b", "/b/c/d")); | ||
assertTrue(KeyUtils.isParent("/b/", "/b/c/d")); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.