From 1dbe7040e43810f3ed76fd56cf05dce0c98438ef Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 5 Apr 2009 16:42:30 +0000 Subject: [PATCH] working on distribution infrastructure some more, ssh working git-svn-id: svn://anubis/fart/trunk@222 7f9b0f55-74a9-4bce-be96-3c2cd072584d --- distrib/distrib.cc | 15 +++++++++++++-- distrib/distrib.h | 4 +++- main/Scene.cc | 26 ++++++++++++++++++++++++++ main/Scene.h | 14 +++++++++++++- main/fart.cc | 22 ++++++++++++++++++---- 5 files changed, 73 insertions(+), 8 deletions(-) diff --git a/distrib/distrib.cc b/distrib/distrib.cc index c25babb..8a5891e 100644 --- a/distrib/distrib.cc +++ b/distrib/distrib.cc @@ -53,10 +53,14 @@ int distrib::connect(const string & host) } else /* in the child */ { + char server_port_str[15]; + sprintf(server_port_str, "%d", m_serverport); execlp("ssh", "ssh", host.c_str(), "fart", "--host", m_servername.c_str(), - "--port", m_serverport, - NULL); + "--port", server_port_str, + (char *) NULL); + + /* we should not get here */ cerr << "Error " << errno << " with execlp()!" << endl; exit(33); } @@ -66,6 +70,8 @@ int distrib::connect(const string & host) int distrib::startServer() { + connect(); + char hostname[1000]; gethostname(&hostname[0], 1000); m_servername = hostname; @@ -105,3 +111,8 @@ int distrib::startServer() return 0; } + +int distrib::startClient(const char * server, int port) +{ + return 0; +} diff --git a/distrib/distrib.h b/distrib/distrib.h index 9c7d03d..e16a49c 100644 --- a/distrib/distrib.h +++ b/distrib/distrib.h @@ -9,11 +9,13 @@ class distrib { public: int readHostFile(const char * filename); - int connect(); int startServer(); + int startClient(const char * server, int port); protected: + int connect(); int connect(const std::string & host); + std::vector m_hosts; std::vector m_children; std::string m_servername; diff --git a/main/Scene.cc b/main/Scene.cc index f26c89e..8632d5c 100644 --- a/main/Scene.cc +++ b/main/Scene.cc @@ -29,6 +29,7 @@ Scene::Scene(const map & options, m_ambient_light = Color(0.2, 0.2, 0.2); m_max_depth = 10; m_transforms.push(Transform()); + m_server = true; load(filename); @@ -65,6 +66,31 @@ Scene::Scene(const map & options, { m_verbose = true; } + else if (it->first == "host") + { + m_server_name = it->second; + m_server = false; + } + else if (it->first == "port") + { + m_server_port = atoi(it->second); + } + else if (it->first == "hosts") + { + m_hosts_file = it->second; + } + } + + /* start the distribution infrastructure */ + if (m_server) + { + if (m_hosts_file != "") + m_distrib.readHostFile(m_hosts_file.c_str()); + m_distrib.startServer(); + } + else + { + m_distrib.startClient(m_server_name.c_str(), m_server_port); } /* view plane distance is calculated based on the field of view */ diff --git a/main/Scene.h b/main/Scene.h index c14dccf..38af097 100644 --- a/main/Scene.h +++ b/main/Scene.h @@ -7,16 +7,21 @@ #include #include #include + #include "util/refptr.h" #include "util/Ray.h" #include "util/Color.h" #include "util/Material.h" + +#include "distrib/distrib.h" + #include "shapes/shapes.h" -#include "Light.h" #include "parser/parser.h" #include "parser/nodes.h" +#include "Light.h" + #define SCENE_FACTOR_THRESHOLD 0.02 class Scene @@ -84,6 +89,13 @@ class Scene double m_half_sample_span; std::map< std::string, refptr > m_materials; + /* distribution infrastructure */ + bool m_server; + std::string m_server_name; + std::string m_hosts_file; + int m_server_port; + distrib m_distrib; + /* framebuffer */ unsigned char * m_data; }; diff --git a/main/fart.cc b/main/fart.cc index a601446..dbcafb9 100644 --- a/main/fart.cc +++ b/main/fart.cc @@ -20,6 +20,7 @@ void usage(const char * progname) cout << " -m|--multisample " << endl; cout << " -f|--field-of-view " << endl; cout << " -d|--max-depth " << endl; + cout << " --hosts " << endl; cout << " -v|--verbose" << endl; exit(42); } @@ -31,7 +32,6 @@ int main(int argc, char * argv[]) map scene_options; static const struct option long_options[] = { - { "help", no_argument, NULL, 256 }, { "output-file", required_argument, NULL, 'o' }, { "width", required_argument, NULL, 'w' }, { "height", required_argument, NULL, 'h' }, @@ -39,6 +39,10 @@ int main(int argc, char * argv[]) { "field-of-view", required_argument, NULL, 'f' }, { "max-depth", required_argument, NULL, 'd' }, { "verbose", no_argument, NULL, 'v' }, + { "help", no_argument, NULL, 256 }, + { "host", required_argument, NULL, 257 }, + { "port", required_argument, NULL, 258 }, + { "hosts", required_argument, NULL, 259 }, { NULL, 0, NULL, 0 } }; @@ -47,9 +51,6 @@ int main(int argc, char * argv[]) { switch (opt) { - case 256: - usage(argv[0]); - break; case 'o': scene_options["output-file"] = optarg; break; @@ -71,8 +72,21 @@ int main(int argc, char * argv[]) case 'v': scene_options["verbose"] = optarg; break; + case 256: + usage(argv[0]); + break; + case 257: + scene_options["host"] = optarg; + break; + case 258: + scene_options["port"] = optarg; + break; + case 259: + scene_options["hosts"] = optarg; + break; default: usage(argv[0]); + break; } }