Skip to content

Commit

Permalink
mds:add conf allocateSegmentStrategy
Browse files Browse the repository at this point in the history
  • Loading branch information
xu-chaojie committed Nov 23, 2023
1 parent 2fc6702 commit ee0b0bb
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
2 changes: 2 additions & 0 deletions conf/mds.conf
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ mds.topology.PoolUsagePercentLimit=85
mds.topology.choosePoolPolicy=0
# enable LogicalPool ALLOW/DENY status
mds.topology.enableLogicalPoolStatus=false
# allocate segment by 0:logicalpool/1:pyhsicalpool/2:both
mds.topology.allocateSegmentStrategy=1

#
# copyset config
Expand Down
3 changes: 3 additions & 0 deletions src/mds/server/mds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ void MDS::InitTopologyOption(TopologyOption *topologyOption) {
conf_->GetValueFatalIfFail(
"mds.topology.enableLogicalPoolStatus",
&topologyOption->enableLogicalPoolStatus);
conf_->GetValueFatalIfFail(
"mds.topology.allocateSegmentStrategy",
&topologyOption->allocateSegmentStrategy);
}

void MDS::InitTopology(const TopologyOption& option) {
Expand Down
23 changes: 19 additions & 4 deletions src/mds/topology/topology_chunk_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,25 @@ void TopologyChunkAllocatorImpl::GetRemainingSpaceInLogicalPool(
<< ", isSomeCSFull: " << isSomeCSFull
<< "}";

if ((diskRemianning > 0) &&
(allocRemainning > 0) &&
!isSomeCSFull) {
(*enoughSpacePools)[pid] = diskRemianning;
switch (allocateSegmentStrategy_) {
case AllocateSegmentStrategy::kLogicalPool:
if (allocRemainning > 0) {
(*enoughSpacePools)[pid] = allocRemainning;
}
break;
case AllocateSegmentStrategy::kPhysicalPool:
if ((diskRemianning > 0) &&
!isSomeCSFull) {
(*enoughSpacePools)[pid] = diskRemianning;
}
break;
default:
if ((diskRemianning > 0) &&
(allocRemainning > 0) &&
!isSomeCSFull) {
(*enoughSpacePools)[pid] = diskRemianning;
}
break;
}
}
}
Expand Down
13 changes: 12 additions & 1 deletion src/mds/topology/topology_chunk_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ enum class ChoosePoolPolicy {
kWeight,
};

enum class AllocateSegmentStrategy {
kLogicalPool = 0,
kPhysicalPool,
kBoth,
};

class TopologyChunkAllocator {
public:
TopologyChunkAllocator() {}
Expand Down Expand Up @@ -85,7 +91,10 @@ class TopologyChunkAllocatorImpl : public TopologyChunkAllocator {
chunkFilePoolAllocHelp_(chunkFilePoolAllocHelp),
available_(option.PoolUsagePercentLimit),
policy_(static_cast<ChoosePoolPolicy>(option.choosePoolPolicy)),
enableLogicalPoolStatus_(option.enableLogicalPoolStatus) {
enableLogicalPoolStatus_(option.enableLogicalPoolStatus),
allocateSegmentStrategy_(
static_cast<AllocateSegmentStrategy>(
option.allocateSegmentStrategy)) {
std::srand(std::time(nullptr));
}
~TopologyChunkAllocatorImpl() {}
Expand Down Expand Up @@ -180,6 +189,8 @@ class TopologyChunkAllocatorImpl : public TopologyChunkAllocator {
ChoosePoolPolicy policy_;
// enableLogicalPoolStatus
bool enableLogicalPoolStatus_;
// allocate segment stragegy
AllocateSegmentStrategy allocateSegmentStrategy_;
};

/**
Expand Down
5 changes: 4 additions & 1 deletion src/mds/topology/topology_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ struct TopologyOption {
int choosePoolPolicy;
// enable LogicalPool ALLOW/DENY status
bool enableLogicalPoolStatus;
// allocate segment by 0:logicalpool/1:pyhsicalpool/2:both
int allocateSegmentStrategy;

TopologyOption()
: TopologyUpdateToRepoSec(0),
Expand All @@ -54,7 +56,8 @@ struct TopologyOption {
CreateCopysetRpcRetrySleepTimeMs(500),
UpdateMetricIntervalSec(0),
choosePoolPolicy(0),
enableLogicalPoolStatus(false) {}
enableLogicalPoolStatus(false),
allocateSegmentStrategy(2) {}
};

} // namespace topology
Expand Down

0 comments on commit ee0b0bb

Please sign in to comment.