RavenNetTestServer.cpp 2.03 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <string>

#include <ITASimulationScheduler/Raven/RavenNetServer.h>

#include <ITASimulationScheduler/Raven/R_RavenSimulator.h>
#include <ITASimulationScheduler/Raven/R_RavenLocalScheduler.h>

#include <ITAFilesystemUtils.h>

#include <omp.h>

using namespace std;

int main(int argc, char** argv) {

	if( argc != 2 )
	{
		cerr << "Syntax error, usage: RavenNetTestServer RAVENDATABASEPATH" << endl;
		return 255;
	}

	string sRavenDataBasePath = string( argv[1] );
	if( doesDirectoryExist( sRavenDataBasePath ) == false )
	{
		cerr << "Given Raven data base path '" << sRavenDataBasePath << "' not found on this machine" << endl;
		return 255;
	}	

	cout << "OpenMP max threads: " << omp_get_max_threads() << endl;

	string sServerName = "0.0.0.0"; // all interfaces
	unsigned int uiPort = 12480;
	IRavenNetServer::tPortList liFreePorts;
	liFreePorts.push_back( IRavenNetServer::tPortRange( uiPort+1, 12499 ) );

	cout << "Waiting for connections on all interfaces using port " << uiPort << endl;

	IRavenNetServer* pServer = IRavenNetServer::Create();

	int iMode = IRavenNetServer::SCHEDULER;

	if (iMode & IRavenNetServer::SIMULATOR)
	{
		// Create and set up Standalone Raven Simulator
		CRavenSimulator* pSimulator = new CRavenSimulator(sRavenDataBasePath);

		// Create server and connect Raven instance
Pascal Palenda's avatar
Pascal Palenda committed
49
		pServer->SetRavenSimulator( (ISimulationInterface*) pSimulator );
50
51
52
53
54
	}

	if (iMode & IRavenNetServer::SCHEDULER)
	{
		// Create and set up Raven Scheduler on this machine
Pascal Palenda's avatar
Pascal Palenda committed
55
		CLocalScheduler::CConfiguration oConf;
56
		oConf.sRavenDataBasePath = sRavenDataBasePath;
Pascal Palenda's avatar
Pascal Palenda committed
57
58
		CLocalScheduler* pScheduler = new CLocalScheduler( oConf );
		pServer->SetRavenSimulationScheduler( (ISimulationSchedulerInterface*) pScheduler );
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
	}
	
	// Start
	if( pServer->Initialize(sServerName, (int) uiPort, liFreePorts, iMode) != IRavenNetServer::RAVEN_NO_ERROR ) {
		cerr << "Could not initialize server" << endl;
	}

	int iAnyKey;
	cout << endl << "Any key quits ..." << endl << endl;	
	cin >> iAnyKey;

	pServer->Finalize(); // Lscht auch den Simulator
	
	return 0;
}