Ejemplo n.º 1
0
bool CFlowGraphModule::PreLoadModule(const char* fileName)
{
	m_fileName = fileName;

	XmlNodeRef moduleRef = gEnv->pSystem->LoadXmlFromFile(fileName);

	if (!moduleRef)
	{
		CryWarning(VALIDATOR_MODULE_FLOWGRAPH, VALIDATOR_WARNING, "Unable to preload Flowgraph Module: %s", PathUtil::GetFileName(fileName).c_str());
		return false;
	}

	assert(!stricmp(moduleRef->getTag(), "Graph"));

	bool module = false;
	moduleRef->getAttr("isModule", module);
	assert(module);

	XmlString tempName;
	if (moduleRef->getAttr("moduleName", tempName))
		m_name = tempName;

	bool bResult = (m_pRootGraph != NULL);
	assert(m_pRootGraph == NULL);

	// first handle module ports
	XmlNodeRef modulePorts = moduleRef->findChild("ModuleInputsOutputs");
	RemoveModulePorts();
	if (modulePorts)
	{
		int nPorts = modulePorts->getChildCount();
		for (int i = 0; i < nPorts; ++i)
		{
			XmlString portName;
			int       portType;
			bool      isInput;

			XmlNodeRef port = modulePorts->getChild(i);
			port->getAttr("Name", portName);
			port->getAttr("Type", portType);
			port->getAttr("Input", isInput);

			IFlowGraphModule::SModulePortConfig portConfig;
			portConfig.name  = portName.c_str();
			portConfig.type  = (EFlowDataTypes)portType;
			portConfig.input = isInput;

			AddModulePort(portConfig);
		}
	}

	// and create nodes for this module (needs to be done before actual graph load, so that the
	//	nodes can be created there)
	RegisterNodes();

	return bResult;
}
Ejemplo n.º 2
0
/* shared library initialization function */
void
_PG_init(void)
{
	if (!process_shared_preload_libraries_in_progress)
	{
		ereport(ERROR, (errmsg("Citus can only be loaded via shared_preload_libraries"),
						errhint("Add citus to shared_preload_libraries configuration "
								"variable in postgresql.conf in master and workers. Note "
								"that citus should be at the beginning of "
								"shared_preload_libraries.")));
	}

	/*
	 * Perform checks before registering any hooks, to avoid erroring out in a
	 * partial state.
	 *
	 * In many cases (e.g. planner and utility hook, to run inside
	 * pg_stat_statements et. al.) we have to be loaded before other hooks
	 * (thus as the innermost/last running hook) to be able to do our
	 * duties. For simplicity insist that all hooks are previously unused.
	 */
	if (planner_hook != NULL ||
		ExplainOneQuery_hook != NULL ||
		ExecutorStart_hook != NULL ||
		ExecutorRun_hook != NULL ||
		ExecutorFinish_hook != NULL ||
		ExecutorEnd_hook != NULL ||
		ProcessUtility_hook != NULL)
	{
		ereport(ERROR, (errmsg("Citus has to be loaded first"),
						errhint("Place citus at the beginning of "
								"shared_preload_libraries.")));
	}

	/*
	 * Extend the database directory structure before continuing with
	 * initialization - one of the later steps might require them to exist.
	 */
	CreateRequiredDirectories();

	/*
	 * Register Citus configuration variables. Do so before intercepting
	 * hooks or calling initialization functions, in case we want to do the
	 * latter in a configuration dependent manner.
	 */
	RegisterCitusConfigVariables();

	/* make our additional node types known */
	RegisterNodes();

	/* intercept planner */
	planner_hook = multi_planner;

	/* intercept explain */
	ExplainOneQuery_hook = MultiExplainOneQuery;

	/* intercept executor */
	ExecutorStart_hook = multi_ExecutorStart;
	ExecutorRun_hook = multi_ExecutorRun;
	ExecutorFinish_hook = multi_ExecutorFinish;
	ExecutorEnd_hook = multi_ExecutorEnd;

	/* register utility hook */
	ProcessUtility_hook = multi_ProcessUtility;

	/* register for planner hook */
	set_rel_pathlist_hook = multi_relation_restriction_hook;

	/* organize that task tracker is started once server is up */
	TaskTrackerRegister();

	/* initialize transaction callbacks */
	RegisterRouterExecutorXactCallbacks();
	RegisterShardPlacementXactCallbacks();

	/* enable modification of pg_catalog tables during pg_upgrade */
	if (IsBinaryUpgrade)
	{
		SetConfigOption("allow_system_table_mods", "true", PGC_POSTMASTER,
						PGC_S_OVERRIDE);
	}
}