/** * Set the MBean name, that may be unknown when constructor is called. * @param name its name. * @return the MBean ObjectName * @throws JMException could not create MBean instance */ public ObjectName setName(final String name) throws JMException { this.name = name; objectName = JonasObjectName.cluster(domainName, name, getType()); return objectName; }
/** * Register a cluster daemon proxy in the domain. * @param cdName the cluster daemon's name * @param serverName name of the current jonas server (master instance) * @param urls connection urls for the cluster daemon * @throws MalformedObjectNameException can't create ObjectName for the * ClusterDaemon's MBean */ @SuppressWarnings( {"unchecked", "unchecked"}) public void registerClusterDaemonProxy(final String cdName, final String serverName, final Collection urls) throws MalformedObjectNameException { if (!ismaster) { throw new RuntimeException("This is not the master."); } // this cluster daemon is not registered // give a name and register mbean ObjectName on = JonasObjectName.clusterDaemonProxy(domainName, cdName); ClusterDaemonProxy cdp = new ClusterDaemonProxy(this, cdName, urls); cdp.setObjectName(on.toString()); if (clusterDaemons.get(cdName) != null) { // the clusterd is already registered. // remove it first clusterDaemons.remove(cdName); } clusterDaemons.put(cdName, cdp); }
/** * Gives the JMX connection Url used in the domain to connect to a remote server. * @param remoteServerName name of the remote server * @param domainName domain name * @param serverName local server name * @return the JMX connection Url used in the domain to connect to a remote server * @throws MalformedObjectNameException */ public static String getConnectionUrl(final String remoteServerName, final String domainName, final String serverName) throws MalformedObjectNameException { ObjectName on = JonasObjectName.serverProxy(domainName, remoteServerName); return (String) JonasManagementRepr.getAttribute(on, "ConnectionUrl", serverName); } }
ObjectName on = JonasObjectName.clusterDaemonProxy(domainName, cdname); cdp.setObjectName(on.toString()); ObjectName on = JonasObjectName.serverProxy(domainName, svname); sp.setObjectName(on.toString()); sp = new ServerProxy(this, svname, loc.getUrlList(), cdp); ObjectName on = JonasObjectName.serverProxy(domainName, svname); sp.setObjectName(on.toString());
ObjectName on = JonasObjectName.serverProxy(domainName, svname); proxy.setObjectName(on.toString()); ObjectName on = JonasObjectName.clusterMember(domainName, svname, getType(), name); member.setObjectName(on); MBeanServer mbeanServer = jmx.getJmxServer();
/** * Object name of archive configuration. * @param domainName The domain name * @param serverName The server name * @return ObjectName corresponding to the archive configuration */ public static ObjectName getArchiveConfigObjectName(final String domainName, final String serverName) { ObjectName onUtils = JonasObjectName.ArchiveConfig(domainName); return getFirstMbean(onUtils, serverName); } /**
/** * Object name of rar configuration. * @param domainName The domain name * @param serverName The server name * @return Corresponding ObjectName */ public static ObjectName getRarConfigObjectName(final String domainName, final String serverName) { ObjectName onUtils = JonasObjectName.RarConfig(domainName); return getFirstMbean(onUtils, serverName); }
/** * Return the SubType of a Security Factory in the current server. * @param p_NameFactory The factory name to find * @return The SubType or null if not found * @throws ManagementException any. * @throws MalformedObjectNameException if the objectName is malformed */ public static String findSecurityFactorySubType(final String p_NameFactory, final String domainName, final String serverName) throws MalformedObjectNameException { String sName; String sSubType = null; ObjectName on = null; Iterator itNames = getListMBeanName(JonasObjectName.allSecurityFactories(domainName), serverName).iterator(); while (itNames.hasNext()) { on = new ObjectName(itNames.next().toString()); sName = on.getKeyProperty("name"); if (p_NameFactory.equals(sName) == true) { sSubType = on.getKeyProperty("subtype"); break; } } return sSubType; }
/** * Return the list of Security Ldap Factories in the current server. * @return The list of Security Ldap Factories * @throws MalformedObjectNameException any. */ public static ArrayList getSecurityLdapFactories(final String domainName, final String serverName) throws MalformedObjectNameException { String sName; ArrayList<String> al = new ArrayList<String>(); Iterator itNames = getListMBeanName(JonasObjectName.allSecurityLdapFactories(domainName), serverName).iterator(); while (itNames.hasNext()) { sName = extractValueMbeanName(",name", itNames.next().toString()); if (sName != null) { al.add(sName); } } Collections.sort(al); return al; }
/** * Return the list of Security Datasource Factories in the current server. * @return The list of Security Datasource Factories * @throws MalformedObjectNameException any. */ public static ArrayList getSecurityDatasourceFactories(final String domainName, final String serverName) throws MalformedObjectNameException { String sName; ArrayList<String> al = new ArrayList<String>(); Iterator itNames = getListMBeanName(JonasObjectName.allSecurityDatasourceFactories(domainName), serverName). iterator(); while (itNames.hasNext()) { sName = extractValueMbeanName(",name", itNames.next().toString()); if (sName != null) { al.add(sName); } } Collections.sort(al); return al; }
/** * Return the list of all roles in a resource. * @param domainName the domain name * @param p_Resource The resource * @return The list of roles * @throws ManagementException any. * @throws MalformedObjectNameException if the objectName is malformed */ public static ArrayList getRoles(final String domainName, final String p_Resource, final String serverName) throws ManagementException, MalformedObjectNameException { String sName; ArrayList<String> al = new ArrayList<String>(); Iterator itNames = getListMBeanName(JonasObjectName.allRoles(domainName, p_Resource), serverName).iterator(); while (itNames.hasNext()) { sName = extractValueMbeanName(",name", itNames.next().toString()); if (sName != null) { al.add(sName); } } Collections.sort(al); return al; }
/** * Return the list of all groups in a resource. * @param domainName the domain name * @param p_Resource The resource * @return The list of groups * @throws ManagementException any. * @throws MalformedObjectNameException if the objectName is malformed */ public static ArrayList getGroups(final String domainName, final String p_Resource, final String serverName) throws ManagementException, MalformedObjectNameException { String sName; ArrayList<String> al = new ArrayList<String>(); Iterator itNames = getListMBeanName(JonasObjectName.allGroups(domainName, p_Resource), serverName).iterator(); while (itNames.hasNext()) { sName = extractValueMbeanName(",name", itNames.next().toString()); if (sName != null) { al.add(sName); } } Collections.sort(al); return al; }
/** * @param clusterName * @return the protocol used */ public String getProtocol(final String clusterName) { String domainName = getDomainName(); ObjectName on = null; try { on = JonasObjectName.cluster(domainName, clusterName, "CmiCluster"); } catch (Exception e) { logger.error("Error in getProtocol", e); return null; } return getStringAttribute(on, "Protocol"); }
/** * Start the server. * @param serverName the name of the server to start * @param standby <code>true</code> to enter standby mode. */ public void startServer(final String serverName, final boolean standby) { String currentServerName = getServerName(); String domainName = getDomainName(); ObjectName on = null; try { on = JonasObjectName.serverProxy(domainName, serverName); } catch (MalformedObjectNameException e) { logger.log(BasicLevel.ERROR, "bad objectName: " + e); return; } String opName = "start"; Object[] pstandby = {standby}; String[] signature = {boolean.class.toString()}; JonasManagementRepr.invoke(on, opName, pstandby, signature, currentServerName); }
/** * Get the ClusterDaemonProxy MBean ObjectName for a given cluster daemon. * @param clusterdaemonName the name of the cluster daemon * @return ClusterDaemonProxy MBean ObjectName */ private ObjectName getClusterdaemonOn(final String clusterdaemonName) { String domain = getDomainName(); ObjectName clusterdaemonOn = null; try { clusterdaemonOn = JonasObjectName.clusterDaemonProxy(domain, clusterdaemonName); } catch (MalformedObjectNameException e) { // TODO Auto-generated catch block e.printStackTrace(); } return clusterdaemonOn; }
/** * @param clusterName * @return the delay used by clients to update their cluster view */ public int getDelayToRefresh(final String clusterName) { String domainName = getDomainName(); ObjectName on = null; try { on = JonasObjectName.cluster(domainName, clusterName, "CmiCluster"); } catch (Exception e) { logger.error("Error in getDelayToRefresh", e); return -1; } return getIntegerAttribute(on, "DelayToRefresh"); } }
/** * Stop the server. * @param serverName the name of the server to stop * @param standby <code>true</code> to enter standby mode. */ public void stopServer(final String serverName, final boolean standby) { String currentServerName = getServerName(); String domainName = getDomainName(); ObjectName on = null; try { on = JonasObjectName.serverProxy(domainName, serverName); } catch (MalformedObjectNameException e) { logger.log(BasicLevel.ERROR, "bad objectName: " + e); return; } String opName = "stop"; Object[] pstandby = {standby}; String[] signature = {boolean.class.toString()}; JonasManagementRepr.invoke(on, opName, pstandby, signature, currentServerName); }
on = JonasObjectName.clusterDaemonProxy(domainName, clusterdName); cdp.setObjectName(on.toString()); clusterDaemons.put(clusterdName, cdp);
on = JonasObjectName.cluster(domainName, domainName, clusterType); } catch (MalformedObjectNameException e) {
on = JonasObjectName.serverProxy(domainName, jonasServerName); sp.setObjectName(on.toString()); } catch (MalformedObjectNameException e) {