directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 9676 - in incubator/directory/eve/trunk/eve/frontend/output/spi: . src/java/org/apache/eve/output
Date Mon, 22 Mar 2004 10:39:19 GMT
Author: akarasulu
Date: Mon Mar 22 02:39:18 2004
New Revision: 9676

Added:
   incubator/directory/eve/trunk/eve/frontend/output/spi/src/java/org/apache/eve/output/LoggingOutputMonitor.java
   incubator/directory/eve/trunk/eve/frontend/output/spi/src/java/org/apache/eve/output/OutputMonitor.java
   incubator/directory/eve/trunk/eve/frontend/output/spi/src/java/org/apache/eve/output/OutputMonitorAdapter.java
Modified:
   incubator/directory/eve/trunk/eve/frontend/output/spi/project.xml
   incubator/directory/eve/trunk/eve/frontend/output/spi/src/java/org/apache/eve/output/OutputManager.java
Log:
added monitor with a few impls and added service methods

Modified: incubator/directory/eve/trunk/eve/frontend/output/spi/project.xml
==============================================================================
--- incubator/directory/eve/trunk/eve/frontend/output/spi/project.xml	(original)
+++ incubator/directory/eve/trunk/eve/frontend/output/spi/project.xml	Mon Mar 22 02:39:18
2004
@@ -16,6 +16,20 @@
       
     <dependencies>
       <dependency>
+        <groupId>commons-lang</groupId>
+        <artifactId>commons-lang</artifactId>
+        <version>2.0</version>
+        <url>http://jakarta.apache.org/commons/lang</url>
+      </dependency>
+      
+      <dependency>
+        <groupId>commons-logging</groupId>
+        <artifactId>commons-logging</artifactId>
+        <version>1.0.3</version>
+        <url>http://jakarta.apache.org/commons/logging</url>
+      </dependency>
+      
+      <dependency>
         <groupId>incubator-directory</groupId>
         <artifactId>eve-frontend-common-api</artifactId>
         <version>SNAPSHOT</version>

Added: incubator/directory/eve/trunk/eve/frontend/output/spi/src/java/org/apache/eve/output/LoggingOutputMonitor.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/eve/frontend/output/spi/src/java/org/apache/eve/output/LoggingOutputMonitor.java
Mon Mar 22 02:39:18 2004
@@ -0,0 +1,156 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.eve.output ;
+
+
+import java.util.EventObject ;
+
+import org.apache.commons.logging.Log ;
+import org.apache.commons.logging.LogFactory ;
+import org.apache.commons.lang.exception.ExceptionUtils ;
+
+import org.apache.eve.event.ConnectEvent ;
+import org.apache.eve.listener.ClientKey ;
+import org.apache.eve.event.DisconnectEvent ;
+import org.apache.eve.listener.KeyExpiryException ;
+
+
+/**
+ * A logging monitor for any OutputManager.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class LoggingOutputMonitor implements OutputMonitor
+{
+    private final Log log = LogFactory.getLog( "OutputManager" ) ;
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#failedOnWrite(
+     * org.apache.eve.output.OutputManager, org.apache.eve.listener.ClientKey, 
+     * java.lang.Throwable)
+     */
+    public void failedOnWrite( OutputManager manager, ClientKey key, 
+                               Throwable t )
+    {
+        if ( log.isErrorEnabled() )
+        {
+            log.error( manager + " failed while trying to write to client " 
+                    + key + ":\n"
+                    + ExceptionUtils.getFullStackTrace( t ) ) ;
+        }
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#writeOccurred(
+     * org.apache.eve.output.OutputManager, org.apache.eve.listener.ClientKey)
+     */
+    public void writeOccurred( OutputManager manager, ClientKey key )
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( manager + " wrote to client " + key ) ;
+        }
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#writeLockAcquired(
+     * org.apache.eve.output.OutputManager, org.apache.eve.listener.ClientKey)
+     */
+    public void writeLockAcquired( OutputManager manager, ClientKey key )
+    {
+        if ( log.isTraceEnabled() )
+        {
+            log.trace( manager + " locked channel for client " + key ) ;
+        }
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#channelMissing(
+     * org.apache.eve.output.OutputManager, org.apache.eve.listener.ClientKey)
+     */
+    public void channelMissing( OutputManager manager, ClientKey key )
+    {
+        if ( log.isWarnEnabled() )
+        {
+            log.warn( manager + " could not find channel for client " + key ) ;
+        }
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#keyExpired(
+     * org.apache.eve.output.OutputManager, org.apache.eve.listener.ClientKey, 
+     * org.apache.eve.listener.KeyExpiryException)
+     */
+    public void keyExpired( OutputManager manager, ClientKey key,
+							KeyExpiryException e )
+    {
+        if ( log.isWarnEnabled() )
+        {
+            log.warn( manager + " cannot use expired key for client " + key 
+                    + ":\n" + ExceptionUtils.getFullStackTrace( e ) ) ;
+        }
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#failedOnInform(
+     * org.apache.eve.output.OutputManager, java.util.EventObject, 
+     * java.lang.Throwable)
+     */
+    public void failedOnInform( OutputManager manager, EventObject event,
+								Throwable fault )
+    {
+        if ( log.isErrorEnabled() )
+        {
+            log.error( manager + " failed to be informed of " + event ) ;
+        }
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#addedClient(
+     * org.apache.eve.output.OutputManager, org.apache.eve.event.ConnectEvent)
+     */
+    public void addedClient( OutputManager manager, ConnectEvent event )
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( manager + " added client " + event.getClientKey() ) ;
+        }
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#removedClient(
+     * org.apache.eve.output.OutputManager, 
+     * org.apache.eve.event.DisconnectEvent)
+     */
+    public void removedClient( OutputManager manager, DisconnectEvent event )
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( manager + " removed client " + event.getClientKey() ) ;
+        }
+    }
+}

