コード例 #1
0
ファイル: channel_client.cpp プロジェクト: dawnbreaks/arch
int main(int argc, char** argv)
{
    if (argc != 2)
    {
        printf("Need one arg for this programme.");
        return -1;
    }
    int total = atoi(argv[1]);
    printf("Total:%d\n", total);
    ChannelService service;
    ClientSocketChannel* client = service.NewClientSocketChannel();
    ChannelOptions ops;
    ops.user_write_buffer_water_mark = 8192;
    ops.user_write_buffer_flush_timeout_mills = 1;

    SocketHostAddress address("127.0.0.1", 48100);
    SocketUnixAddress unix_address("./server.unix");
    SocketHostAddress local("127.0.0.1", 5678);
    SocketUnixAddress local_unix_address("./client.unix");
    client->Bind(&local_unix_address);
    client->Connect(&unix_address);
    client->Configure(ops);
    client->GetPipeline().AddLast("decoder", new DelimiterBasedFrameDecoder(8192, CommonDelimiters::CRLFDelimiter()));
    client->GetPipeline().AddLast("default", new ClientHandler(
            total));

    uint64 start = get_current_epoch_millis();
    arch::logging::Logger* logger = arch::logging::LoggerFactory::GetDevelopLogger();
    logger->SetLevel(arch::logging::INFO_LOG_LEVEL);
    service.Start(true);
    uint64 end = get_current_epoch_millis();
    printf("Cost %llums for total %d send/recv transaction.\n", (end - start), total);
    return 1;
}
コード例 #2
0
ファイル: channel_service.cpp プロジェクト: mrkeng/ardb
void ChannelService::StartSubPool()
{
    if (m_thread_pool_size > 1)
    {
        struct LaunchThread: public Thread
        {
                ChannelService* serv;
                LaunchThread(ChannelService* s) :
                        serv(s)
                {
                }
                void Run()
                {
                    serv->Start();
                }
        };

        for (uint32 i = 0; i < m_thread_pool_size; i++)
        {
            ChannelService* s = new ChannelService(m_setsize);
            s->m_pool_index = i + 1;
            s->RegisterUserRoutineCallback(m_user_routine, m_user_routine_data);
            s->RegisterUserEventCallback(m_user_cb, m_user_cb_data);
            m_sub_pool.push_back(s);
            LaunchThread* launch = new LaunchThread(s);
            launch->Start();
            m_sub_pool_ts.push_back(launch);
        }
    }
}
コード例 #3
0
ファイル: channel_service.cpp プロジェクト: omegablitz/ardb
void ChannelService::OnStopCB(Channel*, void* data)
{
    ChannelService* serv = (ChannelService*) data;
    ChannelServicePool::iterator it = serv->m_sub_pool.begin();
    while (it != serv->m_sub_pool.end())
    {
        ChannelService* sub = *it;
        sub->AsyncIO(0, OnStopCB, sub);
        it++;
    }
    aeStop(serv->m_eventLoop);
    serv->Wakeup();
}
コード例 #4
0
ファイル: channel_server.cpp プロジェクト: dawnbreaks/arch
int main(int argc, char** argv)
{
	//    if (argc != 2)
	//    {
	//        printf("Nedd one arg for this programme.");
	//        return -1;
	//    }
	//    int total = atoi(argv[1]);
	//    printf("Total:%d\n", total);
	ChannelService service;
	ServerSocketChannel* server = service.NewServerSocketChannel();
	ChannelOptions ops;
	ops.user_write_buffer_water_mark = 8192;
	ops.user_write_buffer_flush_timeout_mills = 1;


	SocketHostAddress address("192.168.56.101", 48100);
	//SocketHostAddress local("0.0.0.0", 20001);
	SocketUnixAddress unixLocal("./server.unix");
	server->Bind(&unixLocal);
	server->Configure(ops);
	//client->Connect(&address);
	//client->Configure(ops);
	//client->GetPipeline().AddLast("decoder", new DelimiterBasedFrameDecoder(8192, CommonDelimiters::CRLFDelimiter()));
	ServerHandler handler;
	//server->GetPipeline().AddLast("default", new ServerHandler());
	server->SetChannelPipelineInitializor(pipelineInit, &handler);
	server->SetChannelPipelineFinalizer(pipelineFinalize, NULL);

	uint64 start = get_current_epoch_millis();
	arch::logging::Logger* logger =
	        arch::logging::LoggerFactory::GetDevelopLogger();
	logger->SetLevel(arch::logging::INFO_LOG_LEVEL);
	service.Start(true);
	uint64 end = get_current_epoch_millis();
	//printf("Cost %ums for total %d send/recv transaction.\n", (end - start),
	//        total);
	return 1;
}
コード例 #5
0
ファイル: clients.cpp プロジェクト: Ivasek/ardb
			void Run()
			{
				IdleConn conn;
				uint64 now = get_current_epoch_millis();
				while (lru.PeekFront(conn) && (now - conn.ts >= maxIdleTime))
				{

					Channel* ch = serv->GetChannel(conn.conn_id);
					if (NULL != ch)
					{
						DEBUG_LOG("Closed timeout connection:%d.", ch->GetID());
						ch->Close();
					}
					lru.PopFront();
				}
			}
コード例 #6
0
ファイル: channel_service.cpp プロジェクト: mrkeng/ardb
 void Run()
 {
     serv->Start();
 }
コード例 #7
0
ファイル: ardb.hpp プロジェクト: Abioy/ardb
 Timer& GetTimer()
 {
     return m_service->GetTimer();
 }
コード例 #8
0
ファイル: master.cpp プロジェクト: kouhate/ardb
	static void DumpRDBRoutine(void* cb)
	{
		ChannelService* serv = (ChannelService*) cb;
		serv->Continue();
	}