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

import org.apache.commons.lang3.StringUtils;

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

/**
 * The Class JmsFileStoreAgent.
 * <ul>
 * <li>1. Function :</li>
 * <li>2. Summary :</li>
 * <li>3. Notification :</li>
 * </ul>
 * 
 * @author  : $Author: 
 * @version : $Revision: 1.4 $
 */
public class JmsFileStoreAgent extends AbstractScheduledAgent {

    /** The host status service. */
    private HostStatusService hostStatusService;

    /** The rms properties. */
    private RmsProperties rmsProperties;

    /* (non-Javadoc)
     * @see java.lang.Runnable#run()
     */
    public void run() {
	        try {String osName = System.getProperty("os.name", "");
	    	if(StringUtils.contains(osName.toLowerCase(), "win")) {
	    		logger.debug("OS "+osName+ " is skip to check status");
	    		return;
	    	}
            EAIEngineStatusVo vo = (EAIEngineStatusVo) applicationContext.getBean("eaiEngineStatusVo");

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

            int percentage = hostStatusService.getDiskPercentage(path);

            vo.setJmsFileStoreUseAge(percentage);
        } catch (Exception e) {
            logger.warn(e.getMessage());
        }
    }

    /**
     * Sets the host status service.
     * 
     * @param hostStatusService the new host status service
     */
    public void setHostStatusService(HostStatusService hostStatusService) {
        this.hostStatusService = hostStatusService;
    }

    /**
     * Sets the rms properties.
     * 
     * @param rmsProperties the new rms properties
     */
    public void setRmsProperties(RmsProperties rmsProperties) {
        this.rmsProperties = rmsProperties;
    }

}
