Example #1
0
void printUDT(std::wstringstream& str,const UDT& udt,int depth)
{
  printDepth(str,depth);
  //str << udt.getID() << L" " << udt.getTypeID() << L" ";
  str << udt.getKind() << L" " << udt.getName();
  UDT::Bases bases = udt.getBases();
  printBaseList(str,bases);
  str << std::endl;

  printDepth(str,depth);
  str << L"{\n";

  CV_access_e protection = udt.getDefaultProtection();

  UDT::Nested nested = udt.getNested();
  for(UDT::Nested::const_iterator it = nested.begin(); it != nested.end(); ++it)
  {
    printUDT(str,*it,depth+1);
  }

/*
  std::wstring friends = udt.getFriends();
  if(!friends.empty())
  {
    printDepth(str,depth);
    str << L"//friends " << friends << std::endl;
  }
*/

  std::wstring enums = udt.getEnums();
  if(!enums.empty())
  {
    str << enums;
  }

  std::wstring typedefs = udt.getTypedefs();
  if(!typedefs.empty())
  {
    str << typedefs;
  }

  UDT::DataMembers dataMembers = udt.getDataMembers();
  printMembers(str,dataMembers,depth,protection);

  UDT::Functions functions = udt.getFunctions();
  printFunctions(str,functions,depth,protection);

  printDepth(str,depth);
  str << L"};\n";
}
Example #2
0
bool P3ReplicationGroup::prebindControlToReplica(OverlayPeerInfoPtr& replica) {
    ACE_GUARD_RETURN(ACE_SYNCH_RECURSIVE_MUTEX, mon, m_lock, false);
    ACE_Connector<FTControlClientHandler, ACE_SOCK_Connector> connector;
    Endpoint endpoint;
    replica->getFTSAPInfo()->getFirstEndpoint(endpoint);
    ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::prebindControlToReplica - SAP=%s\n"), endpoint.toString().c_str()));
    ThreadPerConnection *tpc = new ThreadPerConnection();
    //ACE_Strong_Bound_Ptr<ThreadPerConnection, ACE_Recursive_Thread_Mutex>* tpcPrt = new
    //      ACE_Strong_Bound_Ptr<ThreadPerConnection, ACE_Recursive_Thread_Mutex > (tpc);
    ExecutionModelPtr* tpcPrt = new
            ExecutionModelPtr(tpc);

    FTControlClientHandler* ftControlClient = new FTControlClientHandler(
            this,
            replica->getUUID(),
            replica->getFID(),
            this->getGroupUUID(),
            false, false, tpcPrt, 0, 0, 0);

    printMembers();
    SAPInfoPtr ftDataSAPInfo;

    //*(getGroupMembers()));
    CPUReservation* reserve = 0;
    CPUQoS* cpuQoS = new CPUPriorityQoS(CPUQoS::SCHEDULE_RT_DEFAULT, CPUQoS::MAX_RT_PRIO);
    if (this->m_ft->getQoSManager() != 0) {
        reserve = m_ft->getQoSManager()->createCPUReservation("HRT", cpuQoS);
    }
    tpc->bind(ftControlClient);
    tpc->open(reserve, cpuQoS);
    //tpc->bind(ftControlClient);
    connector.reactor(tpc->getResources()->getReactor());

    if (connector.connect(ftControlClient, endpoint.getAddr()) == -1) {
        ACE_ERROR((LM_ERROR, ACE_TEXT("(%T)%@\n"),
                ACE_TEXT("(%T)ERROR: P3ReplicationGroup::prebindControlToReplica - connect failed:")));
        ftControlClient->close();
        delete ftControlClient;
        return false;
    } else {
        if (m_debugP3ReplicationGroup) {
            ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::prebindControlToReplica - Connect to replica OK! UUID=%s\n"),
                    replica->getUUID()->toString().c_str()));
        }
    }
    ftControlClient->preBindSession();
    if (m_debugP3ReplicationGroup) {
        ACE_DEBUG((LM_DEBUG,
                ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::prebindControlToReplica() - update(dataft) = (%@)\n"),
                ftDataSAPInfo.get()
                ));
    }
    if (m_clientControlManager.add(ftControlClient) == -1) {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::prebindControlToReplica - failed to add to group! UUID=%s\n"),
                replica->getUUID()->toString().c_str()));
        return false;
    }

    if (ftControlClient->asynchronous(true, false) == -1) {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::prebindControlToReplica - failed to async! UUID=%s\n"),
                replica->getUUID()->toString().c_str()));
        ftControlClient->close();
        return false;
    }
    ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::prebindControlToReplica - OK! UUID=%s\n"),
            replica->getUUID()->toString().c_str()));
    return true;
}
Example #3
0
bool P3ReplicationGroup::bindControlToReplica(OverlayPeerInfoPtr& replica) {
    ACE_GUARD_RETURN(ACE_SYNCH_RECURSIVE_MUTEX, mon, m_lock, false);
    ACE_Connector<FTControlClientHandler, ACE_SOCK_Connector> connector;
    Endpoint endpoint;
    replica->getFTSAPInfo()->getFirstEndpoint(endpoint);
    //printf("==============bindControlToReplica endpoint=%s\n", endpoint.toString().c_str());

    ThreadPerConnection *tpc = new ThreadPerConnection();
    //ACE_Strong_Bound_Ptr<ThreadPerConnection, ACE_Recursive_Thread_Mutex>* tpcPrt = new
    //      ACE_Strong_Bound_Ptr<ThreadPerConnection, ACE_Recursive_Thread_Mutex > (tpc);
    ExecutionModelPtr* tpcPrt = new
            ExecutionModelPtr(tpc);

    FTControlClientHandler* ftControlClient = new FTControlClientHandler(
            this,
            replica->getUUID(),
            replica->getFID(),
            this->getGroupUUID(),
            false, false, tpcPrt, 0, 0, 0);

    printMembers();
    SAPInfoPtr ftDataSAPInfo;

    //*(getGroupMembers()));
    tpc->bind(ftControlClient);
    tpc->open();
    //tpc->bind(ftControlClient);
    connector.reactor(tpc->getResources()->getReactor());

    if (connector.connect(ftControlClient, endpoint.getAddr()) == -1) {
        ACE_ERROR((LM_ERROR, ACE_TEXT("(%T)%@\n"),
                ACE_TEXT("(%T)ERROR: P3ReplicationGroup::bindControlToReplica - connect failed:")));
        ftControlClient->close();
        delete ftControlClient;
        return false;
    } else {
        if (m_debugP3ReplicationGroup) {
            ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::bindControlToReplica - Connect to replica OK! UUID=%s\n"),
                    replica->getUUID()->toString().c_str()));
        }
    }
    UUIDPtr sid;
    getSID(sid);
    ftControlClient->initSession(
            sid,
            m_groupUUID,
            //m_iid,
            this->getServiceParams(),
            this->getPrimary(),
            this->getReplicaList(),
            ftDataSAPInfo);
    if (m_debugP3ReplicationGroup) {
        ACE_DEBUG((LM_DEBUG,
                ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::bindControlToReplica() - update(dataft) = (%@)\n"),
                ftDataSAPInfo.get()
                ));
    }
    if (m_clientControlManager.add(ftControlClient) == -1) {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::bindControlToReplica - to add to group! UUID=%s\n"),
                replica->getUUID()->toString().c_str()));
        return false;
    }
    //this->updateFTDataSAP(replica->getUUID(), ftDataSAPInfo); //why???
    replica->setFTDataSAP(ftDataSAPInfo);

    if (ftControlClient->asynchronous(true, false) == -1) {
        ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::bindControlToReplica - to aync! UUID=%s\n"),
                replica->getUUID()->toString().c_str()));
        ftControlClient->close();
        return false;
    }
    ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::bindControlToReplica -OK UUID=%s\n"),
            replica->getUUID()->toString().c_str()));
    return true;
}