Skip to content

Commit

Permalink
merge 202406 into main (#3896)
Browse files Browse the repository at this point in the history
merge 202406 into main
  • Loading branch information
yhilmare authored Nov 25, 2024
2 parents 6cd4325 + e5d0f46 commit b582b0b
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public SuccessResponse<RecyclebinSettings> getRecyclebinSettings(@PathVariable S

@ApiOperation(value = "updateRecyclebinSettings", notes = "更新回收站设置,sid示例:sid:1000-1:d:db1")
@RequestMapping(value = "/settings", method = RequestMethod.PATCH)
@StatefulRoute(multiState = true, stateIdExpression = "#req.sessionIds",
@StatefulRoute(stateIdExpression = "#req.sessionIds",
stateManager = "dbRecyclebinUpdateStateManager")
public SuccessResponse<RecyclebinSettings> updateRecyclebinSettings(@RequestBody UpdateRecyclebinSettingsReq req) {
List<ConnectionSession> sessions = req.getSessionIds().stream().map(s -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ public SuccessResponse<String> startBatchCompile(@PathVariable String sessionId,
@ApiOperation(value = "end batchCompile", notes = "终止批量编译")
@RequestMapping(value = {"/{sessionId}/databases/{databaseName}/batchCompilations/{id}",
"/{sessionId}/currentDatabase/batchCompilations/{id}"}, method = RequestMethod.DELETE)
@StatefulRoute(stateName = StateName.DB_SESSION, stateIdExpression = "#sessionId")
@StatefulRoute(stateName = StateName.UUID_STATEFUL_ID, stateIdExpression = "#id")
public SuccessResponse<Boolean> endBatchCompile(@PathVariable String id) {
return Responses.success(plService.endBatchCompile(id));
}

@ApiOperation(value = "get result for batchCompile", notes = "获取批量编译PL对象的结果")
@RequestMapping(value = {"/{sessionId}/databases/{databaseName}/batchCompilations/{id}",
"/{sessionId}/currentDatabase/batchCompilations/{id}"}, method = RequestMethod.GET)
@StatefulRoute(stateName = StateName.DB_SESSION, stateIdExpression = "#id")
@StatefulRoute(stateName = StateName.UUID_STATEFUL_ID, stateIdExpression = "#id")
public SuccessResponse<BatchCompileResp> getBatchCompileResult(@PathVariable String id) {
return Responses.success(plService.getBatchCompileResult(id));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.oceanbase.odc.service.datasecurity.model.SensitiveRule;
import com.oceanbase.odc.service.db.browser.DBSchemaAccessors;
import com.oceanbase.odc.service.session.factory.DefaultConnectSessionFactory;
import com.oceanbase.odc.service.state.StatefulUuidStateIdGenerator;
import com.oceanbase.tools.dbbrowser.model.DBTableColumn;
import com.oceanbase.tools.dbbrowser.schema.DBSchemaAccessor;

Expand All @@ -56,11 +57,12 @@
@Component
public class SensitiveColumnScanningTaskManager {

private final SensitiveColumnScanningResultCache cache = SensitiveColumnScanningResultCache.getInstance();
@Autowired
@Qualifier("scanSensitiveColumnExecutor")
private ThreadPoolTaskExecutor executor;

private final SensitiveColumnScanningResultCache cache = SensitiveColumnScanningResultCache.getInstance();
@Autowired
private StatefulUuidStateIdGenerator statefulUuidStateIdGenerator;

public SensitiveColumnScanningTaskInfo start(List<Database> databases, List<SensitiveRule> rules,
ConnectionConfig connectionConfig, Map<Long, List<SensitiveColumnMeta>> databaseId2SensitiveColumns) {
Expand All @@ -84,7 +86,8 @@ public SensitiveColumnScanningTaskInfo start(List<Database> databases, List<Sens
database2View2ColumnsList.put(database, view2Columns);
}
}
SensitiveColumnScanningTaskInfo taskInfo = new SensitiveColumnScanningTaskInfo(projectId, objectCount);
SensitiveColumnScanningTaskInfo taskInfo = new SensitiveColumnScanningTaskInfo(
statefulUuidStateIdGenerator.generateStateId("SensitiveColumn"), projectId, objectCount);
if (objectCount == 0) {
taskInfo.setCompleteTime(new Date());
taskInfo.setStatus(ScanningTaskStatus.SUCCESS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
import com.oceanbase.odc.service.iam.UserService;
import com.oceanbase.odc.service.iam.auth.AuthenticationFacade;
import com.oceanbase.odc.service.session.factory.DefaultConnectSessionFactory;
import com.oceanbase.odc.service.state.model.StateName;
import com.oceanbase.odc.service.state.model.StatefulRoute;
import com.oceanbase.tools.dbbrowser.model.DBTableColumn;
import com.oceanbase.tools.dbbrowser.schema.DBSchemaAccessor;

Expand All @@ -90,38 +92,28 @@
@Authenticated
public class SensitiveColumnService {

private static final SensitiveColumnMapper mapper = SensitiveColumnMapper.INSTANCE;
@Autowired
private SensitiveRuleService ruleService;

@Autowired
private MaskingAlgorithmService algorithmService;

@Autowired
private ConnectionService connectionService;

@Autowired
private SensitiveColumnRepository repository;

@Autowired
private UserService userService;

@Autowired
private DatabaseService databaseService;

@Autowired
private SensitiveColumnScanningTaskManager scanningTaskManager;

@Autowired
private AuthenticationFacade authenticationFacade;

@Autowired
private HorizontalDataPermissionValidator permissionValidator;

@Autowired
private VersionDiffConfigService versionDiffConfigService;

private static final SensitiveColumnMapper mapper = SensitiveColumnMapper.INSTANCE;

@Transactional(rollbackFor = Exception.class)
@PreAuthenticate(hasAnyResourceRole = {"OWNER, DBA, SECURITY_ADMINISTRATOR"}, resourceType = "ODC_PROJECT",
indexOfIdParam = 0)
Expand Down Expand Up @@ -388,6 +380,7 @@ public SensitiveColumnScanningTaskInfo startScanning(@NotNull Long projectId,
@Transactional(rollbackFor = Exception.class)
@PreAuthenticate(hasAnyResourceRole = {"OWNER, DBA, SECURITY_ADMINISTRATOR"}, resourceType = "ODC_PROJECT",
indexOfIdParam = 0)
@StatefulRoute(stateName = StateName.UUID_STATEFUL_ID, stateIdExpression = "#taskId")
public SensitiveColumnScanningTaskInfo getScanningResults(@NotNull Long projectId, @NotBlank String taskId) {
SensitiveColumnScanningTaskInfo taskInfo = scanningTaskManager.get(taskId);
if (!Objects.equals(taskInfo.getProjectId(), projectId)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Date;
import java.util.List;

import com.oceanbase.odc.common.util.StringUtils;
import com.oceanbase.odc.core.shared.constant.ErrorCode;

import lombok.Getter;
Expand All @@ -43,8 +42,9 @@ public class SensitiveColumnScanningTaskInfo {
private ErrorCode errorCode;
private String errorMsg;

public SensitiveColumnScanningTaskInfo(@NonNull Long projectId, @NonNull Integer allTableCount) {
this.taskId = StringUtils.uuid();
public SensitiveColumnScanningTaskInfo(@NonNull String taskId, @NonNull Long projectId,
@NonNull Integer allTableCount) {
this.taskId = taskId;
this.projectId = projectId;
this.status = ScanningTaskStatus.CREATED;
this.allTableCount = allTableCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
Expand Down Expand Up @@ -78,6 +77,7 @@
import com.oceanbase.odc.service.permission.database.model.DatabasePermissionType;
import com.oceanbase.odc.service.session.ConnectConsoleService;
import com.oceanbase.odc.service.session.SessionProperties;
import com.oceanbase.odc.service.state.StatefulUuidStateIdGenerator;
import com.oceanbase.tools.dbbrowser.model.DBObjectType;
import com.oceanbase.tools.dbbrowser.model.DBPLObjectIdentity;
import com.oceanbase.tools.dbbrowser.parser.PLParser;
Expand Down Expand Up @@ -107,6 +107,9 @@ public class DBPLService {
@Autowired
private DBResourcePermissionHelper permissionHelper;

@Autowired
private StatefulUuidStateIdGenerator statefulUuidStateIdGenerator;

private static final Integer DEFAULT_MAX_CONCURRENT_BATCH_COMPILE_TASK_COUNT = 10;
private final DefaultSqlExecuteTaskManager taskManager;
private final Map<String, Pair<BatchCompileTaskCallable, Future<BatchCompileResp>>> runningTaskMap;
Expand Down Expand Up @@ -181,7 +184,7 @@ public String startBatchCompile(@NonNull ConnectionSession session,
if (StringUtils.isBlank(databaseName)) {
// it means batch compile refers to current database
handle = taskManager.submit(taskCallable);
taskId = UUID.randomUUID().toString();
taskId = statefulUuidStateIdGenerator.generateStateId("BatchCompile");
} else {
throw new UnsupportedException("Batch compile PL in another database is not supported yet");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ private void executeInTaskFramework(JobExecutionContext context) {
: dataDeleteParameters.getTargetDatabaseId()));
parameters.getSourceDs().setQueryTimeout(dataDeleteParameters.getQueryTimeout());
parameters.getTargetDs().setQueryTimeout(dataDeleteParameters.getQueryTimeout());
parameters.setShardingStrategy(dataDeleteParameters.getShardingStrategy());

Long jobId =
publishJob(parameters, dataDeleteParameters.getTimeoutMillis(), dataDeleteParameters.getDatabaseId());
Expand Down

0 comments on commit b582b0b

Please sign in to comment.