Modified: incubator/directory/eve/trunk/eve/frontend/output/spi/src/java/org/apache/eve/output/OutputManager.java
==============================================================================
--- incubator/directory/eve/trunk/eve/frontend/output/spi/src/java/org/apache/eve/output/OutputManager.java
(original)
+++ incubator/directory/eve/trunk/eve/frontend/output/spi/src/java/org/apache/eve/output/OutputManager.java
Mon Mar 22 02:39:18 2004
@@ -17,7 +17,15 @@
 package org.apache.eve.output ;
 
 
+import java.io.IOException ;
+
+import java.nio.ByteBuffer ;
+
+import org.apache.eve.listener.ClientKey ;
+
+
 /**
+ * Service interface used to manage output.
  *
  * @author <a href="mailto:directory-dev@incubator.apache.org">
  * Apache Directory Project</a>
@@ -25,5 +33,15 @@
  */
 public interface OutputManager
 {
-    void dummy() ;
+    /** Old Avalon requirement for a service role */
+    String ROLE = OutputManager.class.getName() ;
+
+    /**
+     * Writes or rather sends a peice of PDU data to a client.
+     * 
+     * @param key the key of the client to send the buffer to
+     * @param buf the buffer of PDU data
+     * @throws IOException if there is a failure while sending the data
+     */
+    void write( ClientKey key, ByteBuffer buf ) throws IOException ;
 }

Added: incubator/directory/eve/trunk/eve/frontend/output/spi/src/java/org/apache/eve/output/OutputMonitor.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/eve/frontend/output/spi/src/java/org/apache/eve/output/OutputMonitor.java
Mon Mar 22 02:39:18 2004
@@ -0,0 +1,108 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.eve.output ;
+
+
+import java.util.EventObject ;
+
+import org.apache.eve.listener.ClientKey ; 
+import org.apache.eve.event.ConnectEvent ;
+import org.apache.eve.event.DisconnectEvent ;
+import org.apache.eve.listener.KeyExpiryException ;
+
+
+/**
+ * A monitor for the OutputManager.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface OutputMonitor
+{
+    /**
+     * Monitors failed send events to a client.
+     * 
+     * @param manager the OutputManager sending the data
+     * @param key the key of the client data is sent to
+     * @param t the fault causing the failure
+     */
+    void failedOnWrite( OutputManager manager, ClientKey key, Throwable t ) ;
+    
+    /**
+     * Monitors send events to a client.
+     * 
+     * @param manager the OutputManager sending the data
+     * @param key the key of the client data is sent to
+     */
+    void writeOccurred( OutputManager manager, ClientKey key ) ;
+    
+    /**
+     * Monitors locks acquired to write to a client's output channel.
+     * 
+     * @param manager the OutputManager write locking
+     * @param key the key of the client lock is for
+     */
+    void writeLockAcquired( OutputManager manager, ClientKey key ) ;
+    
+    /**
+     * Monitors situations where a channel is no longer present for a client.
+     * 
+     * @param manager the OutputManager detecting the missing channel
+     * @param key the key of the client the channel was missing from
+     */
+    void channelMissing( OutputManager manager, ClientKey key ) ;
+    
+    /**
+     * Monitors failures resulting from accessing a client key that has been 
+     * expired.
+     * 
+     * @param manager the OutputManager accessing the key
+     * @param key the key of the client that expired
+     * @param e the key expiration exception
+     */
+    void keyExpired( OutputManager manager, ClientKey key, 
+                     KeyExpiryException e ) ;
+    
+    /**
+     * Monitors failures on inform events to subscriber methods.
+     * 
+     * @param manager the OutputManager that failed to inform
+     * @param event the event that failed to be routed
+     * @param fault the faulting exception associated with the failure
+     */
+    void failedOnInform( OutputManager manager, EventObject event, 
+                         Throwable fault ) ;
+    
+    /**
+     * Called when connections are established and clients are registered with
+     * the OutputManager.
+     * 
+     * @param manager the output manager with which a client was registered
+     * @param event the ConnectEvent that caused registration
+     */
+    void addedClient( OutputManager manager, ConnectEvent event ) ;
+    
+    /**
+     * Called when connections are dropped and clients are unregistered with
+     * the OutputManager.
+     * 
+     * @param manager the output manager with which a client was unregistered
+     * @param event the DisconnectEvent that caused unregistration
+     */
+    void removedClient( OutputManager manager, DisconnectEvent event ) ;
+}

