Ejemplo n.º 1
0
/**
 * 初始化 nid->docId的字典 和 deletemap
 *
 * @param path     数据存放路径
 *
 * @return  0: success ;   -1: 程序处理失败
 */
int initIdDict(const char * path, bool sync = true)
{
    DocIdManager * mgr = DocIdManager::getInstance();

    if ( NULL == mgr )
    {
        TERR("DocIdManager instance is null");
        return -1;
    }

    if ( (NULL == path) || strlen( path ) <= 0 )
    {
        TERR("idDict node's path attribute is null");
        return -1;
    }

    TLOG("begin to load nid->docId dict and deleteMap! path:%s", path);

    mgr->setDataSync( sync );
    if ( false == mgr->load( path ) )
    {
        TERR("load nid->docId dict and deleteMap failed! path:%s", path);
        return -1;
    }

    TLOG("load nid->docId dict and deleteMap success!");

    return 0;
}
Ejemplo n.º 2
0
void toAWR::instanceChanged(int pos)
{
	QVariant d = dbid->itemData(pos);
	QStringList l = d.toStringList();
	std::stringstream s;
	for(QList<QString>::iterator i=l.begin(); i!=l.end(); ++i)
	{
		s << ":\'" << (*i).toAscii().constData() << '\'';
	}
	TLOG(0,toDecorator,__HERE__) << "Instance changed:" << pos << s.str() << std::endl;
	QString dbid = l.at(0);
	QString inst = l.at(1);
	try
	{
		toQList sparams, eparams;
		sparams.push_back(dbid);
		sparams.push_back(inst);
		sparams.push_back(startdate->date().toString("yyyy:MM:dd"));
		sparams.push_back(startdate->date().toString("yyyy:MM:dd"));
		TLOG(1,toDecorator,__HERE__) << "FSNAP: ("  << sparams.size() << ")" << std::endl;
		fsnap->query(toSQL::sql("toAWR:Snaps", connection()), const_cast<const toQList&>(sparams ) );
		fsnap->refresh();
		eparams.push_back(dbid);
		eparams.push_back(inst);
		eparams.push_back(enddate->date().toString("yyyy:MM:dd"));
		eparams.push_back(enddate->date().toString("yyyy:MM:dd"));
		TLOG(1,toDecorator,__HERE__) << "TSNAP: ("  << eparams.size() << ")" << std::endl;
		tsnap->query(toSQL::sql("toAWR:Snaps", connection()), const_cast<const toQList&>(eparams ) );
		tsnap->refresh();
	}
	TOCATCH;
};
Ejemplo n.º 3
0
void toAWR::instanceChanged(int pos)
{
    QVariant d = dbid->itemData(pos);
    QStringList l = d.toStringList();
    std::stringstream s;
    for (QList<QString>::iterator i = l.begin(); i != l.end(); ++i)
    {
        s << ":\'" << (*i).toLatin1().constData() << '\'';
    }
    TLOG(0, toDecorator, __HERE__) << "Instance changed:" << pos << s.str() << std::endl;
    QString dbid = l.at(0);
    QString inst = l.at(1);
    try
    {
        toQueryParams sparams, eparams;
        sparams <<  dbid << inst << startdate->date().toString("yyyy:MM:dd") << startdate->date().toString("yyyy:MM:dd");
        TLOG(1, toDecorator, __HERE__) << "FSNAP: ("  << sparams.size() << ")" << std::endl;
        fsnap->refreshWithParams(sparams);


        eparams << dbid << inst << enddate->date().toString("yyyy:MM:dd") << enddate->date().toString("yyyy:MM:dd");
        TLOG(1, toDecorator, __HERE__) << "TSNAP: ("  << eparams.size() << ")" << std::endl;
        tsnap->refreshWithParams(eparams);
    }
    TOCATCH;
};
Ejemplo n.º 4
0
/**
 * 初始化 增量 index
 *
 * @param path     数据存放路径
 *
 * @return  0: success ;   -1: 程序处理失败
 */
