| Method from org.jboss.ha.framework.server.HAManagementService Detail: |
public Object _createMBean(String pClass,
ObjectName pName,
Object[] pParameters,
String[] pSignature) {
Object lReturn = null;
try {
log.info( "_createMBean(), name: " + pName );
lReturn = server.createMBean( pClass, pName, pParameters, pSignature );
}
catch( Exception e ) {
// Return the exception instead
lReturn = e;
}
return lReturn;
}
|
public Object _getAttribute(ObjectName pName,
String pAttribute) {
Object lReturn = null;
try {
lReturn = server.getAttribute( pName, pAttribute );
}
catch( Exception e ) {
// Ignore them
}
return lReturn;
}
|
public AttributeList _getAttributes(ObjectName pName,
String[] pAttributes) {
AttributeList lReturn = null;
try {
lReturn = server.getAttributes( pName, pAttributes );
}
catch( Exception e ) {
// Ignore them
}
return lReturn;
}
|
public Object _invoke(ObjectName pName,
String pOperationName,
Object[] pParams,
String[] pSignature) {
Object lReturn = null;
try {
log.info( "_invoke(), name: " + pName + ", operation: " + pOperationName +
", params: " + pParams + ", signature: " + pSignature );
lReturn = server.invoke(
pName,
pOperationName,
pParams,
pSignature
);
}
catch( Exception e ) {
// Return the exception instead
lReturn = e;
}
return lReturn;
}
|
public Object _setAttribute(ObjectName pName,
Attribute pAttribute) {
Object lReturn = null;
try {
log.info( "_setAttribute(), name: " + pName + ", attribute: " + pAttribute );
server.setAttribute( pName, pAttribute );
}
catch( Exception e ) {
// Return the exception instead
lReturn = e;
}
return lReturn;
}
|
public Object _setAttributes(ObjectName pName,
AttributeList pAttributes) {
Object lReturn = null;
try {
log.info( "_setAttributes(), name: " + pName + ", attribute: " + pAttributes );
server.setAttributes( pName, pAttributes );
}
catch( Exception e ) {
// Return the exception instead
lReturn = e;
}
return lReturn;
}
|
public Object _unregisterMBean(ObjectName pName) {
Object lReturn = null;
try {
log.info( "_unregisterMBean(), name: " + pName );
server.unregisterMBean( pName );
}
catch( Exception e ) {
// Return the exception instead
lReturn = e;
}
return lReturn;
}
|
public void addNotificationListener(ObjectName pBroadcaster,
ObjectName pListener,
NotificationFilter pFilter,
Object pHandback) throws InstanceNotFoundException, RemoteException {
server.addNotificationListener( pBroadcaster, pListener, pFilter, pHandback );
}
|
public ObjectInstance createMBean(String pClass,
ObjectName pName,
Object[] pParameters,
String[] pSignature) throws MBeanRegistrationException, InstanceAlreadyExistsException, NotCompliantMBeanException, ReflectionException, MBeanException, RemoteException {
List lValues = null;
Object[] lArguments = new Object[] {
pClass,
pName,
pParameters,
pSignature
};
try {
log.info( "call _createMBean()" );
lValues = mPartition.callMethodOnCluster(
SERVICE_NAME,
"_createMBean",
lArguments,
false
);
}
catch( Exception e ) {
//AS ToDo: must be checked later how to go ahead here
throw new RemoteException( "Could not create a MBean on the cluster", e );
}
Iterator i = lValues.iterator();
ObjectInstance lInstance = null;
Throwable lException = null;
while( i.hasNext() ) {
Object lValue = i.next();
if( lValue instanceof ObjectInstance ) {
if( lInstance == null ) {
lInstance = (ObjectInstance) lValue;
}
} else
if( lValue instanceof Throwable ) {
if( lException == null ) {
lException = (Throwable) lValue;
}
}
}
if( lException != null ) {
if( lInstance != null ) {
// Remove all existing MBeans
try {
unregisterMBean( lInstance.getObjectName() );
}
catch( Exception e ) {
// Ignore any exception
}
}
if( lException instanceof InstanceAlreadyExistsException ) {
throw (InstanceAlreadyExistsException) lException;
}
if( lException instanceof MBeanException ) {
throw (MBeanException) lException;
}
if( lException instanceof MBeanRegistrationException ) {
throw (MBeanRegistrationException) lException;
}
if( lException instanceof NotCompliantMBeanException ) {
throw (NotCompliantMBeanException) lException;
}
if( lException instanceof ReflectionException ) {
throw (ReflectionException) lException;
}
throw new RemoteException( lException.toString() );
}
return lInstance;
}
|
protected void createService() throws Exception {
}
Looks up the Server Config instance to figure out the
temp-directory and the farm-deploy-directory |
public Object getAttribute(ObjectName pName,
String pAttribute) throws InstanceNotFoundException, ReflectionException, AttributeNotFoundException, MBeanException, RemoteException {
// First we try to get the attribute from the local node
// and if not found the look for an instance out in the
// node. This does not apply for JVMs.
//AS ToDo: JVMs are not supported yet
Object lReturn = null;
try {
lReturn = server.getAttribute( pName, pAttribute );
}
catch( InstanceNotFoundException infe ) {
// Ignore and search on the cluster
Object[] lArguments = new Object[] {
pName,
pAttribute
};
List lValues = null;
try {
lValues = mPartition.callMethodOnCluster(
SERVICE_NAME,
"_getAttribute",
lArguments,
false
);
}
catch( Exception e ) {
throw new RemoteException( "Could not get management attributes on the cluster", e );
}
Iterator i = lValues.iterator();
while( i.hasNext() ) {
Object lValue = i.next();
if( lValue != null ) {
lReturn = lValue;
break;
}
}
if( lReturn == null ) {
// Throw the instance not found exception because there is none
throw infe;
}
}
return lReturn;
}
|
public AttributeList getAttributes(ObjectName pName,
String[] pAttributes) throws InstanceNotFoundException, ReflectionException, RemoteException {
// First we try to get the attribute from the local node
// and if not found the look for an instance out in the
// node. This does not apply for JVMs.
//AS ToDo: JVMs are not supported yet
//AS ToDo: Now only the first list is taken, shall we add a merge capabilities ?
AttributeList lReturn = null;
try {
lReturn = server.getAttributes( pName, pAttributes );
}
catch( InstanceNotFoundException infe ) {
// Ignore and search on the cluster
Object[] lArguments = new Object[] {
pName,
pAttributes
};
List lValues = null;
try {
lValues = mPartition.callMethodOnCluster(
SERVICE_NAME,
"_getAttributes",
lArguments,
false
);
}
catch( Exception e ) {
throw new RemoteException( "Could not get management attributes on the cluster", e );
}
Iterator i = lValues.iterator();
while( i.hasNext() ) {
Object lValue = i.next();
if( lValue != null ) {
lReturn = (AttributeList) lValue;
break;
}
}
if( lReturn == null ) {
// Throw the instance not found exception because there is none
throw infe;
}
}
return lReturn;
}
|
public String getDefaultDomain() throws RemoteException {
return J2EEManagedObject.getDomainName();
}
|
public ListenerRegistration getListenerRegistry() throws RemoteException {
return null;
/*
return new ListenerRegistration(
(ManagementHome) mContext.getEJBObject().getEJBHome(),
new String[] {}
);
*/
}
|
public Integer getMBeanCount() throws RemoteException {
try {
return new Integer(
queryNames(
new ObjectName( getDefaultDomain() + ":*" ),
null
).size()
);
}
catch( Exception e ) {
}
return new Integer( 0 );
}
|
public MBeanInfo getMBeanInfo(ObjectName pName) throws IntrospectionException, InstanceNotFoundException, ReflectionException, RemoteException {
return server.getMBeanInfo( pName );
}
|
public String getName() {
return "HA Management Service";
}
|
public Object invoke(ObjectName pName,
String pOperationName,
Object[] pParams,
String[] pSignature) throws InstanceNotFoundException, ReflectionException, MBeanException, RemoteException {
Object lReturn = null;
InstanceNotFoundException lException = null;
log.info( "invoke(), name: " + pName + ", operation: " + pOperationName +
", params: " + pParams + ", signature: " + pSignature );
try {
lReturn = server.invoke( pName, pOperationName, pParams, pSignature );
}
catch( InstanceNotFoundException infe ) {
lException = infe;
}
Object[] lArguments = new Object[] {
pName,
pOperationName,
pParams,
pSignature
};
List lValues = null;
try {
log.info( "call _invoke()" );
lValues = mPartition.callMethodOnCluster(
SERVICE_NAME,
"_invoke",
lArguments,
true
);
}
catch( Exception e ) {
throw new RemoteException( "Could not get management attributes on the cluster", e );
}
Iterator i = lValues.iterator();
while( i.hasNext() ) {
Object lValue = i.next();
if( lValue instanceof Throwable ) {
log.debug( "invoke a method on the cluster caused an exception: " + lValue );
if( lValue instanceof InstanceNotFoundException ) {
// Go ahead when INFE is found
continue;
}
}
// A non-INFE is found therefore ignore all the other INFE
lException = null;
if( lValue != null ) {
lReturn = lValue;
break;
}
}
if( lException != null ) {
// Only if all calls throws an INFE it will throw this exception
throw lException;
}
return lReturn;
}
|
public boolean isRegistered(ObjectName pName) throws RemoteException {
return server.isRegistered( pName );
}
|
public void preDeregister() throws Exception {
super.preDeregister();
}
Removes the Notification Listener |
public ObjectName preRegister(MBeanServer pServer,
ObjectName pName) throws Exception {
super.preRegister( pServer, pName );
log.info( "HA Management Service MBean online" );
mHAManagementName = new ObjectName(
OBJECT_NAME + ",Partition=" + mBackgroundPartition
);
return mHAManagementName;
}
Saves the MBeanServer reference, create the Farm Member Name and
add its Notification Listener to listen for Deployment / Undeployment
notifications from the MainDeployer . |
public Set queryNames(ObjectName pName,
QueryExp pQuery) throws RemoteException {
return server.queryNames( pName, pQuery );
}
|
public void removeNotificationListener(ObjectName pBroadcaster,
ObjectName pListener) throws ListenerNotFoundException, InstanceNotFoundException, RemoteException {
server.removeNotificationListener( pBroadcaster, pListener );
}
|
public void setAttribute(ObjectName pName,
Attribute pAttribute) throws InstanceNotFoundException, InvalidAttributeValueException, ReflectionException, AttributeNotFoundException, MBeanException, RemoteException {
InstanceNotFoundException lException = null;
try {
server.setAttribute( pName, pAttribute );
}
catch( InstanceNotFoundException infe ) {
lException = infe; // Remember that instance was not found
}
Object[] lArguments = new Object[] {
pName,
pAttribute
};
List lValues = null;
try {
log.info( "call _setAttribute()" );
lValues = mPartition.callMethodOnCluster(
SERVICE_NAME,
"_setAttribute",
lArguments,
true
);
}
catch( Exception e ) {
throw new RemoteException( "Could not set management attributes on the cluster", e );
}
Iterator i = lValues.iterator();
while( i.hasNext() ) {
Object lValue = i.next();
// If one value is null (because the method does not return a value) then
// everything is fine
if( lValue instanceof Throwable ) {
log.debug( "invoke a method on the cluster caused an exception: " + lValue );
if( lValue instanceof InstanceNotFoundException ) {
if( lException == null ) {
lException = (InstanceNotFoundException) lValue; // Remember this exception
}
} else {
// Only Throwables are returned
if( lValue instanceof AttributeNotFoundException ) {
throw (AttributeNotFoundException) lValue;
}
if( lValue instanceof InvalidAttributeValueException ) {
throw (InvalidAttributeValueException) lValue;
}
if( lValue instanceof MBeanException ) {
throw (MBeanException) lValue;
}
if( lValue instanceof ReflectionException ) {
throw (ReflectionException) lValue;
}
throw new RemoteException( lValue.toString() );
}
}
}
if( lException != null ) {
throw lException; // Now this exception can be thrown because it has low priority
}
}
|
public AttributeList setAttributes(ObjectName pName,
AttributeList pAttributes) throws InstanceNotFoundException, ReflectionException, RemoteException {
Object lReturn = null;
InstanceNotFoundException lException = null;
try {
lReturn = server.setAttributes( pName, pAttributes );
}
catch( InstanceNotFoundException infe ) {
lException = infe;
}
Object[] lArguments = new Object[] {
pName,
pAttributes
};
List lValues = null;
try {
log.info( "call _setAttributes()" );
lValues = mPartition.callMethodOnCluster(
SERVICE_NAME,
"_setAttributes",
lArguments,
true
);
}
catch( Exception e ) {
throw new RemoteException( "Could not set management attributes on the cluster", e );
}
Iterator i = lValues.iterator();
while( i.hasNext() ) {
Object lValue = i.next();
// If one value is null (because the method does not return a value) then
// everything is fine
if( lValue instanceof Throwable ) {
log.debug( "set Attributes on the cluster caused an exception: " + lValue );
if( lValue instanceof InstanceNotFoundException ) {
if( lException == null ) {
lException = (InstanceNotFoundException) lValue; // Remember this exception
}
} else {
if( lValue instanceof ReflectionException ) {
throw (ReflectionException) lValue;
}
throw new RemoteException( lValue.toString() );
}
}
}
if( lException != null ) {
// If no other exception is thrown then the INFE will be thrown here
throw lException;
}
return (AttributeList) lReturn;
}
|
protected void startService() throws Exception {
mClusterPartitionName = new ObjectName( "jboss:service=" + mBackgroundPartition );
log.debug( "registerRPCHandler" );
mPartition = (HAPartition) server.getAttribute(
mClusterPartitionName,
"HAPartition"
);
mPartition.registerRPCHandler( SERVICE_NAME, this );
}
Register itself as RPC-Handler to the HA-Partition
and add the farm deployment directory to the scanner |
protected void stopService() {
}
Remove the farm deployment directory from the scanner |
public void unregisterMBean(ObjectName pName) throws InstanceNotFoundException, MBeanRegistrationException, RemoteException {
List lValues = null;
Object[] lArguments = new Object[] {
pName
};
try {
log.info( "call _unregisterMBean()" );
lValues = mPartition.callMethodOnCluster(
SERVICE_NAME,
"_unregisterMBean",
lArguments,
false
);
}
catch( Exception e ) {
//AS ToDo: must be checked later how to go ahead here
throw new RemoteException( "Could not unregister a MBean on the cluster", e );
}
Iterator i = lValues.iterator();
Throwable lException = null;
while( i.hasNext() ) {
Object lValue = i.next();
if( lValue instanceof Throwable ) {
lException = (Throwable) lValue;
break;
}
}
if( lException != null ) {
if( lException instanceof InstanceNotFoundException ) {
throw (InstanceNotFoundException) lException;
}
if( lException instanceof MBeanRegistrationException ) {
throw (MBeanRegistrationException) lException;
}
throw new RemoteException( lException.toString() );
}
}
|