Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed bug in clieng_gen script

Summary: Thrift keyword 'oneway' wasn't recognized by the script,
and was treaded as part of the return type.

Tags:

Reviewers:

CCs:

Blamed Revisions:

Tickets:
  • Loading branch information...
commit 71ae2dc14c3306f3943f53167f355b6f66731315 1 parent 7436abe
@prasko prasko authored
View
9 scripts/client_gen.py
@@ -92,7 +92,14 @@ def read_services(data):
rs[1], re.DOTALL)
for rw in raw_funs:
- f = Function(TType.parse(rw[0].translate(None, ' ')), rw[1])
+
+ if rw[0].find('oneway') != -1:
+ tip = TType.parse(
+ ''.join(rw[0].strip().split(' ')[1:]).translate(None, ' '))
+ else:
+ tip = TType.parse(rw[0].translate(None, ' '))
+
+ f = Function(tip, rw[1])
raw_params = [p.strip().translate(None, '\n\r')
for p in rw[2].split(',')]
View
4 src/dispatcher/dispatcher_client.h
@@ -1,4 +1,4 @@
-#ifndef EVAL_DISPATCHER_CLIENT_H_
+ #ifndef EVAL_DISPATCHER_CLIENT_H_
#define EVAL_DISPATCHER_CLIENT_H_
#include <string>
@@ -32,9 +32,9 @@ class DispatcherClient {
transport_->open();
} catch(const apache::thrift::TException &tx) {
// TODO(someone): log this
-
}
}
+
~DispatcherClient() {
try {
transport_->close();
View
6 src/worker/worker.thrift
@@ -21,10 +21,10 @@
service Worker {
- bool ping(),
+ oneway void ping(),
/**
- * Sets the given task for computation on the worker.
+ * Sets the given job for computation on the worker.
*/
- oneway void giveTask(1:i32 taskId)
+ oneway void giveJob(1:i32 jobId)
}
View
62 src/worker/worker_client.h
@@ -0,0 +1,62 @@
+#ifndef EVAL_WORKER_CLIENT_H_
+#define EVAL_WORKER_CLIENT_H_
+
+#include <string>
+#include <protocol/TBinaryProtocol.h>
+#include <transport/TSocket.h>
+#include <transport/TBufferTransports.h>
+#include <transport/TTransportUtils.h>
+#include <boost/shared_ptr.hpp>
+
+#include "gen-cpp/Worker.h"
+
+namespace eval {
+
+class WorkerClient {
+ public:
+
+ WorkerClient(const std::string &ip, const int port) {
+ boost::shared_ptr<apache::thrift::transport::TTransport> socket(
+ new apache::thrift::transport::TSocket(ip, port));
+
+ transport_ = boost::shared_ptr<apache::thrift::transport::TTransport>(
+ new apache::thrift::transport::TBufferedTransport(socket));
+
+ boost::shared_ptr<apache::thrift::protocol::TProtocol> protocol(
+ new apache::thrift::protocol::TBinaryProtocol(transport_));
+
+ client_ = boost::shared_ptr< ::WorkerClient>(
+ new ::WorkerClient(protocol));
+
+ try {
+ transport_->open();
+ } catch(const apache::thrift::TException &tx) {
+ // TODO(someone): log this
+ }
+ }
+
+ ~WorkerClient() {
+ try {
+ transport_->close();
+ } catch(const apache::thrift::TException &tx) {
+ // TODO(someone): log this
+ }
+ }
+
+ void ping() {
+ client_->ping();
+ }
+
+ void giveJob(const int jobId) {
+ client_->giveJob(jobId);
+ }
+
+ private:
+ boost::shared_ptr< ::WorkerClient> client_;
+ boost::shared_ptr<apache::thrift::transport::TTransport> transport_;
+
+};
+
+} // namespace
+
+#endif // EVAL_WORKER_CLIENT_H_
View
5 src/worker/worker_handler.cc
@@ -25,12 +25,11 @@
namespace eval {
-bool WorkerHandler::ping(){
+void WorkerHandler::ping(){
// TODO(prasko): implement
- return true;
}
-void WorkerHandler::giveTask(const int taskId) {
+void WorkerHandler::giveJob(const int jobId) {
// TODO(prasko): implement work
usleep(5);
}
View
4 src/worker/worker_handler.h
@@ -31,9 +31,9 @@ class WorkerHandler : virtual public WorkerIf {
WorkerHandler() {}
- bool ping();
+ void ping();
- void giveTask(const int taskId);
+ void giveJob(const int /* taskId */);
};
} // namespace
View
1  src/worker/worker_main.cc
@@ -67,6 +67,7 @@ void startServer(int port) {
int main(int argc, char **argv) {
assert(argc == 3);
+
/*
TODO(prasko): read configuration:
- dispatcher's ip+port
Please sign in to comment.
Something went wrong with that request. Please try again.