Skip to content

Commit

Permalink
mongodb数据库禁写插件测试问题修复
Browse files Browse the repository at this point in the history
Signed-off-by: daizhenyu <[email protected]>
  • Loading branch information
daizhenyu committed Feb 26, 2024
1 parent 801752d commit d92eef4
Show file tree
Hide file tree
Showing 18 changed files with 739 additions and 316 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
* limitations under the License.
*/

package com.huaweicloud.sermant.mongodb.interceptors;
package com.huaweicloud.sermant.database.interceptor;

import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext;
import com.huaweicloud.sermant.database.config.DatabaseWriteProhibitionManager;
import com.huaweicloud.sermant.database.controller.DatabaseController;
import com.huaweicloud.sermant.database.interceptor.AbstractDatabaseInterceptor;

/**
* mongodb抽象interceptor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public ClassMatcher getClassMatcher() {

@Override
public InterceptDeclarer[] getInterceptDeclarers(ClassLoader classLoader) {
return MongoDbEnhancementHelper.getMixedBulkWriteOperationInterceptDeclarers();
return new InterceptDeclarer[]{
MongoDbEnhancementHelper.getExecuteInterceptDeclarer(),
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2024-2024 Huawei Technologies Co., Ltd. All rights reserved.
*
* 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.huaweicloud.sermant.mongodb.declarers;

import com.huaweicloud.sermant.core.plugin.agent.declarer.AbstractPluginDeclarer;
import com.huaweicloud.sermant.core.plugin.agent.declarer.InterceptDeclarer;
import com.huaweicloud.sermant.core.plugin.agent.matcher.ClassMatcher;
import com.huaweicloud.sermant.mongodb.utils.MongoDbEnhancementHelper;

/**
* SyncOperationHelperDeclarer类增强声明器
*
* @author daizhenyu
* @since 2024-02-22
**/
public class SyncOperationHelperDeclarer extends AbstractPluginDeclarer {
@Override
public ClassMatcher getClassMatcher() {
return MongoDbEnhancementHelper.getSyncOperationHelperDeclarerClassMatcher();
}

@Override
public InterceptDeclarer[] getInterceptDeclarers(ClassLoader classLoader) {
return MongoDbEnhancementHelper.getSyncOperationHelperInterceptDeclarers();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,30 @@
import com.huaweicloud.sermant.database.constant.DatabaseType;
import com.huaweicloud.sermant.database.entity.DatabaseInfo;
import com.huaweicloud.sermant.database.handler.DatabaseHandler;
import com.huaweicloud.sermant.database.interceptor.AbstractMongoDbInterceptor;

import com.mongodb.ServerAddress;
import com.mongodb.internal.binding.WriteBinding;

/**
* 执行重试write操作的拦截器
* executeCommand、executeRetryableCommand、executeRetryableWrite方法拦截器
*
* @author daizhenyu
* @since 2024-01-18
* @since 2024-02-23
**/
public class ExecuteRetryableCommandInterceptor extends AbstractMongoDbInterceptor {
public class GeneralExecuteInterceptor extends AbstractMongoDbInterceptor {
/**
* 无参构造方法
*/
public ExecuteRetryableCommandInterceptor() {
public GeneralExecuteInterceptor() {
}

/**
* 有参构造方法
*
* @param handler 写操作处理器
*/
public ExecuteRetryableCommandInterceptor(DatabaseHandler handler) {
public GeneralExecuteInterceptor(DatabaseHandler handler) {
this.handler = handler;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
import com.huaweicloud.sermant.database.constant.DatabaseType;
import com.huaweicloud.sermant.database.entity.DatabaseInfo;
import com.huaweicloud.sermant.database.handler.DatabaseHandler;
import com.huaweicloud.sermant.database.interceptor.AbstractMongoDbInterceptor;

import com.mongodb.ServerAddress;
import com.mongodb.internal.binding.WriteBinding;
import com.mongodb.internal.operation.MixedBulkWriteOperation;

/**
* MixedBulkWriteOperation类拦截声明器
* MixedBulkWriteOperation类execute方法拦截声明器
*
* @author daizhenyu
* @since 2024-01-16
Expand Down
Loading

0 comments on commit d92eef4

Please sign in to comment.