forked from oceanbase/odc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
475 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
libs/db-browser/src/main/java/com/oceanbase/tools/dbbrowser/model/DBUserDetailIdentity.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,33 @@ | ||
/* | ||
* Copyright (c) 2023 OceanBase. | ||
* | ||
* Licensed 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 com.oceanbase.tools.dbbrowser.model; | ||
|
||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
/** | ||
* @author yaobin | ||
* @date 2023-09-27 | ||
* @since 4.2.3 | ||
*/ | ||
@Data | ||
@EqualsAndHashCode(callSuper = false) | ||
public class DBUserDetailIdentity extends DBObjectIdentity { | ||
|
||
private DBUserLockStatusType userStatus; | ||
} | ||
|
36 changes: 36 additions & 0 deletions
36
libs/db-browser/src/main/java/com/oceanbase/tools/dbbrowser/model/DBUserLockStatusType.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,36 @@ | ||
/* | ||
* Copyright (c) 2023 OceanBase. | ||
* | ||
* Licensed 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 com.oceanbase.tools.dbbrowser.model; | ||
|
||
/** | ||
* @author yaobin | ||
* @date 2023-09-27 | ||
* @since 4.2.3 | ||
*/ | ||
public enum DBUserLockStatusType { | ||
|
||
LOCKED, | ||
|
||
UNLOCKED; | ||
|
||
public static DBUserLockStatusType from(int lockedStatus) { | ||
if (lockedStatus != 1 && lockedStatus != 0) { | ||
throw new IllegalArgumentException("invalid Statue"); | ||
} | ||
return lockedStatus == 1 ? LOCKED : UNLOCKED; | ||
} | ||
} |
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
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
85 changes: 85 additions & 0 deletions
85
...rc/test/java/com/oceanbase/odc/service/onlineschemachange/DBUserLogStatusMonitorTest.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,85 @@ | ||
/* | ||
* Copyright (c) 2023 OceanBase. | ||
* | ||
* Licensed 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 com.oceanbase.odc.service.onlineschemachange; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import com.oceanbase.odc.TestConnectionUtil; | ||
import com.oceanbase.odc.core.session.ConnectionSession; | ||
import com.oceanbase.odc.core.shared.constant.ConnectType; | ||
import com.oceanbase.odc.service.onlineschemachange.monitor.DBUserLogStatusMonitorFactory; | ||
import com.oceanbase.odc.service.onlineschemachange.monitor.DBUserMonitor; | ||
|
||
/** | ||
* @author yaobin | ||
* @date 2023-10-10 | ||
* @since 4.2.3 | ||
*/ | ||
public class DBUserLogStatusMonitorTest { | ||
|
||
private static ConnectionSession obMySqlConnSession; | ||
private static ConnectionSession obOracleConnSession; | ||
|
||
@BeforeClass | ||
public static void startUp() { | ||
obMySqlConnSession = TestConnectionUtil.getTestConnectionSession(ConnectType.OB_MYSQL); | ||
obOracleConnSession = TestConnectionUtil.getTestConnectionSession(ConnectType.OB_ORACLE); | ||
} | ||
|
||
@Test | ||
public void test_monitor_ob_mysql_successful() throws InterruptedException { | ||
List<String> toMonitorUsers = new ArrayList<>(); | ||
toMonitorUsers.add("root"); | ||
doMonitor(toMonitorUsers, obMySqlConnSession); | ||
} | ||
|
||
@Test | ||
public void test_monitor_ob_oracle_successful() throws InterruptedException { | ||
List<String> toMonitorUsers = new ArrayList<>(); | ||
toMonitorUsers.add("SYS"); | ||
doMonitor(toMonitorUsers, obOracleConnSession); | ||
} | ||
|
||
private static void doMonitor(List<String> toMonitorUsers, ConnectionSession connectionSession) | ||
throws InterruptedException { | ||
Integer period = 200; | ||
Integer timeout = 5000; | ||
TimeUnit timeUnit = TimeUnit.MILLISECONDS; | ||
DBUserLogStatusMonitorFactory monitorFactory = new DBUserLogStatusMonitorFactory(null); | ||
DBUserMonitor dbUserMonitor = monitorFactory.generateDBUserMonitor(connectionSession, | ||
toMonitorUsers, period, timeout, timeUnit); | ||
|
||
ExecutorService executorService = Executors.newSingleThreadExecutor(); | ||
try { | ||
executorService.execute(dbUserMonitor); | ||
Assert.assertFalse(dbUserMonitor.isDone()); | ||
Thread.sleep(5000 - 1); | ||
dbUserMonitor.stop(); | ||
Assert.assertTrue(dbUserMonitor.isDone()); | ||
} finally { | ||
executorService.shutdownNow(); | ||
} | ||
} | ||
} |
Oops, something went wrong.