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
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ protected void onAllReplicasetFailure(
new ProcedureException(
new MetadataException(
String.format(
"Alter view %s failed when [%s] because all replicaset of schemaRegion %s failed. %s",
"Alter view %s failed when [%s] because failed to execute in all replicaset of schemaRegion %s. Failure nodes: %s",
viewPathToSourceMap.keySet(),
taskName,
consensusGroupId.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
public abstract class DataNodeRegionTaskExecutor<Q, R> {

protected final ConfigManager configManager;
protected final Map<TConsensusGroupId, TRegionReplicaSet> targetSchemaRegionGroup;
protected final Map<TConsensusGroupId, TRegionReplicaSet> targetRegionGroup;
protected final boolean executeOnAllReplicaset;

protected final CnToDnRequestType dataNodeRequestType;
Expand All @@ -53,25 +53,25 @@ public abstract class DataNodeRegionTaskExecutor<Q, R> {

protected DataNodeRegionTaskExecutor(
ConfigManager configManager,
Map<TConsensusGroupId, TRegionReplicaSet> targetSchemaRegionGroup,
Map<TConsensusGroupId, TRegionReplicaSet> targetRegionGroup,
boolean executeOnAllReplicaset,
CnToDnRequestType dataNodeRequestType,
BiFunction<TDataNodeLocation, List<TConsensusGroupId>, Q> dataNodeRequestGenerator) {
this.configManager = configManager;
this.targetSchemaRegionGroup = targetSchemaRegionGroup;
this.targetRegionGroup = targetRegionGroup;
this.executeOnAllReplicaset = executeOnAllReplicaset;
this.dataNodeRequestType = dataNodeRequestType;
this.dataNodeRequestGenerator = dataNodeRequestGenerator;
}

protected DataNodeRegionTaskExecutor(
ConfigNodeProcedureEnv env,
Map<TConsensusGroupId, TRegionReplicaSet> targetSchemaRegionGroup,
Map<TConsensusGroupId, TRegionReplicaSet> targetRegionGroup,
boolean executeOnAllReplicaset,
CnToDnRequestType dataNodeRequestType,
BiFunction<TDataNodeLocation, List<TConsensusGroupId>, Q> dataNodeRequestGenerator) {
this.configManager = env.getConfigManager();
this.targetSchemaRegionGroup = targetSchemaRegionGroup;
this.targetRegionGroup = targetRegionGroup;
this.executeOnAllReplicaset = executeOnAllReplicaset;
this.dataNodeRequestType = dataNodeRequestType;
this.dataNodeRequestGenerator = dataNodeRequestGenerator;
Expand All @@ -82,9 +82,9 @@ void execute() {
Map<TConsensusGroupId, Set<TDataNodeLocation>> failedHistory = new HashMap<>();
Map<TDataNodeLocation, List<TConsensusGroupId>> dataNodeConsensusGroupIdMap =
executeOnAllReplicaset
? getAllReplicaDataNodeRegionGroupMap(targetSchemaRegionGroup)
? getAllReplicaDataNodeRegionGroupMap(targetRegionGroup)
: getLeaderDataNodeRegionGroupMap(
configManager.getLoadManager().getRegionLeaderMap(), targetSchemaRegionGroup);
configManager.getLoadManager().getRegionLeaderMap(), targetRegionGroup);
while (!dataNodeConsensusGroupIdMap.isEmpty()) {
DataNodeAsyncRequestContext<Q, R> clientHandler =
prepareRequestHandler(dataNodeConsensusGroupIdMap);
Expand Down Expand Up @@ -162,7 +162,7 @@ private Map<TDataNodeLocation, List<TConsensusGroupId>> getAvailableDataNodeLoca
for (List<TConsensusGroupId> consensusGroupIdList :
failedDataNodeConsensusGroupIdMap.values()) {
for (TConsensusGroupId consensusGroupId : consensusGroupIdList) {
TRegionReplicaSet regionReplicaSet = targetSchemaRegionGroup.get(consensusGroupId);
TRegionReplicaSet regionReplicaSet = targetRegionGroup.get(consensusGroupId);
TDataNodeLocation selectedDataNode = null;
Integer leaderId = leaderMap.get(consensusGroupId);
Set<TDataNodeLocation> failedDataNodeSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,13 @@ private class DeactivateTemplateRegionTaskExecutor<Q>
DeactivateTemplateRegionTaskExecutor(
String taskName,
ConfigNodeProcedureEnv env,
Map<TConsensusGroupId, TRegionReplicaSet> targetSchemaRegionGroup,
Map<TConsensusGroupId, TRegionReplicaSet> targetDataRegionGroup,
boolean executeOnAllReplicaset,
CnToDnRequestType dataNodeRequestType,
BiFunction<TDataNodeLocation, List<TConsensusGroupId>, Q> dataNodeRequestGenerator) {
super(
env,
targetSchemaRegionGroup,
targetDataRegionGroup,
executeOnAllReplicaset,
dataNodeRequestType,
dataNodeRequestGenerator);
Expand Down Expand Up @@ -491,8 +491,12 @@ protected void onAllReplicasetFailure(
new ProcedureException(
new MetadataException(
String.format(
"Deactivate template of %s failed when [%s] because all replicaset of schemaRegion %s failed. %s",
requestMessage, taskName, consensusGroupId.id, dataNodeLocationSet))));
"Deactivate template of %s failed when [%s] because failed to execute in all replicaset of %s %s. Failure nodes: %s",
requestMessage,
taskName,
consensusGroupId.type,
consensusGroupId.id,
dataNodeLocationSet))));
interruptTask();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private long constructBlackList(ConfigNodeProcedureEnv env) {
List<TSStatus> successResult = new ArrayList<>();
DeleteLogicalViewRegionTaskExecutor<TConstructViewSchemaBlackListReq> constructBlackListTask =
new DeleteLogicalViewRegionTaskExecutor<TConstructViewSchemaBlackListReq>(
"construct view schemaengine black list",
"construct view schema engine black list",
env,
targetSchemaRegionGroup,
CnToDnRequestType.CONSTRUCT_VIEW_SCHEMA_BLACK_LIST,
Expand Down Expand Up @@ -208,7 +208,7 @@ private void invalidateCache(ConfigNodeProcedureEnv env) {
private void deleteViewSchema(ConfigNodeProcedureEnv env) {
DeleteLogicalViewRegionTaskExecutor<TDeleteViewSchemaReq> deleteTimeSeriesTask =
new DeleteLogicalViewRegionTaskExecutor<>(
"delete view schemaengine",
"delete view in schema engine",
env,
env.getConfigManager().getRelatedSchemaRegionGroup(patternTree),
CnToDnRequestType.DELETE_VIEW,
Expand Down Expand Up @@ -244,7 +244,7 @@ protected void rollbackState(
throws IOException, InterruptedException, ProcedureException {
DeleteLogicalViewRegionTaskExecutor<TRollbackViewSchemaBlackListReq> rollbackStateTask =
new DeleteLogicalViewRegionTaskExecutor<>(
"roll back view schemaengine black list",
"roll back view schema engine black list",
env,
env.getConfigManager().getRelatedSchemaRegionGroup(patternTree),
CnToDnRequestType.ROLLBACK_VIEW_SCHEMA_BLACK_LIST,
Expand Down Expand Up @@ -379,7 +379,7 @@ protected void onAllReplicasetFailure(
new ProcedureException(
new MetadataException(
String.format(
"Delete view %s failed when [%s] because all replicaset of schemaRegion %s failed. %s",
"Delete view %s failed when [%s] because failed to execute in all replicaset of schemaRegion %s. Failure nodes: %s",
requestMessage, taskName, consensusGroupId.id, dataNodeLocationSet))));
interruptTask();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private long constructBlackList(ConfigNodeProcedureEnv env) {
List<TSStatus> successResult = new ArrayList<>();
DeleteTimeSeriesRegionTaskExecutor<TConstructSchemaBlackListReq> constructBlackListTask =
new DeleteTimeSeriesRegionTaskExecutor<TConstructSchemaBlackListReq>(
"construct schemaengine black list",
"construct schema engine black list",
env,
targetSchemaRegionGroup,
CnToDnRequestType.CONSTRUCT_SCHEMA_BLACK_LIST,
Expand Down Expand Up @@ -249,7 +249,7 @@ private void executeDeleteData(ConfigNodeProcedureEnv env, PathPatternTree patte
private void deleteTimeSeriesSchema(ConfigNodeProcedureEnv env) {
DeleteTimeSeriesRegionTaskExecutor<TDeleteTimeSeriesReq> deleteTimeSeriesTask =
new DeleteTimeSeriesRegionTaskExecutor<>(
"delete timeseries schemaengine",
"delete time series in schema engine",
env,
env.getConfigManager().getRelatedSchemaRegionGroup(patternTree),
CnToDnRequestType.DELETE_TIMESERIES,
Expand Down Expand Up @@ -286,7 +286,7 @@ protected void rollbackState(
if (deleteTimeSeriesState == DeleteTimeSeriesState.CONSTRUCT_BLACK_LIST) {
DeleteTimeSeriesRegionTaskExecutor<TRollbackSchemaBlackListReq> rollbackStateTask =
new DeleteTimeSeriesRegionTaskExecutor<>(
"roll back schemaengine black list",
"roll back schema engine black list",
env,
env.getConfigManager().getRelatedSchemaRegionGroup(patternTree),
CnToDnRequestType.ROLLBACK_SCHEMA_BLACK_LIST,
Expand Down Expand Up @@ -395,13 +395,13 @@ private class DeleteTimeSeriesRegionTaskExecutor<Q>
DeleteTimeSeriesRegionTaskExecutor(
String taskName,
ConfigNodeProcedureEnv env,
Map<TConsensusGroupId, TRegionReplicaSet> targetSchemaRegionGroup,
Map<TConsensusGroupId, TRegionReplicaSet> targetDataRegionGroup,
boolean executeOnAllReplicaset,
CnToDnRequestType dataNodeRequestType,
BiFunction<TDataNodeLocation, List<TConsensusGroupId>, Q> dataNodeRequestGenerator) {
super(
env,
targetSchemaRegionGroup,
targetDataRegionGroup,
executeOnAllReplicaset,
dataNodeRequestType,
dataNodeRequestGenerator);
Expand Down Expand Up @@ -438,8 +438,12 @@ protected void onAllReplicasetFailure(
new ProcedureException(
new MetadataException(
String.format(
"Delete timeseries %s failed when [%s] because all replicaset of schemaRegion %s failed. %s",
requestMessage, taskName, consensusGroupId.id, dataNodeLocationSet))));
"Delete time series %s failed when [%s] because failed to execute in all replicaset of %s %s. Failure nodes: %s",
requestMessage,
taskName,
consensusGroupId.type,
consensusGroupId.id,
dataNodeLocationSet))));
interruptTask();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public class SchemaUtils {
/**
* Check whether the specific template is activated on the given pattern tree.
*
* @return true if the template is activated on the given pattern tree, false otherwise.
* @return {@code true} if the template is activated on the given pattern tree, {@code false}
* otherwise.
* @throws MetadataException if any error occurs when checking the activation.
*/
public static boolean checkDataNodeTemplateActivation(
Expand All @@ -61,6 +62,7 @@ public static boolean checkDataNodeTemplateActivation(
try {
patternTree.serialize(dataOutputStream);
} catch (IOException ignored) {
// ByteArrayOutputStream won't throw IOException
}
ByteBuffer patternTreeBytes = ByteBuffer.wrap(byteArrayOutputStream.toByteArray());

Expand Down Expand Up @@ -111,8 +113,8 @@ protected void onAllReplicasetFailure(
exception[0] =
new MetadataException(
String.format(
"all replicaset of schemaRegion %s failed. %s",
consensusGroupId.id, dataNodeLocationSet));
"Failed to execute in all replicaset of schemaRegion %s when checking the template %s on %s. Failure nodes: %s",
consensusGroupId.id, template, patternTree, dataNodeLocationSet));
interruptTask();
}
};
Expand All @@ -131,13 +133,12 @@ protected void onAllReplicasetFailure(
/**
* Check whether any template is activated on the given schema regions.
*
* @return true if the template is activated on the given pattern tree, false otherwise.
* @throws MetadataException if any error occurs when checking the activation.
* @throws MetadataException if any error occurs when checking the activation, or there are
* templates under the databases.
*/
public static void checkSchemaRegionUsingTemplate(
ConfigManager configManager, List<PartialPath> deleteDatabasePatternPaths)
throws MetadataException {

PathPatternTree deleteDatabasePatternTree = new PathPatternTree();
for (PartialPath path : deleteDatabasePatternPaths) {
deleteDatabasePatternTree.appendPathPattern(path);
Expand Down Expand Up @@ -189,8 +190,8 @@ protected void onAllReplicasetFailure(
exception[0] =
new MetadataException(
String.format(
"all replicaset of schemaRegion %s failed. %s",
consensusGroupId.id, dataNodeLocationSet));
"Failed to execute in all replicaset of schemaRegion %s when checking templates on path %s. Failure nodes: %s",
consensusGroupId.id, deleteDatabasePatternPaths, dataNodeLocationSet));
interruptTask();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ protected void onAllReplicasetFailure(
new ProcedureException(
new MetadataException(
String.format(
"Set template %s to %s failed when [check timeseries existence on DataNode] because all replicaset of schemaRegion %s failed. %s",
"Set template %s to %s failed when [check time series existence on DataNode] because "
+ "failed to check time series existence in all replicaset of schemaRegion %s. Failure nodes: %s",
templateName,
templateSetPath,
consensusGroupId.id,
Expand Down