int ResManagerMainSegment2ndPhase(void)
{
	int res = FUNC_RETURN_OK;

	elog(DEBUG5, "HAWQ RM SEG is triggered.");

	/* Register message handlers */
	registerMessageHandler(REQUEST_QE_MOVETOCGROUP, handleQEMoveToCGroup);
	registerMessageHandler(REQUEST_QE_MOVEOUTCGROUP, handleQEMoveOutCGroup);
	registerMessageHandler(REQUEST_QE_SETWEIGHTCGROUP, handleQESetWeightCGroup);
	registerMessageHandler(REQUEST_RM_INCREASE_MEMORY_QUOTA, handleRMIncreaseMemoryQuota);
	registerMessageHandler(REQUEST_RM_DECREASE_MEMORY_QUOTA, handleRMDecreaseMemoryQuota);
	registerMessageHandler(REQUEST_RM_TMPDIR, handleRMSEGRequestTmpDir);
	registerMessageHandler(REQUEST_RM_RUALIVE, handleRMSEGRequestRUAlive);


	/**************************************************************************
	 * New socket facility poll based server.
	 **************************************************************************/
	res = initializeSocketServer_RMSEG();
	if ( res != FUNC_RETURN_OK ) {
		elog(LOG, "Fail to initialize socket server. Segment sleeps for ever.");
		MainHandler_RMSEGDummyLoop();
	}

	initializeRMSEG2RMComm();

	/*
	 * Resource enforcement: initialize, cleanup, and rebuild CGroup hash table
	 * when segment resource manager starts/restarts
	 */
	initCGroupThreads();

	InitFileAccess();

	/*
	 * Notify postmaster that HAWQ RM is ready. Ignore the possible problem that
	 * the parent process quits. HAWQ RM will automatically detect if its parent
	 * dies, then HAWQ RM should exit normally.
	 */
	kill(DRMGlobalInstance->ParentPID, SIGUSR2);
	elog(LOG, "HAWQ RM SEG process works now.");

    /* Start request handler to provide services. */
    res = MainHandlerLoop_RMSEG();

    elog(RMLOG, "HAWQ RM SEG server goes into exit phase.");
    return res;

}
Esempio n. 2
0
/*
 * Early initialization of a backend (either standalone or under postmaster).
 * This happens even before InitPostgres.
 *
 * This is separate from InitPostgres because it is also called by auxiliary
 * processes, such as the background writer process, which may not call
 * InitPostgres at all.
 */
void
BaseInit(void)
{
    /*
     * Attach to shared memory and semaphores, and initialize our
     * input/output/debugging file descriptors.
     */
    InitCommunication();
    DebugFileOpen();

    /* Do local initialization of file, storage and buffer managers */
    InitFileAccess();
    smgrinit();
    InitBufferPoolAccess();
}