int initIncIndex(const char * path, bool sync, bool et, int32_t inc_max_num )
{
    IndexIncManager * mgr = IndexIncManager::getInstance();

    if ( NULL == mgr )
    {
        TERR("IndexIncManager instance is null");
        return -1;
    }

    if ( (NULL == path) || strlen( path ) <= 0 )
    {
        TERR("index node's path attribute is null");
        return -1;
    }

    TLOG("begin to load inc index! path:%s", path);

    mgr->setDataSync( sync );
    mgr->setExportIdx( et );
    mgr->setMaxIncNum( inc_max_num );
    if ( mgr->open( path ) < 0 )
    {
        TERR("load inc index failed! path:%s", path);
        return -1;
    }

    TLOG("load inc index success!");

    return 0;
}
Ejemplo n.º 5
0
/**
 * 初始化  行政区划转换编码表
 *
 * @param path     数据存放路径  完整路径
 *
 * @return  0: success ;   -1: 程序处理失败
 */
int initProvCity(const char * path)
{
    ProvCityManager * mgr = ProvCityManager::getInstance();

    if ( NULL == mgr )
    {
        TERR("ProvCityManager instance is null");
        return -1;
    }

    if ( (NULL == path) || strlen( path ) <= 0 )
    {
        TERR("provcity node's path attribute is null");
        return -1;
    }

    TLOG("begin to load provcity! path:%s", path);

    if ( false == mgr->load( path ) )
    {
        TERR("load inc index failed! path:%s", path);
        return -1;
    }

    TLOG("load provcity success!");

    return 0;
}
Ejemplo n.º 6
0
/**
 * 初始化 全量index 的 builder, 重新打开, 为了修改
 *
 * @param path     数据存放路径
 *
 * @return  0: success ;   -1: 程序处理失败
 */
