| 53 | class DistGraphClientImpl : public GraphClientImplBase<DistGraphClientTypes> { |
| 54 | public: |
| 55 | bool Init(const GraphConfig& config) { |
| 56 | resource_.reset(new graph_op::DistGSOpResource); |
| 57 | |
| 58 | std::vector<deepx_core::TcpEndpoint> endpoints = |
| 59 | deepx_core::MakeTcpEndpoints(config.ip_ports()); |
| 60 | auto rpc_connector = NewRpcConnector(); |
| 61 | if (!rpc_connector->Connect(endpoints)) { |
| 62 | return false; |
| 63 | } |
| 64 | resource_->set_rpc_connector(std::move(rpc_connector)); |
| 65 | |
| 66 | int shard_num = (int)endpoints.size(); |
| 67 | if (shard_num <= 0) { |
| 68 | DXERROR("Number of shard: %d must be greater than 0.", shard_num); |
| 69 | return false; |
| 70 | } |
| 71 | DXINFO("Number of shard is: %d.", shard_num); |
| 72 | |
| 73 | // op factory init |
| 74 | factory_ = graph_op::DistGSOpFactory::GetInstance(); |
| 75 | if (!factory_->Init(resource_.get(), shard_num)) { |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | return PostInitCacheStorage(resource_.get()) && |
| 80 | PostInitServerDistribution(shard_num, resource_.get()); |
| 81 | } |
| 82 | }; |
| 83 | |
| 84 | std::unique_ptr<GraphClientImpl> NewDistGraphClientImpl( |
no test coverage detected