-
Notifications
You must be signed in to change notification settings - Fork 409
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
Showing
2,026 changed files
with
6,800 additions
and
56,382 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,30 +1,32 @@ | ||
#pragma once | ||
|
||
#include <Poco/Exception.h> | ||
#include <exception> | ||
#include <string> | ||
#include <Poco/Exception.h> | ||
|
||
namespace pingcap { | ||
namespace pingcap | ||
{ | ||
|
||
const int MismatchClusterIDCode = 1; | ||
const int GRPCErrorCode = 2; | ||
const int InitClusterIDFailed = 3; | ||
const int UpdatePDLeaderFailed = 4; | ||
const int TimeoutError = 5; | ||
const int RegionUnavailable = 6; | ||
const int LogicalError = 7; | ||
const int LockError = 8; | ||
|
||
class Exception : public Poco::Exception | ||
{ | ||
public: | ||
Exception() {} /// For deferred initialization. | ||
Exception() {} /// For deferred initialization. | ||
Exception(const std::string & msg, int code = 0) : Poco::Exception(msg, code) {} | ||
Exception(const std::string & msg, const std::string & arg, int code = 0) : Poco::Exception(msg, arg, code) {} | ||
Exception(const std::string & msg, const Exception & exc, int code = 0) : Poco::Exception(msg, exc, code) {} | ||
explicit Exception(const Poco::Exception & exc) : Poco::Exception(exc.displayText()) {} | ||
|
||
Exception * clone() const override { return new Exception(*this); } | ||
void rethrow() const override { throw *this; } | ||
|
||
}; | ||
|
||
} | ||
} // namespace pingcap |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#include <Poco/Logger.h> | ||
|
||
namespace pingcap { | ||
namespace pingcap | ||
{ | ||
using Poco::Logger; | ||
} |
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 |
---|---|---|
@@ -1,41 +1,43 @@ | ||
#pragma once | ||
|
||
#include<string> | ||
#include<vector> | ||
#include <string> | ||
#include <vector> | ||
|
||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wunused-parameter" | ||
#include <kvproto/enginepb.pb.h> | ||
#pragma GCC diagnostic pop | ||
|
||
namespace pingcap { | ||
namespace pd { | ||
namespace pingcap | ||
{ | ||
namespace pd | ||
{ | ||
|
||
class IClient { | ||
class IClient | ||
{ | ||
public: | ||
// virtual uint64_t getClusterID() = 0; | ||
// virtual uint64_t getClusterID() = 0; | ||
|
||
virtual ~IClient() {} | ||
|
||
virtual uint64_t getTS() = 0; | ||
|
||
virtual std::tuple<metapb::Region, metapb::Peer, std::vector<metapb::Peer>> getRegion(std::string key) = 0; | ||
|
||
// virtual std::pair<metapb::Region, metapb::Peer> getPrevRegion(std::string key) = 0; | ||
// virtual std::pair<metapb::Region, metapb::Peer> getPrevRegion(std::string key) = 0; | ||
|
||
virtual std::tuple<metapb::Region, metapb::Peer, std::vector<metapb::Peer>> getRegionByID(uint64_t region_id) = 0; | ||
|
||
virtual metapb::Store getStore(uint64_t store_id) = 0; | ||
|
||
// virtual std::vector<metapb::Store> getAllStores() = 0; | ||
// virtual std::vector<metapb::Store> getAllStores() = 0; | ||
|
||
virtual uint64_t getGCSafePoint() = 0; | ||
|
||
virtual bool isMock() = 0; | ||
|
||
}; | ||
|
||
using ClientPtr = std::shared_ptr<IClient>; | ||
|
||
} | ||
} | ||
} // namespace pd | ||
} // namespace pingcap |
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 |
---|---|---|
@@ -1,46 +1,34 @@ | ||
#pragma once | ||
|
||
#include <limits> | ||
#include <pd/IClient.h> | ||
#include <limits> | ||
|
||
namespace pingcap { | ||
namespace pd { | ||
namespace pingcap | ||
{ | ||
namespace pd | ||
{ | ||
|
||
using Clock = std::chrono::system_clock; | ||
using Seconds = std::chrono::seconds; | ||
|
||
class MockPDClient : public IClient { | ||
class MockPDClient : public IClient | ||
{ | ||
public: | ||
MockPDClient() = default; | ||
|
||
~MockPDClient() override {} | ||
|
||
uint64_t getGCSafePoint() override | ||
{ | ||
return (Clock::now() - Seconds(2)).time_since_epoch().count(); | ||
} | ||
uint64_t getGCSafePoint() override { return 1000000000000000; } | ||
|
||
uint64_t getTS() override | ||
{ | ||
return Clock::now().time_since_epoch().count(); | ||
} | ||
uint64_t getTS() override { return Clock::now().time_since_epoch().count(); } | ||
|
||
std::tuple<metapb::Region, metapb::Peer, std::vector<metapb::Peer>> getRegion(std::string) override { | ||
throw "not implemented"; | ||
} | ||
std::tuple<metapb::Region, metapb::Peer, std::vector<metapb::Peer>> getRegion(std::string) override { throw "not implemented"; } | ||
|
||
std::tuple<metapb::Region, metapb::Peer, std::vector<metapb::Peer>> getRegionByID(uint64_t) override { | ||
throw "not implemented"; | ||
} | ||
std::tuple<metapb::Region, metapb::Peer, std::vector<metapb::Peer>> getRegionByID(uint64_t) override { throw "not implemented"; } | ||
|
||
metapb::Store getStore(uint64_t) override { | ||
throw "not implemented"; | ||
} | ||
metapb::Store getStore(uint64_t) override { throw "not implemented"; } | ||
|
||
bool isMock() override { | ||
return true; | ||
} | ||
bool isMock() override { return true; } | ||
}; | ||
|
||
} | ||
} | ||
} // namespace pd | ||
} // namespace pingcap |
Oops, something went wrong.