directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r415073 - in /directory/sandbox/akarasulu/mina-profiling/client: ./ src/main/assembly/ src/main/java/org/apache/mina/performance/test/client/
Date Sat, 17 Jun 2006 22:08:20 GMT
Author: akarasulu
Date: Sat Jun 17 15:08:19 2006
New Revision: 415073

URL: http://svn.apache.org/viewvc?rev=415073&view=rev
Log:
adding manifest, client starter shellscript, log4j setup and the client code

Added:
    directory/sandbox/akarasulu/mina-profiling/client/client.sh   (with props)
    directory/sandbox/akarasulu/mina-profiling/client/log4j.properties
    directory/sandbox/akarasulu/mina-profiling/client/src/main/assembly/
    directory/sandbox/akarasulu/mina-profiling/client/src/main/assembly/main.xml
    directory/sandbox/akarasulu/mina-profiling/client/src/main/java/org/apache/mina/performance/test/client/TestClient.java
    directory/sandbox/akarasulu/mina-profiling/client/src/main/java/org/apache/mina/performance/test/client/TestClientHandler.java
Modified:
    directory/sandbox/akarasulu/mina-profiling/client/pom.xml

Added: directory/sandbox/akarasulu/mina-profiling/client/client.sh
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/mina-profiling/client/client.sh?rev=415073&view=auto
==============================================================================
--- directory/sandbox/akarasulu/mina-profiling/client/client.sh (added)
+++ directory/sandbox/akarasulu/mina-profiling/client/client.sh Sat Jun 17 15:08:19 2006
@@ -0,0 +1,9 @@
+#!/bin/sh
+if [ -e target/client-1.0-SNAPSHOT-app.jar ] ; then
+  echo client uber jar exists
+else
+  echo client uber jar not found need to build it
+  mvn clean assembly:assembly
+fi
+
+java -Dlog4j.configuration=file://$(pwd)/log4j.properties -jar client-1.0-SNAPSHOT-app.jar
$@

Propchange: directory/sandbox/akarasulu/mina-profiling/client/client.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/sandbox/akarasulu/mina-profiling/client/log4j.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/mina-profiling/client/log4j.properties?rev=415073&view=auto
==============================================================================
--- directory/sandbox/akarasulu/mina-profiling/client/log4j.properties (added)
+++ directory/sandbox/akarasulu/mina-profiling/client/log4j.properties Sat Jun 17 15:08:19
2006
@@ -0,0 +1,6 @@
+log4j.rootCategory=WARN, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n
+

Modified: directory/sandbox/akarasulu/mina-profiling/client/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/mina-profiling/client/pom.xml?rev=415073&r1=415072&r2=415073&view=diff
==============================================================================
--- directory/sandbox/akarasulu/mina-profiling/client/pom.xml (original)
+++ directory/sandbox/akarasulu/mina-profiling/client/pom.xml Sat Jun 17 15:08:19 2006
@@ -12,4 +12,38 @@
   <url>http://directory.apache.org</url>
   <dependencies>
   </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifest>
+              <mainClass>
+		org.apache.mina.performance.test.client.TestClient
+              </mainClass>
+            </manifest>
+          </archive>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-assembly-plugin</artifactId>
+	<version>2.1-SNAPSHOT</version>
+        <configuration>
+          <archive>
+            <manifest>
+              <mainClass>
+                org.apache.mina.performance.test.client.TestClient
+              </mainClass>
+            </manifest>
+          </archive>
+          <descriptor>src/main/assembly/main.xml</descriptor>
+          <classifier>app</classifier>
+          <appendAssemblyId>false</appendAssemblyId>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>

Added: directory/sandbox/akarasulu/mina-profiling/client/src/main/assembly/main.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/mina-profiling/client/src/main/assembly/main.xml?rev=415073&view=auto
==============================================================================
--- directory/sandbox/akarasulu/mina-profiling/client/src/main/assembly/main.xml (added)
+++ directory/sandbox/akarasulu/mina-profiling/client/src/main/assembly/main.xml Sat Jun 17
15:08:19 2006
@@ -0,0 +1,25 @@
+<assembly>
+  <id>apacheds-main</id>
+  <formats>
+    <format>jar</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <fileSets>
+    <fileSet>
+      <directory>target/classes</directory>
+      <outputDirectory>/</outputDirectory>
+    </fileSet>
+  </fileSets>
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory>/</outputDirectory>
+      <unpack>true</unpack>
+      <scope>runtime</scope>
+      <excludes>
+        <exclude>ant:ant</exclude>
+        <exclude>checkstyle:checkstyle</exclude>
+        <exclude>xerces:xercesImpl</exclude>
+      </excludes>
+    </dependencySet>
+  </dependencySets>
+</assembly>

