Esempio n. 1
0
galera::TrxHandle*
galera::Wsdb::get_conn_query(int                 version,
                             const wsrep_uuid_t& source_id,
                             wsrep_trx_id_t      conn_id,
                             bool                create)
{
    gu::Lock lock(mutex_);
    ConnMap::iterator i;

    if ((i = conn_map_.find(conn_id)) == conn_map_.end())
    {
        if (create == true)
        {
            Conn& conn(create_conn(conn_id));
            TrxHandle* trx(new TrxHandle(
                               version, source_id, conn_id, -1, true));
            conn.assign_trx(trx);
            return trx;
        }
        else
        {
            return 0;
        }
    }

    if (i->second.get_trx() == 0 && create == true)
    {
        TrxHandle* trx(new TrxHandle(version, source_id, conn_id, -1, true));
        i->second.assign_trx(trx);
    }

    return i->second.get_trx();
}
Esempio n. 2
0
void TraceThread::trace(TraceData &td)
{
	td.threadId = static_cast<syg_ulong_ptr>(pthread_self());
	TraceData trx(td);
	instance()->receivedTrace(td);
	traceQue.pushAndNotify(td);
}
            void operator()(TrxMap::value_type& vt) const
            {
                {
                    TrxHandle* trx(vt.second);
                    TrxHandleLock lock(*trx);

                    if (trx->is_committed() == false)
                    {
                        log_warn << "trx not committed in purge and discard: "
                                 << *trx;
                    }

                    if (trx->depends_seqno() > -1)
                    {
                        cert_.purge_for_trx(trx);
                    }

                    if (trx->refcnt() > 1)
                    {
                        log_debug << "trx "     << trx->trx_id()
                                  << " refcnt " << trx->refcnt();
                    }
                }
                vt.second->unref();
            }