int initIdxBuilder(const char * path)
{
    IndexBuilder * builder = IndexBuilder::getInstance();

    if ( NULL == builder )
    {
        TERR("IndexBuilder instance is null");
        return -1;
    }

    if ( (NULL == path) || strlen( path ) <= 0 )
    {
        TERR("index node's path attribute is null");
        return -1;
    }

    TLOG("begin to load full index! path:%s", path);

    if ( builder->reopen( path ) < 0)
    {
        TERR("load full index failed! path:%s", path);
        return -1;
    }

    TLOG("load full index success!");

    return 0;
}
Ejemplo n.º 7
0
QString toQSqlConnectionSub::version()
{
    QString ret;
    try
    {
        LockingPtr<QSqlDatabase> ptr(Connection, Lock);

        QSqlQuery query = ptr->exec(toSQL::sql("toQSqlConnection:Version", ParentConnection));
        if (query.next())
        {
            if (query.isValid())
            {
                QSqlRecord record = query.record();
                QVariant val = query.value(record.count() - 1);
                ret = val.toString().toLatin1();
            }
        }
    }
    catch (std::exception const&e)
    {
        TLOG(1, toDecorator, __HERE__) << "	Ignored exception:" << e.what() << std::endl;
        throw e;
    }
    catch (QString const&s)
    {
        TLOG(1, toDecorator, __HERE__) << "	Ignored exception:" << s << std::endl;
        throw s;
    }
    catch (...)
    {
        TLOG(1, toDecorator, __HERE__) << "	Ignored exception." << std::endl;
        throw;
    }
    return ret;
}
Ejemplo n.º 8
0
bool CPeer::ReadPacketForDOM( __in DWORD dwReceiveSize/* = 0*/ )
{
	INT iResult = 0;

	if( dwReceiveSize )
	{
		CNetwork::m_dwNumberOfBytesRecvd = dwReceiveSize;

		if( IntegratedLoadForRawData() == false )
		{
			TLOG( LOG_DEBUG, _T( "[ERROR] Failed to receive packet." ) );
			return false;
		}
	}

	// 수신 요청
	if( m_bIsSD_RECEIVE == false )
	{
		iResult = CNetwork::Receiving();
		if( iResult == NETWORK_IOC_STATE_FAILURE )
		{
			TLOG( LOG_DEBUG, _T( "[ERROR] Failed to request a receiving." ) );
			return false;
		}
	}

	return true;
}
Ejemplo n.º 9
0
bool CPeer::ReadPacketForWSAES( __out BYTE* pbyReceivedPacket/* = NULL*/ )
{
	INT iResult = 0;

	// 주의! 수신 데이터에 대한 1차 적재 처리와 2차 적재 처리에 비율
	//		 수신 데이터를 CNetwork::m_byReceiveBuffer에서 CPeer::m_byReceivedDataBuffer로 옮기는 것을
	//		 1차 적재라고 한다면 CPeer::m_byReceivedDataBuffer에서 수신용 Queue로 옮기는 것을 2차 적재라고 하자.
	//		 1차 적재 처리와 2차 적재 처리에 비율은 Packet을 수신하는 과정에서 Hang이 발생하는 것을 줄이는데 도움이 될 것 같다.
	//		 여기서 고려된 비율은 '1차 적재 처리 : 2차 적재 처리 = 2 : 3'이다.
	//		 즉, 1차 적재 처리가 2번 이뤄지면 2차 적재 처리는 3번 이뤄지도록 구현하여 1차 적재에 대비하여
	//		 CPeer::m_byReceivedDataBuffer가 항상 비워진 상태가 될 수 있도록 유도하는 것이다.
	if( pbyReceivedPacket )  // Packet별 Local 처리를 위해 수신 Packet 추출
	{
		ULONG_PTR ulOffset = -1;
		LPVOID lpPacketOwner = NULL;
		BYTE* pbyExtractedUnitPacket = NULL;
		DWORD dwPacketLength = 0;

		SCOPED_LOCK( m_CS )
		{
			if( m_ReadPD.GetFromQueue( &ulOffset, &lpPacketOwner, &pbyExtractedUnitPacket, &dwPacketLength ) == false )
				return false;

			// 추출 값 검사
			if( ulOffset == -1 ||
				lpPacketOwner == NULL ||
				pbyExtractedUnitPacket == NULL ||
				( dwPacketLength == 0 || PACKET_BUFFER_SIZE < dwPacketLength ) )
			{
				TLOG( LOG_DEBUG, _T( "[ERROR] Need to check. Failed to extract into the read packet queue." ) );
				TLOG( LOG_DEBUG,
					_T( "          ulOffset : %#p, lpPacketOwner : %#p, pbyExtractedUnitPacket : %#p, dwPacketLength : %lu" ),
					  ulOffset, lpPacketOwner, pbyExtractedUnitPacket, dwPacketLength );
				dwPacketLength = 0;
				if( 0 < ulOffset )
					m_ReadPD.RemoveFromMap( ulOffset );
				m_ReadPD.PopFromQueue();
				return false;
			}

			// 주의! pbyReceivedPacket에 크기를 알 수 없으므로 Buffer overflow가 발생할 가능성이 있다.
			// TODO: pbyReceivedPacket에 크기를 알 수 있도록 수정해야 한다.
			CopyMemory( pbyReceivedPacket, pbyExtractedUnitPacket, dwPacketLength );
			m_ReadPD.RemoveFromMap( ulOffset );
			m_ReadPD.PopFromQueue();
		}
	}
	else  // 수신 후, 수신용 Queue에 삽입
	{
		// 주의! FD_READ에 따라 CNetwork::Receiving()이 호출되기 전인
		//		 if( CNetwork::m_bWasPendingRecv ) Block 안에서 return하는 것은 신중해야 한다.
		// WSA_IO_PENDING에 대한 처리
		if( CNetwork::m_bWasPendingRecv )
Ejemplo n.º 10
0
void toEditExtensions::autoIndentBuffer(void)
{
    if (Current)
    {
        QString text = Current->text();
        int pos = 0;
        while (pos < text.length() && text.at(pos).isSpace())
        {
            pos++;
        }
        Current->selectAll();
        try
        {
            try
            {
                Current->insert(toSQLParse::indent(text.mid(pos), toCurrentConnection(Current)));
            }
            catch (...)
            {
                TLOG(1, toDecorator, __HERE__) << "	Ignored exception." << std::endl;
                Current->insert(toSQLParse::indent(text.mid(pos)));
            }
        }
        TOCATCH;
    }
}
Ejemplo n.º 11
0
void toEditExtensions::autoIndentBlock(void)
{
    if (Current)
    {
        try
        {
            int line1, col1, line2, col2;
            if (Current->getSelection(&line1, &col1, &line2, &col2))
            {
                QString t = Current->text(line1).mid(0, col1);
                t += QString::fromLatin1("a");
                int chars = 0;
                QString ind = toSQLParse::indentString(toSQLParse::countIndent(t, chars));
                QString mrk = Current->selectedText();
                QString res;
                try
                {
                    res = toSQLParse::indent(ind + mrk, toCurrentConnection(Current));
                }
                catch (...)
                {
                    TLOG(1, toDecorator, __HERE__) << "	Ignored exception." << std::endl;
                    res = toSQLParse::indent(ind + mrk);
                }
                t = Current->text(line2);
                unsigned int l = res.length() - ind.length();
                if (col2 == int(t.length()) && t.length() > 0) // Strip last newline if on last col of line
                    l--;
                res = res.mid(ind.length(), l); // Strip indent.
                Current->insert(res, true);
            }
        }
        TOCATCH;
    }
}
Ejemplo n.º 12
0
void toAWR::endDateChanged(QDate date)
{
	std::cerr << "endDateChanged:" << date.toString() << std::endl;

	int pos = dbid->currentIndex();
	QVariant d = dbid->itemData(pos);
	QStringList l = d.toStringList();
	std::stringstream s;
	for(QList<QString>::iterator i=l.begin(); i!=l.end(); ++i)
	{
		s << ":\'" << (*i).toAscii().constData() << '\'';
	}
	TLOG(0,toDecorator,__HERE__) << "end date changed:" << date.toString("YYYY:MM:DD") << std::endl;
	QString dbid = l.at(0);
	QString inst = l.at(1);
	try
	{
		toQList params;
		params.push_back(dbid);
		params.push_back(inst);
		params.push_back(date.toString("yyyy:MM:dd"));
		params.push_back(date.toString("yyyy:MM:dd"));
		fsnap->setSelectionPolicy(toResultCombo::None);
		tsnap->query(toSQL::sql("toAWR:Snaps", connection()), const_cast<const toQList&>(params ) );
		tsnap->refresh();
	}
	TOCATCH;

}
Ejemplo n.º 13
0
void toConnectionPool::fix(int member)
{
    if(!Connection)
        return;

    LockingPtr<SubList> ptr(Pool, PoolLock);
    PooledSub *psub = (*ptr)[member];
    psub->State = Broken;
    ptr.unlock();

    Connection->closeConnection(psub->Sub);
    PooledState state = Broken;
    toConnectionSub *sub = 0;
    try
    {
        sub = Connection->addConnection();
        state = Free;
    }
    catch(...)
    {
        TLOG(1, toDecorator, __HERE__) << "	Ignored exception." << std::endl;
        state = Broken;
    }

    ptr.lock();
    psub->State = state;
    psub->Sub = sub;
}
Ejemplo n.º 14
0
toEventQuery::toEventQuery(QObject *parent
                           , QSharedPointer<toConnectionSubLoan> &conn
                           , QString const& sql
                           , toQueryParams const& param
                           , FETCH_MODE mode
                           , QList<QString> const &init
                           //, toResultStats *stats
                          )
    : QObject(parent)
    , SQL(sql)
    , Param(param)
    , ColumnCount(0)
    , Processed(0L)
    //, Statistics(stats)
    , Thread(NULL)
    , Worker(NULL)
    , Started(false)
    , WorkDone(false)
    , Connection(conn)
    , CancelCondition(new toEventQuery::WaitConditionWithMutex())
    , Mode(mode)
{
    /* BIG FAT WARNING QThread's parent must be  NULL, so it is not disposed when toEventQuery is deleted.
     * Theoretically (and practically) it can be freed after ~toEventQuery is processed
     */
    Thread = new BGThread(NULL);
    Thread->setObjectName("toEventQuery");
    TLOG(7, toDecorator, __HERE__) << "toEventQuery created" << std::endl;
}
Ejemplo n.º 15
0
// Split the node using best cut.
bool Node::Split(Node*& pLeftChild, Node*& pRightChild)
{
    SampleSet* pLeftSampleSet = NULL;
    SampleSet* pRightSampleSet = NULL;
    int nSampleCount = mpSampleSet->GetSampleCount();
    if(!mpSampleSet->Split(mpCut, pLeftSampleSet, pRightSampleSet))
    {
        return false;
    }
    ClearSampleSet();
    int nLeftSampleCount = pLeftSampleSet->GetSampleCount();
    int nRightSampleCount = pRightSampleSet->GetSampleCount();
    TLOG("split: (%d:%d) => [(%d:%d), (%d:%d)]", mnNodeId,
         nSampleCount, mnNodeId * 2 + 1, nLeftSampleCount, mnNodeId * 2 + 2,
         nRightSampleCount);
    pLeftChild = new Node(pLeftSampleSet, mpConf, mpLoss, mnNodeId * 2 + 1);
    pRightChild = new Node(pRightSampleSet, mpConf, mpLoss, mnNodeId * 2 + 2);
    pLeftChild->mpParent = this;
    pRightChild->mpParent = this;
    mpLeftChild = pLeftChild;
    mpRightChild = pRightChild;
    mpLeftChild->mSampleCount = nLeftSampleCount;
    mpRightChild->mSampleCount = nRightSampleCount;
    return true;
} // Split()
Ejemplo n.º 16
0
toRollbackDialog::toRollbackDialog(toConnection &Connection, QWidget* parent, const char* name)
    : QDialog(parent)//, name, true)
{
    setupUi(this);

    toHelp::connectDialog(this);

    try
    {
        toConnectionSubLoan conn(Connection);
        toQuery q(conn, SQLTablespace, toQueryParams());
        while (!q.eof())
            Tablespace->addItem((QString)q.readValue());
    }
    catch (...)
    {
        TLOG(1, toDecorator, __HERE__) << "	Ignored exception." << std::endl;
    }
    connect(Tablespace, SIGNAL(textChanged(const QString &)),
            this, SLOT(valueChanged(const QString &)));

    Storage = new toStorageDefinition(DialogTabs);
    Storage->forRollback(true);
    DialogTabs->addTab(Storage, tr("Storage"));

    OkButton->setEnabled(false);
}
Ejemplo n.º 17
0
void mysqlQuery::cancel(void)
{
    if (!Connection->ConnectionID.isEmpty())
    {
        try
        {
            toConnection const &conn = query()->connection();
            const QString &sql = toSQL::sql(SQLCancel, conn);
            if (!sql.isEmpty() && sql != "native")
            {
                toConnectionSubLoan c(const_cast<toConnection&>(conn));
                toQuery(c, sql, toQueryParams() << Connection->ConnectionID);
            }
            else
            {
                // don't lock here or deadlock while waiting
                // for query to finish
                QSqlDatabase *c = const_cast<QSqlDatabase *>(&(Connection->Connection));
                //TODO PgSQL only? native_cancel(c->driver());
            }
        }
        catch (...)
        {
            TLOG(1, toDecorator, __HERE__) << "	Ignored exception." << std::endl;
        }
    }
}
Ejemplo n.º 18
0
void toAWR::endDateChanged(QDate date)
{
    std::cerr << "endDateChanged:" << date.toString() << std::endl;

    int pos = dbid->currentIndex();
    QVariant d = dbid->itemData(pos);
    QStringList l = d.toStringList();
    std::stringstream s;
    for (QList<QString>::iterator i = l.begin(); i != l.end(); ++i)
    {
        s << ":\'" << (*i).toLatin1().constData() << '\'';
    }
    TLOG(0, toDecorator, __HERE__) << "end date changed:" << date.toString("YYYY:MM:DD") << std::endl;
    QString dbid = l.at(0);
    QString inst = l.at(1);
    try
    {
        toQueryParams params;
        params << dbid << inst << date.toString("yyyy:MM:dd") << date.toString("yyyy:MM:dd");
        tsnap->setSelectionPolicy(toResultCombo::None);
        tsnap->refreshWithParams(params);
    }
    TOCATCH;

}
Ejemplo n.º 19
0
bool GraphicsLayerAndroid::createTransformAnimationsFromKeyframes(const KeyframeValueList& valueList,
                                                                  const Animation* animation,
                                                                  const String& keyframesName,
                                                                  double beginTime,
                                                                  const IntSize& boxSize)
{
    ASSERT(valueList.property() == AnimatedPropertyWebkitTransform);
    TLOG("createTransformAnimationFromKeyframes, name(%s) beginTime(%.2f)",
        keyframesName.latin1().data(), beginTime);

    KeyframeValueList* operationsList = new KeyframeValueList(AnimatedPropertyWebkitTransform);
    for (unsigned int i = 0; i < valueList.size(); i++) {
        TransformAnimationValue* originalValue = (TransformAnimationValue*)valueList.at(i);
        PassRefPtr<TimingFunction> timingFunction(const_cast<TimingFunction*>(originalValue->timingFunction()));
        TransformAnimationValue* value = new TransformAnimationValue(originalValue->keyTime(),
                                                                     originalValue->value(),
                                                                     timingFunction);
        operationsList->insert(value);
    }

    RefPtr<AndroidTransformAnimation> anim = AndroidTransformAnimation::create(animation,
                                                                               operationsList,
                                                                               beginTime);

    if (keyframesName.isEmpty())
        anim->setName(propertyIdToString(valueList.property()));
    else
        anim->setName(keyframesName);


    m_contentLayer->addAnimation(anim.release());

    needsNotifyClient();
    return true;
}
Ejemplo n.º 20
0
void* CMServer::thread_udp(void* vpPara)
{
    CMServer* cpClass = (CMServer*)vpPara;
    char buffer[MAX_UDP_PACKET_SIZE];

    while(cpClass->m_stop_flag == 0)
    {
        int32_t ret_len = cpClass->m_pudpserver->receive(buffer, MAX_UDP_PACKET_SIZE);
        if(cpClass->m_stop_flag)
            break;

        StatInput in;
        StatOutput out;
        if(in.bufToNode(buffer, ret_len) <= 0) {
            TLOG("getNodeState failed\n");
            continue;
        }
        in.op_time = cpClass->m_cur_time;
        cpClass->m_cmtree.process(&in, &out);
    }

    pthread_mutex_lock(&cpClass->m_lock);
    cpClass->m_stop_flag++;
    pthread_mutex_unlock(&cpClass->m_lock);

    return NULL;
}
Ejemplo n.º 21
0
toToolWidget::toToolWidget(toTool &tool, const QString &ctx, QWidget *parent, toConnection &conn, const char *name)
    : QWidget(parent),
      toHelpContext(ctx),
      toConnectionWidget(conn, this),
      Tool(tool),
      Action(NULL)
{
    if (name)
    {
        setObjectName(name);
        setCaption(name);
    }
    // make sure widget gets deleted
    setAttribute(Qt::WA_DeleteOnClose);
    // have to set the basic layout for widgets. It's requested later
    QVBoxLayout *vbox = new QVBoxLayout(this);
    vbox->setSpacing(0);
    vbox->setContentsMargins(0, 0, 0, 0);
    setLayout(vbox);

    Timer = NULL;

    connect(&toWorkSpaceSingle::Instance(), SIGNAL(activeToolChaged(toToolWidget*)), this, SLOT(slotWindowActivated(toToolWidget*)));
    connect(&toWorkSpaceSingle::Instance(), SIGNAL(activeToolChaged(toToolWidget*)), this, SLOT(toolActivated(toToolWidget*)));

    if (parent)
    {
        // Voodoo for making connection changing cascade to sub tools.
        try
        {
            toToolWidget *tool = toToolWidget::currentTool(parent);
            if (tool)
                connect(tool, SIGNAL(connectionChange()), this, SLOT(parentConnection()));
        }
        catch (std::exception const &e)
        {
            TLOG(1, toDecorator, __HERE__) << "       Ignored exception:" << std::endl
                                           << e.what() << std::endl;
        }
        catch (...)
        {
            TLOG(1, toDecorator, __HERE__) << "       Ignored exception." << std::endl;
        }
    }
}
Ejemplo n.º 22
0
void* CMServer::thread_load(void* vpPara)
{
    CMServer* cpClass = (CMServer*)vpPara;

    char c; 
    int fd, n;
    umask(0);
    if((mkfifo(cpClass->m_pip_name, (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) < 0) && 
            (errno != EEXIST)) {
        TLOG("mkfifo pipe error, name=%s\n", cpClass->m_pip_name);
        return NULL;
    }
    fd = open(cpClass->m_pip_name, O_RDONLY | O_NONBLOCK);
    if(fd < 0) {
        TLOG("open pipe=%s failed", cpClass->m_pip_name);
        return NULL;
    }

    while(cpClass->m_stop_flag == 0)
    {
        if((n=read(fd, &c, 1)) < 0 && errno != EAGAIN) {
            TLOG("sync read error(exit),pip_name=%s", cpClass->m_pip_name);	
            break;
        }
        if(cpClass->m_stop_flag) break;
        if(n != 1) { 
            usleep(1);
            continue;
        }
        if(c == 'a') { 
            cpClass->m_cmtree.loadSyncInfo();
            TLOG("sync make tree load");
        }	else {
            TLOG("error cmd(%c) at pipe=%s", c, cpClass->m_pip_name);
        }
    }
    close(fd);

    pthread_mutex_lock(&cpClass->m_lock);
    cpClass->m_stop_flag++;
    pthread_mutex_unlock(&cpClass->m_lock);

    return NULL;
}
Ejemplo n.º 23
0
void Waiter::init0()
{
    proceeder.reset(this, [](Waiter* w) {
        if (w->proceed != nullptr)
        {
            TLOG("wait completed, proceeding");
            w->proceed();
        }
    });
}
Ejemplo n.º 24
0
void toConnectionPoolTest::test()
{
    for(int i = 0; Pool && i < Pool->size(); i++)
    {
        TLOG(0, toDecorator, __HERE__) << "Pool member id:"  << i << std::endl;
        toConnectionPool::PooledState state = Pool->test(i);
        if(state == toConnectionPool::Busy)
        {
            TLOG(0, toDecorator, __HERE__) << "Pool member id:"  << i << " Busy" << std::endl;
            continue;
        }

        if(state == toConnectionPool::Broken)
        {
            TLOG(0, toDecorator, __HERE__) << "Pool member id:"  << i << " Broken" << std::endl;
            Pool->fix(i);
        }
    }
}
Ejemplo n.º 25
0
_Noreturn void ReThrowException(const ::trotl::OciException &exc)
{
    TLOG(5, toDecorator, __HERE__)
            << "Exception thrown, what:" << exc.what() << std::endl
            << exc.get_sql() << std::endl
            << "--------------------------------------------------------------------------------"
            << std::endl;

    toConnection::exception ret(QString::fromUtf8(exc.get_mesg()), exc.parse_offset(), exc.line(), exc.column());
    throw ret;
}
Ejemplo n.º 26
0
void mysqlQuery::bindParam(QSqlQuery *q, toQueryParams const &params)
{
    Q_ASSERT_X(BindParams.size() <= params.size()
               , qPrintable(__QHERE__)
               , qPrintable(QString("Bind variables mismatch: %1 vs. %2").arg(BindParams.size()).arg(params.size())));
    for (int i = 0; i < BindParams.size(); i++)
    {
        q->bindValue(BindParams.at(i), params.at(i).displayData());
        TLOG(6, toDecorator, __HERE__) << "	Binding " << BindParams.at(i) << " <= " << params.at(i).displayData() << std::endl;
    }
}
Ejemplo n.º 27
0
void toResultSchema::refresh(void)
{
    try
    {
        toResultCombo::refresh();
    }
    catch (...)
    {
        TLOG(1,toDecorator,__HERE__) << "       Ignored exception." << std::endl;
    }
}
Ejemplo n.º 28
0
QString toToolWidget::currentSchema(QWidget *cur)
{
    while (cur)
    {
    	toToolWidget *widget = dynamic_cast<toToolWidget *>(cur);
        if (widget)
            return widget->schema();
        cur = cur->parentWidget();
    }
    TLOG(2, toDecorator, __HERE__) << "Couldn't find parent toToolWidget. Internal error." << std::endl;
    return "";
}
Ejemplo n.º 29
0
bool CMMapFile::openEx(const char *szFileName, int flag, size_t length)
{
	if (!(flag & FILE_OPEN_READ)) return false;
	m_szFileName = strdup(szFileName);

	assert(m_pBase==NULL);
	if (m_pHander.m_fd > 0)
	{
		if(::close(m_pHander.m_fd) != 0){
			TERR("CMMapFile: close file fail: %s", strerror(errno));
		}else{
			m_pHander.m_fd = -1;
		}
	}
	m_pHander.m_fd = ::open(szFileName, O_RDONLY, 0644);
	if (m_pHander.m_fd == -1) {
		TERR("打开文件出错 %s 文件可能不存在, errno: %d, %s", szFileName, errno, strerror(errno));
		return false;
	}
	struct stat statInfo;
	if (fstat(m_pHander.m_fd, &statInfo ) < 0) {
		TERR("文件 %s fstat失败!", szFileName);
		::close(m_pHander.m_fd);
		return false;
	}
	m_nLength = statInfo.st_size;		//文件长度
	if(m_nLength == 0) return true;

    int mmap_flags = MAP_SHARED;
    if (index_lib::IndexConfigParams::getInstance()->isMemLock()) {
        TLOG("open %s with MAP_LOCKED flag!", szFileName);
        m_pBase = (char*)mmap(0, m_nLength, PROT_READ, mmap_flags | MAP_LOCKED, m_pHander.m_fd, 0);
        if (m_pBase == MAP_FAILED && errno == EAGAIN) {
            TERR("open %s with MAP_LOCKED flag failed: %s!", szFileName, strerror(errno));
            m_pBase = (char*)mmap(0, m_nLength, PROT_READ, mmap_flags, m_pHander.m_fd, 0);
        }
    }
    else {
        m_pBase = (char*)mmap(0, m_nLength, PROT_READ, mmap_flags, m_pHander.m_fd, 0);
    }

	//允许m_pBase 为NULL(文件size 为0的情况),后面程序逻辑上保证不去读取文件内容
	if(m_pBase == MAP_FAILED) {
		TERR("文件 %s 映射内存文件出错! error code:%d", szFileName,errno);
		::close(m_pHander.m_fd);
		m_pBase = NULL;
		return false;
	}
	madvise(m_pBase, m_nLength, MADV_SEQUENTIAL);	//Expect  page  references in sequential order.

	return true;
}
Ejemplo n.º 30
0
    QToolBar *toAllocBar(QWidget *parent, const QString &str)
    {
        QString db;
        try
        {
            db = toConnection::currentConnection(parent).description(false);
        }
        catch (QString const& e)
        {
            TLOG(1, toDecorator, __HERE__) << "	Ignored exception: " << e << std::endl;
        }
        catch (...)
        {
            TLOG(1, toDecorator, __HERE__) << "	Ignored exception." << std::endl;
        }

        QString name = str;
        if (!db.isEmpty() && toConfigurationNewSingle::Instance().option(ToConfiguration::Global::IncludeDbCaptionBool).toBool())
        {
            name += QString::fromLatin1(" ");
            name += db;
        }

        QToolBar *tool;

        QMainWindow *main = dynamic_cast<QMainWindow *>(parent);
        if (main)
            tool = toMainWindow::lookup()->addToolBar(name);
        else
            tool = new QToolBar(parent);

        // Enforce smaller toolbars on mac
        tool->setIconSize(QSize(16, 16));

        tool->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
                                        QSizePolicy::Fixed));
        tool->setFocusPolicy(Qt::NoFocus);
        return tool;
    }