working on distribution infrastructure some more, ssh working

git-svn-id: svn://anubis/fart/trunk@222 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2009-04-05 16:42:30 +00:00
parent 74399fe145
commit 1dbe7040e4
5 changed files with 73 additions and 8 deletions

View File

@ -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;
}

View File

@ -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<std::string> m_hosts;
std::vector<int> m_children;
std::string m_servername;

View File

@ -29,6 +29,7 @@ Scene::Scene(const map<string, const char *> & 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<string, const char *> & 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 */

View File

@ -7,16 +7,21 @@
#include <vector>
#include <utility>
#include <stack>
#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<Material> > 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;
};

View File

@ -20,6 +20,7 @@ void usage(const char * progname)
cout << " -m|--multisample <level>" << endl;
cout << " -f|--field-of-view <vertical-fov>" << endl;
cout << " -d|--max-depth <max-recursion-depth>" << endl;
cout << " --hosts <hosts-file>" << endl;
cout << " -v|--verbose" << endl;
exit(42);
}
@ -31,7 +32,6 @@ int main(int argc, char * argv[])
map<string, const char *> 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;
}
}