Esempio n. 4
0
void galera::GcsActionSource::dispatch(void*                    recv_ctx,
                                       const struct gcs_action& act)
{
    assert(recv_ctx != 0);
    assert(act.buf != 0);
    assert(act.seqno_l > 0);

    switch (act.type)
    {
    case GCS_ACT_TORDERED:
    {
        assert(act.seqno_g > 0);
        GcsActionTrx trx(act);
        trx.trx()->set_state(TrxHandle::S_REPLICATING);
        replicator_.process_trx(recv_ctx, trx.trx());
        break;
    }
    case GCS_ACT_COMMIT_CUT:
    {
        wsrep_seqno_t seq;
        gu::unserialize8(reinterpret_cast<const gu::byte_t*>(act.buf),
                         act.size, 0, seq);
        replicator_.process_commit_cut(seq, act.seqno_l);
        break;
    }
    case GCS_ACT_CONF:
    {
        const gcs_act_conf_t* conf(
            reinterpret_cast<const gcs_act_conf_t*>(act.buf)
            );

        wsrep_view_info_t* view_info(
            galera_view_info_create(conf, conf->my_state == GCS_NODE_STATE_PRIM)
            );

        replicator_.process_conf_change(recv_ctx, *view_info,
                                        conf->repl_proto_ver,
                                        state2repl(*conf), act.seqno_l);
        free(view_info);
        break;
    }
    case GCS_ACT_STATE_REQ:
        replicator_.process_state_req(recv_ctx, act.buf, act.size, act.seqno_l,
                                      act.seqno_g);
        break;
    case GCS_ACT_JOIN:
    {
        wsrep_seqno_t seq;
        gu::unserialize8(reinterpret_cast<const gu::byte_t*>(act.buf),
                         act.size, 0, seq);
        replicator_.process_join(seq, act.seqno_l);
        break;
    }
    case GCS_ACT_SYNC:
        replicator_.process_sync(act.seqno_l);
        break;
    default:
        gu_throw_fatal << "unrecognized action type: " << act.type;
    }
}
Esempio n. 5
0
void      
PluginManager::defaultLoad(  )
{   
   qDebug() << "  " << "Default load started" ;

    QDir workDir(baseFolder);

    if ( !workDir.exists() )
    {
        QString em= tr("base folder %1 doesn't exist, default load failed")
	              .arg( baseFolder );
        emit errorAppeared( em ); 
	return ;
    }

  //=== get current available plugins =====
    QStringList currAvailable = workDir.entryList(QDir::Files);
#if defined(Q_OS_WIN)
    QRegExp trx("*.dll") ;
#elif defined(__MACH__)
    QRegExp trx("*.dylib");
#else
    QRegExp trx("*.so");
#endif
    trx.setPatternSyntax(QRegExp::Wildcard );

    currAvailable.filter( trx );

    qDebug() << "  " << "can load this plugins: " << currAvailable ;

  //=== 
    foreach(QString pluginFileName, currAvailable)
    {
       QString fullfn( workDir.absoluteFilePath( pluginFileName ) );
       QString newName;
       int ti = readPluginInformation( fullfn, newName);
       if (! ti )
       {
           acceptPlugin(fullfn, newName);
       }
    }//    foreach(QString pluginFileName, currAvailable)
inline galera::TrxHandle*
galera::Wsdb::create_trx(const TrxHandle::Params& params,
                         const wsrep_uuid_t&  source_id,
                         wsrep_trx_id_t const trx_id)
{
    TrxHandle* trx(TrxHandle::New(trx_pool_, params, source_id, -1, trx_id));

    gu::Lock lock(trx_mutex_);

    std::pair<TrxMap::iterator, bool> i
        (trx_map_.insert(std::make_pair(trx_id, trx)));

    if (gu_unlikely(i.second == false)) gu_throw_fatal;

    return i.first->second;
}
Esempio n. 7
0
void mmTransDialog::OnOk(wxCommandEvent& event)
{
    m_trx_data.STATUS = "";
    m_trx_data.NOTES = textNotes_->GetValue();
    m_trx_data.TRANSACTIONNUMBER = textNumber_->GetValue();
    m_trx_data.TRANSDATE = dpc_->GetValue().FormatISODate();
    wxStringClientData* status_obj = (wxStringClientData*) choiceStatus_->GetClientObject(choiceStatus_->GetSelection());
    if (status_obj) m_trx_data.STATUS = Model_Checking::toShortStatus(status_obj->GetData());

    if (!validateData()) return;

    Model_Checking::Data *r = Model_Checking::instance().get(m_trx_data.TRANSID);
    if (m_new_trx || m_duplicate)
        r = Model_Checking::instance().create();

    Model_Checking::putDataToTransaction(r, m_trx_data);

    m_trx_data.TRANSID = Model_Checking::instance().save(r);

    Model_Splittransaction::Data_Set splt;
    for (const auto& entry : local_splits) 
    {
        Model_Splittransaction::Data *s = Model_Splittransaction::instance().create();
        s->CATEGID = entry.CATEGID;
        s->SUBCATEGID = entry.SUBCATEGID;
        s->SPLITTRANSAMOUNT = entry.SPLITTRANSAMOUNT;
        splt.push_back(*s);
    }
    Model_Splittransaction::instance().update(splt, m_trx_data.TRANSID);

    if (CustomFieldDialog_)
        CustomFieldDialog_->OnSave(true);

    if (m_new_trx || m_duplicate)
    {
        const wxString& RefType = Model_Attachment::reftype_desc(Model_Attachment::TRANSACTION);
        mmAttachmentManage::RelocateAllAttachments(RefType, -1, m_trx_data.TRANSID);
        Model_CustomFieldData::instance().RelocateAllData(RefType, -1, m_trx_data.TRANSID);
    }

    const Model_Checking::Data& tran(*r);
    Model_Checking::Full_Data trx(tran);
    wxLogDebug("%s", trx.to_json());
    EndModal(wxID_OK);
}
Esempio n. 8
0
static int InitialiseCap (TRI_cap_constraint_t* cap,
                          TRI_document_collection_t* document) {
  TRI_ASSERT(cap->_count > 0 || cap->_size > 0);

  TRI_headers_t* headers = document->_headersPtr;  // ONLY IN INDEX (CAP)
  size_t currentCount    = headers->count();
  int64_t currentSize    = headers->size();

  if ((cap->_count > 0 && currentCount <= cap->_count) &&
      (cap->_size > 0 && currentSize <= cap->_size)) {
    // nothing to do
    return TRI_ERROR_NO_ERROR;
  }
  else {
    TRI_vocbase_t* vocbase = document->_vocbase;
    TRI_voc_cid_t cid = document->_info._cid;

    triagens::arango::SingleCollectionWriteTransaction<UINT64_MAX> trx(new triagens::arango::StandaloneTransactionContext(), vocbase, cid);
    trx.addHint(TRI_TRANSACTION_HINT_LOCK_NEVER, false);
    trx.addHint(TRI_TRANSACTION_HINT_NO_BEGIN_MARKER, false);
    trx.addHint(TRI_TRANSACTION_HINT_NO_ABORT_MARKER, false);
    trx.addHint(TRI_TRANSACTION_HINT_SINGLE_OPERATION, false); // this is actually not true, but necessary to create trx id 0

    int res = trx.begin();

    if (res != TRI_ERROR_NO_ERROR) {
      return res;
    }

    TRI_transaction_collection_t* trxCollection = trx.trxCollection();
    res = ApplyCap(cap, document, trxCollection);

    res = trx.finish(res);

    return res;
  }
}
Esempio n. 9
0
void s_hull_del_ray2( std::vector<Shx> &pts, std::vector<Triad> &triads)
{
    
    size_t nump = pts.size();
    
    
    float r = pts[0].r;
    float c = pts[0].c;
    for( long k=0; k<nump; k++){
        float dr = pts[k].r-r;
        float dc = pts[k].c-c;
        
        pts[k].ro = dr*dr + dc*dc;
        
    }
    
    sort( pts.begin(), pts.end() );
    
    
    float r1 = pts[0].r;
    float c1 = pts[0].c;
    
    float r2 = pts[1].r;
    float c2 = pts[1].c;
    size_t mid = -1;
    float romin2 = 100000000.0, ro2, R,C;
    
    size_t k=2;
    while (k<nump){
        
        circle_cent2(r1,c1,r2,c2,  pts[k].r,  pts[k].c, r,c,ro2);
        if( ro2 < romin2 && ro2 > 0 ){
            mid = k;
            romin2 = ro2;
            R = r;
            C = c;
            
        }
        else if( romin2 *4 < pts[k].ro )
            k=nump;
        
        k++;
    }
    
    //std::cerr << "earwig noodles " << pts[1].id << " " << pts[mid].id << " " << romin2 << endl;
    
    Shx pt0 = pts[0];
    Shx pt1 = pts[1];
    Shx pt2 = pts[mid];
    
    pts.erase(pts.begin() + mid);  // necessary for round off reasons:((((((
    pts.erase(pts.begin() );
    pts.erase(pts.begin() );
    
    for( long k=0; k<nump-3; k++){
        float dr = pts[k].r-R;
        float dc = pts[k].c-C;
        
        pts[k].ro = dr*dr + dc*dc;
        
    }
    
    sort( pts.begin(), pts.end() );
    
    pts.insert(pts.begin(), pt2);
    pts.insert(pts.begin(), pt1);
    pts.insert(pts.begin(), pt0);
    
    long slump [nump];
    
    for( long k=0; k<nump; k++){
        slump[ pts[k].id] = k;
    }
    
    std::vector<Shx> hull;
    
    
    r = (pts[0].r + pts[1].r + pts[2].r )/3.0;
    c = (pts[0].c + pts[1].c + pts[2].c )/3.0;
    
    float dr0 = pts[0].r - r,  dc0 = pts[0].c - c;
    float tr01 =  pts[1].r - pts[0].r, tc01 =  pts[1].c - pts[0].c;
    
    float df = -tr01* dc0 + tc01*dr0;
    if( df < 0 ){   // [ 0 1 2 ]
        pt0.tr = pt1.r-pt0.r;
        pt0.tc = pt1.c-pt0.c;
        pt0.trid = 0;
        hull.push_back( pt0 );
        
        pt1.tr = pt2.r-pt1.r;
        pt1.tc = pt2.c-pt1.c;
        pt1.trid = 0;
        hull.push_back( pt1 );
        
        pt2.tr = pt0.r-pt2.r;
        pt2.tc = pt0.c-pt2.c;
        pt2.trid = 0;
        hull.push_back( pt2 );
        
        
        Triad tri(pt0.id,pt1.id,pt2.id);
        tri.ro = romin2;
        tri.R = R;
        tri.C = C;
        
        triads.push_back(tri);
        
    }
    else{          // [ 0 2 1 ] as anti-clockwise turning is the work of the devil....
        pt0.tr = pt2.r-pt0.r;
        pt0.tc = pt2.c-pt0.c;
        pt0.trid = 0;
        hull.push_back( pt0 );
        
        pt2.tr = pt1.r-pt2.r;
        pt2.tc = pt1.c-pt2.c;
        pt2.trid = 0;
        hull.push_back( pt2 );
        
        pt1.tr = pt0.r-pt1.r;
        pt1.tc = pt0.c-pt1.c;
        pt1.trid = 0;
        hull.push_back( pt1 );
        
        Triad tri(pt0.id,pt2.id,pt1.id);
        tri.ro = romin2;
        tri.R = R;
        tri.C = C;
        triads.push_back(tri);
    }
    
    // add new points into hull (removing obscured ones from the chain)
    // and creating triangles....
    // that will need to be flipped.
    
    float dr, dc, rx,cx;
    Shx  ptx;
    size_t numt;
    
    for( long k=3; k<nump; k++){
        rx = pts[k].r;    cx = pts[k].c;
        ptx.r = rx;
        ptx.c = cx;
        ptx.id = pts[k].id;
        
        size_t numh = hull.size();
        dr = rx- hull[0].r;    dc = cx- hull[0].c;  // outwards pointing from hull[0] to pt.
        
        if(0){
            cerr << "numt = " << triads.size() << endl;
            cerr << "ids = [ " ;
            for(long g=0; g<numh; g++){
                cerr << hull[g].id+1 << ' ' ;
            }
            cerr <<   hull[0].id+1 << "];" << endl;
            
            
            cerr << "trids = [ " ;
            for(long g=0; g<numh; g++){
                cerr << hull[g].trid+1 << ' ' ;
            }
            cerr <<   hull[0].trid+1 << "];" << endl;
            
            
            cerr << "h_test = [ " ;
            for(long g=0; g<numh-1; g++){
                float gaf = -(hull[g+1].c-hull[g].c) * hull[g].tr + (hull[g+1].r-hull[g].r)*hull[g].tc;
                cerr << gaf << ' ' ;
            }
            
            cerr <<   -(hull[0].c-hull[numh-1].c) * hull[numh-1].tr +
            (hull[0].r-hull[numh-1].r)*hull[numh-1].tc << "];" << endl;
            
        }
        
        
        std::vector<long> pidx, tridx;
        long hidx;  // new hull point location within hull.....
        
        
        float df = -dc* hull[0].tr + dr*hull[0].tc;    // visibility test vector.
        if( df < 0 ){  // starting with a visible hull facet !!!
            
            hidx = 0;
            
            // check to see if segment numh is also visible
            df = -dc* hull[numh-1].tr + dr*hull[numh-1].tc;
            //cerr << df << ' ' ;
            if( df < 0 ){    // visible.
                pidx.push_back(hull[numh-1].id);
                tridx.push_back(hull[numh-1].trid);
                
                
                for( long h=0; h<numh-1; h++){
                    // if segment h is visible delete h
                    dr = rx- hull[h].r;    dc = cx- hull[h].c;
                    df = -dc* hull[h].tr + dr*hull[h].tc;
                    pidx.push_back(hull[h].id);
                    tridx.push_back(hull[h].trid);
                    if( df < 0 ){
                        hull.erase(hull.begin() + h);
                        h--;
                        numh--;
                    }
                    else{	  // quit on invisibility
                        ptx.tr = hull[h].r - ptx.r;
                        ptx.tc = hull[h].c - ptx.c;
                        
                        hull.insert( hull.begin() , ptx);
                        numh++;
                        break;
                    }
                }
                // look backwards through the hull structure.
                
                for( size_t h=numh-2; h>0; h--){
                    // if segment h is visible delete h + 1
                    dr = rx- hull[h].r;    dc = cx- hull[h].c;
                    df = -dc* hull[h].tr + dr*hull[h].tc;
                    
                    if( df < 0 ){  // h is visible
                        pidx.insert(pidx.begin(), hull[h].id);
                        tridx.insert(tridx.begin(), hull[h].trid);
                        hull.erase(hull.begin() + h+1);  // erase end of chain
                        
                    }
                    else{
                        
                        h = hull.size()-1;
                        hull[h].tr = -hull[h].r + ptx.r;   // points at start of chain.
                        hull[h].tc = -hull[h].c + ptx.c;
                        break;
                    }
                }
                
                df = 9;
                
            }
            else{
                //	cerr << df << ' ' << endl;
                hidx = 1;  // keep pt hull[0]
                tridx.push_back(hull[0].trid);
                pidx.push_back(hull[0].id);
                
                for( long h=1; h<numh; h++){
                    // if segment h is visible delete h
                    dr = rx- hull[h].r;    dc = cx- hull[h].c;
                    df = -dc* hull[h].tr + dr*hull[h].tc;
                    pidx.push_back(hull[h].id);
                    tridx.push_back(hull[h].trid);
                    if( df < 0 ){                     // visible
                        hull.erase(hull.begin() + h);
                        h--;
                        numh--;
                    }
                    else{	  // quit on invisibility
                        ptx.tr = hull[h].r - ptx.r;
                        ptx.tc = hull[h].c - ptx.c;
                        
                        hull[h-1].tr = ptx.r - hull[h-1].r;
                        hull[h-1].tc = ptx.c - hull[h-1].c;
                        
                        hull.insert( hull.begin()+h, ptx);
                        break;
                    }
                }
            }
            
            df = 8;
            
        }
        else{
            long e1 = -1,  e2 = numh;
            for( long h=1; h<numh; h++){
                dr = rx- hull[h].r;    dc = cx- hull[h].c;
                df = -dc* hull[h].tr + dr*hull[h].tc;
                if( df < 0 ){
                    if( e1 < 0 ) e1 = h;  // fist visible
                }
                else{
                    if( e1 > 0 ){ // first invisible segment.
                        e2 = h;
                        break;
                    }
                }
                
            }
            
            
            // triangle pidx starts at e1 and ends at e2 (inclusive).
            if( e2 < numh ){
                for( long e=e1; e<=e2; e++){
                    pidx.push_back(hull[e].id);
                    tridx.push_back(hull[e].trid);
                }
            }
            else{
                for( long e=e1; e<e2; e++){
                    pidx.push_back(hull[e].id);
                    tridx.push_back(hull[e].trid);   // there are only n-1 triangles from n hull pts.
                }
                pidx.push_back(hull[0].id);
            }
            
            
            // erase elements e1+1 : e2-1 inclusive.
            
            if( e1 < e2-1){
                hull.erase(hull.begin() + e1+1, hull.begin()+ e2);
            }
            
            // insert ptx at location e1+1.
            if( e2 == numh){
                ptx.tr = hull[0].r - ptx.r;
                ptx.tc = hull[0].c - ptx.c;
            }
            else{
                ptx.tr = hull[e1+1].r - ptx.r;
                ptx.tc = hull[e1+1].c - ptx.c;
            }
            
            hull[e1].tr = ptx.r - hull[e1].r;
            hull[e1].tc = ptx.c - hull[e1].c;
            
            hull.insert( hull.begin()+e1+1, ptx);
            hidx = e1+1;
            
        }
        
        
        long a = ptx.id, T0;
        Triad trx( a, 0,0);
        r1 = pts[slump[a]].r;
        c1 = pts[slump[a]].c;
        
        size_t npx = pidx.size()-1;
        numt = triads.size();
        T0 = numt;
        
        if( npx == 1){
            trx.b = pidx[0];
            trx.c = pidx[1];
            
            // compute circum circle radius squared (only relative size is required for flipping)
            
            r2 = pts[slump[trx.b]].r;
            c2 = pts[slump[trx.b]].c;
            
            circle_cent2(r1,c1,r2,c2, pts[slump[trx.c]].r,pts[slump[trx.c]].c , r,c,ro2);
            trx.ro = ro2;
            trx.R = r;
            trx.C = c;
            
            trx.bc = tridx[0];
            trx.ab = -1;
            trx.ac = -1;
            
            // index back into the triads.
            Triad &txx = triads[tridx[0]];
            if( ( trx.b == txx.a && trx.c == txx.b) |( trx.b == txx.b && trx.c == txx.a)) {
                txx.ab = numt;
            }
            else if( ( trx.b == txx.a && trx.c == txx.c) |( trx.b == txx.c && trx.c == txx.a)) {
                txx.ac = numt;
            }
            else if( ( trx.b == txx.b && trx.c == txx.c) |( trx.b == txx.c && trx.c == txx.b)) {
                txx.bc = numt;
            }
            
            
            hull[hidx].trid = numt;
            if( hidx > 0 )
                hull[hidx-1].trid = numt;
            else{
                numh = hull.size();
                hull[numh-1].trid = numt;
            }
            triads.push_back( trx );
            numt++;
        }
        
        else{
            trx.ab = -1;
            for(long p=0; p<npx; p++){
                trx.b = pidx[p];
                trx.c = pidx[p+1];
                
                // compute circum circle radius squared (only relative size is required for flipping)
                
                r2 = pts[slump[trx.b]].r;
                c2 = pts[slump[trx.b]].c;
                
                circle_cent2(r1,c1,r2,c2, pts[slump[trx.c]].r,pts[slump[trx.c]].c , r,c,ro2);
                trx.ro = ro2;
                trx.R = r;
                trx.C = c;
                
                
                trx.bc = tridx[p];
                if( p > 0 )
                    trx.ab = numt-1;
                trx.ac = numt+1;
                
                // index back into the triads.
                Triad &txx = triads[tridx[p]];
                if( ( trx.b == txx.a && trx.c == txx.b) |( trx.b == txx.b && trx.c == txx.a)) {
                    txx.ab = numt;
                }
                else if( ( trx.b == txx.a && trx.c == txx.c) |( trx.b == txx.c && trx.c == txx.a)) {
                    txx.ac = numt;
                }
                else if( ( trx.b == txx.b && trx.c == txx.c) |( trx.b == txx.c && trx.c == txx.b)) {
                    txx.bc = numt;
                }
                
                //	if( trx.ab == 26777 || trx.ac == 26777 || trx.bc == 26777){
                //	  long foon = 7;
                //	}
                
                triads.push_back( trx );
                numt++;
            }
            triads[numt-1].ac=-1;
            
            hull[hidx].trid = numt-1;
            if( hidx > 0 )
                hull[hidx-1].trid = T0;
            else{
                numh = hull.size();
                hull[numh-1].trid = T0;
            }
            
            
        }
        
        
        //    write_Triads(triads, "tris.mat");
        //long dfx = 9;
        //T_flip2( pts, triads, slump, numt, T0);
        
        //write_Triads(triads, "tris2.mat");
        
    }
    
    cerr << "of triangles " << triads.size() << " to be flipped. "<< endl;
    
    //write_Triads(triads, "tris0.mat");
    
    std::set<long> ids, ids2;
    T_flip3( pts, triads, slump, numt, 0, ids);
    
    
    long nits = ids.size(), nit=1;
    while(  nits > 0 && nit < 20){
        // char nam[128];
        //sprintf(nam, "tris_%d.mat", nit);
        //write_Triads(triads, nam);
        
        T_flip4( pts, triads, slump, ids);
        nits = ids.size();
        nit ++;
        
    }
    //write_Triads(triads, "triangles3.mat");
    
    return;
}