void rice::p2p::aggregation::AggregationImpl_handleDebugCommand_13_receiveResult_13_1::receiveException(::java::lang::Exception* e)
{
    if(npc(AggregationImpl_handleDebugCommand_13_this->AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::WARNING)
        npc(AggregationImpl_handleDebugCommand_13_this->AggregationImpl_this->logger)->logException(u"Monitor.add component insertion failed: "_j, e);

    receiveResult(static_cast< ::java::lang::Object* >(e));
}
void rice::p2p::aggregation::AggregationImpl_refreshInternal_28::receiveException(::java::lang::Exception* e)
{
    if(npc(AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::WARNING)
        npc(AggregationImpl_this->logger)->logException(::java::lang::StringBuilder().append(u"Exception while refreshing "_j)->append(npc((*ids)[currentIndex])->toStringFull())
            ->append(u", e="_j)->toString(), e);

    receiveResult(static_cast< ::java::lang::Object* >(e));
}
Exemplo n.º 3
0
    Delegator::Delegator(zmq::context_t& context, const DelegatorSettings& settings, bool& running)
        : context_(context),
          requester_(context, ZMQ_ROUTER, "toRequester"),
          heartbeat_(context, ZMQ_PAIR, "toHBRouter"),
          network_(context, ZMQ_ROUTER, "toNetwork"),
          router_("main", {&requester_, &heartbeat_, &network_}),
          msPollRate_(settings.msPollRate),
          hbSettings_(settings.heartbeat),
          running_(running),
          nextJobId_(0),
          nJobTypes_(settings.nJobTypes)
    {
      // Initialise the local sockets
      requester_.bind(DELEGATOR_SOCKET_ADDR);
      heartbeat_.bind(SERVER_HB_SOCKET_ADDR);
      network_.setFallback([&](const Message& m) { sendFailed(m); });
      std::string address = "tcp://*:" + std::to_string(settings.port);
      network_.bind(address);

      LOG(INFO) << "Delegator listening on tcp://*:" + std::to_string(settings.port);

      // Specify the Delegator functionality
      auto fDisconnect = [&](const Message& m) { disconnectWorker(m); };
      auto fNewWorker = [&](const Message &m)
      {
        //forwarding to HEARTBEAT
        heartbeat_.send(m);
        std::string worker = m.address.front();
        if (workers_.count(worker) == 0)
          connectWorker(m);
      };

      auto fRcvRequest = [&](const Message &m) { receiveRequest(m); };
      auto fRcvResult = [&](const Message &m) { receiveResult(m); };
      auto fForwardToHB = [&](const Message& m) { heartbeat_.send(m); };
      auto fForwardToNetwork = [&](const Message& m) { network_.send(m); };
      auto fForwardToHBAndDisconnect = [&](const Message& m)
        { fForwardToHB(m); fDisconnect(m); };

      // Bind functionality to the router
      const uint REQUESTER_SOCKET = 0, HB_SOCKET = 1, NETWORK_SOCKET = 2;

      router_.bind(REQUESTER_SOCKET, REQUEST, fRcvRequest);
      router_.bind(NETWORK_SOCKET, HELLO, fNewWorker);
      router_.bind(NETWORK_SOCKET, RESULT, fRcvResult);
      router_.bind(NETWORK_SOCKET, HEARTBEAT, fForwardToHB);
      router_.bind(NETWORK_SOCKET, GOODBYE, fForwardToHBAndDisconnect);
      router_.bind(HB_SOCKET, HEARTBEAT, fForwardToNetwork);
      router_.bind(HB_SOCKET, GOODBYE, fDisconnect);

      auto fOnPoll = [&] () {onPoll();};
      router_.bindOnPoll(fOnPoll);
    }
Exemplo n.º 4
0
bool KDBSearchEngine2::init()
{
    if(di!=0) return true; //if there already is a DBinterface we are ok
    else
    {
	di = new DataBaseInterface(dbDirectory,&settings);
	connect(di,SIGNAL(newResult(QueryResult)),this,SLOT(receiveResult(QueryResult)));
	//FIXME: what wbout ready()
	if(!di->mainOk()) return false;  //check if the main DB is OK.

	return true;
    }

}
void rice::persistence::testing::LRUCacheTest_testRandomInserts_10::receiveResult(::java::lang::Object* o)
{
    if(count == LAST_NUM_REMAINING) {
        LRUCacheTest_this->stepStart(u"Removing random subset of objects"_j);
    }
    if(npc(o)->equals(new ::java::lang::Boolean(false))) {
        LRUCacheTest_this->stepDone(Test::FAILURE(), ::java::lang::StringBuilder().append(u"Deletion of "_j)->append(count)
            ->append(u" failed."_j)->toString());
        return;
    }
    if(count == END_NUM) {
        LRUCacheTest_this->stepDone(Test::SUCCESS());
        npc(checkRandom)->receiveResult(new ::java::lang::Integer(num_deleted));
        return;
    }
    if(npc(npc(LRUCacheTest_this->environment)->getRandomSource())->nextBoolean()) {
        num_deleted++;
        npc(LRUCacheTest_this->cache)->uncache((*LRUCacheTest_this->data)[int32_t(13) + (count += SKIP)], this);
    } else {
        count += SKIP;
        receiveResult(static_cast< ::java::lang::Object* >(new ::java::lang::Boolean(true)));
    }
}
void rice::p2p::aggregation::AggregationImpl_refreshInternal_28::receiveResult(::java::lang::Object* o)
{
    auto lastResult = o;
    while (true) {
        if(currentIndex >= 0) {
            if(npc(AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::FINE)
                npc(AggregationImpl_this->logger)->log(::java::lang::StringBuilder().append(u"receiveResult("_j)->append(static_cast< ::java::lang::Object* >(lastResult))
                    ->append(u") for index "_j)
                    ->append(currentIndex)
                    ->append(u", length="_j)
                    ->append(npc(ids)->length)->toString());

            if(npc(AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::FINE)
                npc(AggregationImpl_this->logger)->log(::java::lang::StringBuilder().append(u"Internal refresh of "_j)->append(npc((*ids)[currentIndex])->toStringFull())
                    ->append(u" returned "_j)
                    ->append(static_cast< ::java::lang::Object* >(lastResult))->toString());

            result->set(currentIndex, lastResult);
        }
        currentIndex++;
        if(currentIndex >= npc(ids)->length) {
            if(objectsMissing > 0)
                if(npc(AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::WARNING)
                    npc(AggregationImpl_this->logger)->log(::java::lang::StringBuilder().append(u"refresh: "_j)->append(objectsMissing)
                        ->append(u"/"_j)
                        ->append(npc(ids)->length)
                        ->append(u" objects not in aggregate list, fetched "_j)
                        ->append(objectsFetched)
                        ->append(u" (max "_j)
                        ->append(AggregationImpl_this->maxReaggregationPerRefresh)
                        ->append(u")"_j)->toString());


            auto nOK = int32_t(0);
            for (auto i = int32_t(0); i < npc(ids)->length; i++) 
                                if(dynamic_cast< ::java::lang::Boolean* >((*result)[i]) != nullptr)
                    nOK++;


            if(npc(AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::INFO)
                npc(AggregationImpl_this->logger)->log(::java::lang::StringBuilder().append(u"refreshInternal: Processed "_j)->append(npc(ids)->length)
                    ->append(u" keys, completed "_j)
                    ->append(nOK)->toString());

            for (auto i = int32_t(0); i < npc(ids)->length; i++) 
                                if(npc(AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::FINER)
                    npc(AggregationImpl_this->logger)->log(::java::lang::StringBuilder().append(u" - "_j)->append(npc((*ids)[i])->toStringFull())
                        ->append(u": "_j)
                        ->append(static_cast< ::java::lang::Object* >((*result)[i]))->toString());


            npc(command)->receiveResult(result);
            return;
        }
        auto const id = (*ids)[currentIndex];
        auto const expiration = (*expirations)[currentIndex];
        if(npc(AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::INFO)
            npc(AggregationImpl_this->logger)->log(::java::lang::StringBuilder().append(u"Refresh("_j)->append(npc(id)->toStringFull())
                ->append(u", expiration="_j)
                ->append(expiration)
                ->append(u") started"_j)->toString());

        auto adc = java_cast< AggregateDescriptor* >(npc(AggregationImpl_this->aggregateList)->getADC(id));
        if(adc != nullptr) {
            auto objDescIndex = npc(adc)->lookupNewest(id);
            if(objDescIndex < 0) {
                if(npc(AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::WARNING)
                    npc(AggregationImpl_this->logger)->log(u"NL: Aggregate found, but object not found in aggregate?!? -- aborted"_j);

                npc(command)->receiveException(new AggregationException(u"Inconsistency detected in aggregate list -- try restarting the application"_j));
                return;
            }
            if(npc((*npc(adc)->objects)[objDescIndex])->refreshedLifetime < expiration) {
                if(npc(AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::FINE)
                    npc(AggregationImpl_this->logger)->log(::java::lang::StringBuilder().append(u"Changing expiration date from "_j)->append(npc((*npc(adc)->objects)[objDescIndex])->refreshedLifetime)
                        ->append(u" to "_j)
                        ->append(expiration)->toString());

                npc(AggregationImpl_this->aggregateList)->setObjectRefreshedLifetime(adc, objDescIndex, expiration);
            } else {
                if(npc(AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::FINE)
                    npc(AggregationImpl_this->logger)->log(::java::lang::StringBuilder().append(u"Expiration is "_j)->append(npc((*npc(adc)->objects)[objDescIndex])->refreshedLifetime)
                        ->append(u" already, no update needed"_j)->toString());

            }
            lastResult = new ::java::lang::Boolean(true);
            continue;
        } else {
            auto waitingIds = npc(AggregationImpl_this->waitingList)->scan();
            auto iter = npc(waitingIds)->getIterator();
            while (npc(iter)->hasNext()) {
                auto const vkey = java_cast< ::rice::p2p::glacier::VersionKey* >(java_cast< ::java::lang::Object* >(npc(iter)->next()));
                if(npc(npc(vkey)->getId())->equals(id)) {
                    auto thisObject = java_cast< ObjectDescriptor* >(npc(AggregationImpl_this->waitingList)->getMetadata(vkey));
                    if(npc(AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::INFO)
                        npc(AggregationImpl_this->logger)->log(::java::lang::StringBuilder().append(u"Refreshing in waiting list: "_j)->append(npc(vkey)->toStringFull())->toString());

                    if(thisObject == nullptr) {
                        if(npc(AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::WARNING)
                            npc(AggregationImpl_this->logger)->log(::java::lang::StringBuilder().append(u"Broken object in waiting list: "_j)->append(npc(vkey)->toStringFull())
                                ->append(u", removing..."_j)->toString());

                        ::rice::Continuation* const myParent = this;
                        npc(AggregationImpl_this->waitingList)->unstore(vkey, new AggregationImpl_refreshInternal_28_receiveResult_28_1(this, vkey, myParent));
                        return;
                    }
                    if(npc(thisObject)->refreshedLifetime < expiration) {
                        auto newDescriptor = new ObjectDescriptor(npc(thisObject)->key, npc(thisObject)->version, npc(thisObject)->currentLifetime, expiration, npc(thisObject)->size);
                        ::rice::Continuation* const myParent = this;
                        npc(AggregationImpl_this->waitingList)->setMetadata(vkey, newDescriptor, new AggregationImpl_refreshInternal_28_receiveResult_28_2(this, vkey, myParent));
                        return;
                    } else {
                        if(npc(AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::FINE)
                            npc(AggregationImpl_this->logger)->log(::java::lang::StringBuilder().append(u"Object found in waiting list and no update needed: "_j)->append(npc(vkey)->toStringFull())->toString());

                        receiveResult(static_cast< ::java::lang::Object* >(new ::java::lang::Boolean(true)));
                        return;
                    }
                }
            }
            objectsMissing++;
            if(AggregationImpl_this->addMissingAfterRefresh) {
                if(objectsFetched < AggregationImpl_this->maxReaggregationPerRefresh) {
                    objectsFetched++;
                    ::rice::Continuation* const myParent = this;
                    npc(AggregationImpl_this->objectStore)->lookup(id, false, new AggregationImpl_refreshInternal_28_receiveResult_28_3(this, id, expiration, myParent));
                    return;
                } else {
                    if(npc(AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::FINE)
                        npc(AggregationImpl_this->logger)->log(::java::lang::StringBuilder().append(u"Refresh: Limit of "_j)->append(AggregationImpl_this->maxReaggregationPerRefresh)
                            ->append(u" reaggregations exceeded; postponing id="_j)
                            ->append(npc(id)->toStringFull())->toString());

                    lastResult = new ::java::lang::Boolean(true);
                    continue;
                }
            } else {
                if(npc(AggregationImpl_this->logger)->level <= ::rice::environment::logging::Logger::WARNING)
                    npc(AggregationImpl_this->logger)->log(::java::lang::StringBuilder().append(u"Refresh: Refreshed object not found in any aggregate: "_j)->append(npc(id)->toStringFull())->toString());

                lastResult = new ::java::lang::Boolean(true);
                continue;
            }
        }
    }
}
void rice::pastry::socket::nat::rendezvous::RendezvousPNSApplication_getLeafSet_1::receiveResult(::java::lang::Object* result)
{ 
    receiveResult(dynamic_cast< ::rice::pastry::leafset::LeafSet* >(result));
}
void org::mpisws::p2p::transport::ssl::SSLTransportLayerImpl_openSocket_1_receiveResult_1_1::receiveResult(::java::lang::Object* result)
{ 
    receiveResult(dynamic_cast< SSLSocketManager* >(result));
}
Exemplo n.º 9
0
bool KDBSearchEngine2::startSearch(QString str)
{
    kdDebug(0) << "Start a new search. Looking for: " << str << endl;
    
    static QString queryString;
    
    queryString=str;  //set the latest query string (note: it is static)
    
    if(autoupdate)
    {
	updateSettings();
    }
    
    
    if(!init()) return false;    //-check initialization
    di->stop(true); //stop all new emits from database interface
    emit started(); //say everybody we are starting
    
    if(searching) return true; //We already have a search loop, as soon as we come back
    //on the search loop we will start the new search (queryString).
    
    searching=true;  //really start searching
    
    QString searchingString;
    
    do //Search loop, it stops only when finished and latest searched string is the actual query string.
    {
	searchingString=queryString; //-set new search string
	di->stop(false);  	   //-unlock searching
	
	if(numberOfResult<1) numberOfResult=1;

//	di->singleWordMatch(searchingString,0,true);

	GenericSearchAlgorithm strategy(di,&settings);

	//Let's create a search sequence:
	ExactSearchAlgorithm exact(di,&settings);
	AlphaSearchAlgorithm alpha(di,&settings);
	SentenceArchiveSearchAlgorithm sent(di,&settings);
	ChunkByChunkSearchAlgorithm sbys(di,&settings);
	ChunkByChunkSearchAlgorithm wbyw(di,&settings);
	CorrelationSearchAlgorithm corr(di,&settings);
	FuzzyChunkSearchAlgorithm fs(di,&settings);
	FuzzyChunkSearchAlgorithm fw(di,&settings);

	SentenceChunkFactory sf(di);
	sbys.setChunkFactory(&sf);
	fs.setChunkFactory(&sf);


	WordChunkFactory wf(di);
	wbyw.setChunkFactory(&wf);
	fw.setChunkFactory(&wf);

	strategy.addAlgorithm(&exact);
	strategy.addAlgorithm(&alpha);
	strategy.addAlgorithm(&sent);
	strategy.addAlgorithm(&sbys);
	//strategy.addAlgorithm(&fs);
	strategy.addAlgorithm(&fw);
	strategy.addAlgorithm(&corr);
	strategy.addAlgorithm(&wbyw);


	connect(&strategy,SIGNAL(newResult(QueryResult)),this,SLOT(receiveResult(QueryResult)));
	strategy.exec(searchingString);	disconnect(&strategy,SIGNAL(newResult(QueryResult)),this,SLOT(receiveResult(QueryResult)));


	kdDebug(0) << "End of search for " << searchingString  << endl;
    }
    while(searchingString!=queryString);
    kdDebug(0) << "Exiting the search loop" << endl;
    //if != someone asked a different string when we was searching
    //so we restart our search (maybe a cleanresult is needed?).
    
    
    di->stop(false);  //-clean searching locks
    searching=false;  //-clean searching locks
    emit finished();  //Finished
    
    return true;
    
}
void org::mpisws::p2p::transport::util::BufferReaderWriter_BufferReaderWriter_1::receiveResult(::java::lang::Object* result)
{ 
    receiveResult(dynamic_cast< ::java::nio::ByteBuffer* >(result));
}
void org::mpisws::p2p::testing::transportlayer::TestNodeHandleFetcher_main_1::receiveResult(::java::lang::Object* result)
{ 
    receiveResult(dynamic_cast< ::rice::pastry::NodeHandle* >(result));
}
void JClientChangePasswordProcessor::process(const QByteArray& data){
	QDataStream stream(data);
	JCode code;
	stream>>code;
	emit receiveResult(code);
}
void org::mpisws::p2p::transport::table::TableTransprotLayerImpl_handleValueRequest_4::receiveResult(::java::lang::Object* result)
{ 
    receiveResult(dynamic_cast< ::java::nio::ByteBuffer* >(result));
}
void org::mpisws::p2p::transport::table::TableTransprotLayerImpl_incomingSocket_3::receiveResult(::java::lang::Object* result)
{ 
    receiveResult(dynamic_cast< ::java::nio::ByteBuffer* >(result));
}
Exemplo n.º 15
0
void rice::tutorial::remotesocket::Tutorial_Tutorial_1::receiveResult(::java::lang::Object* result)
{ 
    receiveResult(dynamic_cast< ::rice::p2p::commonapi::appsocket::AppSocket* >(result));
}
void org::mpisws::p2p::transport::peerreview::PeerReviewImpl_requestCertificate_2::receiveResult(::java::lang::Object* result)
{ 
    receiveResult(dynamic_cast< ::java::security::cert::X509Certificate* >(result));
}
void org::mpisws::p2p::transport::rendezvous::RendezvousTransportLayerImpl_readAcceptHeader_6_receiveSelectResult_6_2::receiveResult(::java::lang::Object* result)
{ 
    receiveResult(dynamic_cast< ::org::mpisws::p2p::transport::P2PSocket* >(result));
}
void org::mpisws::p2p::transport::rendezvous::RendezvousTransportLayerImpl_openSocketUsingRouting_2::receiveResult(::java::lang::Object* result)
{ 
    receiveResult(dynamic_cast< ::java::lang::Integer* >(result));
}
void rice::pastry::socket::internet::InternetPastryNodeFactory_findExternalAddressHelper_2::receiveResult(::java::lang::Object* result)
{ 
    receiveResult(dynamic_cast< ::java::net::InetAddress* >(result));
}
void rice::pastry::socket::internet::InternetPastryNodeFactory_findExternalNodes_1::receiveResult(::java::lang::Object* result)
{ 
    receiveResult(dynamic_cast< ::java::util::Collection* >(result));
}
void rice::pastry::socket::appsocket::AppSocketPastryNodeFactory_getSocketFactory_1_getSocketChannel_1_2::receiveResult(::java::lang::Object* result)
{ 
    receiveResult(dynamic_cast< ::org::mpisws::p2p::transport::P2PSocket* >(result));
}
void org::mpisws::p2p::transport::table::TableTransprotLayerImpl_requestValue_1_receiveResult_1_1::receiveResult(::java::lang::Object* result)
{ 
    receiveResult(dynamic_cast< ::org::mpisws::p2p::transport::P2PSocket* >(result));
}