#34 Expose a webservice to register jmx-servers

1.5 Release
open
nobody
None
5
2005-11-22
2005-09-09
ftardif
No

In the context of a framework with many applications to
manage, it would be nice to have a webservice (RMI by
example) in the JManage server that expose methods to
add an application remotely in it instead of doing it
manually.

Discussion

  • Rakesh Kalra

    Rakesh Kalra - 2005-09-18

    Logged In: YES
    user_id=1058292

    Can you please describe the use case which
    will use this feature?

     
  • Rakesh Kalra

    Rakesh Kalra - 2005-09-18
    • assigned_to: nobody --> rkalra
     
  • ftardif

    ftardif - 2005-09-19

    Logged In: YES
    user_id=1342231

    The need of this feature is to avoid the manual insertion of
    an application in the jmanage.

    So, at startup of any application on our framework
    (containing many applications on many platforms/servers), a
    simple "automatic" web service remote call on jmanage (or
    even via jmx if jmanage would expose a mbean with
    appropriate operation) would insert the application in the
    config.xml. Then, the support and administration team could
    always have a well synchornized snapshot of the platform.

     
  • ftardif

    ftardif - 2005-10-05

    Logged In: YES
    user_id=1342231

    I attach a patch that suggest a draft of fix for this issue.

    It register an ssl-rmi connector via a new servlet (must be
    defined in web.xml). It then expose a AppRegisterBean which
    offer methods to add and remove an application in jmanage
    automatically. It also automatically deal with clusters
    depending of the app name.

    The patch is well working for my needs, but it should be
    generalized for broad jmanage uses.

     
  • ftardif

    ftardif - 2005-10-05

    patch

     
  • Nobody/Anonymous

    Logged In: NO

    little enhancements:

    package com.bell.cts.jmx.jmanage;

    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.Map;
    import java.util.logging.Level;
    import java.util.logging.Logger;

    import org.jmanage.core.config.ApplicationClusterConfig;
    import org.jmanage.core.config.ApplicationConfig;
    import org.jmanage.core.config.ApplicationConfigFactory;
    import org.jmanage.core.config.ApplicationConfigManager;

    public class AppRegister implements AppRegisterMBean{
    private static final String CLASS_NAME =
    AppRegister.class.getName();
    private static final String PACKAGE_NAME =
    CLASS_NAME.substring(0, CLASS_NAME.lastIndexOf("."));
    private static final String CLUSTER_NAME = "cluster-name";

    private static Logger sLogger =
    Logger.getLogger(PACKAGE_NAME);

    public void register(String pClusterName,
    String pInstanceName,
    String pUrl,
    String pUser,
    String pPassword)
    {
    String lAppId = ApplicationConfig.getNextApplicationId();
    Map lParams = new HashMap();
    lParams.put(CLUSTER_NAME, pClusterName);
    ApplicationConfig lNewAppConfig =
    ApplicationConfigFactory.create(lAppId,

    pInstanceName,

    "jsr160",

    null,

    null,

    pUrl,

    pUser,

    pPassword,

    lParams);

    if
    (ApplicationConfigManager.getApplicationConfigByName(pInstanceName)
    == null) {
    ApplicationConfigManager.addApplication(lNewAppConfig);
    sLogger.log(Level.INFO, pInstanceName + " has been
    registered");
    }

    ApplicationConfig lPossibleCluster;
    lPossibleCluster =
    ApplicationConfigManager.getApplicationConfigByName(pClusterName);

    if (lPossibleCluster != null &&
    lPossibleCluster.isCluster()) {
    ApplicationClusterConfig lCluster =
    (ApplicationClusterConfig)lPossibleCluster;
    ApplicationConfigManager.deleteApplication(lNewAppConfig);
    lNewAppConfig.setClusterConfig(lCluster);
    lCluster.addApplication(lNewAppConfig);
    sLogger.log(Level.INFO, pInstanceName + " is added to
    the cluster " + pClusterName);
    } else {
    //Verify if an other app exist so a cluster would be
    needed
    for (Object lItem :
    ApplicationConfigManager.getApplications()) {
    ApplicationConfig lOtherAppConfig =
    (ApplicationConfig)lItem;
    if (!lOtherAppConfig.isCluster()
    && !lOtherAppConfig.getName().equals(pInstanceName)
    &&
    pClusterName.equals((String)lOtherAppConfig.getParamValues().get(CLUSTER_NAME)))

    {
    String lClusterId =
    ApplicationClusterConfig.getNextApplicationId();
    ApplicationClusterConfig lCluster;
    lCluster = new
    ApplicationClusterConfig(lClusterId, pClusterName);
    sLogger.log(Level.INFO, "New Cluster created : " +
    pClusterName);

    ApplicationConfigManager.deleteApplication(lNewAppConfig);
    lNewAppConfig.setClusterConfig(lCluster);
    lCluster.addApplication(lNewAppConfig);
    sLogger.log(Level.INFO,
    lNewAppConfig.getName() + " is added
    to the cluster " + pClusterName);

    ApplicationConfigManager.deleteApplication(lOtherAppConfig);
    lOtherAppConfig.setClusterConfig(lCluster);
    lCluster.addApplication(lOtherAppConfig);
    sLogger.log(Level.INFO,
    lOtherAppConfig.getName() + " is added
    to the cluster " + pClusterName);

    ApplicationConfigManager.addApplication(lCluster);

    }
    }
    }
    }

    public void unRegister(String pClusterName,
    String pInstanceName,
    String pUrl,
    String pUser,
    String pPassword)
    {
    ApplicationConfig lConfig =
    ApplicationConfigManager.getApplicationConfigByName(pInstanceName);
    if (lConfig!=null) {

    ApplicationConfigManager.deleteApplication(lConfig.getApplicationId());
    sLogger.log(Level.INFO, pInstanceName + " has been
    unregistered");
    }

    ApplicationConfig lPossibleCluster;
    lPossibleCluster =
    ApplicationConfigManager.getApplicationConfigByName(pClusterName);
    if (lPossibleCluster != null
    && lPossibleCluster.isCluster()
    && lPossibleCluster.getApplications().size() == 0)
    {

    ApplicationConfigManager.deleteApplication(lPossibleCluster);
    }
    }

    }

     
  • Rakesh Kalra

    Rakesh Kalra - 2005-10-26
    • milestone: --> 536160
     
  • Rakesh Kalra

    Rakesh Kalra - 2005-10-26
    • assigned_to: rkalra --> nobody
     
  • Rakesh Kalra

    Rakesh Kalra - 2005-11-22

    Logged In: YES
    user_id=1058292

    Moved to 1.5 release.

     
  • Rakesh Kalra

    Rakesh Kalra - 2005-11-22
    • milestone: 536160 --> 1.5 Release
     
  • Nobody/Anonymous

    Logged In: NO

    Alternatively, it may be worthwhile to consider integrating jManage with one of the discovery mechanisms suggested in the JMX specification. For example, provide a mechanism for jManage to discover applications via Service Location Protocol (SLP), Jini, or via an LDAP query.

     

Log in to post a comment.