Added: incubator/directory/eve/trunk/eve/frontend/output/spi/src/java/org/apache/eve/output/OutputMonitorAdapter.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/eve/frontend/output/spi/src/java/org/apache/eve/output/OutputMonitorAdapter.java
Mon Mar 22 02:39:18 2004
@@ -0,0 +1,125 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.eve.output ;
+
+
+import java.util.EventObject ;
+
+import org.apache.commons.lang.exception.ExceptionUtils ;
+
+import org.apache.eve.event.ConnectEvent ;
+import org.apache.eve.listener.ClientKey ;
+import org.apache.eve.event.DisconnectEvent ;
+import org.apache.eve.listener.KeyExpiryException ;
+
+
+/**
+ * A do nothing output monitor adapter.  For safety's sake error conditions are
+ * printed to the console.  
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">
+ * Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class OutputMonitorAdapter implements OutputMonitor
+{
+
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#
+     * failedOnWrite(org.apache.eve.output.OutputManager, 
+     * org.apache.eve.listener.ClientKey, java.lang.Throwable)
+     */
+    public void failedOnWrite( OutputManager manager, ClientKey key, 
+                               Throwable t )
+    {
+        System.err.println( "Failed on write to client " + key + ":\n" 
+                + ExceptionUtils.getFullStackTrace( t ) ) ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#writeOccurred(
+     * org.apache.eve.output.OutputManager, org.apache.eve.listener.ClientKey)
+     */
+    public void writeOccurred( OutputManager manager, ClientKey key )
+    {
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#writeLockAcquired(
+     * org.apache.eve.output.OutputManager, org.apache.eve.listener.ClientKey)
+     */
+    public void writeLockAcquired( OutputManager manager, ClientKey key )
+    {
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#channelMissing(
+     * org.apache.eve.output.OutputManager, org.apache.eve.listener.ClientKey)
+     */
+    public void channelMissing( OutputManager manager, ClientKey key )
+    {
+        System.err.println( "Channel for client " + key + " missing." ) ; 
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#keyExpired(
+     * org.apache.eve.output.OutputManager, 
+     * org.apache.eve.listener.KeyExpiryException)
+     */
+    public void keyExpired( OutputManager manager, ClientKey key, 
+                            KeyExpiryException e )
+    {
+        System.err.println( "Key for client " + key + ":\n" 
+                + ExceptionUtils.getFullStackTrace( e ) ) ;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#failedOnInform(
+     * org.apache.eve.output.OutputManager, java.util.EventObject, 
+     * java.lang.Throwable)
+     */
+    public void failedOnInform( OutputManager manager, EventObject event,
+            Throwable fault )
+    {
+        System.err.println( "Failed to inform of " + event + ":\n" 
+                + ExceptionUtils.getFullStackTrace( fault ) ) ;
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#addedClient(
+     * org.apache.eve.output.OutputManager, org.apache.eve.event.ConnectEvent)
+     */
+    public void addedClient( OutputManager manager, ConnectEvent event )
+    {
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.eve.output.OutputMonitor#removedClient(
+     * org.apache.eve.output.OutputManager, 
+     * org.apache.eve.event.DisconnectEvent)
+     */
+    public void removedClient( OutputManager manager, DisconnectEvent event )
+    {
+    }
+}

Mime
View raw message