示例#1
0
int main(int argc, char* argv[])
{
	/* get the NetAddr of the server */
	NetAddr netAddr(argv[1]);

	/* get netaddr to the proxy */
	NetAddr proxy(argv[2]);

	/* get size of objects */
	int objectSize;
	istringstream ss(argv[3]);
	ss >> objectSize;

	/* Initialize Server with our NetAddr */
	Ginnungagap::Initialize(SERVER, 50, netAddr, netAddr);

	/* Start necessary threads */
	Ginnungagap::Instance()->startDataSenderThread();
	Ginnungagap::Instance()->startDataAndConnectionReceiverThread();
	Ginnungagap::Instance()->startMessageHandlerThread();

	/* set terminal in ``any key''-mode */
	struct termios oldT, newT;
	ioctl(0, TCGETS, &oldT);
	newT = oldT;
	newT.c_lflag &= ~ECHO;
	newT.c_lflag &= ~ICANON;
	ioctl(0, TCSETS, &newT);

	cout << "Press any key once proxy is connected" << endl;
	cin.get();
	cout << "Migrating objects..." << endl;


	TestObject* test;
	for (int i = 0; i != 10000; ++i)
	{
		test = new TestObject(objectSize);
		Ginnungagap::Instance()->nameService()->bind(*test);
		Ginnungagap::Instance()->migrationService()->migrateObject(test->objectId(), proxy);
		usleep(30000);
	}

	cout << "Done migrating objects, press any key to exit" << endl;
	cin.get();

	/* restore original terminal mode */
	ioctl(0, TCSETS, &oldT);
	return 1;
}