public class PerformanceTask
{
/**
* 调测日志记录器。
*/
private static Logger logger = Logger.getLogger(PerformanceTask.class);
/**
* 发送失败重试
*/
private static final int RETRYTIME = 3;
/**
* PortalStartProcessID
*/
private static final int PORTALSTARTPROCESSID = 300;
/**
* PortalEndProcessID
*/
private static final int PORTALENDPROCESSID = 600;
/**
* 性能统计类-业务性能
*/
private Performance performance = null;
/**
* 性能统计类-系统性能
*/
private SystemPerformance systemPerformance = null;
/**
* 数据汇集客户端
*/
private DataCollectClient dataCollectClient = null;
/**
* 数据汇集的JavaBean-业务性能汇聚
*/
private DataCollect dataCollectPerformance = null;
/**
* 数据汇集的JavaBean-系统性能汇聚
*/
private DataCollect dataCollectSystemPerformance = null;
/**
* 系统话筒发送对象
*/
private SystemPerformance sendSystemPerformance = new SystemPerformance();
/**
* 话筒客户端发送数据函数。 如果三次都失败,则继续统计,
* 不初始化统计数据。下个发送周期在发送
*
*/
public void sendMessageOnTime()
{
logger.recordEnterMethodLog();
if (null == dataCollectClient)
{
dataCollectClient = new DataCollectClientImpl();
}
//发送业务性能数据方法
sendPerformanceData();
if ((CommonProcess.getProcessID() < PORTALENDPROCESSID)
&& (CommonProcess.getProcessID() > PORTALSTARTPROCESSID))
{
sendSystemPerformanceData();
}
logger.recordExitMethodLog();
}
/**
* 发送业务性能信息
*
*/
private void sendPerformanceData()
{
logger.recordEnterMethodLog();
if (null == performance)
{
// 根据performance从spring中获取性能对象
performance = (Performance) ContextRegistry.getContextHolder().getBean("performance");
if (null != performance)
{
// 获取框槽号需要等系统参数刷新之后,所以需要在此处赋值。
performance.setPortalServerId(CommonProcess.getSubRackNumber()
+ "-" + CommonProcess.getSlotNumber() + "-"
+ CommonProcess.getProcessID());
}
}
if (null == dataCollectPerformance)
{
dataCollectPerformance = new DataCollect(PortalCommonConst.PERFORMANCE_MSG_ID, performance);
}
if (null != performance)
{
int result = ErrorCodeDecode.SUCCESS;
long lonTIme = 0;
Timestamp ts = null;
// 向服务端发送统计到的话筒数据,发送失败重试,重试三次,
// 如果三次重试都失败,继续统计,不初始化统计数据,下个发送周期再发送。
for (int i = 0; i < RETRYTIME; i++)
{
// 设置业务性能记录时间为系统当前时间
lonTIme = CommonProcess.getCurTimeByZone();
ts = new Timestamp(lonTIme);
performance.setPerformanceDateTime(ts);
dataCollectPerformance.setObject(performance);
// 客户端发送信息
result = dataCollectClient.sendMessage(dataCollectPerformance);
if (ErrorCodeDecode.SUCCESS == result)
{
performance.init();
break;
}
}
}
else
{
logger.recordErrorsLog("Performance is empty");
}
logger.recordExitMethodLog();
}
/**
* 发送系统性能信息
*
*/
private void sendSystemPerformanceData()
{
logger.recordEnterMethodLog();
if (null == systemPerformance)
{
// 根据sysPerformance从spring中获取系统性能对象
systemPerformance = (SystemPerformance) ContextRegistry.getContextHolder().getBean("systemPerformance");
}
//为发送的系统性能对象赋值
systemPerformance.getAvgSystemPerform(sendSystemPerformance);
if (null == dataCollectSystemPerformance)
{
dataCollectSystemPerformance = new DataCollect(PortalCommonConst.SYSTEM_PERFORMANCE_MSG_ID,
sendSystemPerformance);
}
if (sendSystemPerformance.checkData())
{
int resultPerformance = ErrorCodeDecode.SUCCESS;
long lonTIme = 0;
Timestamp ts = null;
// 向服务端发送统计到的话筒数据,发送失败重试,重试三次,
// 如果三次重试都失败,继续统计,不初始化统计数据,下个发送周期再发送。
for (int i = 0; i < RETRYTIME; i++)
{
lonTIme = CommonProcess.getCurTimeByZone();
ts = new Timestamp(lonTIme);
logger.recordDebugLog("Long current time is " + lonTIme);
logger.recordDebugLog("Current time is " + ts);
sendSystemPerformance.setSystemPerformanceDateTime(ts);
dataCollectSystemPerformance.setObject(sendSystemPerformance);
// 客户端发送信息
resultPerformance = dataCollectClient.sendMessage(dataCollectSystemPerformance);
if (ErrorCodeDecode.SUCCESS == resultPerformance)
{
systemPerformance.init();
break;
}
}
}
else
{
logger.recordErrorsLog("systemPerformance is empty");
}
logger.recordExitMethodLog();
}
}
{
/**
* 调测日志记录器。
*/
private static Logger logger = Logger.getLogger(PerformanceTask.class);
/**
* 发送失败重试
*/
private static final int RETRYTIME = 3;
/**
* PortalStartProcessID
*/
private static final int PORTALSTARTPROCESSID = 300;
/**
* PortalEndProcessID
*/
private static final int PORTALENDPROCESSID = 600;
/**
* 性能统计类-业务性能
*/
private Performance performance = null;
/**
* 性能统计类-系统性能
*/
private SystemPerformance systemPerformance = null;
/**
* 数据汇集客户端
*/
private DataCollectClient dataCollectClient = null;
/**
* 数据汇集的JavaBean-业务性能汇聚
*/
private DataCollect dataCollectPerformance = null;
/**
* 数据汇集的JavaBean-系统性能汇聚
*/
private DataCollect dataCollectSystemPerformance = null;
/**
* 系统话筒发送对象
*/
private SystemPerformance sendSystemPerformance = new SystemPerformance();
/**
* 话筒客户端发送数据函数。 如果三次都失败,则继续统计,
* 不初始化统计数据。下个发送周期在发送
*
*/
public void sendMessageOnTime()
{
logger.recordEnterMethodLog();
if (null == dataCollectClient)
{
dataCollectClient = new DataCollectClientImpl();
}
//发送业务性能数据方法
sendPerformanceData();
if ((CommonProcess.getProcessID() < PORTALENDPROCESSID)
&& (CommonProcess.getProcessID() > PORTALSTARTPROCESSID))
{
sendSystemPerformanceData();
}
logger.recordExitMethodLog();
}
/**
* 发送业务性能信息
*
*/
private void sendPerformanceData()
{
logger.recordEnterMethodLog();
if (null == performance)
{
// 根据performance从spring中获取性能对象
performance = (Performance) ContextRegistry.getContextHolder().getBean("performance");
if (null != performance)
{
// 获取框槽号需要等系统参数刷新之后,所以需要在此处赋值。
performance.setPortalServerId(CommonProcess.getSubRackNumber()
+ "-" + CommonProcess.getSlotNumber() + "-"
+ CommonProcess.getProcessID());
}
}
if (null == dataCollectPerformance)
{
dataCollectPerformance = new DataCollect(PortalCommonConst.PERFORMANCE_MSG_ID, performance);
}
if (null != performance)
{
int result = ErrorCodeDecode.SUCCESS;
long lonTIme = 0;
Timestamp ts = null;
// 向服务端发送统计到的话筒数据,发送失败重试,重试三次,
// 如果三次重试都失败,继续统计,不初始化统计数据,下个发送周期再发送。
for (int i = 0; i < RETRYTIME; i++)
{
// 设置业务性能记录时间为系统当前时间
lonTIme = CommonProcess.getCurTimeByZone();
ts = new Timestamp(lonTIme);
performance.setPerformanceDateTime(ts);
dataCollectPerformance.setObject(performance);
// 客户端发送信息
result = dataCollectClient.sendMessage(dataCollectPerformance);
if (ErrorCodeDecode.SUCCESS == result)
{
performance.init();
break;
}
}
}
else
{
logger.recordErrorsLog("Performance is empty");
}
logger.recordExitMethodLog();
}
/**
* 发送系统性能信息
*
*/
private void sendSystemPerformanceData()
{
logger.recordEnterMethodLog();
if (null == systemPerformance)
{
// 根据sysPerformance从spring中获取系统性能对象
systemPerformance = (SystemPerformance) ContextRegistry.getContextHolder().getBean("systemPerformance");
}
//为发送的系统性能对象赋值
systemPerformance.getAvgSystemPerform(sendSystemPerformance);
if (null == dataCollectSystemPerformance)
{
dataCollectSystemPerformance = new DataCollect(PortalCommonConst.SYSTEM_PERFORMANCE_MSG_ID,
sendSystemPerformance);
}
if (sendSystemPerformance.checkData())
{
int resultPerformance = ErrorCodeDecode.SUCCESS;
long lonTIme = 0;
Timestamp ts = null;
// 向服务端发送统计到的话筒数据,发送失败重试,重试三次,
// 如果三次重试都失败,继续统计,不初始化统计数据,下个发送周期再发送。
for (int i = 0; i < RETRYTIME; i++)
{
lonTIme = CommonProcess.getCurTimeByZone();
ts = new Timestamp(lonTIme);
logger.recordDebugLog("Long current time is " + lonTIme);
logger.recordDebugLog("Current time is " + ts);
sendSystemPerformance.setSystemPerformanceDateTime(ts);
dataCollectSystemPerformance.setObject(sendSystemPerformance);
// 客户端发送信息
resultPerformance = dataCollectClient.sendMessage(dataCollectSystemPerformance);
if (ErrorCodeDecode.SUCCESS == resultPerformance)
{
systemPerformance.init();
break;
}
}
}
else
{
logger.recordErrorsLog("systemPerformance is empty");
}
logger.recordExitMethodLog();
}
}