本文整理汇总了C++中Transporter::isConnected方法的典型用法代码示例。如果您正苦于以下问题:C++ Transporter::isConnected方法的具体用法?C++ Transporter::isConnected怎么用?C++ Transporter::isConnected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transporter
的用法示例。
在下文中一共展示了Transporter::isConnected方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void
TransporterRegistry::update_connections()
{
for (int i= 0, n= 0; n < nTransporters; i++){
Transporter * t = theTransporters[i];
if (!t)
continue;
n++;
const NodeId nodeId = t->getRemoteNodeId();
switch(performStates[nodeId]){
case CONNECTED:
case DISCONNECTED:
break;
case CONNECTING:
if(t->isConnected())
report_connect(nodeId);
break;
case DISCONNECTING:
if(!t->isConnected())
report_disconnect(nodeId, 0);
break;
}
}
}
示例2: reportError
SendStatus
TransporterRegistry::prepareSend(const SignalHeader * const signalHeader,
Uint8 prio,
const Uint32 * const signalData,
NodeId nodeId,
class SectionSegmentPool & thePool,
const SegmentedSectionPtr ptr[3]){
Transporter *t = theTransporters[nodeId];
if(t != NULL &&
(((ioStates[nodeId] != HaltOutput) && (ioStates[nodeId] != HaltIO)) ||
((signalHeader->theReceiversBlockNumber == 252)||
(signalHeader->theReceiversBlockNumber == 4002)))) {
if(t->isConnected()){
Uint32 lenBytes = t->m_packer.getMessageLength(signalHeader, ptr);
if(lenBytes <= MAX_MESSAGE_SIZE){
Uint32 * insertPtr = t->getWritePtr(lenBytes, prio);
if(insertPtr != 0){
t->m_packer.pack(insertPtr, prio, signalHeader, signalData, thePool, ptr);
t->updateWritePtr(lenBytes, prio);
return SEND_OK;
}
/**
* @note: on linux/i386 the granularity is 10ms
* so sleepTime = 2 generates a 10 ms sleep.
*/
int sleepTime = 2;
for(int i = 0; i<50; i++){
if((nSHMTransporters+nSCITransporters) == 0)
NdbSleep_MilliSleep(sleepTime);
insertPtr = t->getWritePtr(lenBytes, prio);
if(insertPtr != 0){
t->m_packer.pack(insertPtr, prio, signalHeader, signalData, thePool, ptr);
t->updateWritePtr(lenBytes, prio);
break;
}
}
if(insertPtr != 0){
/**
* Send buffer full, but resend works
*/
reportError(callbackObj, nodeId, TE_SEND_BUFFER_FULL);
return SEND_OK;
}
WARNING("Signal to " << nodeId << " lost(buffer)");
reportError(callbackObj, nodeId, TE_SIGNAL_LOST_SEND_BUFFER_FULL);
return SEND_BUFFER_FULL;
} else {
return SEND_MESSAGE_TOO_BIG;
}
} else {
DEBUG("Signal to " << nodeId << " lost(disconnect) ");
return SEND_DISCONNECTED;
}
} else {
DEBUG("Discarding message to block: "
<< signalHeader->theReceiversBlockNumber
<< " node: " << nodeId);
if(t == NULL)
return SEND_UNKNOWN_NODE;
return SEND_BLOCKED;
}
}
示例3: if
// run as own thread
void
TransporterRegistry::start_clients_thread()
{
int persist_mgm_count= 0;
DBUG_ENTER("TransporterRegistry::start_clients_thread");
while (m_run_start_clients_thread) {
NdbSleep_MilliSleep(100);
persist_mgm_count++;
if(persist_mgm_count==50)
{
ndb_mgm_check_connection(m_mgm_handle);
persist_mgm_count= 0;
}
for (int i= 0, n= 0; n < nTransporters && m_run_start_clients_thread; i++){
Transporter * t = theTransporters[i];
if (!t)
continue;
n++;
const NodeId nodeId = t->getRemoteNodeId();
switch(performStates[nodeId]){
case CONNECTING:
if(!t->isConnected() && !t->isServer) {
bool connected= false;
/**
* First, we try to connect (if we have a port number).
*/
if (t->get_s_port())
connected= t->connect_client();
/**
* If dynamic, get the port for connecting from the management server
*/
if( !connected && t->get_s_port() <= 0) { // Port is dynamic
int server_port= 0;
struct ndb_mgm_reply mgm_reply;
if(!ndb_mgm_is_connected(m_mgm_handle))
ndb_mgm_connect(m_mgm_handle, 0, 0, 0);
if(ndb_mgm_is_connected(m_mgm_handle))
{
int res=
ndb_mgm_get_connection_int_parameter(m_mgm_handle,
t->getRemoteNodeId(),
t->getLocalNodeId(),
CFG_CONNECTION_SERVER_PORT,
&server_port,
&mgm_reply);
DBUG_PRINT("info",("Got dynamic port %d for %d -> %d (ret: %d)",
server_port,t->getRemoteNodeId(),
t->getLocalNodeId(),res));
if( res >= 0 )
{
/**
* Server_port == 0 just means that that a mgmt server
* has not received a new port yet. Keep the old.
*/
if (server_port)
t->set_s_port(server_port);
}
else if(ndb_mgm_is_connected(m_mgm_handle))
{
g_eventLogger.info("Failed to get dynamic port to connect to: %d", res);
ndb_mgm_disconnect(m_mgm_handle);
}
else
{
g_eventLogger.info("Management server closed connection early. "
"It is probably being shut down (or has problems). "
"We will retry the connection. %d %s %s line: %d",
ndb_mgm_get_latest_error(m_mgm_handle),
ndb_mgm_get_latest_error_desc(m_mgm_handle),
ndb_mgm_get_latest_error_msg(m_mgm_handle),
ndb_mgm_get_latest_error_line(m_mgm_handle)
);
}
}
/** else
* We will not be able to get a new port unless
* the m_mgm_handle is connected. Note that not
* being connected is an ok state, just continue
* until it is able to connect. Continue using the
* old port until we can connect again and get a
* new port.
*/
}
}
break;
case DISCONNECTING:
if(t->isConnected())
t->doDisconnect();
break;
default:
break;
}
}
}
DBUG_VOID_RETURN;
//.........这里部分代码省略.........