📄 attachrpl.cpp
字号:
/***************************************************************** * * * This file is a part of the eXtremeDB-HA Application Framework * * Copyright (c) 2001-2006 McObject LLC * * All Rights Reserved * * * ***************************************************************** * ++ * * PROJECT: eXtremeDB(tm) (c) 2003 McObject LLC * * SUBSYSTEM: HA support * * MODULE: attachrpl.cpp * * ABSTRACT: C++ implementation of master connection thread * * * VERSION: 1.0 * * HISTORY: * 1.0- 1 SS 18-Feb-2004 Created it was * * -- *****************************************************************/#include "framework.hpp"#if 0/* * The thread opens a channel for listening the connections requests from replicas. * It is always waiting for the requests. For this purpose it calls the function * * mco_nw_attach_replica(). * * This function is dependent on communication protocol therefore it is implemented in * protocol dependent modules (appnwfio.c appnwpip.c appnwTCP.c appnwUDP.c). * * Once the thread receives the request it creates the communication channel and calls * function mco_HA_attach_replica() in order to create copy of master's database on * replica side (also see mco_nw_attach_replica() and mco_nw_attach_master()). */void HA::ListenToReplicas(){ char str[HOST_MAX_NAMELENGTH]; MCO_RET ret; // result code int count; // working cell THREAD_PROC_MODE(); Printf( "Thread ListenToReplicas() started\n"); strcpy(str, nw_MasterName); sprintf(&str[strlen(str)-2],"%02d", id*10);/* * This structure describes timeouts that are necessary to set the finite times to functions * of attaching and detaching replicas and of transaction commits */ conpar.commit_timeout = TM_MASTER_COMMIT; // timeout for commit conpar.initial_timeout = TM_ATTACH_REPLICA; // initial sync timeout conpar.detach_timeout = TM_DETACH_REPLICA; // send detach request, timeout for replica's commit conpar.wait_data_timeout= TM_WAIT_FOR_DATA; // amount of time replica waits for the next commit/* * The infinite cycle for listening connection requests from replicas and creating copies of * the master's database */ for(;;) {/* * mco_nw_attach_replica() - * Creates a communication channel and creates copy of master's database on replication side */ ret = AttachReplica(str, 0, (unsigned long)TM_ACCEPT_TIMEOUT ); if ( ret ) { if(ret != MCO_E_NW_TIMEOUT) { Printf( "\nfailed with error %d\n", ret ); switch(ret) { case MCO_E_NW_KILLED_BY_REPLICA: Printf("\n\n*** master is killed by replica ***\n"); (*pStop_flag)++; return; case MCO_E_NW_FATAL: case MCO_E_NW_NOTSUPP: case MCO_E_NW_BUSY: case MCO_E_NW_NOMEM: exit(-1); default: break; } } } else { count = GetNumberOfReplicas()-1; // show current number of replicas Printf("*** attached (%d), time of initialization phase = %ld ms ***\n", count, *pIinit_time); } }}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -