void start()
    {
        ActivityTimer s(totalCycles, timeActivities, NULL);
        dataLinkStart();

        eogPending = false;
        if (container.queryLocal() || firstNode())
        {
            CMessageBuffer reqMsg;
            reqMsg.setReplyTag(replyTag);
            reqMsg.append(smt_actMsg);
            reqMsg.append(container.queryOwner().queryGraphId());
            reqMsg.append(container.queryId());

            if (!container.queryJob().queryJobComm().sendRecv(reqMsg, 0, container.queryJob().querySlaveMpTag(), LONGTIMEOUT))
                throwUnexpected();

            masterReplyMsg.swapWith(reqMsg);
        }
    }
Beispiel #2
0
    bool send(INode *node,unsigned timeout)
    {
        unsigned retries = 3;
        loop {
            try {
                CMessageBuffer mb;
                serialize(mb);
                if (queryWorldCommunicator().sendRecv(mb,node,MPTAG_SASHA_REQUEST,timeout?timeout:12*60*60*1000)) { // could take a long time!
                    clearIds();
                    clearResults();
                    if (action==SCA_WORKUNIT_SERVICES_GET) {
                        mb.swapWith(wusbuf);
                    }
                    else {
                        unsigned n=0;
                        unsigned i;
                        if (mb.length()-mb.getPos()>=sizeof(unsigned)) {
                            mb.read(n);
                            for (i=0;i<n;i++) {
                                StringAttr s;
                                mb.read(s);
                                addId(s.get());
                            }
                            if (mb.length()-mb.getPos()>=sizeof(unsigned)+sizeof(bool)) {
                                mb.read(resultoverflow);
                                mb.read(n);
                                for (i=0;i<n;i++) {
                                    StringAttr res;
                                    mb.read(res);
                                    size32_t reslen = res.length();
                                    results.append(*new StringAttrItem(res,reslen));
                                    resultsize += reslen;
                                }
                                if (mb.length()-mb.getPos()>=sizeof(unsigned)) {
                                    mb.read(numdts);
                                    free(dts);
                                    dts = NULL;
                                    if (numdts) {
                                        dts = (CDateTime *)calloc(numdts,sizeof(CDateTime));
                                        for (i=0;i<numdts;i++)
                                            dts[i].deserialize(mb);
                                    }
                                }

                            }
                        }
                    }
                    return true;
                }   
                else
                    break;
            }
            catch (IException *e) {
                if ((--retries==0)||(action==SCA_STOP))
                    throw;
                EXCLOG(e,"CSashaCommand send");
                ::Release(e);
            }
            try { // shouldn't really be necessary but make sure socket really closed
                queryWorldCommunicator().disconnect(node);
            }
            catch (IException *e) {
                EXCLOG(e,"CSashaCommand disconnect");
                ::Release(e);
            }
        }; 
        return false;
    }
 void broadcast(MemoryBuffer &buffer)
 {
     clear();
     broadcasting.swapWith(buffer);
     doBroadcast();
 }