Skip to content
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
2 changes: 1 addition & 1 deletion client
Submodule client updated 37 files
+1 −1 src/component/CommonTable/index.tsx
+256 −234 src/component/OSSDragger2/index.tsx
+14 −14 src/component/Task/AsyncTask/CreateModal/index.tsx
+1 −1 src/component/Task/CreateModals.tsx
+1 −1 src/component/Task/DataArchiveTask/CreateModal/index.tsx
+1 −1 src/component/Task/DataClearTask/CreateModal/index.tsx
+1 −39 src/component/Task/DetailModal.tsx
+3 −1 src/component/Task/PartitionTask/CreateModal/index.tsx
+114 −45 src/component/Task/StructureComparisonTask/DetailContent/index.tsx
+8 −1 src/component/Task/component/PartitionPolicyFormTable/PreviewSQLModal/index.less
+10 −7 src/component/Task/component/PartitionPolicyFormTable/PreviewSQLModal/index.tsx
+3 −1 src/component/Task/component/PartitionPolicyFormTable/configModal.tsx
+9 −3 src/component/Task/component/PartitionPolicyFormTable/index.tsx
+21 −8 src/component/Task/component/PartitionPolicyTable/ConfigTable.tsx
+12 −9 src/component/Task/component/PartitionPolicyTable/index.less
+3 −1 src/component/Task/component/PartitionPolicyTable/index.tsx
+9 −1 src/constant/record.ts
+8 −0 src/d.ts/index.ts
+6 −3 src/locales/must/strings/en-US.json
+6 −3 src/locales/must/strings/zh-CN.json
+6 −3 src/locales/must/strings/zh-TW.json
+8 −4 src/main/renderService/index.ts
+16 −4 src/main/utils/index.ts
+2 −2 src/page/Datasource/Datasource/NewDatasourceDrawer/index.tsx
+38 −3 src/page/Project/Database/index.tsx
+1 −1 src/page/Project/Sensitive/components/SensitiveColumn/components/ManualForm.tsx
+1 −1 src/page/Project/Sensitive/components/SensitiveColumn/components/SacnRule.tsx
+2 −0 src/page/Secure/Env/components/EnvironmentTable.tsx
+11 −3 src/page/Secure/Env/components/column.tsx
+6 −0 src/page/Secure/Env/components/index.less
+2 −0 src/page/Secure/Env/constant.ts
+12 −18 src/page/Secure/Record/RecordPage/component.tsx
+4 −0 src/page/Secure/RiskLevel/components/options.ts
+2 −2 src/page/Secure/components/FormRecordExportModal/index.tsx
+288 −275 src/page/Workspace/SideBar/ResourceTree/Nodes/table.tsx
+1 −1 src/page/Workspace/components/CreateTable/Columns/columns.tsx
+7 −3 src/page/Workspace/components/SessionContextWrap/SessionSelect/SessionDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ protected boolean isTimedOut() {

protected void validate() throws InvalidSessionException {
if (this.isTimedOut()) {
this.expire();
Date lastAccessTime = this.getLastAccessTime();
long timeout = this.getTimeoutMillis();
Serializable sessionId = this.getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.apache.commons.lang3.Validate;

import com.oceanbase.odc.common.util.ExceptionUtils;
import com.oceanbase.odc.core.authority.exception.InvalidSessionException;
import com.oceanbase.odc.core.authority.session.DelegateSecuritySession;
import com.oceanbase.odc.core.authority.session.SecuritySession;
Expand Down Expand Up @@ -234,7 +235,9 @@ private void forEachListener(Consumer<SecuritySessionEventListener> consumer) {
try {
consumer.accept(listener);
} catch (Throwable e) {
log.warn("Failed to call listener's method", e);
StackTraceElement element = Thread.currentThread().getStackTrace()[2];
log.warn("Failed to call listener {}#{}, error={}", listener.getClass().getName(),
element.getMethodName(), ExceptionUtils.getRootCauseReason(e));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.function.Consumer;
import java.util.function.Predicate;

import com.oceanbase.odc.common.util.ExceptionUtils;
import com.oceanbase.odc.core.datasource.DataSourceFactory;
import com.oceanbase.odc.core.shared.constant.ConnectType;
import com.oceanbase.odc.core.shared.constant.DialectType;
Expand Down Expand Up @@ -267,7 +268,9 @@ private void forEachListener(Consumer<ConnectionSessionEventListener> consumer)
try {
consumer.accept(listener);
} catch (Throwable e) {
log.warn("Failed to call listener's method", e);
StackTraceElement element = Thread.currentThread().getStackTrace()[2];
log.warn("Failed to call listener {}#{}, error={}", listener.getClass().getName(),
element.getMethodName(), ExceptionUtils.getRootCauseReason(e));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public abstract class BaseValidatedConnectionSessionManager extends BaseConnecti
private final TaskManager taskManager;
@Getter
private long scanIntervalMillis = SESSION_MANAGER_SCAN_INTERVAL_MILLIS;
private volatile boolean asynTaskHasBeenStarted = false;
private volatile boolean asyncTaskHasBeenStarted = false;
private final List<Predicate<ConnectionSession>> validators = new LinkedList<>();

public BaseValidatedConnectionSessionManager(@NonNull TaskManager taskManager) {
Expand All @@ -62,8 +62,8 @@ public void addSessionValidator(@NonNull Predicate<ConnectionSession> predicate)
}

public synchronized void enableAsyncRefreshSessionManager() {
if (!asynTaskHasBeenStarted) {
asynTaskHasBeenStarted = true;
if (!asyncTaskHasBeenStarted) {
asyncTaskHasBeenStarted = true;
taskManager.submit(new ConnectionSessionValidateTask(this, this.validators, scanIntervalMillis));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void run() {
sessions.stream().filter(s -> that.validatePredicates.stream().anyMatch(p -> !p.test(s)))
.forEach(session -> {
try {
log.info("Session failed to pass verification, session={}", session);
log.info("Session failed to pass verification, sessionId={}", session.getId());
session.expire();
} catch (Exception e) {
log.warn("Failed to remove a session from manager, sessionId={}", session.getId(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import org.apache.commons.io.FileUtils;

import com.oceanbase.odc.common.util.ExceptionUtils;
import com.oceanbase.odc.core.datasource.CloneableDataSourceFactory;
import com.oceanbase.odc.core.datasource.DataSourceFactory;
import com.oceanbase.odc.core.shared.constant.ConnectType;
Expand Down Expand Up @@ -166,7 +167,8 @@ public synchronized void expire() {
this.id, sessionLevelDir);
}
} catch (IOException exception) {
log.warn("Failed to delete session level directory, dir={}", sessionLevelDir, exception);
log.warn("Failed to delete session level directory, dir={}, sessionId={}",
sessionLevelDir, this.id, exception);
}
log.info("Connection session was closed successfully, sessionId={}", this.id);
}
Expand Down Expand Up @@ -261,7 +263,6 @@ protected boolean isTimedOut() {

protected void validate() throws ExpiredSessionException {
if (this.isTimedOut()) {
this.expire();
Date lastAccessTime = this.getLastAccessTime();
long timeout = this.getTimeoutMillis();
Serializable sessionId = this.getId();
Expand All @@ -285,9 +286,10 @@ private void closeDataSource() {
}
try {
((AutoCloseable) dataSource).close();
log.info("Datasource is closed successfully, name={}", key);
log.info("Datasource is closed successfully, name={}, sessionId={}", key, this.id);
} catch (Exception e) {
log.warn("Failed to close dataSource, name={}", key, e);
log.warn("Failed to close dataSource, name={}, sessionId={}, error={}",
key, this.id, ExceptionUtils.getRootCauseReason(e));
}
}
}
Expand All @@ -299,8 +301,12 @@ private void closeTaskManager() {
}
try {
taskManager.close();
if (log.isDebugEnabled()) {
log.debug("TaskManager is closed successfully, sessionId={}", this.id);
}
} catch (Exception e) {
log.warn("Failed to close task manager", e);
log.warn("Failed to close the task manager, sessionId={}, error={}",
this.id, ExceptionUtils.getRootCauseReason(e));
}
}

Expand All @@ -314,7 +320,8 @@ private void closeBinaryFileManager() {
log.debug("Binary data manager closed successfully, sessionId={}", this.id);
}
} catch (Exception e) {
log.warn("Binary file manager shutdown failed, sessionId={}, manager={}", this.id, this.dataManager, e);
log.warn("Binary file manager shutdown failed, sessionId={}, manager={}, error={}",
this.id, this.dataManager, ExceptionUtils.getRootCauseReason(e));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ public void onExpireSucceed(ConnectionSession session) {
try {
this.sessionManager.removeSession(session);
} catch (Throwable e) {
log.warn("Fail to delete an expired Session, session={}", session, e);
log.warn("Fail to delete an expired session, sessionId={}", session.getId(), e);
}
}

@Override
public void onExpireFailed(ConnectionSession session, Throwable e) {
log.error("Fail to expire a session, session={}", session, e);
log.warn("Failed to expire a session, sessionId={}", session.getId(), e);
}

}
Expand Down Expand Up @@ -197,6 +197,8 @@ public void doAction() {
ConnectionSession session = this.delayDeleteSessionId2Session.get(this.sessionId);
if (session == null) {
return;
} else {
this.delayDeleteSessionId2Session.remove(this.sessionId);
}
session.expire();
log.info("Delayed deletion of connection session successfully, sessionId={}, AET={}", this.sessionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ public static List<OffsetString> splitWithOffset(ConnectionSession connectionSes
return split(connectionSession.getDialectType(), processor, sql, removeCommentPrefix);
}



private static List<OffsetString> split(DialectType dialectType, SqlCommentProcessor processor, String sql,
boolean removeCommentPrefix) {
PreConditions.notBlank(processor.getDelimiter(), "delimiter", "Empty or blank delimiter is not allowed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;

import com.oceanbase.odc.core.authority.SecurityManager;
import com.oceanbase.odc.core.authority.permission.Permission;
import com.oceanbase.odc.core.authority.util.Authenticated;
import com.oceanbase.odc.core.authority.util.PreAuthenticate;
import com.oceanbase.odc.core.authority.util.SkipAuthorize;
Expand Down Expand Up @@ -179,10 +181,24 @@ public class DatabaseService {
@Autowired
private DatabasePermissionHelper databasePermissionHelper;

@Autowired
private SecurityManager securityManager;

@Transactional(rollbackFor = Exception.class)
@SkipAuthorize("internal authenticated")
public Database detail(@NonNull Long id) {
return getDatabase(id);
Database database = entityToModel(databaseRepository.findById(id)
.orElseThrow(() -> new NotFoundException(ResourceType.ODC_DATABASE, "id", id)), true);
if (Objects.nonNull(database.getProject()) && Objects.nonNull(database.getProject().getId())) {
projectPermissionValidator.checkProjectRole(database.getProject().getId(), ResourceRoleName.all());
return database;
}
Permission requiredPermission = this.securityManager
.getPermissionByActions(database.getDataSource(), Collections.singletonList("read"));
if (this.securityManager.isPermitted(requiredPermission)) {
return database;
}
throw new NotFoundException(ResourceType.ODC_DATABASE, "id", id);
}

@SkipAuthorize("odc internal usage")
Expand All @@ -191,15 +207,6 @@ public Database getBasicSkipPermissionCheck(Long id) {
.orElseThrow(() -> new NotFoundException(ResourceType.ODC_DATABASE, "id", id)));
}

private Database getDatabase(Long id) {
Database database = entityToModel(databaseRepository.findById(id)
.orElseThrow(() -> new NotFoundException(ResourceType.ODC_DATABASE, "id", id)), true);
if (Objects.nonNull(database.getProject()) && Objects.nonNull(database.getProject().getId())) {
projectPermissionValidator.checkProjectRole(database.getProject().getId(), ResourceRoleName.all());
}
return database;
}

@SkipAuthorize("odc internal usage")
@Transactional(rollbackFor = Exception.class)
public ConnectionConfig findDataSourceForConnectById(@NonNull Long id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
public class ConnectConsoleService {

public static final int DEFAULT_GET_RESULT_TIMEOUT_SECONDS = 3;
private static String SHOW_TABLE_COLUMN_INFO = "SHOW_TABLE_COLUMN_INFO";
private static final String SHOW_TABLE_COLUMN_INFO = "SHOW_TABLE_COLUMN_INFO";
@Autowired
private ConnectSessionService sessionService;
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -34,7 +37,9 @@
import org.springframework.jdbc.core.JdbcTemplate;

import com.oceanbase.odc.plugin.schema.obmysql.OBMySQLTableExtension;
import com.oceanbase.odc.plugin.task.api.partitionplan.datatype.TimeDataType;
import com.oceanbase.odc.plugin.task.api.partitionplan.invoker.drop.DropPartitionGenerator;
import com.oceanbase.odc.plugin.task.api.partitionplan.util.TimeDataTypeUtil;
import com.oceanbase.odc.plugin.task.obmysql.partitionplan.invoker.drop.OBMySQLHistoricalPartitionPlanDropGenerator;
import com.oceanbase.odc.test.database.TestDBConfiguration;
import com.oceanbase.odc.test.database.TestDBConfigurations;
Expand Down Expand Up @@ -80,7 +85,14 @@ public void generate_datetimeTbl_succeed() throws Exception {
List<DBTablePartitionDefinition> toDelete = generator.invoke(connection, dbTable, getParameters(2, 3));
List<String> actuals = toDelete.stream().map(DBTableAbstractPartitionDefinition::getName)
.collect(Collectors.toList());
Assert.assertEquals(Arrays.asList("p20230901", "p20231001", "p20231101", "p20231201"), actuals);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -2);
String bound = new SimpleDateFormat("''yyyy-MM-dd HH:mm:ss''")
.format(TimeDataTypeUtil.removeExcessPrecision(calendar.getTime(), TimeDataType.MONTH));
List<String> expect = dbTable.getPartition().getPartitionDefinitions().stream()
.filter(d -> d.getMaxValues().get(0).compareTo(bound) < 0)
.map(DBTableAbstractPartitionDefinition::getName).collect(Collectors.toList());
Assert.assertEquals(expect, actuals);
}
}

Expand All @@ -95,7 +107,14 @@ public void generate_unixTimestampTbl_succeed() throws Exception {
List<DBTablePartitionDefinition> toDelete = generator.invoke(connection, dbTable, getParameters(2, 3));
List<String> actuals = toDelete.stream().map(DBTableAbstractPartitionDefinition::getName)
.collect(Collectors.toList());
Assert.assertEquals(Arrays.asList("p20230901", "p20231001", "p20231101", "p20231201"), actuals);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -2);
Date date = TimeDataTypeUtil.removeExcessPrecision(calendar.getTime(), TimeDataType.MONTH);
String bound = date.getTime() / 1000 + "";
List<String> expect = dbTable.getPartition().getPartitionDefinitions().stream()
.filter(d -> d.getMaxValues().get(0).compareTo(bound) < 0)
.map(DBTableAbstractPartitionDefinition::getName).collect(Collectors.toList());
Assert.assertEquals(expect, actuals);
}
}

Expand Down