Added: directory/sandbox/akarasulu/mina-profiling/client/src/main/java/org/apache/mina/performance/test/client/TestClient.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/mina-profiling/client/src/main/java/org/apache/mina/performance/test/client/TestClient.java?rev=415073&view=auto
==============================================================================
--- directory/sandbox/akarasulu/mina-profiling/client/src/main/java/org/apache/mina/performance/test/client/TestClient.java
(added)
+++ directory/sandbox/akarasulu/mina-profiling/client/src/main/java/org/apache/mina/performance/test/client/TestClient.java
Sat Jun 17 15:08:19 2006
@@ -0,0 +1,50 @@
+package org.apache.mina.performance.test.client;
+
+import java.net.InetSocketAddress;
+
+import org.apache.mina.common.ConnectFuture;
+import org.apache.mina.common.IoConnector;
+import org.apache.mina.common.IoConnectorConfig;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.common.RuntimeIOException;
+import org.apache.mina.transport.socket.nio.SocketConnector;
+
+
+
+public class TestClient
+{
+    public static void main( String[] args ) throws Exception
+    {
+        if( args.length == 0 )
+        {
+            System.out.println( "Please specify the number of searches to perform." );
+            return;
+        }
+
+        IoConnector connector = new SocketConnector( 2 );
+        ( ( IoConnectorConfig ) connector.getDefaultConfig() ).setConnectTimeout( 10 );
+        
+        IoSession session;
+        for( ;; )
+        {
+            try
+            {
+                ConnectFuture future = connector.connect( 
+                    new InetSocketAddress( "newton", 10389 ), new TestClientHandler( Integer.parseInt(
args[0] ) ) );
+                
+                future.join();
+                session = future.getSession();
+                break;
+            }
+            catch( RuntimeIOException e )
+            {
+                System.err.println( "Failed to connect." );
+                e.printStackTrace();
+                Thread.sleep( 5000 );
+            }
+        }
+
+        // wait until the summation is done
+        session.getCloseFuture().join();
+    }
+}

Added: directory/sandbox/akarasulu/mina-profiling/client/src/main/java/org/apache/mina/performance/test/client/TestClientHandler.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/mina-profiling/client/src/main/java/org/apache/mina/performance/test/client/TestClientHandler.java?rev=415073&view=auto
==============================================================================
--- directory/sandbox/akarasulu/mina-profiling/client/src/main/java/org/apache/mina/performance/test/client/TestClientHandler.java
(added)
+++ directory/sandbox/akarasulu/mina-profiling/client/src/main/java/org/apache/mina/performance/test/client/TestClientHandler.java
Sat Jun 17 15:08:19 2006
@@ -0,0 +1,86 @@
+package org.apache.mina.performance.test.client;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoFuture;
+import org.apache.mina.common.IoHandlerAdapter;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.LoggingFilter;
+
+
+
+public class TestClientHandler extends IoHandlerAdapter
+{
+    private static final byte[] BIND_REQ = 
+        new byte[] {
+            0x30, 0x0c, 0x02, 0x01, 0x01, 0x60, 0x07, 0x02, 0x01, 0x03, 0x04, 0x00
+    };
+    private static final byte[] SEARCH_REQ =
+        new byte[] {
+            0x30, 0x25, 0x02, 0x01, 0x02, 0x63, 0x20, 0x04, 0x00, 0x0a, 0x01, 0x00, 0x0a,
0x01, 
+            0x00, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x00, ( byte ) 0x87, 0x0b,
0x6f, 0x62,
+            0x6a, 0x65, 0x63, 0x74, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x30, 0x00
+    };
+    private static final byte[] UNBIND_REQ =
+        new byte[] {
+            0x30, 0x05, 0x02, 0x01, 0x03, 0x42, 0x00
+    };
+    
+    
+    private final int maxSearchRequests;
+    private int requestCount = 0;
+    
+    
+    public TestClientHandler( int maxSearchRequests )
+    {
+        this.maxSearchRequests = maxSearchRequests;
+    }
+
+    
+    public void sessionCreated( IoSession session ) throws Exception
+    {
+        session.getFilterChain().addLast( "logger", new LoggingFilter() );
+    }
+
+    
+    public void sessionOpened( IoSession session ) throws Exception
+    {
+        session.write( ByteBuffer.wrap( BIND_REQ ) );
+    }
+    
+    public void messageReceived( IoSession session, Object message )
+    {
+        ByteBuffer buf = ( ByteBuffer ) message;
+        byte b5 = buf.get( 5 );
+        byte[] payload = new byte[buf.remaining()];
+        buf.get( payload );
+        
+        switch( b5 )
+        {
+            // bind response
+            case( 0x61 ):
+                session.write( ByteBuffer.wrap( SEARCH_REQ ) );
+                requestCount++;
+                break;
+            // search entry response
+            case( 0x64 ):
+                break;
+            // search done response
+            case( 0x65 ):
+                if ( requestCount >= maxSearchRequests )
+                {
+                    session.write( ByteBuffer.wrap( UNBIND_REQ ) );
+                    IoFuture future = session.close();
+                    future.join( 500 );
+                    System.exit( 0 );
+                }
+                else
+                {
+                    session.write( ByteBuffer.wrap( SEARCH_REQ ) );
+                    requestCount++;
+                }
+                break;
+            default:
+                throw new IllegalStateException( "Unidentified PDU" );
+        }
+    }
+}



Mime
View raw message