blob: 3cb1fc65b00f8841265e8be2ddc2e362e04f0457 [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2000-2019 Ericsson Telecom AB //
// //
// All rights reserved. This program and the accompanying materials //
// are made available under the terms of the Eclipse Public License v2.0 //
// which accompanies this distribution, and is available at //
// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html //
///////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////
// Module: EPTF_CLL_CSUIHandler_Functions
//
// Purpose:
// This TTCN-3 module contains generic function definitions and altsteps
// for EPTF central scheduling UIHandler.
//
// Module paramters:
// tsp_debug_EPTF_CSUIHandler - *boolean* - if true, logging is enabled
//
// Module depens on:
// <EPTF_CLL_Base_Definitions>
// <EPTF_CLL_Common_Definitions>
// <EPTF_CLL_CS_Definitions>
// <EPTF_CLL_CSUIHandler_Definitions>
// <EPTF_CLL_CSAdmin_Functions>
// <EPTF_CLL_CSLB_Functions>
// <EPTF_CLL_Base_Functions>
// <EPTF_CLL_Variable_Definitions>
// <EPTF_CLL_Variable_Functions>
// <EPTF_CLL_ExecCtrl_Definitions>
// <EPTF_CLL_ExecCtrlUIHandler_Functions>
// <EPTF_CLL_ExecCtrlClient_Functions>
// <EPTF_CLL_HostAdmin_Definitions>
// <EPTF_CLL_HostAdminUI_Definitions>
// <EPTF_CLL_HostAdminUI_Functions>
// <EPTF_CLL_Logging_Definitions>
// <EPTF_CLL_Logging_Functions>
// <EPTF_CLL_LoggingUI_Definitions>
// <EPTF_CLL_LoggingUI_Functions>
// <EPTF_CLL_LoggingUIClient_Functions>
// <EPTF_CLL_UIHandler_Definitions>
// <EPTF_CLL_UIHandlerClient_Functions>
// <XTDP_PDU_Defs>
//
// Current Owner:
// Gabor Tatarka (egbotat)
//
// Last review date:
// -
////////////////////////////////////////////////////
module EPTF_CLL_CSUIHandler_Functions
{
import from EPTF_CLL_Base_Definitions all;
import from EPTF_CLL_CS_Definitions all;
import from EPTF_CLL_CSUIHandler_Definitions all;
import from EPTF_CLL_CSAdmin_Functions all;
import from EPTF_CLL_CSLB_Functions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_Variable_Functions all;
import from EPTF_CLL_ExecCtrl_Definitions all;
import from EPTF_CLL_ExecCtrlUIHandler_Functions all;
import from EPTF_CLL_HostAdminUI_Definitions all;
import from EPTF_CLL_HostAdminUI_Functions all;
import from EPTF_CLL_Logging_Definitions all;
import from EPTF_CLL_Logging_Functions all;
import from EPTF_CLL_LoggingUI_Definitions all;
import from EPTF_CLL_LoggingUIClient_Functions all;
import from EPTF_CLL_UIHandler_Definitions all;
import from EPTF_CLL_UIHandlerClient_Functions all;
//===========================================================================
// Module parameters
//===========================================================================
modulepar boolean tsp_debug_EPTF_CSUIHandler := false;
////////////////////////////////////////////////////
//Function: f_EPTF_CS_Admin_UIHandler_init_CT
//
//Purpose:
// Function for initializing CS_ApplAdminBase component.
//
//Parameters:
// - pl_selfName - *in* *charstring* - EPTF self-name
// - pl_adminIdx - *in* *integer* - admin index
// - pl_ExecCtrlRef - *in* <EPTF_ExecCtrl_CT> - Execution Control component reference
// - pl_EPTF_CS_AdminInit - *in* <EPTF_CS_AdminInit_FT> - user defined init function reference
// - pl_loggingUi_compRef - *in* <EPTF_LoggingUI_CT> - LoggingUI component reference
// - pl_loadBalancingAvailable - *in* *boolean* - true if load balancing is to be used
//
//Errors:
//
//Detailed comments:
//
////////////////////////////////////////////////////
public function f_EPTF_CS_Admin_UIHandler_init_CT(
in charstring pl_selfName,
in integer pl_adminIdx,
in EPTF_ExecCtrl_CT pl_ExecCtrlRef,
in EPTF_UIHandler_CT pl_UIHandlerRef,
in EPTF_CS_AdminInit_FT pl_EPTF_CS_AdminInit,
in EPTF_LoggingUI_CT pl_loggingUi_compRef := null,
in boolean pl_loadBalancingAvailable := false)
runs on EPTF_CS_ApplAdminBase_UIHandler_CT
{
if(f_EPTF_CS_initialized()) {
f_EPTF_CSUIHandler_debug(log2str(%definitionId& ": already initialized"));
return;
}
if(pl_loggingUi_compRef != null) {
f_EPTF_LoggingUIClient_init_CT(pl_selfName, pl_loggingUi_compRef, pl_UIHandlerRef);
} else {
f_EPTF_Logging_init_CT(pl_selfName);
}
v_CSUIHandler_loggingMaskId :=
f_EPTF_Logging_registerComponentMasks(tsp_EPTF_CSUIHandler_loggingComponentMask, c_EPTF_CS_loggingEventClasses, EPTF_Logging_CLL);
if(tsp_debug_EPTF_CSUIHandler) {
f_EPTF_Logging_enableLocalMask(v_CSUIHandler_loggingMaskId, c_EPTF_CS_loggingClassIdx_Debug);
} else {
f_EPTF_Logging_disableLocalMask(v_CSUIHandler_loggingMaskId, c_EPTF_CS_loggingClassIdx_Debug);
}
if(pl_loadBalancingAvailable) {
f_EPTF_LB_UIHandler_init(f_EPTF_Base_selfName(), pl_UIHandlerRef);
}
f_EPTF_UIHandlerClient_init_CT(f_EPTF_Base_selfName(), pl_UIHandlerRef);
f_EPTF_CS_Admin_init_CT(f_EPTF_Base_selfName(), pl_adminIdx, pl_ExecCtrlRef, pl_EPTF_CS_AdminInit);
f_EPTF_ExecCtrlClient_UIHandler_init_CT(f_EPTF_Base_selfName(), pl_ExecCtrlRef, pl_UIHandlerRef, pl_loggingUi_compRef);
/*timer T;
T.start(5.0);
T.timeout;
f_EPTF_CS_Admin_initGui();*/
}
////////////////////////////////////////////////////
//Function: f_EPTF_CS_Admin_UIHandler_behavior
//
//Purpose:
// Behavior function for the Cenral Scheduling Admin UIHandler. The function reference parameters
// with *runs on self* make it necessary to start a user defined function on the admin
// and call this function from within that function.
//
//Parameters:
// - pl_selfName - *in* *charstring* - EPTF self-name
// - pl_adminIdx - *in* *integer* - admin index
// - pl_ExecCtrlRef - *in* <EPTF_ExecCtrl_CT> - Execution Control component reference
// - pl_UIHandlerRef - *in* <EPTF_UIHandler_CT> - UIHandler component reference
// - pl_EPTF_CS_AdminInit - *in* <EPTF_CS_AdminInit_FT> - user defined init function reference
// - pl_loadBalancingAvailable - *in* *boolean* - true if load balancing is to be used
// - pl_loggingUi_compRef - *in* <EPTF_LoggingUI_CT> - LoggingUI component reference
//
//Errors:
//
//Detailed comments:
//
////////////////////////////////////////////////////
public function f_EPTF_CS_Admin_UIHandler_behavior(
in charstring pl_selfName,
in integer pl_adminIdx,
in EPTF_ExecCtrl_CT pl_ExecCtrlRef,
in EPTF_UIHandler_CT pl_UIHandlerRef,
in EPTF_CS_AdminInit_FT pl_EPTF_CS_AdminInit,
in boolean pl_loadBalancingAvailable,
in EPTF_LoggingUI_CT pl_loggingUi_compRef := null)
runs on EPTF_CS_ApplAdminBase_UIHandler_CT
{
/* if(sizeof(tsp_EPTF_CS_LGenHostnameList) <= 1) {
pl_loadBalancingAvailable := false;
}*/
f_EPTF_CS_Admin_UIHandler_init_CT(pl_selfName, pl_adminIdx, pl_ExecCtrlRef, pl_UIHandlerRef, pl_EPTF_CS_AdminInit, pl_loggingUi_compRef, pl_loadBalancingAvailable);
if(tsp_debug_EPTF_CS_Admin_Functions) { f_EPTF_CSUIHandler_debug(log2str(%definitionId& ": entering main alt loop")); }
f_EPTF_Base_wait4Shutdown();
if(tsp_debug_EPTF_CS_Admin_Functions) { f_EPTF_CSUIHandler_debug(log2str(%definitionId& ": exited main alt loop")); }
if(tsp_debug_EPTF_CS_Admin_Functions) {
for(var integer i := 0; i < f_EPTF_CS_getNumberOfLoadgens(); i := i + 1) {
var EPTF_Base_CT vl_compRef := f_EPTF_CS_getCompRefOfLGen(i);
if(vl_compRef.running == false) {
f_EPTF_CSUIHandler_debug(log2str("LGen[", i, "] stopped operation. Component reference: ", vl_compRef));
} else {
f_EPTF_CSUIHandler_debug(log2str("LGen[", i, "] still running. Component reference: ", vl_compRef));
}
}
}
f_EPTF_Base_cleanup_CT();
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_LB_UIHandler_init
//
// Purpose:
// Initializes the loadBalancing UIHandler.
//
// Parameters:
// - pl_selfName - *in* *integer* - EPTF self-name
// - pl_UIHandler - *in* <EPTF_UIHandler_CT> - UIHandler component reference
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
private function f_EPTF_LB_UIHandler_init(in charstring pl_selfName, in EPTF_UIHandler_CT pl_UIHandler)
runs on EPTF_CS_ApplAdminBase_UIHandler_CT
{
if(f_EPTF_LB_getInitialized()) { return; }
f_EPTF_Var_init_CT(pl_selfName);
for (var integer i:=0; i<sizeof(tsp_EPTF_CS_LGenHostnameList); i:=i+1) {
var charstring vl_hostAdminName := f_EPTF_Base_selfName() & ".HostAdmin." & int2str(i);
v_hostAdminUIs[i] := EPTF_HostAdminUI_CT.create(-, tsp_EPTF_CS_LGenHostnameList[i]);
v_hostAdminUIs[i].start(f_EPTF_HostAdminUI_behavior(vl_hostAdminName, tsp_EPTF_CS_LGenHostnameList[i], pl_UIHandler));
f_EPTF_LB_subscribeToHostAdminLoadVar(i, vl_hostAdminName, v_hostAdminUIs[i]);
}
f_EPTF_LB_setInitialized(true);
f_EPTF_Base_registerCleanup(refers(f_EPTF_LB_UIHandler_cleanup));
}
private function f_EPTF_LB_UIHandler_cleanup() runs on EPTF_CS_ApplAdminBase_UIHandler_CT
{
f_EPTF_LB_setInitialized(false);
}
group Logging {
///////////////////////////////////////////////////////////
// Function: f_EPTF_CSUIHandler_error
//
// Purpose:
// Function to log an error from CSUIHandler feature.
//
// Parameters:
// - pl_message - *in* *charstring* - the message to log
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
private function f_EPTF_CSUIHandler_error(in charstring pl_message)
runs on EPTF_CS_ApplAdminBase_UIHandler_CT
{
f_EPTF_Logging_error(true, tsp_EPTF_CSUIHandler_loggingComponentMask&": "&pl_message);
f_EPTF_Base_stopAll();
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_CSUIHandler_warning
//
// Purpose:
// Function to log a warning from CSUIHandler feature.
//
// Parameters:
// - pl_message - *in* *charstring* - the message to log
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
private function f_EPTF_CSUIHandler_warning(in @lazy charstring pl_message)
runs on EPTF_CS_ApplAdminBase_UIHandler_CT
{
f_EPTF_Logging_warningV2(pl_message, v_CSUIHandler_loggingMaskId, {c_EPTF_CS_loggingClassIdx_Warning});
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_CSUIHandler_debug
//
// Purpose:
// Function to log a debug message from CSUIHandler feature.
//
// Parameters:
// - pl_message - *in* *charstring* - the message to log
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
private function f_EPTF_CSUIHandler_debug(in @lazy charstring pl_message)
runs on EPTF_CS_ApplAdminBase_UIHandler_CT
{
f_EPTF_Logging_debugV2(pl_message, v_CSUIHandler_loggingMaskId, {c_EPTF_CS_loggingClassIdx_Debug});
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_CSUIHandler_debugEnabled
//
// Purpose:
// Function to check if debug is enabled for CSUIHandler
//
// Parameters:
// -
//
// Return Value:
// *boolean* - true if debug enalbed
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
private function f_EPTF_CSUIHandler_debugEnabled()
runs on EPTF_CS_ApplAdminBase_UIHandler_CT
return boolean
{
return f_EPTF_Logging_isEnabled(v_CSUIHandler_loggingMaskId, c_EPTF_CS_loggingClassIdx_Debug);
}
} // group Logging
} // end of module