forked from opencurve/curve
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request opencurve#7 from cw123/fs_mds_metaserver_3
curvefs metaserver mds
- Loading branch information
Showing
53 changed files
with
5,101 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/sh | ||
|
||
cpplint --recursive curvefs | ||
if [ $? -ne 0 ] | ||
then | ||
echo "cpplint failed" | ||
exit | ||
fi | ||
|
||
if [ "$1" = "debug" ] | ||
then | ||
DEBUG_FLAG="--compilation_mode=dbg" | ||
fi | ||
|
||
bazel build curvefs/src/metaserver:curvefs_metaserver --copt -DHAVE_ZLIB=1 ${DEBUG_FLAG} -s --define=with_glog=true --define=libunwind=true --copt -DGFLAGS_NS=google --copt -Wno-error=format-security --copt -DUSE_BTHREAD_MUTEX --copt -DCURVEVERSION=${curve_version} --linkopt -L/usr/local/lib | ||
if [ $? -ne 0 ] | ||
then | ||
echo "build metaserver failed" | ||
exit | ||
fi | ||
|
||
bazel build curvefs/src/mds:curvefs_mds --copt -DHAVE_ZLIB=1 ${DEBUG_FLAG} -s --define=with_glog=true --define=libunwind=true --copt -DGFLAGS_NS=google --copt -Wno-error=format-security --copt -DUSE_BTHREAD_MUTEX --copt -DCURVEVERSION=${curve_version} --linkopt -L/usr/local/lib | ||
if [ $? -ne 0 ] | ||
then | ||
echo "build mds failed" | ||
exit | ||
fi | ||
|
||
bazel build curvefs/test/metaserver:metaserver_test --copt -DHAVE_ZLIB=1 ${DEBUG_FLAG} -s --define=with_glog=true --define=libunwind=true --copt -DGFLAGS_NS=google --copt -Wno-error=format-security --copt -DUSE_BTHREAD_MUTEX --copt -DCURVEVERSION=${curve_version} --linkopt -L/usr/local/lib | ||
if [ $? -ne 0 ] | ||
then | ||
echo "build mds failed" | ||
exit | ||
fi | ||
|
||
bazel build curvefs/test/mds:mds_test --copt -DHAVE_ZLIB=1 ${DEBUG_FLAG} -s --define=with_glog=true --define=libunwind=true --copt -DGFLAGS_NS=google --copt -Wno-error=format-security --copt -DUSE_BTHREAD_MUTEX --copt -DCURVEVERSION=${curve_version} --linkopt -L/usr/local/lib | ||
if [ $? -ne 0 ] | ||
then | ||
echo "build mds failed" | ||
exit | ||
fi | ||
|
||
if [ "$1" = "test" ] | ||
then | ||
./bazel-bin/curvefs/test/metaserver/metaserver_test | ||
if [ $? -ne 0 ] | ||
then | ||
echo "metaserver_test failed" | ||
exit | ||
fi | ||
./bazel-bin/curvefs/test/mds/mds_test | ||
if [ $? -ne 0 ] | ||
then | ||
echo "mds_test failed" | ||
exit | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# | ||
# mds服务端口 | ||
# | ||
mds.listen.addr=127.0.0.1:6700 | ||
|
||
# | ||
# space服务端口 | ||
# | ||
space.addr=127.0.0.1:6702 | ||
space.rpcTimeoutMs=500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# | ||
# metaserver服务端口 | ||
# | ||
metaserver.listen.addr=127.0.0.1:6701 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# | ||
# Copyright (c) 2021 NetEase Inc. | ||
# | ||
# 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. | ||
# | ||
|
||
COPTS = [ | ||
"-DGFLAGS=gflags", | ||
"-DOS_LINUX", | ||
"-DSNAPPY", | ||
"-DHAVE_SSE42", | ||
"-DHAVE_ZLIB", | ||
"-DNDEBUG", | ||
"-fno-omit-frame-pointer", | ||
"-momit-leaf-frame-pointer", | ||
"-msse4.2", | ||
"-pthread", | ||
"-Wsign-compare", | ||
"-Wno-unused-parameter", | ||
"-Wno-unused-variable", | ||
"-Woverloaded-virtual", | ||
"-Wnon-virtual-dtor", | ||
"-Wno-missing-field-initializers", | ||
"-std=c++11", | ||
] | ||
|
||
cc_library( | ||
name="mds", | ||
hdrs=glob(["*.h"]), | ||
srcs=glob(["*.cpp"], | ||
exclude = ["main.cpp"] | ||
), | ||
copts = COPTS, | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//external:brpc", | ||
"//curvefs/proto:mds_cc_proto", | ||
"//curvefs/proto:space_cc_proto", | ||
"//src/common/concurrent:curve_concurrent", | ||
"//src/common:curve_common", | ||
], | ||
) | ||
|
||
cc_binary( | ||
name = "curvefs_mds", | ||
srcs = glob([ | ||
"main.cpp", | ||
]), | ||
copts = COPTS, | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//curvefs/src/mds:mds", | ||
], | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright (c) 2021 NetEase Inc. | ||
* | ||
* 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. | ||
*/ | ||
|
||
/* | ||
* @Project: curve | ||
* @Date: 2021-06-04 14:11:16 | ||
* @Author: chenwei | ||
*/ | ||
|
||
#include "curvefs/src/mds/fs.h" | ||
namespace curvefs { | ||
namespace mds { | ||
MdsFsInfo::MdsFsInfo(uint32_t fsId, std::string fsName, uint64_t rootInodeId, | ||
uint64_t capacity, uint64_t blockSize, const common::Volume& volume) { | ||
fsId_ = fsId; | ||
fsName_ = fsName; | ||
rootInodeId_ = rootInodeId; | ||
capacity_ = capacity; | ||
blockSize_ = blockSize; | ||
volume_.CopyFrom(volume); | ||
mountNum_ = 0; | ||
} | ||
|
||
void MdsFsInfo::ConvertToProto(FsInfo *file) { | ||
// ReadLockGuard readLockGuard(rwLock_); | ||
file->set_fsid(fsId_); | ||
file->set_fsname(fsName_); | ||
file->set_rootinodeid(rootInodeId_); | ||
file->set_capacity(capacity_); | ||
file->set_blocksize(blockSize_); | ||
file->set_mountnum(mountNum_); | ||
file->mutable_volume()->CopyFrom(volume_); | ||
*file->mutable_mountpoints() = {mountPointList_.begin(), | ||
mountPointList_.end()}; | ||
return; | ||
} | ||
|
||
std::list<MountPoint> MdsFsInfo::GetMountPointList() { | ||
return mountPointList_; | ||
} | ||
|
||
bool MdsFsInfo::MountPointEmpty() { | ||
return mountNum_ == 0; | ||
} | ||
|
||
bool MdsFsInfo::MountPointExist(const MountPoint& mountpoint) { | ||
// ReadLockGuard readLockGuard(rwLock_); | ||
for (auto it : mountPointList_) { | ||
if (it.host() == mountpoint.host() | ||
&& it.mountdir() == mountpoint.mountdir()) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
void MdsFsInfo::AddMountPoint(const MountPoint& mountpoint) { | ||
// WriteLockGuard writeLockGuard(rwLock_); | ||
mountPointList_.push_back(mountpoint); | ||
mountNum_++; | ||
return; | ||
} | ||
|
||
FSStatusCode MdsFsInfo::DeleteMountPoint(const MountPoint& mountpoint) { | ||
// WriteLockGuard writeLockGuard(rwLock_); | ||
for (auto it = mountPointList_.begin(); it != mountPointList_.end(); it++) { | ||
if (it->host() == mountpoint.host() | ||
&& it->mountdir() == mountpoint.mountdir()) { | ||
mountPointList_.erase(it); | ||
mountNum_--; | ||
return FSStatusCode::OK; | ||
} | ||
} | ||
return FSStatusCode::NOT_FOUND; | ||
} | ||
|
||
uint32_t MdsFsInfo::GetFsId() const { | ||
return fsId_; | ||
} | ||
|
||
std::string MdsFsInfo::GetFsName() const { | ||
return fsName_; | ||
} | ||
|
||
Volume MdsFsInfo::GetVolumeInfo() { | ||
return volume_; | ||
} | ||
} // namespace mds | ||
} // namespace curvefs |
Oops, something went wrong.