Exemple #1
0
pDest
DestHashFiles::getDest_( char_ptr & bucket )
{
    if( d_->onefd_ )
    {
        pDest raw = d_->destFactory_->getFileDest( bucket.get());
        pDest buffered( new DestBuffered( 1024, raw, false ));
        return buffered;
    }
    mcpd_t::iterator desti;
    mcpd_t::iterator deste=d_->mdest_.end();
    desti=d_->mdest_.find( bucket.get() );
	if( desti==deste )
	{
		d_->names_.push_front( bucket );

		char filename[FILENAME_MAX];
		memset(filename,'\0', FILENAME_MAX );
		snprintf(filename,FILENAME_MAX,d_->template_.get(),bucket.get());
        pDest f = d_->destFactory_->getFileDest( filename );
        pDest b = DestThreadedBuffer::factory( f, d_->cfg_ );
        return (
            *(
                d_->mdest_.insert(
                    pair<const char *, pDest>(
                        bucket.get(), b
                    )
                ).first
            )
        ).second;
	}
    return (*desti).second ;
}
    void PushToSubscriberRunnable::run()
    {
        while(1) 
        {
            try
            {
                // the elements method blocks on the ServiceStatusMaps's mutex
                ptr<Service::ServiceStatusList> pServiceStatusList = serviceStatusMap_->elements(serviceName_.get(), host_.get());

                APPLOG_INFO("Pushing ServiceStatusList with %d entries to %s %s, which requested host:%s, service:%s", 
                            pServiceStatusList->length(),
                            serviceRef_.serviceName.in(),
                            serviceRef_.url.in(), 
                            host_.get(), 
                            serviceName_.get());

                Service::NodeMonitorPushConsumer_var nodeMonitorPushConsumer ;

                if( ! SharedServiceMain::instance()->resolve_consumer( 
                        nodeMonitorPushConsumer, serviceRef_.ior.in()) && 
                    ! SharedServiceMain::instance()->resolve_consumer( 
                        nodeMonitorPushConsumer, serviceRef_.url.in())
                )
                {
                    PANICV("could not resolve url or ior for %s.", serviceRef_.url.in());
                }

                APPLOG_DBG("resolved reference, pushing status" );
                nodeMonitorPushConsumer->pushStatusList(*pServiceStatusList);

                APPLOG_DBG("reset ior" );
                serviceRef_.ior = SharedServiceMain::instance()->getORB()->object_to_string( 
                    nodeMonitorPushConsumer );
            }
            catch (CORBA::Exception &ce) 
            {
                //AppExceptionHandler really needs to learn about CORBA...
                APPLOG_ABORT("caught CORBA::Exception trying to push to subscriber %s [%s][%s]", 
                    serviceRef_.url.in(), ce._rep_id(), ce._name() );
            }
            catch (std::exception &e) 
            {
                AppExceptionHandler::instance()->handleLogOnly( e );
            }
            catch ( ... )
            {
                AppExceptionHandler::instance()->handleLogOnly();
            }
            APPLOG_DBG("usleep(%d)", sleeptime_);
            usleep (sleeptime_);
        }
    }
Exemple #3
0
	inline bool Read(HANDLE Pipe, char_ptr& Data)
	{
		bool Result=false;
		size_t DataSize = 0;
		if(ReadPipe(Pipe, &DataSize, sizeof(DataSize)))
		{
			if(DataSize)
			{
				Data.reset(DataSize);
				if(ReadPipe(Pipe, Data.get(), DataSize))
				{
					Result=true;
				}
			}
			else
			{
				Result=true;
			}
		}
		return Result;
	}