Exemple #1
0
	/*
	 * parse preferred list and
	 * append (hostname, rackname, requested container number) into the message
	 */
	foreach(cell, preferred)
	{
		PAIR pair = (PAIR)lfirst(cell);
		SegResource segres = (SegResource)(pair->Key);
		ResourceBundle resource = (ResourceBundle)(pair->Value);
		int16_t num_containers = resource->Core;
		int16_t flag = 0; /* not used yet */
		char *hostname = GET_SEGINFO_GRMHOSTNAME(&(segres->Stat->Info));
		char *rackname = GET_SEGINFO_GRMRACKNAME(&(segres->Stat->Info));
		uint32_t preferredLen = sizeof(preferredLen) + sizeof(num_containers) + sizeof(flag) +
								__SIZE_ALIGN64((strlen(hostname) + 1 + strlen(rackname) + 1));
		appendSMBVar(&sendBuffer, preferredLen);
		appendSMBVar(&sendBuffer, num_containers);
		appendSMBVar(&sendBuffer, flag);
		appendSMBStr(&sendBuffer, hostname);
		appendSMBStr(&sendBuffer, rackname);
		appendSelfMaintainBufferTill64bitAligned(&sendBuffer);
		elog(LOG, "YARN mode resource broker build a preferred request."
				  "host:%s, rack:%s, container number:%d",
				  hostname, rackname, num_containers);
	}
Exemple #2
0
/*
 * Return cluster report including all node status. The response should be
 * handled asynchronously.
 */
int RB_LIBYARN_getClusterReport(const char  *quename,
								List 	   **machines,
								double 	    *maxcapacity)
{
	int		 res		= FUNC_RETURN_OK;
	uint32_t MessageID	= RM2RB_GET_CLUSTERREPORT;
	int		 piperes	= 0;

	if ( PipeReceivePending )
	{
		elog(DEBUG5, "YARN resource broker skip sending cluster report due to "
					 "not getting response of last request.");
		return FUNC_RETURN_OK;
	}

	/* Write request to pipe */
	SelfMaintainBufferData sendBuffer;
	initializeSelfMaintainBuffer(&sendBuffer, PCONTEXT);
	appendSMBVar(&sendBuffer, MessageID);
	appendSelfMaintainBufferTill64bitAligned(&sendBuffer);

	RPCRequestRBGetClusterReportHeadData request;
	request.QueueNameLen = __SIZE_ALIGN64(strlen(quename) + 1);
	request.Reserved     = 0;
	appendSMBVar(&sendBuffer, request);
	appendSMBStr(&sendBuffer, quename);
	appendSelfMaintainBufferTill64bitAligned(&sendBuffer);

	piperes = pipewrite(ResBrokerRequestPipe[1],
						sendBuffer.Buffer,
						sendBuffer.Cursor + 1);
	if ( piperes != sendBuffer.Cursor + 1 )
	{
		elog(WARNING, "YARN mode resource broker failed to generate cluster "
					  "report request to resource broker process through pipe. "
				      "Wrote length %d, expected length %d, errno %d",
				      piperes,
				      sendBuffer.Cursor + 1,
					  errno);
		res = RESBROK_PIPE_ERROR;
	}
	destroySelfMaintainBuffer(&sendBuffer);
	elog(LOG, "YARN mode resource broker generated cluster report request to "
			  "resource broker process.");
	PipeReceivePending = res == FUNC_RETURN_OK;
	return res;
}
void SimpleStringReplaceFirst(SimpStringPtr str, char *oldstr, char *newstr)
{
	char *pos = strstr(str->Str, oldstr);
	/* If the old string does not exist, no need to do any update. */
	if ( pos == NULL )
		return;

	SelfMaintainBufferData smb;
	initializeSelfMaintainBuffer(&smb, str->Context);
	if ( str->Str != pos ) {
		appendSelfMaintainBuffer(&smb, str->Str, pos - str->Str);
	}
	int oldstrlen = strlen(oldstr);
	appendSelfMaintainBuffer(&smb, newstr, strlen(newstr));
	if ( oldstrlen + (pos - str->Str) < str->Len ) {
		appendSMBStr(&smb, pos + oldstrlen);
	}
	setSimpleStringWithContent(str, smb.Buffer, getSMBContentSize(&smb));
	destroySelfMaintainBuffer(&smb);
}