A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DispatcherClient.cc
Go to the documentation of this file.
1 /*****************************************************************************
2  * *
3  * Copyright 2018 Rice University *
4  * *
5  * Licensed under the Apache License, Version 2.0 (the "License"); *
6  * you may not use this file except in compliance with the License. *
7  * You may obtain a copy of the License at *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14  * See the License for the specific language governing permissions and *
15  * limitations under the License. *
16  * *
17  *****************************************************************************/
18 #ifndef OBJECTQUERYMODEL_DISPATCHERCLIENT_CC
19 #define OBJECTQUERYMODEL_DISPATCHERCLIENT_CC
20 
21 #include "DispatcherClient.h"
22 #include "SimpleRequest.h"
24 
25 namespace pdb {
26 
28 
29 DispatcherClient::DispatcherClient(int portIn, std::string addressIn, PDBLoggerPtr myLoggerIn)
30  : myHelper(portIn, addressIn, myLoggerIn) {
31  this->logger = myLoggerIn;
32  this->port = portIn;
33  this->address = addressIn;
34 }
35 
37 
39 
40 bool DispatcherClient::registerSet(std::pair<std::string, std::string> setAndDatabase,
42  std::string& errMsg) {
43 
44  return simpleRequest<DispatcherRegisterPartitionPolicy, SimpleRequestResult, bool>(
45  logger,
46  port,
47  address,
48  false,
49  1024,
50  [&](Handle<SimpleRequestResult> result) {
51  if (result != nullptr) {
52  if (!result->getRes().first) {
53  errMsg = "Error registering partition policy for " + setAndDatabase.first +
54  ":" + setAndDatabase.second + ": " + result->getRes().second;
55  logger->error(errMsg);
56  return false;
57  }
58  return true;
59  }
60  errMsg =
61  "Error registering partition policy: got nothing back from the DispatcherServer";
62  return false;
63  },
64  setAndDatabase.first,
65  setAndDatabase.second,
66  policy);
67 }
68 }
69 
70 #include "StorageClientTemplate.cc"
71 
72 #endif
bool registerSet(std::pair< std::string, std::string > setAndDatabase, PartitionPolicy::Policy policy, std::string &errMsg)
std::shared_ptr< PDBLogger > PDBLoggerPtr
Definition: PDBLogger.h:40
void registerHandlers(PDBServer &forMe) override