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
TestScanWork.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 TESTSCANWORK_CC
19 #define TESTSCANWORK_CC
20 
21 #include "TestScanWork.h"
22 #include "PDBVector.h"
23 #include "InterfaceFunctions.h"
25 #include "PDBPage.h"
26 #include "DataProxy.h"
27 #include <string>
28 using namespace std;
29 
32  int& counter)
33  : counter(counter) {
34  this->iter = iter;
35  this->server = server;
36 }
37 
38 // do the actual work
39 
40 void TestScanWork::execute(PDBBuzzerPtr callerBuzzer) {
42  logger->writeLn("TestScanWork: running...");
43 
44  // create a new connection to frontend server
45  string errMsg;
46  pdb::PDBCommunicatorPtr communicatorToFrontEnd = make_shared<pdb::PDBCommunicator>();
47  communicatorToFrontEnd->connectToInternetServer(
48  logger, server->getConf()->getPort(), "localhost", errMsg);
49 
50  NodeID nodeId = server->getNodeID();
51  DataProxyPtr proxy = make_shared<DataProxy>(
52  nodeId, communicatorToFrontEnd, this->server->getSharedMem(), logger);
53 
54  PDBPagePtr page;
55  while (this->iter->hasNext()) {
56  page = this->iter->next();
57  // page still can be nullptr, so we MUST check nullptr here.
58  if (page != nullptr) {
59  std::cout << "processing page with pageId=" << page->getPageID() << std::endl;
63  std::cout << "there are " << objects->size() << " objects on the page." << std::endl;
64 
65  // clean the page;
66  if (proxy->unpinUserPage(
67  nodeId, page->getDbID(), page->getTypeID(), page->getSetID(), page) == false) {
68  logger->writeLn("TestScanWork: can not add finished page to cleaner.");
69  callerBuzzer->buzz(PDBAlarm::QueryError);
70  return;
71  }
72  }
73  }
74  callerBuzzer->buzz(PDBAlarm::WorkAllDone, counter);
75  return;
76 }
77 
78 #endif
shared_ptr< PDBPage > PDBPagePtr
Definition: PDBPage.h:32
Handle< ObjType > getRootObject()
Definition: Record.cc:46
shared_ptr< DataProxy > DataProxyPtr
Definition: DataProxy.h:30
unsigned int NodeID
Definition: DataTypes.h:27
void execute(PDBBuzzerPtr callerBuzzer) override
Definition: TestScanWork.cc:40
std::shared_ptr< PDBCommunicator > PDBCommunicatorPtr
pdb::HermesExecutionServer * server
Definition: TestScanWork.h:46
shared_ptr< PDBBuzzer > PDBBuzzerPtr
Definition: PDBBuzzer.h:32
PageCircularBufferIteratorPtr iter
Definition: TestScanWork.h:45
std::shared_ptr< PDBLogger > PDBLoggerPtr
Definition: PDBLogger.h:40
TestScanWork(PageCircularBufferIteratorPtr iter, pdb::HermesExecutionServer *server, int &counter)
Definition: TestScanWork.cc:30
shared_ptr< PageCircularBufferIterator > PageCircularBufferIteratorPtr