package com.eactive.eai.rms.client.agent;

import org.apache.commons.lang3.StringUtils;

import com.eactive.eai.rms.client.SocketClient;
import com.eactive.eai.rms.client.context.RmsProperties;
import com.eactive.eai.rms.client.service.EaiEngineStatusService;
import com.eactive.eai.rms.client.service.HostStatusService;
import com.eactive.eai.rms.onl.vo.EAIEngineStatusVo;

/**
 * The Class EaiEngineStatusAgent.
 * <ul>
 * <li>1. Function : Eai Engine의 상태정보를 수집 하는 agent</li>
 * <li>2. Summary :</li>
 * <li>3. Notification :</li>
 * </ul>
 * 
 * @author  : $Author: 박기섭 $
 * @version : $Revision: 1.2 $
 */
public class EaiEngineStatusAgent extends AbstractScheduledAgent {

    private EaiEngineStatusService eaiEngineSingleStatusService;
    private SocketClient socketClient;
    private HostStatusService hostStatusService;
    private RmsProperties rmsProperties;

    /* (non-Javadoc)
     * @see java.lang.Runnable#run()
     */
    public void run() {
        try {

            EAIEngineStatusVo vo = eaiEngineSingleStatusService.getEAIEngineStatus();

            String path = rmsProperties.getStringProperty(RmsProperties.JMS_DISK_SPACE_PATH);

            int percentage = hostStatusService.getDiskPercentage(path);

            vo.setJmsFileStoreUseAge(percentage);

            socketClient.send(vo);
            logger.debug("SEND EaiEngineStatusAgent : " + vo );
        } catch (Exception e) {
            logger.error(e.getMessage(),e);
        }
    }

    public void setEaiEngineSingleStatusService(
            EaiEngineStatusService eaiEngineSingleStatusService) {
        this.eaiEngineSingleStatusService = eaiEngineSingleStatusService;
    }

    public void setSocketClient(SocketClient socketClient) {
        this.socketClient = socketClient;
    }

    public void setHostStatusService(HostStatusService hostStatusService) {
        this.hostStatusService = hostStatusService;
    }

    public void setRmsProperties(RmsProperties rmsProperties) {
        this.rmsProperties = rmsProperties;
    }

}
