/**
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 2006-2007 Bull S.A.S.
 * Contact: jonas-team@ow2.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or 1any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
 */
package org.ow2.jonas.cluster.daemon;

import java.util.ArrayList;
import java.util.Hashtable;
/**
 * Defines the MBean interface. Don't use Models MBeans as it will imply some
 * external libraries like commons-modeler (easier).
 * @author Benoit Pelletier
 */
/**
 * @author eyindanga
 *
 */
public interface ClusterDaemonMBean {



    /**
     * @return Object Name
     */
    String getobjectName();

    /**
     * Sets the object name of this mbean
     * @param name the Object Name
     */
    void setobjectName(String name);

    /**
     * @return true if it is an event provider
     */
    boolean iseventProvider();

    /**
     * @return true if this managed object implements J2EE State Management Model
     */
    boolean isstateManageable();

    /**
     * @return true if this managed object implements the J2EE StatisticProvider Model
     */
    boolean isstatisticsProvider();
    /**
     * @return
     */
    public ArrayList serversNames();

    /**
     * @return cluster daemon controlled server names.
     */
    public ArrayList getControlledServersNames();
    /**
     * @return the JAVA_HOME for a specified server name
     * @param name JOnAS instance name
     */
    String getJavaHome4Server(String name);

    /**
     * @return the JONAS_ROOT for a specified server name
     * @param name JOnAS instance name
     */
    String getJonasRoot4Server(String name);

    /**
     * @return the JONAS_BASE for a specified server name
     * @param name JOnAS instance name
     */
    String getJonasBase4Server(String name);

    /**
     * @return the user command for a specified server name
     * @param name JOnAS instance name
     */
    String getJonasCmd4Server(String name);

    /**
     * @return xprm for a specified server name
     * @param name JOnAS instance name
     */
    String getXprm4Server(String name);

    /**
     * @return autoBoot value for a specified server name
     * @param name JOnAS instance name
     */
    String getAutoBoot4Server(String name);

    /**
     * Reload the configuration
     * @throws ClusterDaemonException if an error occurs
     */
    void reloadConfiguration() throws ClusterDaemonException;

    /**
     * Add a server configuration
     * @param name server name
     * @param description server description
     * @param javaHome JAVA_HOME dir
     * @param jonasBase JONAS_BASE dir
     * @param jonasRoot JONAS_ROOT dir
     * @param xprm extra JVM parameters
     * @param autoBoot automatic start
     * @param jonasCmd user command
     * @throws ClusterDaemonException if an error occurs
     */
    @SuppressWarnings("unchecked")
    void addServer(String name, String description, String javaHome, String jonasRoot, String jonasBase, String xprm, String autoBoot, String jonasCmd, String saveIt) throws ClusterDaemonException;

    /**
     * Modify a server configuration
     * @param name server name
     * @param description server description
     * @param javaHome JAVA_HOME dir
     * @param jonasBase JONAS_BASE dir
     * @param jonasRoot JONAS_ROOT dir
     * @param xprm extra JVM parameters
     * @param autoBoot automatic start
     * @param jonasCmd user command
     * @throws ClusterDaemonException if an error occurs
     */
    void modifyServer(String name, String description, String javaHome, String jonasRoot, String jonasBase, String xprm, String autoBoot, String jonasCmd) throws ClusterDaemonException;

    /**
     * Remove this server from cluster daemon control.
     * @param serverName the server to remove
     * @param saveIt if true then flush clusterd configuration
     */
    public void removeServer(String serverName, String saveIt);

    /**
     * Start a JOnAS instance
     * @param name instance name
     * @param domainName domain name
     * @param prm extra parameters
     * @throws ClusterDaemonException if an error occurs
     */
    void startJOnAS(String name, String domainName, String prm) throws ClusterDaemonException;

    /**
     * Stop a JOnAS instance
     * @param name instance name
     * @throws ClusterDaemonException if an error occurs
     */
    void stopJOnAS(String name) throws ClusterDaemonException;

    /**
     * Ping a JOnAS instance (MBean interface)
     * @param name instance name
     * @return exit code of the ping (0 ok, 1 ko)
     * @throws ClusterDaemonException if an error occurs
     */
    int pingJOnAS(String name) throws ClusterDaemonException;

    /**
     * Start all the JOnAS instances configured with auto-reboot
     * @param domainName domain name
     * @param prm extra parameters
     * @return the nodes list with an indicator started/starting failed
     */
    String startAllJOnAS(String domainName, String prm);

    /**
     * Stop all the JOnAS instances
     * @return the nodes list with an indicator stopped/stopping failed
     */
    String stopAllJOnAS();

    /**
     * Stop the cluster daemon instance
     */
    void stopClusterDaemon();
    /**
     * @return clusterd jmx url
     */
    String getJmxUrl();
    /**
     *
     * @return Operating system processors number
     */
    public String getOperatingSystemAvailableProcessors();
    /**
     *
     * @return OS name
     */
    public String getOperatingSystemName();
    /**
     *
     * @return Os architecture
     */
    public String getOperatingSystemArch();
    /**
     *
     * @return OS version
     */
    public String getOperatingSystemVersion();
    /**
     *
     * @return Spec vendor
     */
    public String getRunTimeSpecVendor();
    /**
     *
     * @return Spec version
     */
    public String getRunTimeSpecVersion();
    /**
     *
     * @return the Vm name
     */
    public String getRunTimeVmName();
    /**
     *
     * @return Vm vendor
     */
    public String getRunTimeVmVendor();
    /**
     *
     * @return Vm version
     */
    public String getRunTimeVmVersion();
    /**
     * @return hashtable with dynamic attributes keys and values.
     */
    public Hashtable<String, String> getDynamicHostAttributes();
    /**
     *retrieve the state of the given controlled server
     * @param srvName
     * @return true if the server is running
     */
    public boolean checkServerState(String srvName);

    /**
     * Getting remote Vm used Memory
     * @return the value of current used memory
     * @throws ClusterDaemonException
     */

    public String vmCurrentUsedMemory() throws ClusterDaemonException;

    /**
     * Getting remote Vm Total Memory
     * @return the value of  Vm Total memory
     * @throws ClusterDaemonException
     */
    public String vmTotalMemory() throws ClusterDaemonException;

    /**
     * Getting remote Vm's Current used Heap memory
     * @return the value of Vm's Current used Heap memory
     * @throws ClusterDaemonException
     */
    public String vmCurrentUsedHeapMemory() throws ClusterDaemonException;

    /**
     * Getting remote Vm's Current used non Heap memory
     * @return the value of Vm's Current used non Heap memory
     * @throws ClusterDaemonException
     */
    public String getVmCurrentUsedNonHeapMemory() throws ClusterDaemonException;

    /**
     * Getting Operating system Current used space
     * @return the value of Operating system Current used space
     * @throws Exception
     */
    public String osCurrentUsedSpace() throws Exception;

    /**
     * Getting Operating system Current used space
     * @return the value of Operating system Total space
     * @throws ClusterDaemonException
     */
    public String osTotalSpace() throws ClusterDaemonException ;



}
