leif 2002/10/25 08:42:26
Modified: instrument-client/src/java/org/apache/excalibur/instrument/client
InstrumentManagerConnection.java
InstrumentManagerTreeModel.java
Log:
Fix a problem where a client reconnecting to a new server instance was causing
Altrmi errors. This was a client problem. It was attempting to reference objects
that no longer exist in the new server instance.
Revision Changes Path
1.7 +6 -6
jakarta-avalon-excalibur/instrument-client/src/java/org/apache/excalibur/instrument/client/InstrumentManagerConnection.java
Index: InstrumentManagerConnection.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/instrument-client/src/java/org/apache/excalibur/instrument/client/InstrumentManagerConnection.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- InstrumentManagerConnection.java 6 Sep 2002 02:35:17 -0000 1.6
+++ InstrumentManagerConnection.java 25 Oct 2002 15:42:26 -0000 1.7
@@ -93,6 +93,7 @@
m_closed = true;
m_treeModel = new InstrumentManagerTreeModel( this );
+ // Set the logger when the connection logger is set.
addInstrumentManagerConnectionListener( m_treeModel );
setLayout( new BorderLayout() );
@@ -168,6 +169,7 @@
public void enableLogging( Logger logger )
{
m_logger = logger.getChildLogger( "conn_" + m_host + "_" + m_port );
+ m_treeModel.enableLogging( m_logger.getChildLogger( "treeModel" ) );
}
Logger getLogger()
@@ -342,7 +344,7 @@
// Also, take this oportunity to update all of the leased samples in
// the model.
- m_treeModel.updateAllLeasedSamples();
+ m_treeModel.renewAllSampleLeases();
m_lastLeaseRenewalTime = now;
}
@@ -363,14 +365,12 @@
m_altrmiFactory = new ClientClassAltrmiFactory( false );
m_altrmiFactory.setHostContext( altrmiHostContext );
- /*
- System.out.println("Listing Published Objects At Server...");
+ getLogger().debug("Listing Published Altrmi Objects At Server...");
String[] listOfPublishedObjectsOnServer = m_altrmiFactory.list();
for ( int i = 0; i < listOfPublishedObjectsOnServer.length; i++ )
{
- System.out.println( "..[" + i + "]:" + listOfPublishedObjectsOnServer[i] );
+ getLogger().debug( " [" + i + "]:" + listOfPublishedObjectsOnServer[i]
);
}
- */
m_manager = (InstrumentManagerClient)m_altrmiFactory.lookup(
"InstrumentManagerClient" );
1.4 +34 -11
jakarta-avalon-excalibur/instrument-client/src/java/org/apache/excalibur/instrument/client/InstrumentManagerTreeModel.java
Index: InstrumentManagerTreeModel.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/instrument-client/src/java/org/apache/excalibur/instrument/client/InstrumentManagerTreeModel.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- InstrumentManagerTreeModel.java 6 Sep 2002 02:14:09 -0000 1.3
+++ InstrumentManagerTreeModel.java 25 Oct 2002 15:42:26 -0000 1.4
@@ -20,6 +20,8 @@
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+
import org.apache.excalibur.instrument.manager.interfaces.InstrumentableDescriptor;
import org.apache.excalibur.instrument.manager.interfaces.InstrumentDescriptor;
import org.apache.excalibur.instrument.manager.interfaces.InstrumentManagerClient;
@@ -28,6 +30,7 @@
import org.apache.excalibur.altrmi.common.AltrmiInvocationException;
class InstrumentManagerTreeModel
+ extends AbstractLogEnabled
implements InstrumentManagerConnectionListener, TreeModel
{
private final InstrumentManagerConnection m_connection;
@@ -63,7 +66,7 @@
*/
public void opened( InstrumentManagerConnection connection )
{
- //System.out.println("InstrumentManagerTreeModel.opened(" + connection +
")");
+ //getLogger.debug("InstrumentManagerTreeModel.opened(" + connection + ")");
refreshModel();
}
@@ -75,7 +78,7 @@
*/
public void closed( InstrumentManagerConnection connection )
{
- //System.out.println("InstrumentManagerTreeModel.closed(" + connection +
")");
+ //getLogger.debug("InstrumentManagerTreeModel.closed(" + connection + ")");
refreshModel();
}
@@ -86,7 +89,7 @@
*/
public void deleted( InstrumentManagerConnection connection )
{
- //System.out.println("InstrumentManagerTreeModel.deleted(" + connection +
")");
+ //getLogger.debug("InstrumentManagerTreeModel.deleted(" + connection + ")");
refreshModel();
}
@@ -116,7 +119,7 @@
*/
public Object getChild( Object parent, int index )
{
- // System.out.println("InstrumentManagerTreeModel.getChild(" + parent + ",
" + index + ")");
+ //getLogger.debug("InstrumentManagerTreeModel.getChild(" + parent + ", " +
index + ")");
if ( parent instanceof DefaultMutableTreeNode )
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode)parent;
@@ -139,7 +142,7 @@
*/
public int getChildCount( Object parent )
{
- // System.out.println("InstrumentManagerTreeModel.getChildCount(" + parent
+ ")");
+ //getLogger.debug("InstrumentManagerTreeModel.getChildCount(" + parent +
")");
if ( parent instanceof DefaultMutableTreeNode )
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode)parent;
@@ -162,7 +165,7 @@
*/
public boolean isLeaf( Object node )
{
- // System.out.println("InstrumentManagerTreeModel.isLeaf(" + node + ")");
+ //getLogger.debug("InstrumentManagerTreeModel.isLeaf(" + node + ")");
if ( node == m_root )
{
// The root must always return false so that trees that do not
@@ -191,7 +194,7 @@
*/
public void valueForPathChanged( TreePath path, Object newValue )
{
- //System.out.println( "InstrumentManagerTreeModel.valueForPathChanged(" +
path +
+ //getLogger.debug( "InstrumentManagerTreeModel.valueForPathChanged(" + path
+
// ", " + newValue + ")" );
}
@@ -200,7 +203,7 @@
*/
public int getIndexOfChild( Object parent, Object child )
{
- // System.out.println("InstrumentManagerTreeModel.getIndexOfChild(" +
parent + ", " + child + ")");
+ //getLogger.debug("InstrumentManagerTreeModel.getIndexOfChild(" + parent +
", " + child + ")");
if ( parent instanceof DefaultMutableTreeNode )
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode)parent;
@@ -219,7 +222,7 @@
*/
public void addTreeModelListener( TreeModelListener listener )
{
- // System.out.println("InstrumentManagerTreeModel.addTreeModelListener(" +
listener + ")");
+ //getLogger.debug("InstrumentManagerTreeModel.addTreeModelListener(" +
listener + ")");
synchronized(this)
{
m_listeners.add( listener );
@@ -234,7 +237,7 @@
*/
public void removeTreeModelListener( TreeModelListener listener )
{
- // System.out.println("InstrumentManagerTreeModel.removeTreeModelListener("
+ listener + ")");
+ //getLogger.debug("InstrumentManagerTreeModel.removeTreeModelListener(" +
listener + ")");
synchronized(this)
{
m_listeners.remove( listener );
@@ -246,6 +249,11 @@
/*---------------------------------------------------------------
* Methods
*-------------------------------------------------------------*/
+ /**
+ * Returns an optimized array of the registered TreeModelListeners.
+ *
+ * @return An array of the registered TreeModelListeners
+ */
private TreeModelListener[] getListeners()
{
TreeModelListener[] listeners = m_listenerArray;
@@ -360,6 +368,13 @@
return null;
}
+ /**
+ * Returns an optimized array of TreeNodes representing the leased
+ * instrument samples in this tree model.
+ *
+ * @return An array of TreeNodes for the leased instrument samples
+ * in the TreeModel.
+ */
private DefaultMutableTreeNode[] getLeasedSampleArray()
{
DefaultMutableTreeNode[] leasedSampleArray = m_leasedSampleArray;
@@ -379,8 +394,9 @@
* Once a minute, all of the leased samples should be updated. This is
* necessary to get the latest expiration times in case other processes
* are also updating the leases.
+ * Called from InstrumentManagerConnection.handleLeasedSamples.
*/
- void updateAllLeasedSamples()
+ void renewAllSampleLeases()
{
DefaultMutableTreeNode[] leasedSampleArray = getLeasedSampleArray();
@@ -395,6 +411,9 @@
}
}
+ /**
+ * Remove any instrument samples whose current leases have expired.
+ */
void purgeExpiredSamples()
{
DefaultMutableTreeNode[] leasedSampleArray = getLeasedSampleArray();
@@ -432,6 +451,8 @@
{
m_root.removeAllChildren();
m_elementMap.clear();
+ m_leasedSampleMap.clear();
+ m_leasedSampleArray = null;
fireTreeStructureChanged( new TreeModelEvent( this,
m_root.getPath() ) );
}
}
@@ -442,6 +463,8 @@
// All data will change.
m_root.removeAllChildren();
m_elementMap.clear();
+ m_leasedSampleMap.clear();
+ m_leasedSampleArray = null;
fireTreeStructureChanged( new TreeModelEvent( this, new Object[] {
m_root } ) );
}
--
To unsubscribe, e-mail: <mailto:avalon-cvs-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@;jakarta.apache.org>