-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
heng
committed
Jun 12, 2019
1 parent
8a3735a
commit fe82c25
Showing
23 changed files
with
1,078 additions
and
22 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
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
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,39 @@ | ||
/* Copyright (c) 2019 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#ifndef META_PROCESSORS_COMMON_H_ | ||
#define META_PROCESSORS_COMMON_H_ | ||
|
||
#include "base/Base.h" | ||
|
||
namespace nebula { | ||
namespace meta { | ||
|
||
static const PartitionID kDefaultPartId = 0; | ||
static const GraphSpaceID kDefaultSpaceId = 0; | ||
|
||
class LockUtils { | ||
public: | ||
LockUtils() = delete; | ||
#define GENERATE_LOCK(Entry) \ | ||
static folly::SharedMutex& Entry##Lock() { \ | ||
static folly::SharedMutex l; \ | ||
return l; \ | ||
} | ||
|
||
GENERATE_LOCK(space); | ||
GENERATE_LOCK(id); | ||
GENERATE_LOCK(tag); | ||
GENERATE_LOCK(edge); | ||
|
||
#undef GENERATE_LOCK | ||
}; | ||
|
||
|
||
} // namespace meta | ||
} // namespace nebula | ||
#endif // META_PROCESSORS_COMMON_H_ | ||
|
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,96 @@ | ||
/* Copyright (c) 2019 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#include "meta/processors/admin/AdminClient.h" | ||
|
||
namespace nebula { | ||
namespace meta { | ||
|
||
folly::Future<Status> AdminClient::transLeader(GraphSpaceID spaceId, | ||
PartitionID partId, | ||
const HostAddr& leader, | ||
const HostAddr& dst) { | ||
UNUSED(spaceId); | ||
UNUSED(partId); | ||
UNUSED(leader); | ||
UNUSED(dst); | ||
if (injector_) { | ||
return injector_->transLeader(); | ||
} | ||
return Status::OK(); | ||
} | ||
|
||
folly::Future<Status> AdminClient::addPart(GraphSpaceID spaceId, | ||
PartitionID partId, | ||
const HostAddr& host, | ||
bool asLearner) { | ||
UNUSED(spaceId); | ||
UNUSED(partId); | ||
UNUSED(host); | ||
UNUSED(asLearner); | ||
if (injector_) { | ||
return injector_->addPart(); | ||
} | ||
return Status::OK(); | ||
} | ||
|
||
folly::Future<Status> AdminClient::addLearner(GraphSpaceID spaceId, PartitionID partId) { | ||
UNUSED(spaceId); | ||
UNUSED(partId); | ||
if (injector_) { | ||
return injector_->addLearner(); | ||
} | ||
return Status::OK(); | ||
} | ||
|
||
folly::Future<Status> AdminClient::waitingForCatchUpData(GraphSpaceID spaceId, | ||
PartitionID partId) { | ||
UNUSED(spaceId); | ||
UNUSED(partId); | ||
if (injector_) { | ||
return injector_->waitingForCatchUpData(); | ||
} | ||
return Status::OK(); | ||
} | ||
|
||
folly::Future<Status> AdminClient::memberChange(GraphSpaceID spaceId, PartitionID partId) { | ||
UNUSED(spaceId); | ||
UNUSED(partId); | ||
if (injector_) { | ||
return injector_->memberChange(); | ||
} | ||
return Status::OK(); | ||
} | ||
|
||
folly::Future<Status> AdminClient::updateMeta(GraphSpaceID spaceId, | ||
PartitionID partId, | ||
const HostAddr& leader, | ||
const HostAddr& dst) { | ||
UNUSED(spaceId); | ||
UNUSED(partId); | ||
UNUSED(leader); | ||
UNUSED(dst); | ||
if (injector_) { | ||
return injector_->updateMeta(); | ||
} | ||
return Status::OK(); | ||
} | ||
|
||
folly::Future<Status> AdminClient::removePart(GraphSpaceID spaceId, | ||
PartitionID partId, | ||
const HostAddr& host) { | ||
UNUSED(spaceId); | ||
UNUSED(partId); | ||
UNUSED(host); | ||
if (injector_) { | ||
return injector_->removePart(); | ||
} | ||
return Status::OK(); | ||
} | ||
|
||
} // namespace meta | ||
} // namespace nebula | ||
|
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,69 @@ | ||
/* Copyright (c) 2019 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#ifndef META_PROCESSORS_ADMIN_STORAGEADMINCLIENT_H_ | ||
#define META_PROCESSORS_ADMIN_STORAGEADMINCLIENT_H_ | ||
|
||
#include "base/Base.h" | ||
#include <folly/executors/IOThreadPoolExecutor.h> | ||
#include "base/Status.h" | ||
#include "thrift/ThriftClientManager.h" | ||
|
||
namespace nebula { | ||
namespace meta { | ||
|
||
class FaultInjector { | ||
public: | ||
virtual Status transLeader() = 0; | ||
virtual Status addPart() = 0; | ||
virtual Status addLearner() = 0; | ||
virtual Status waitingForCatchUpData() = 0; | ||
virtual Status memberChange() = 0; | ||
virtual Status updateMeta() = 0; | ||
virtual Status removePart() = 0; | ||
}; | ||
|
||
class AdminClient { | ||
public: | ||
AdminClient() = default; | ||
|
||
explicit AdminClient(std::unique_ptr<FaultInjector> injector) | ||
: injector_(std::move(injector)) {} | ||
|
||
~AdminClient() = default; | ||
|
||
folly::Future<Status> transLeader(GraphSpaceID spaceId, | ||
PartitionID partId, | ||
const HostAddr& leader, | ||
const HostAddr& dst); | ||
|
||
folly::Future<Status> addPart(GraphSpaceID spaceId, | ||
PartitionID partId, | ||
const HostAddr& host, | ||
bool asLearner); | ||
|
||
folly::Future<Status> addLearner(GraphSpaceID spaceId, PartitionID partId); | ||
|
||
folly::Future<Status> waitingForCatchUpData(GraphSpaceID spaceId, PartitionID partId); | ||
|
||
folly::Future<Status> memberChange(GraphSpaceID spaceId, PartitionID partId); | ||
|
||
folly::Future<Status> updateMeta(GraphSpaceID spaceId, | ||
PartitionID partId, | ||
const HostAddr& leader, | ||
const HostAddr& dst); | ||
|
||
folly::Future<Status> removePart(GraphSpaceID spaceId, | ||
PartitionID partId, | ||
const HostAddr& host); | ||
|
||
private: | ||
std::unique_ptr<FaultInjector> injector_{nullptr}; | ||
}; | ||
} // namespace meta | ||
} // namespace nebula | ||
|
||
#endif // META_PROCESSORS_ADMIN_STORAGEADMINCLIENT_H_ |
Oops, something went wrong.