voltdb::Client
ConnectionPool::acquireClient(
        std::string hostname,
        std::string username,
        std::string password,
        unsigned short port,
        ClientAuthHashScheme sha)
throw (voltdb::Exception, voltdb::ConnectException, voltdb::LibEventException) {
    return acquireClient(hostname, username, password, NULL, port, sha);
}
Пример #2
0
// Gets Called in a thread
void ServerManager::threadNewConnection(int clientID) {
	string initMsgBuff;
	string cmdName;
	Command* tempCmd;
	Client * newClient = cm->findClientByID(clientID);
	bool success = false;

	cout << " and new connection thread found " << newClient->getSocketID() << endl;

	while (!mtx.try_lock()) {
		// Keep Trying!
	}
	// Mutex is Locked

// Receive Login or NewAccount
	initMsgBuff = newClient->getSocket().Receive();
	//	initMsgBuff = "Login Todd Password 127.0.0.1";


		// Build Command for either
	if (initMsgBuff.find("Login") != std::string::npos) {
		tempCmd = (*cmdMap)["Login"]->Clone();
	}
	//else if (initMsgBuff.find("NewAccount") != std::string::npos) {
	//	tempCmd = (*cmdMap)["NewAccount"]->Clone();
	//}
	else {
		tempCmd = (*cmdMap)["NewAccount"]->Clone();
	}
	tempCmd->Initialize(initMsgBuff);
	success = tempCmd->Execute();

	// Send Result?  Or have the Command return the result
	delete tempCmd;

	// LoginCheck::Execute() will find initMsgType from initMsgBuff
	tempCmd = (*cmdMap)["LoginCheck"]->Clone();
	tempCmd->GetClient(newClient);

	if (success) {
		tempCmd->Initialize(initMsgBuff + " 1");
		// Acquire the Client
		acquireClient(*newClient);
	}
	else {
		tempCmd->Initialize(initMsgBuff + " 0");
	}

	tempCmd->Execute();
	// Unlock ServerManager Data

	cout << "Finished handling new Connection!" << endl;
	mtx.unlock();
}