activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r379619 [13/30] - in /incubator/activemq/trunk: ./ activecluster/ activecluster/src/java/org/apache/activecluster/ activecluster/src/java/org/apache/activecluster/election/ activecluster/src/java/org/apache/activecluster/election/impl/ acti...
Date Tue, 21 Feb 2006 23:14:17 GMT
Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannelServer.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannelServer.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannelServer.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannelServer.java Tue Feb 21 15:12:56 2006
@@ -1,127 +1,127 @@
-/**
- *
- * Copyright 2005-2006 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.activeio.stream.sync.socket;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
-import java.net.URI;
-
-import org.apache.activeio.Channel;
-import org.apache.activeio.stream.sync.StreamChannelServer;
-
-/**
- * A StreamChannelServer that creates
- * {@see org.apache.activeio.net.TcpStreamChannel}objects from accepted
- * tcp socket connections.
- * 
- * @version $Revision$
- */
-public class SocketStreamChannelServer implements StreamChannelServer {
-
-    private ServerSocket serverSocket;
-    private int curentSoTimeout = 0;
-    private final URI bindURI;
-    private final URI connectURI;
-
-
-    /**
-     * @param serverSocket
-     * @param bindURI
-     * @param connectURI
-     */
-    public SocketStreamChannelServer(ServerSocket serverSocket, URI bindURI, URI connectURI) {
-        this.serverSocket=serverSocket;
-        this.bindURI=bindURI;
-        this.connectURI=connectURI;
-    }
-
-    public Channel accept(long timeout) throws IOException {
-        try {
-            if (timeout == StreamChannelServer.WAIT_FOREVER_TIMEOUT)
-                setSoTimeout(0);
-            else if (timeout == StreamChannelServer.NO_WAIT_TIMEOUT)
-                setSoTimeout(1);
-            else
-                setSoTimeout((int) timeout);
-
-            Socket socket = serverSocket.accept();
-            return createChannel(socket);
-
-        } catch (SocketTimeoutException ignore) {
-        }
-        return null;
-    }
-
-    protected Channel createChannel(Socket socket) throws IOException {
-        return new SocketStreamChannel(socket);
-    }
-
-    private void setSoTimeout(int i) throws SocketException {
-        if (curentSoTimeout != i) {
-            serverSocket.setSoTimeout(i);
-            curentSoTimeout = i;
-        }
-    }
-
-    /**
-     * @see org.apache.activeio.Disposable#dispose()
-     */
-    public void dispose() {
-        if (serverSocket == null)
-            return;
-        try {
-            serverSocket.close();
-        } catch (IOException ignore) {
-        }
-        serverSocket = null;
-    }
-
-    /**
-     * @return Returns the bindURI.
-     */
-    public URI getBindURI() {
-        return bindURI;
-    }
-
-    /**
-     * @return Returns the connectURI.
-     */
-    public URI getConnectURI() {
-        return connectURI;
-    }
-
-    public void start() throws IOException {
-    }
-
-    public void stop() throws IOException {
-    }
-    
-    public Object getAdapter(Class target) {
-        if( target.isAssignableFrom(getClass()) ) {
-            return this;
-        }
-        return null;
-    }    
-    
-    public String toString() {
-        return "Socket Server: "+getConnectURI();
-    }    
+/**
+ *
+ * Copyright 2005-2006 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.activeio.stream.sync.socket;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketException;
+import java.net.SocketTimeoutException;
+import java.net.URI;
+
+import org.apache.activeio.Channel;
+import org.apache.activeio.stream.sync.StreamChannelServer;
+
+/**
+ * A StreamChannelServer that creates
+ * {@see org.apache.activeio.net.TcpStreamChannel}objects from accepted
+ * tcp socket connections.
+ * 
+ * @version $Revision$
+ */
+public class SocketStreamChannelServer implements StreamChannelServer {
+
+    private ServerSocket serverSocket;
+    private int curentSoTimeout = 0;
+    private final URI bindURI;
+    private final URI connectURI;
+
+
+    /**
+     * @param serverSocket
+     * @param bindURI
+     * @param connectURI
+     */
+    public SocketStreamChannelServer(ServerSocket serverSocket, URI bindURI, URI connectURI) {
+        this.serverSocket=serverSocket;
+        this.bindURI=bindURI;
+        this.connectURI=connectURI;
+    }
+
+    public Channel accept(long timeout) throws IOException {
+        try {
+            if (timeout == StreamChannelServer.WAIT_FOREVER_TIMEOUT)
+                setSoTimeout(0);
+            else if (timeout == StreamChannelServer.NO_WAIT_TIMEOUT)
+                setSoTimeout(1);
+            else
+                setSoTimeout((int) timeout);
+
+            Socket socket = serverSocket.accept();
+            return createChannel(socket);
+
+        } catch (SocketTimeoutException ignore) {
+        }
+        return null;
+    }
+
+    protected Channel createChannel(Socket socket) throws IOException {
+        return new SocketStreamChannel(socket);
+    }
+
+    private void setSoTimeout(int i) throws SocketException {
+        if (curentSoTimeout != i) {
+            serverSocket.setSoTimeout(i);
+            curentSoTimeout = i;
+        }
+    }
+
+    /**
+     * @see org.apache.activeio.Disposable#dispose()
+     */
+    public void dispose() {
+        if (serverSocket == null)
+            return;
+        try {
+            serverSocket.close();
+        } catch (IOException ignore) {
+        }
+        serverSocket = null;
+    }
+
+    /**
+     * @return Returns the bindURI.
+     */
+    public URI getBindURI() {
+        return bindURI;
+    }
+
+    /**
+     * @return Returns the connectURI.
+     */
+    public URI getConnectURI() {
+        return connectURI;
+    }
+
+    public void start() throws IOException {
+    }
+
+    public void stop() throws IOException {
+    }
+    
+    public Object getAdapter(Class target) {
+        if( target.isAssignableFrom(getClass()) ) {
+            return this;
+        }
+        return null;
+    }    
+    
+    public String toString() {
+        return "Socket Server: "+getConnectURI();
+    }    
 }

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannelServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/ByteArrayInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/ByteArrayOutputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/FactoryFinder.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/FactoryFinder.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/FactoryFinder.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/FactoryFinder.java Tue Feb 21 15:12:56 2006
@@ -1,105 +1,105 @@
-/**
- *
- * Copyright 2005-2006 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.activeio.util;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
-
-
-public class FactoryFinder {
-
-    private final String path;
-    private final ConcurrentHashMap classMap = new ConcurrentHashMap();
-
-    public FactoryFinder(String path) {
-        this.path = path;
-    }
-
-    /**
-     * Creates a new instance of the given key
-     *
-     * @param key is the key to add to the path to find a text file
-     *            containing the factory name
-     * @return a newly created instance
-     */
-    public Object newInstance(String key)
-            throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException
-    {
-        return newInstance(key, null);
-    }
-
-    public Object newInstance(String key, String propertyPrefix)
-            throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException
-    {
-        if (propertyPrefix == null)
-            propertyPrefix = "";
-
-        Class clazz = (Class) classMap.get(propertyPrefix + key);
-        if (clazz == null) {
-            clazz = newInstance(doFindFactoryProperies(key), propertyPrefix);
-            classMap.put(propertyPrefix + key, clazz);
-        }
-        return clazz.newInstance();
-    }
-
-    private Class newInstance(Properties properties, String propertyPrefix) throws ClassNotFoundException, IOException {
-
-        String className = properties.getProperty(propertyPrefix + "class");
-        if (className == null) {
-            throw new IOException("Expected property is missing: " + propertyPrefix + "class");
-        }
-        Class clazz;
-        try {
-            clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
-        } catch (ClassNotFoundException e) {
-            clazz = FactoryFinder.class.getClassLoader().loadClass(className);
-        }
-
-        return clazz;
-    }
-
-    private Properties doFindFactoryProperies(String key) throws IOException {
-        String uri = path + key;
-
-        // lets try the thread context class loader first
-        InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(uri);
-        if (in == null) {
-            in = FactoryFinder.class.getClassLoader().getResourceAsStream(uri);
-            if (in == null) {
-                throw new IOException("Could not find factory class for resource: " + uri);
-            }
-        }
-
-        // lets load the file
-        BufferedInputStream reader = null;
-        try {
-            reader = new BufferedInputStream(in);
-            Properties properties = new Properties();
-            properties.load(reader);
-            return properties;
-        } finally {
-            try {
-                reader.close();
-            } catch (Exception e) {
-            }
-        }
-    }
+/**
+ *
+ * Copyright 2005-2006 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.activeio.util;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+
+
+public class FactoryFinder {
+
+    private final String path;
+    private final ConcurrentHashMap classMap = new ConcurrentHashMap();
+
+    public FactoryFinder(String path) {
+        this.path = path;
+    }
+
+    /**
+     * Creates a new instance of the given key
+     *
+     * @param key is the key to add to the path to find a text file
+     *            containing the factory name
+     * @return a newly created instance
+     */
+    public Object newInstance(String key)
+            throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException
+    {
+        return newInstance(key, null);
+    }
+
+    public Object newInstance(String key, String propertyPrefix)
+            throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException
+    {
+        if (propertyPrefix == null)
+            propertyPrefix = "";
+
+        Class clazz = (Class) classMap.get(propertyPrefix + key);
+        if (clazz == null) {
+            clazz = newInstance(doFindFactoryProperies(key), propertyPrefix);
+            classMap.put(propertyPrefix + key, clazz);
+        }
+        return clazz.newInstance();
+    }
+
+    private Class newInstance(Properties properties, String propertyPrefix) throws ClassNotFoundException, IOException {
+
+        String className = properties.getProperty(propertyPrefix + "class");
+        if (className == null) {
+            throw new IOException("Expected property is missing: " + propertyPrefix + "class");
+        }
+        Class clazz;
+        try {
+            clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
+        } catch (ClassNotFoundException e) {
+            clazz = FactoryFinder.class.getClassLoader().loadClass(className);
+        }
+
+        return clazz;
+    }
+
+    private Properties doFindFactoryProperies(String key) throws IOException {
+        String uri = path + key;
+
+        // lets try the thread context class loader first
+        InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(uri);
+        if (in == null) {
+            in = FactoryFinder.class.getClassLoader().getResourceAsStream(uri);
+            if (in == null) {
+                throw new IOException("Could not find factory class for resource: " + uri);
+            }
+        }
+
+        // lets load the file
+        BufferedInputStream reader = null;
+        try {
+            reader = new BufferedInputStream(in);
+            Properties properties = new Properties();
+            properties.load(reader);
+            return properties;
+        } finally {
+            try {
+                reader.close();
+            } catch (Exception e) {
+            }
+        }
+    }
 }

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/FactoryFinder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/PacketAggregator.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/PacketAggregator.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/PacketAggregator.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/PacketAggregator.java Tue Feb 21 15:12:56 2006
@@ -1,101 +1,101 @@
-/**
- *
- * Copyright 2005-2006 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.activeio.util;
-
-import java.io.IOException;
-
-import org.apache.activeio.packet.AppendedPacket;
-import org.apache.activeio.packet.ByteArrayPacket;
-import org.apache.activeio.packet.EOSPacket;
-import org.apache.activeio.packet.Packet;
-import org.apache.activeio.packet.PacketData;
-
-/**
- * @version $Revision$
- */
-abstract public class PacketAggregator {
-
-    private static final int HEADER_LENGTH = 4;        
-    
-    private final ByteArrayPacket headerBuffer = new ByteArrayPacket(new byte[HEADER_LENGTH]);
-    private final PacketData headerData = new PacketData(headerBuffer);
-
-    Packet incompleteUpPacket;
-    boolean headerLoaded;
-    private int upPacketLength;
-    
-    public void addRawPacket(Packet packet) throws IOException {
-
-        // Passthrough the EOS packet.
-        if( packet == EOSPacket.EOS_PACKET ) {
-            packetAssembled(packet);
-            return;
-        }
-
-        if (incompleteUpPacket != null) {
-            packet = AppendedPacket.join(incompleteUpPacket, packet);
-            incompleteUpPacket = null;
-        }
-
-        while (true) {
-
-            if (!headerLoaded) {
-                headerLoaded = packet.remaining() >= HEADER_LENGTH;
-                if( headerLoaded ) {
-                    PacketData data = new PacketData(packet);
-                    upPacketLength = data.readInt();
-                    if( upPacketLength < 0 ) {
-                        throw new IOException("Up packet lenth was invalid: "+upPacketLength);
-                    }
-                    packet = packet.slice();
-                }
-                if( !headerLoaded )
-                    break;
-            }
-
-            if (packet.remaining() < upPacketLength )
-                break;
-
-            // Get ready to create a slice to send up.
-            int origLimit = packet.limit();
-            packet.limit(upPacketLength);
-            packetAssembled(packet.slice());
-            
-            // Get a slice of the remaining since that will dump
-            // the first packets of an AppendedPacket
-            packet.position(upPacketLength);
-            packet.limit(origLimit);
-            packet = packet.slice();
-
-            // Need to load a header again now.
-            headerLoaded = false;
-        }
-        if (packet.hasRemaining()) {
-            incompleteUpPacket = packet;
-        }
-        
-    }
-
-    protected abstract void packetAssembled(Packet packet);
-    
-    public Packet getHeader( Packet packet ) throws IOException {
-        headerBuffer.clear();
-        headerData.writeInt(packet.remaining());
-        headerBuffer.flip();
-        return headerBuffer;
-    }
+/**
+ *
+ * Copyright 2005-2006 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.activeio.util;
+
+import java.io.IOException;
+
+import org.apache.activeio.packet.AppendedPacket;
+import org.apache.activeio.packet.ByteArrayPacket;
+import org.apache.activeio.packet.EOSPacket;
+import org.apache.activeio.packet.Packet;
+import org.apache.activeio.packet.PacketData;
+
+/**
+ * @version $Revision$
+ */
+abstract public class PacketAggregator {
+
+    private static final int HEADER_LENGTH = 4;        
+    
+    private final ByteArrayPacket headerBuffer = new ByteArrayPacket(new byte[HEADER_LENGTH]);
+    private final PacketData headerData = new PacketData(headerBuffer);
+
+    Packet incompleteUpPacket;
+    boolean headerLoaded;
+    private int upPacketLength;
+    
+    public void addRawPacket(Packet packet) throws IOException {
+
+        // Passthrough the EOS packet.
+        if( packet == EOSPacket.EOS_PACKET ) {
+            packetAssembled(packet);
+            return;
+        }
+
+        if (incompleteUpPacket != null) {
+            packet = AppendedPacket.join(incompleteUpPacket, packet);
+            incompleteUpPacket = null;
+        }
+
+        while (true) {
+
+            if (!headerLoaded) {
+                headerLoaded = packet.remaining() >= HEADER_LENGTH;
+                if( headerLoaded ) {
+                    PacketData data = new PacketData(packet);
+                    upPacketLength = data.readInt();
+                    if( upPacketLength < 0 ) {
+                        throw new IOException("Up packet lenth was invalid: "+upPacketLength);
+                    }
+                    packet = packet.slice();
+                }
+                if( !headerLoaded )
+                    break;
+            }
+
+            if (packet.remaining() < upPacketLength )
+                break;
+
+            // Get ready to create a slice to send up.
+            int origLimit = packet.limit();
+            packet.limit(upPacketLength);
+            packetAssembled(packet.slice());
+            
+            // Get a slice of the remaining since that will dump
+            // the first packets of an AppendedPacket
+            packet.position(upPacketLength);
+            packet.limit(origLimit);
+            packet = packet.slice();
+
+            // Need to load a header again now.
+            headerLoaded = false;
+        }
+        if (packet.hasRemaining()) {
+            incompleteUpPacket = packet;
+        }
+        
+    }
+
+    protected abstract void packetAssembled(Packet packet);
+    
+    public Packet getHeader( Packet packet ) throws IOException {
+        headerBuffer.clear();
+        headerData.writeInt(packet.remaining());
+        headerBuffer.flip();
+        return headerBuffer;
+    }
 }

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/PacketAggregator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/URISupport.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/URISupport.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/URISupport.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/URISupport.java Tue Feb 21 15:12:56 2006
@@ -1,52 +1,52 @@
-/**
- *
- * Copyright 2005-2006 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.activeio.util;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-/**
- * The URISupport class provides a few static methods that provides a few usefull
- * operations to manipulate URIs.
- * 
- * @version $Revision$
- */
-public class URISupport {
-    
-    static public URI changePort(URI bindAddr, int port) throws URISyntaxException {
-        return new URI(bindAddr.getScheme(), bindAddr.getUserInfo(), bindAddr.getHost(), port, bindAddr.getPath(), bindAddr.getQuery(), bindAddr.getFragment());
-    }
-    static public URI changeScheme(URI bindAddr, String scheme) throws URISyntaxException {
-        return new URI(scheme, bindAddr.getUserInfo(), bindAddr.getHost(), bindAddr.getPort(), bindAddr.getPath(), bindAddr.getQuery(), bindAddr.getFragment());
-    }
-    static public URI changeUserInfo(URI bindAddr, String userInfo) throws URISyntaxException {
-        return new URI(bindAddr.getScheme(), userInfo, bindAddr.getHost(), bindAddr.getPort(), bindAddr.getPath(), bindAddr.getQuery(), bindAddr.getFragment());
-    }
-    static public URI changeHost(URI bindAddr, String host) throws URISyntaxException {
-        return new URI(bindAddr.getScheme(), bindAddr.getUserInfo(), host, bindAddr.getPort(), bindAddr.getPath(), bindAddr.getQuery(), bindAddr.getFragment());
-    }
-    static public URI changePath(URI bindAddr, String path) throws URISyntaxException {
-        return new URI(bindAddr.getScheme(), bindAddr.getUserInfo(), bindAddr.getHost(), bindAddr.getPort(), path, bindAddr.getQuery(), bindAddr.getFragment());
-    }
-    static public URI changeQuery(URI bindAddr, String query) throws URISyntaxException {
-        return new URI(bindAddr.getScheme(), bindAddr.getUserInfo(), bindAddr.getHost(), bindAddr.getPort(), bindAddr.getPath(), query, bindAddr.getFragment());
-    }
-    static public URI changeFragment(URI bindAddr, String fragment) throws URISyntaxException {
-        return new URI(bindAddr.getScheme(), bindAddr.getUserInfo(), bindAddr.getHost(), bindAddr.getPort(), bindAddr.getPath(), bindAddr.getQuery(), fragment);
-    }
-
-}
+/**
+ *
+ * Copyright 2005-2006 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.activeio.util;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * The URISupport class provides a few static methods that provides a few usefull
+ * operations to manipulate URIs.
+ * 
+ * @version $Revision$
+ */
+public class URISupport {
+    
+    static public URI changePort(URI bindAddr, int port) throws URISyntaxException {
+        return new URI(bindAddr.getScheme(), bindAddr.getUserInfo(), bindAddr.getHost(), port, bindAddr.getPath(), bindAddr.getQuery(), bindAddr.getFragment());
+    }
+    static public URI changeScheme(URI bindAddr, String scheme) throws URISyntaxException {
+        return new URI(scheme, bindAddr.getUserInfo(), bindAddr.getHost(), bindAddr.getPort(), bindAddr.getPath(), bindAddr.getQuery(), bindAddr.getFragment());
+    }
+    static public URI changeUserInfo(URI bindAddr, String userInfo) throws URISyntaxException {
+        return new URI(bindAddr.getScheme(), userInfo, bindAddr.getHost(), bindAddr.getPort(), bindAddr.getPath(), bindAddr.getQuery(), bindAddr.getFragment());
+    }
+    static public URI changeHost(URI bindAddr, String host) throws URISyntaxException {
+        return new URI(bindAddr.getScheme(), bindAddr.getUserInfo(), host, bindAddr.getPort(), bindAddr.getPath(), bindAddr.getQuery(), bindAddr.getFragment());
+    }
+    static public URI changePath(URI bindAddr, String path) throws URISyntaxException {
+        return new URI(bindAddr.getScheme(), bindAddr.getUserInfo(), bindAddr.getHost(), bindAddr.getPort(), path, bindAddr.getQuery(), bindAddr.getFragment());
+    }
+    static public URI changeQuery(URI bindAddr, String query) throws URISyntaxException {
+        return new URI(bindAddr.getScheme(), bindAddr.getUserInfo(), bindAddr.getHost(), bindAddr.getPort(), bindAddr.getPath(), query, bindAddr.getFragment());
+    }
+    static public URI changeFragment(URI bindAddr, String fragment) throws URISyntaxException {
+        return new URI(bindAddr.getScheme(), bindAddr.getUserInfo(), bindAddr.getHost(), bindAddr.getPort(), bindAddr.getPath(), bindAddr.getQuery(), fragment);
+    }
+
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/util/URISupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/ServerService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/ServiceDaemon.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/ServiceException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/ServiceLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/ServicePool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/SocketService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/StandardServiceStack.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/StandardServiceStackGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/SyncChannelServerDaemon.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/hba/ExactIPAddressPermission.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/hba/ExactIPv6AddressPermission.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/hba/FactorizedIPAddressPermission.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/hba/IPAddressPermission.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/hba/IPAddressPermissionEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/hba/IPAddressPermissionFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/hba/NetmaskIPAddressPermission.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/hba/NetmaskIPv6AddressPermission.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/hba/ServiceAccessController.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/xnet/hba/StartWithIPAddressPermission.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/ChannelFactoryTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/ChannelFactoryTest.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/ChannelFactoryTest.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/ChannelFactoryTest.java Tue Feb 21 15:12:56 2006
@@ -1,141 +1,141 @@
-/**
- *
- * Copyright 2005-2006 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.activeio;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import junit.framework.TestCase;
-
-import org.apache.activeio.AcceptListener;
-import org.apache.activeio.Channel;
-import org.apache.activeio.ChannelFactory;
-import org.apache.activeio.adapter.AsyncToSyncChannel;
-import org.apache.activeio.adapter.SyncToAsyncChannel;
-import org.apache.activeio.packet.async.AsyncChannel;
-import org.apache.activeio.packet.async.AsyncChannelServer;
-import org.apache.activeio.packet.async.nio.NIOAsyncChannel;
-import org.apache.activeio.packet.async.nio.NIOAsyncChannelServer;
-import org.apache.activeio.packet.async.vmpipe.VMPipeAsyncChannelPipe;
-import org.apache.activeio.packet.async.vmpipe.VMPipeAsyncChannelServer;
-import org.apache.activeio.packet.sync.SyncChannel;
-import org.apache.activeio.packet.sync.SyncChannelServer;
-import org.apache.activeio.packet.sync.nio.NIOSyncChannel;
-import org.apache.activeio.packet.sync.nio.NIOSyncChannelServer;
-import org.apache.activeio.packet.sync.socket.SocketSyncChannel;
-import org.apache.activeio.packet.sync.socket.SocketSyncChannelServer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
-import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
-
-/**
- */
-public class ChannelFactoryTest extends TestCase {
-
-    static final Log log = LogFactory.getLog(ChannelFactoryTest.class);
-    static boolean aioDisabled = System.getProperty("disable.aio.tests", "false").equals("true");
-
-    ChannelFactory factory = new ChannelFactory();
-
-    private SyncChannelServer syncChannelServer;
-    private SyncChannel clientSynchChannel;
-    private SyncChannel serverSynchChannel;
-
-    private AsyncChannelServer asyncChannelServer;
-    private AsyncChannel clientAsyncChannel;
-    private AsyncChannel serverAsyncChannel;
-    
-    protected void setUp() throws Exception {
-        log.info("Running: "+getName());
-    }
-
-    public void testSocket() throws IOException, URISyntaxException, InterruptedException {
-        
-        createSynchObjects("socket://localhost:0");
-        assertNotNull( syncChannelServer.getAdapter(SocketSyncChannelServer.class) );
-        assertNotNull( clientSynchChannel.getAdapter(SocketSyncChannel.class) );
-        assertNotNull( serverSynchChannel.getAdapter(SocketSyncChannel.class) );
-        
-        createAsynchObjects("socket://localhost:0");
-        assertNotNull( asyncChannelServer.getAdapter(SocketSyncChannelServer.class) );
-        assertNotNull( clientAsyncChannel.getAdapter(SocketSyncChannel.class) );
-        assertNotNull( serverAsyncChannel.getAdapter(SocketSyncChannel.class) );
-        
-    }
-
-    public void testNIO() throws IOException, URISyntaxException, InterruptedException {
-        
-        createSynchObjects("nio://localhost:0");
-        assertNotNull( syncChannelServer.getAdapter(NIOSyncChannelServer.class) );
-        assertNotNull( clientSynchChannel.getAdapter(NIOSyncChannel.class) );
-        assertNotNull( serverSynchChannel.getAdapter(NIOSyncChannel.class) );
-        
-        createAsynchObjects("nio://localhost:0");
-        assertNotNull( asyncChannelServer.getAdapter(NIOAsyncChannelServer.class) );
-        assertNotNull( clientAsyncChannel.getAdapter(NIOAsyncChannel.class) );
-        assertNotNull( serverAsyncChannel.getAdapter(NIOAsyncChannel.class) );
-        
-    }    
-
-    public void testVMPipe() throws IOException, URISyntaxException, InterruptedException {
-        
-        createSynchObjects("vmpipe://localhost");
-        assertNotNull( syncChannelServer.getAdapter(VMPipeAsyncChannelServer.class) );
-        assertNotNull( clientSynchChannel.getAdapter(VMPipeAsyncChannelPipe.PipeChannel.class) );
-        assertNotNull( serverSynchChannel.getAdapter(VMPipeAsyncChannelPipe.PipeChannel.class) );
-        
-        createAsynchObjects("vmpipe://localhost");
-        assertNotNull( asyncChannelServer.getAdapter(VMPipeAsyncChannelServer.class) );
-        assertNotNull( clientAsyncChannel.getAdapter(VMPipeAsyncChannelPipe.PipeChannel.class) );
-        assertNotNull( serverAsyncChannel.getAdapter(VMPipeAsyncChannelPipe.PipeChannel.class) );
-        
-    }    
-    
-    private void createSynchObjects(String bindURI) throws IOException, URISyntaxException {
-        syncChannelServer = factory.bindSyncChannel(new URI(bindURI));
-        syncChannelServer.start();
-        clientSynchChannel = factory.openSyncChannel(syncChannelServer.getConnectURI());
-        serverSynchChannel = AsyncToSyncChannel.adapt( syncChannelServer.accept(1000*5) );
-        serverSynchChannel.dispose();        
-        clientSynchChannel.dispose();        
-        syncChannelServer.dispose();
-    }
-
-    private void createAsynchObjects(String bindURI) throws IOException, URISyntaxException, InterruptedException {
-        asyncChannelServer = factory.bindAsyncChannel(new URI(bindURI));
-        final CountDownLatch accepted = new CountDownLatch(1);
-        asyncChannelServer.setAcceptListener(new AcceptListener() {
-            public void onAccept(Channel channel) {
-                serverAsyncChannel = SyncToAsyncChannel.adapt(channel);
-                channel.dispose();
-                accepted.countDown();
-            }
-            public void onAcceptError(IOException error) {
-                error.printStackTrace();
-            }
-        });
-        asyncChannelServer.start();
-        clientAsyncChannel = factory.openAsyncChannel(asyncChannelServer.getConnectURI());
-        accepted.await(1000*10, TimeUnit.MILLISECONDS);
-        clientAsyncChannel.dispose();        
-        asyncChannelServer.dispose();
-    }
-
-}
+/**
+ *
+ * Copyright 2005-2006 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.activeio;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import junit.framework.TestCase;
+
+import org.apache.activeio.AcceptListener;
+import org.apache.activeio.Channel;
+import org.apache.activeio.ChannelFactory;
+import org.apache.activeio.adapter.AsyncToSyncChannel;
+import org.apache.activeio.adapter.SyncToAsyncChannel;
+import org.apache.activeio.packet.async.AsyncChannel;
+import org.apache.activeio.packet.async.AsyncChannelServer;
+import org.apache.activeio.packet.async.nio.NIOAsyncChannel;
+import org.apache.activeio.packet.async.nio.NIOAsyncChannelServer;
+import org.apache.activeio.packet.async.vmpipe.VMPipeAsyncChannelPipe;
+import org.apache.activeio.packet.async.vmpipe.VMPipeAsyncChannelServer;
+import org.apache.activeio.packet.sync.SyncChannel;
+import org.apache.activeio.packet.sync.SyncChannelServer;
+import org.apache.activeio.packet.sync.nio.NIOSyncChannel;
+import org.apache.activeio.packet.sync.nio.NIOSyncChannelServer;
+import org.apache.activeio.packet.sync.socket.SocketSyncChannel;
+import org.apache.activeio.packet.sync.socket.SocketSyncChannelServer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
+import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
+
+/**
+ */
+public class ChannelFactoryTest extends TestCase {
+
+    static final Log log = LogFactory.getLog(ChannelFactoryTest.class);
+    static boolean aioDisabled = System.getProperty("disable.aio.tests", "false").equals("true");
+
+    ChannelFactory factory = new ChannelFactory();
+
+    private SyncChannelServer syncChannelServer;
+    private SyncChannel clientSynchChannel;
+    private SyncChannel serverSynchChannel;
+
+    private AsyncChannelServer asyncChannelServer;
+    private AsyncChannel clientAsyncChannel;
+    private AsyncChannel serverAsyncChannel;
+    
+    protected void setUp() throws Exception {
+        log.info("Running: "+getName());
+    }
+
+    public void testSocket() throws IOException, URISyntaxException, InterruptedException {
+        
+        createSynchObjects("socket://localhost:0");
+        assertNotNull( syncChannelServer.getAdapter(SocketSyncChannelServer.class) );
+        assertNotNull( clientSynchChannel.getAdapter(SocketSyncChannel.class) );
+        assertNotNull( serverSynchChannel.getAdapter(SocketSyncChannel.class) );
+        
+        createAsynchObjects("socket://localhost:0");
+        assertNotNull( asyncChannelServer.getAdapter(SocketSyncChannelServer.class) );
+        assertNotNull( clientAsyncChannel.getAdapter(SocketSyncChannel.class) );
+        assertNotNull( serverAsyncChannel.getAdapter(SocketSyncChannel.class) );
+        
+    }
+
+    public void testNIO() throws IOException, URISyntaxException, InterruptedException {
+        
+        createSynchObjects("nio://localhost:0");
+        assertNotNull( syncChannelServer.getAdapter(NIOSyncChannelServer.class) );
+        assertNotNull( clientSynchChannel.getAdapter(NIOSyncChannel.class) );
+        assertNotNull( serverSynchChannel.getAdapter(NIOSyncChannel.class) );
+        
+        createAsynchObjects("nio://localhost:0");
+        assertNotNull( asyncChannelServer.getAdapter(NIOAsyncChannelServer.class) );
+        assertNotNull( clientAsyncChannel.getAdapter(NIOAsyncChannel.class) );
+        assertNotNull( serverAsyncChannel.getAdapter(NIOAsyncChannel.class) );
+        
+    }    
+
+    public void testVMPipe() throws IOException, URISyntaxException, InterruptedException {
+        
+        createSynchObjects("vmpipe://localhost");
+        assertNotNull( syncChannelServer.getAdapter(VMPipeAsyncChannelServer.class) );
+        assertNotNull( clientSynchChannel.getAdapter(VMPipeAsyncChannelPipe.PipeChannel.class) );
+        assertNotNull( serverSynchChannel.getAdapter(VMPipeAsyncChannelPipe.PipeChannel.class) );
+        
+        createAsynchObjects("vmpipe://localhost");
+        assertNotNull( asyncChannelServer.getAdapter(VMPipeAsyncChannelServer.class) );
+        assertNotNull( clientAsyncChannel.getAdapter(VMPipeAsyncChannelPipe.PipeChannel.class) );
+        assertNotNull( serverAsyncChannel.getAdapter(VMPipeAsyncChannelPipe.PipeChannel.class) );
+        
+    }    
+    
+    private void createSynchObjects(String bindURI) throws IOException, URISyntaxException {
+        syncChannelServer = factory.bindSyncChannel(new URI(bindURI));
+        syncChannelServer.start();
+        clientSynchChannel = factory.openSyncChannel(syncChannelServer.getConnectURI());
+        serverSynchChannel = AsyncToSyncChannel.adapt( syncChannelServer.accept(1000*5) );
+        serverSynchChannel.dispose();        
+        clientSynchChannel.dispose();        
+        syncChannelServer.dispose();
+    }
+
+    private void createAsynchObjects(String bindURI) throws IOException, URISyntaxException, InterruptedException {
+        asyncChannelServer = factory.bindAsyncChannel(new URI(bindURI));
+        final CountDownLatch accepted = new CountDownLatch(1);
+        asyncChannelServer.setAcceptListener(new AcceptListener() {
+            public void onAccept(Channel channel) {
+                serverAsyncChannel = SyncToAsyncChannel.adapt(channel);
+                channel.dispose();
+                accepted.countDown();
+            }
+            public void onAcceptError(IOException error) {
+                error.printStackTrace();
+            }
+        });
+        asyncChannelServer.start();
+        clientAsyncChannel = factory.openAsyncChannel(asyncChannelServer.getConnectURI());
+        accepted.await(1000*10, TimeUnit.MILLISECONDS);
+        clientAsyncChannel.dispose();        
+        asyncChannelServer.dispose();
+    }
+
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/ChannelFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/PacketDataTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/PacketDataTest.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/PacketDataTest.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/PacketDataTest.java Tue Feb 21 15:12:56 2006
@@ -1,44 +1,44 @@
-/**
- *
- * Copyright 2005-2006 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.activeio;
-
-import java.io.IOException;
-
-import org.apache.activeio.packet.ByteArrayPacket;
-import org.apache.activeio.packet.PacketData;
-
-import junit.framework.TestCase;
-
-/**
- */
-public class PacketDataTest extends TestCase {
-
-    ByteArrayPacket packet = new ByteArrayPacket(new byte[200]);
-    PacketData data = new PacketData(packet);
-    
-    public void testInteger() throws IOException {
-        data.writeInt(Integer.MAX_VALUE);
-        data.writeInt(Integer.MIN_VALUE);
-        data.writeInt(551);
-        
-        packet.flip();
-        assertEquals(Integer.MAX_VALUE, data.readInt());
-        assertEquals(Integer.MIN_VALUE, data.readInt());      
-        assertEquals(551, data.readInt());      
-    }
-    
-}
+/**
+ *
+ * Copyright 2005-2006 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.activeio;
+
+import java.io.IOException;
+
+import org.apache.activeio.packet.ByteArrayPacket;
+import org.apache.activeio.packet.PacketData;
+
+import junit.framework.TestCase;
+
+/**
+ */
+public class PacketDataTest extends TestCase {
+
+    ByteArrayPacket packet = new ByteArrayPacket(new byte[200]);
+    PacketData data = new PacketData(packet);
+    
+    public void testInteger() throws IOException {
+        data.writeInt(Integer.MAX_VALUE);
+        data.writeInt(Integer.MIN_VALUE);
+        data.writeInt(551);
+        
+        packet.flip();
+        assertEquals(Integer.MAX_VALUE, data.readInt());
+        assertEquals(Integer.MIN_VALUE, data.readInt());      
+        assertEquals(551, data.readInt());      
+    }
+    
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/PacketDataTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/JournalPerfToolSupport.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/JournalPerfToolSupport.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/JournalPerfToolSupport.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/JournalPerfToolSupport.java Tue Feb 21 15:12:56 2006
@@ -1,164 +1,164 @@
-/**
- *
- * Copyright 2005-2006 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.activeio.journal;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Random;
-
-import org.apache.activeio.journal.InvalidRecordLocationException;
-import org.apache.activeio.journal.Journal;
-import org.apache.activeio.journal.JournalEventListener;
-import org.apache.activeio.journal.RecordLocation;
-import org.apache.activeio.packet.ByteArrayPacket;
-
-/**
- * Provides the base class uses to run performance tests against a Journal.
- * Should be subclassed to customize for specific journal implementation.
- * 
- * @version $Revision: 1.1 $
- */
-abstract public class JournalPerfToolSupport implements JournalEventListener {
-
-	private JournalStatsFilter journal;
-	private Random random = new Random();
-	private byte data[];
-	private int workerCount=0;	
-	private PrintWriter statWriter;
-	// Performance test Options
-	
-	// The output goes here:
-	protected File journalDirectory = new File("journal-logs");
-	protected File statCSVFile = new File("stats.csv");;
-
-	// Controls how often we start a new batch of workers.
-	protected int workerIncrement=20;
-	protected long incrementDelay=1000*20;
-	protected boolean verbose=true;
-
-	// Worker configuration.
-	protected int recordSize=1024;
-	protected int syncFrequency=15;	
-	protected int workerThinkTime=100;
-
-    private final class Worker implements Runnable {
-		public void run() {
-			int i=random.nextInt()%syncFrequency;
-			while(true) {
-				boolean sync=false;
-				
-				if( syncFrequency>=0 && (i%syncFrequency)==0 ) {
-					sync=true;
-				}				
-				try {
-					journal.write(new ByteArrayPacket(data), sync);
-					Thread.sleep(workerThinkTime);
-				} catch (Exception e) {
-					e.printStackTrace();
-					return;
-				}
-				i++;						
-			}					
-		}
-	}	
-	
-    /**
-     * @throws IOException
-	 * 
-	 */
-	protected void exec() throws Exception {
-		
-		System.out.println("Client threads write records using: Record Size: "+recordSize+", Sync Frequency: "+syncFrequency+", Worker Think Time: "+workerThinkTime);
-
-		// Create the record and fill it with some values.
-		data = new byte[recordSize];
-		for (int i = 0; i < data.length; i++) {
-			data[i] = (byte)i;
-		}
-		
-		if( statCSVFile!=null ) {
-			statWriter = new PrintWriter(new FileOutputStream(statCSVFile));
-			statWriter.println("Threads,Throughput (k/s),Forcd write latency (ms),Throughput (records/s)");
-		}
-		
-        if( journalDirectory.exists() ) {
-        	deleteDir(journalDirectory);
-        }		
-        journal = new JournalStatsFilter(createJournal()).enableDetailedStats(verbose);
-        journal.setJournalEventListener(this);
-		
-        try {        	
-        	
-        	// Wait a little to see the worker affect the stats.
-        	// Increment the number of workers every few seconds.
-        	while(true) {
-        		System.out.println("Starting "+workerIncrement+" Workers...");
-            	for(int i=0;i <workerIncrement;i++) {
-                	new Thread(new Worker()).start();
-                	workerCount++;
-            	}
-            				
-            	// Wait a little to see the worker affect the stats.
-            	System.out.println("Waiting "+(incrementDelay/1000)+" seconds before next Stat sample.");
-            	Thread.sleep(incrementDelay);
-            	displayStats();
-            	journal.reset();
-        	}
-        	
-        	
-        } finally {
-        	journal.close();
-        }
-	}
-
-	private void displayStats() {		
-		System.out.println("Stats at "+workerCount+" workers.");
-		System.out.println(journal);        	
-		if( statWriter!= null ) {
-			statWriter.println(""+workerCount+","+journal.getThroughputKps()+","+journal.getAvgSyncedLatencyMs()+","+journal.getThroughputRps());
-			statWriter.flush();
-		}
-	}
-
-	/**
-	 * @return
-	 */
-	abstract public Journal createJournal() throws Exception;
-
-	static private void deleteDir(File f) {
-		File[] files = f.listFiles();
-		for (int i = 0; i < files.length; i++) {
-			File file = files[i];
-			file.delete();
-		}
-		f.delete();
-	}
-    
-    
-	public void overflowNotification(RecordLocation safeLocation) {
-		try {
-			System.out.println("Mark set: "+safeLocation);
-			journal.setMark(safeLocation, false);
-		} catch (InvalidRecordLocationException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}		
-	}
-}
+/**
+ *
+ * Copyright 2005-2006 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.activeio.journal;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Random;
+
+import org.apache.activeio.journal.InvalidRecordLocationException;
+import org.apache.activeio.journal.Journal;
+import org.apache.activeio.journal.JournalEventListener;
+import org.apache.activeio.journal.RecordLocation;
+import org.apache.activeio.packet.ByteArrayPacket;
+
+/**
+ * Provides the base class uses to run performance tests against a Journal.
+ * Should be subclassed to customize for specific journal implementation.
+ * 
+ * @version $Revision: 1.1 $
+ */
+abstract public class JournalPerfToolSupport implements JournalEventListener {
+
+	private JournalStatsFilter journal;
+	private Random random = new Random();
+	private byte data[];
+	private int workerCount=0;	
+	private PrintWriter statWriter;
+	// Performance test Options
+	
+	// The output goes here:
+	protected File journalDirectory = new File("journal-logs");
+	protected File statCSVFile = new File("stats.csv");;
+
+	// Controls how often we start a new batch of workers.
+	protected int workerIncrement=20;
+	protected long incrementDelay=1000*20;
+	protected boolean verbose=true;
+
+	// Worker configuration.
+	protected int recordSize=1024;
+	protected int syncFrequency=15;	
+	protected int workerThinkTime=100;
+
+    private final class Worker implements Runnable {
+		public void run() {
+			int i=random.nextInt()%syncFrequency;
+			while(true) {
+				boolean sync=false;
+				
+				if( syncFrequency>=0 && (i%syncFrequency)==0 ) {
+					sync=true;
+				}				
+				try {
+					journal.write(new ByteArrayPacket(data), sync);
+					Thread.sleep(workerThinkTime);
+				} catch (Exception e) {
+					e.printStackTrace();
+					return;
+				}
+				i++;						
+			}					
+		}
+	}	
+	
+    /**
+     * @throws IOException
+	 * 
+	 */
+	protected void exec() throws Exception {
+		
+		System.out.println("Client threads write records using: Record Size: "+recordSize+", Sync Frequency: "+syncFrequency+", Worker Think Time: "+workerThinkTime);
+
+		// Create the record and fill it with some values.
+		data = new byte[recordSize];
+		for (int i = 0; i < data.length; i++) {
+			data[i] = (byte)i;
+		}
+		
+		if( statCSVFile!=null ) {
+			statWriter = new PrintWriter(new FileOutputStream(statCSVFile));
+			statWriter.println("Threads,Throughput (k/s),Forcd write latency (ms),Throughput (records/s)");
+		}
+		
+        if( journalDirectory.exists() ) {
+        	deleteDir(journalDirectory);
+        }		
+        journal = new JournalStatsFilter(createJournal()).enableDetailedStats(verbose);
+        journal.setJournalEventListener(this);
+		
+        try {        	
+        	
+        	// Wait a little to see the worker affect the stats.
+        	// Increment the number of workers every few seconds.
+        	while(true) {
+        		System.out.println("Starting "+workerIncrement+" Workers...");
+            	for(int i=0;i <workerIncrement;i++) {
+                	new Thread(new Worker()).start();
+                	workerCount++;
+            	}
+            				
+            	// Wait a little to see the worker affect the stats.
+            	System.out.println("Waiting "+(incrementDelay/1000)+" seconds before next Stat sample.");
+            	Thread.sleep(incrementDelay);
+            	displayStats();
+            	journal.reset();
+        	}
+        	
+        	
+        } finally {
+        	journal.close();
+        }
+	}
+
+	private void displayStats() {		
+		System.out.println("Stats at "+workerCount+" workers.");
+		System.out.println(journal);        	
+		if( statWriter!= null ) {
+			statWriter.println(""+workerCount+","+journal.getThroughputKps()+","+journal.getAvgSyncedLatencyMs()+","+journal.getThroughputRps());
+			statWriter.flush();
+		}
+	}
+
+	/**
+	 * @return
+	 */
+	abstract public Journal createJournal() throws Exception;
+
+	static private void deleteDir(File f) {
+		File[] files = f.listFiles();
+		for (int i = 0; i < files.length; i++) {
+			File file = files[i];
+			file.delete();
+		}
+		f.delete();
+	}
+    
+    
+	public void overflowNotification(RecordLocation safeLocation) {
+		try {
+			System.out.println("Mark set: "+safeLocation);
+			journal.setMark(safeLocation, false);
+		} catch (InvalidRecordLocationException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}		
+	}
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/JournalPerfToolSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/JournalStatsFilter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/JournalStatsFilter.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/JournalStatsFilter.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/JournalStatsFilter.java Tue Feb 21 15:12:56 2006
@@ -1,265 +1,265 @@
-/**
- *
- * Copyright 2005-2006 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.activeio.journal;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-import org.apache.activeio.packet.Packet;
-import org.apache.activeio.stats.CountStatisticImpl;
-import org.apache.activeio.stats.IndentPrinter;
-import org.apache.activeio.stats.TimeStatisticImpl;
-
-/**
- * A Journal filter that captures performance statistics of the filtered Journal.
- * 
- * @version $Revision: 1.1 $
- */
-public class JournalStatsFilter implements Journal {
-	
-	private final TimeStatisticImpl writeLatency = new TimeStatisticImpl("writeLatency", "The amount of time that is spent waiting for a record to be written to the Journal"); 
-	private final CountStatisticImpl writeRecordsCounter = new CountStatisticImpl("writeRecordsCounter","The number of records that have been written by the Journal");
-	private final CountStatisticImpl writeBytesCounter = new CountStatisticImpl("writeBytesCounter","The number of bytes that have been written by the Journal");
-	private final TimeStatisticImpl synchedWriteLatency = new TimeStatisticImpl(writeLatency, "synchedWriteLatency", "The amount of time that is spent waiting for a synch record to be written to the Journal"); 
-	private final TimeStatisticImpl unsynchedWriteLatency = new TimeStatisticImpl(writeLatency, "unsynchedWriteLatency", "The amount of time that is spent waiting for a non synch record to be written to the Journal"); 	
-	private final TimeStatisticImpl readLatency = new TimeStatisticImpl("readLatency", "The amount of time that is spent waiting for a record to be read from the Journal"); 
-	private final CountStatisticImpl readBytesCounter = new CountStatisticImpl("readBytesCounter","The number of bytes that have been read by the Journal");
-	
-	private final Journal next;
-	private boolean detailedStats;
-
-	
-	/**
-	 * Creates a JournalStatsFilter that captures performance information of <code>next</next>. 
-	 * @param next
-	 */
-	public JournalStatsFilter(Journal next) {
-		this.next = next;
-	}
-	
-	/**
-	 * @see org.codehaus.activemq.journal.Journal#write(byte[], boolean)
-	 */
-	public RecordLocation write(Packet data, boolean sync) throws IOException {
-		//writeWaitTimeStat
-		long start = System.currentTimeMillis();
-		RecordLocation answer = next.write(data, sync);
-		long end = System.currentTimeMillis();
-		
-		writeRecordsCounter.increment();
-		writeBytesCounter.add(data.remaining());
-		if( sync )
-			synchedWriteLatency.addTime(end-start);
-		else 
-			unsynchedWriteLatency.addTime(end-start);
-		return answer;
-	}
-
-	/**
-	 * @see org.codehaus.activemq.journal.Journal#read(org.codehaus.activemq.journal.RecordLocation)
-	 */
-	public Packet read(RecordLocation location)
-			throws InvalidRecordLocationException, IOException {
-		
-		long start = System.currentTimeMillis();
-		Packet answer = next.read(location);		
-		long end = System.currentTimeMillis();
-		
-		readBytesCounter.add(answer.remaining());
-		readLatency.addTime(end-start);
-		return answer;
-	}
-
-	/**
-	 * @see org.codehaus.activemq.journal.Journal#setMark(org.codehaus.activemq.journal.RecordLocation, boolean)
-	 */
-	public void setMark(RecordLocation recordLocator, boolean force)
-			throws InvalidRecordLocationException, IOException {
-		next.setMark(recordLocator, force);
-	}
-
-	/**
-	 * @see org.codehaus.activemq.journal.Journal#getMark()
-	 */
-	public RecordLocation getMark() {
-		return next.getMark();
-	}
-
-	/**
-	 * @see org.codehaus.activemq.journal.Journal#close()
-	 */
-	public void close() throws IOException {
-		next.close();
-	}
-	
-	/**
-	 * @see org.codehaus.activemq.journal.Journal#setJournalEventListener(org.codehaus.activemq.journal.JournalEventListener)
-	 */
-	public void setJournalEventListener(JournalEventListener eventListener) {
-	    next.setJournalEventListener(eventListener);
-	}
-
-	/**
-	 * @see org.codehaus.activemq.journal.Journal#getNextRecordLocation(org.codehaus.activemq.journal.RecordLocation)
-	 */
-	public RecordLocation getNextRecordLocation(RecordLocation lastLocation)
-			throws IOException, InvalidRecordLocationException {		
-		return next.getNextRecordLocation(lastLocation);
-	}
-	
-	/**
-	 * Writes the gathered statistics to the <code>out</code> object.
-	 * 
-	 * @param out
-	 */
-    public void dump(IndentPrinter out) {
-        out.printIndent();
-        out.println("Journal Stats {");        
-        out.incrementIndent();
-        out.printIndent();
-        out.println("Throughput           : "+ getThroughputKps() +" k/s and " + getThroughputRps() +" records/s" );
-        out.printIndent();
-        out.println("Latency with force   : "+ getAvgSyncedLatencyMs() +" ms"  );
-        out.printIndent();
-        out.println("Latency without force: "+ getAvgUnSyncedLatencyMs() +" ms"  );
-
-        out.printIndent();
-        out.println("Raw Stats {");
-        out.incrementIndent();
-                
-        out.printIndent();
-        out.println(writeRecordsCounter);
-        out.printIndent();
-        out.println(writeBytesCounter);
-        out.printIndent();
-        out.println(writeLatency);
-        out.incrementIndent();
-        out.printIndent();
-        out.println(synchedWriteLatency);
-        out.printIndent();
-        out.println(unsynchedWriteLatency);
-        out.decrementIndent();
-
-        out.printIndent();
-        out.println(readBytesCounter);
-        
-        out.printIndent();
-        out.println(readLatency);        
-        out.decrementIndent();
-        out.printIndent();
-        out.println("}");
-        
-        out.decrementIndent();
-        out.printIndent();
-        out.println("}");
-
-    }
-
-    /**
-     * Dumps the stats to a String.
-     * 
-     * @see java.lang.Object#toString()
-     */
-	public String toString() {
-		if( detailedStats ) {
-			StringWriter w = new StringWriter();
-			PrintWriter pw = new PrintWriter(w);		
-			dump(new IndentPrinter(pw, "  "));
-			return w.getBuffer().toString();
-		} else {
-			StringWriter w = new StringWriter();
-			PrintWriter pw = new PrintWriter(w);
-			IndentPrinter out = new IndentPrinter(pw, "  ");
-	        out.println("Throughput           : "+ getThroughputKps() +" k/s and " + getThroughputRps() +" records/s");
-	        out.printIndent();
-	        out.println("Latency with force   : "+getAvgSyncedLatencyMs()+" ms"  );
-	        out.printIndent();
-	        out.println("Latency without force: "+getAvgUnSyncedLatencyMs()+" ms"  );
-			return w.getBuffer().toString();			
-		}
-    }
-
-	/**
-	 * @param detailedStats true if details stats should be displayed by <code>toString()</code> and <code>dump</code>
-	 * @return
-	 */
-	public JournalStatsFilter enableDetailedStats(boolean detailedStats) {		
-		this.detailedStats = detailedStats;
-		return this;
-	}
-
-	/**
-	 * Gets the average throughput in k/s.
-	 * 
-	 * @return the average throughput in k/s.
-	 */
-	public double getThroughputKps() {
-		 long totalTime = writeBytesCounter.getLastSampleTime()-writeBytesCounter.getStartTime(); 
-		 return (((double)writeBytesCounter.getCount()/(double)totalTime)/(double)1024)*1000;
-	}
-
-	/**
-	 * Gets the average throughput in records/s.
-	 * 
-	 * @return the average throughput in records/s.
-	 */
-	public double getThroughputRps() {
-		 long totalTime = writeRecordsCounter.getLastSampleTime()-writeRecordsCounter.getStartTime(); 
-		 return (((double)writeRecordsCounter.getCount()/(double)totalTime))*1000;
-	}
-
-	/**
-	 * Gets the average number of writes done per second
-	 * 
-	 * @return the average number of writes in w/s.
-	 */
-	public double getWritesPerSecond() {
-		 return writeLatency.getAveragePerSecond();
-	}
-
-	/**
-	 * Gets the average sync write latency in ms.
-	 * 
-	 * @return the average sync write latency in ms.
-	 */
-	public double getAvgSyncedLatencyMs() {
-		return synchedWriteLatency.getAverageTime();
-	}
-
-	/**
-	 * Gets the average non sync write latency in ms.
-	 * 
-	 * @return the average non sync write latency in ms.
-	 */
-	public double getAvgUnSyncedLatencyMs() {
-		return unsynchedWriteLatency.getAverageTime();
-	}
-	
-	/**
-	 * Resets the stats sample.
-	 */
-	public void reset() {
-		writeLatency.reset(); 
-		writeBytesCounter.reset();
-		writeRecordsCounter.reset();
-		synchedWriteLatency.reset(); 
-		unsynchedWriteLatency.reset(); 	
-		readLatency.reset(); 
-		readBytesCounter.reset();
-	}
+/**
+ *
+ * Copyright 2005-2006 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.activeio.journal;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.apache.activeio.packet.Packet;
+import org.apache.activeio.stats.CountStatisticImpl;
+import org.apache.activeio.stats.IndentPrinter;
+import org.apache.activeio.stats.TimeStatisticImpl;
+
+/**
+ * A Journal filter that captures performance statistics of the filtered Journal.
+ * 
+ * @version $Revision: 1.1 $
+ */
+public class JournalStatsFilter implements Journal {
+	
+	private final TimeStatisticImpl writeLatency = new TimeStatisticImpl("writeLatency", "The amount of time that is spent waiting for a record to be written to the Journal"); 
+	private final CountStatisticImpl writeRecordsCounter = new CountStatisticImpl("writeRecordsCounter","The number of records that have been written by the Journal");
+	private final CountStatisticImpl writeBytesCounter = new CountStatisticImpl("writeBytesCounter","The number of bytes that have been written by the Journal");
+	private final TimeStatisticImpl synchedWriteLatency = new TimeStatisticImpl(writeLatency, "synchedWriteLatency", "The amount of time that is spent waiting for a synch record to be written to the Journal"); 
+	private final TimeStatisticImpl unsynchedWriteLatency = new TimeStatisticImpl(writeLatency, "unsynchedWriteLatency", "The amount of time that is spent waiting for a non synch record to be written to the Journal"); 	
+	private final TimeStatisticImpl readLatency = new TimeStatisticImpl("readLatency", "The amount of time that is spent waiting for a record to be read from the Journal"); 
+	private final CountStatisticImpl readBytesCounter = new CountStatisticImpl("readBytesCounter","The number of bytes that have been read by the Journal");
+	
+	private final Journal next;
+	private boolean detailedStats;
+
+	
+	/**
+	 * Creates a JournalStatsFilter that captures performance information of <code>next</next>. 
+	 * @param next
+	 */
+	public JournalStatsFilter(Journal next) {
+		this.next = next;
+	}
+	
+	/**
+	 * @see org.codehaus.activemq.journal.Journal#write(byte[], boolean)
+	 */
+	public RecordLocation write(Packet data, boolean sync) throws IOException {
+		//writeWaitTimeStat
+		long start = System.currentTimeMillis();
+		RecordLocation answer = next.write(data, sync);
+		long end = System.currentTimeMillis();
+		
+		writeRecordsCounter.increment();
+		writeBytesCounter.add(data.remaining());
+		if( sync )
+			synchedWriteLatency.addTime(end-start);
+		else 
+			unsynchedWriteLatency.addTime(end-start);
+		return answer;
+	}
+
+	/**
+	 * @see org.codehaus.activemq.journal.Journal#read(org.codehaus.activemq.journal.RecordLocation)
+	 */
+	public Packet read(RecordLocation location)
+			throws InvalidRecordLocationException, IOException {
+		
+		long start = System.currentTimeMillis();
+		Packet answer = next.read(location);		
+		long end = System.currentTimeMillis();
+		
+		readBytesCounter.add(answer.remaining());
+		readLatency.addTime(end-start);
+		return answer;
+	}
+
+	/**
+	 * @see org.codehaus.activemq.journal.Journal#setMark(org.codehaus.activemq.journal.RecordLocation, boolean)
+	 */
+	public void setMark(RecordLocation recordLocator, boolean force)
+			throws InvalidRecordLocationException, IOException {
+		next.setMark(recordLocator, force);
+	}
+
+	/**
+	 * @see org.codehaus.activemq.journal.Journal#getMark()
+	 */
+	public RecordLocation getMark() {
+		return next.getMark();
+	}
+
+	/**
+	 * @see org.codehaus.activemq.journal.Journal#close()
+	 */
+	public void close() throws IOException {
+		next.close();
+	}
+	
+	/**
+	 * @see org.codehaus.activemq.journal.Journal#setJournalEventListener(org.codehaus.activemq.journal.JournalEventListener)
+	 */
+	public void setJournalEventListener(JournalEventListener eventListener) {
+	    next.setJournalEventListener(eventListener);
+	}
+
+	/**
+	 * @see org.codehaus.activemq.journal.Journal#getNextRecordLocation(org.codehaus.activemq.journal.RecordLocation)
+	 */
+	public RecordLocation getNextRecordLocation(RecordLocation lastLocation)
+			throws IOException, InvalidRecordLocationException {		
+		return next.getNextRecordLocation(lastLocation);
+	}
+	
+	/**
+	 * Writes the gathered statistics to the <code>out</code> object.
+	 * 
+	 * @param out
+	 */
+    public void dump(IndentPrinter out) {
+        out.printIndent();
+        out.println("Journal Stats {");        
+        out.incrementIndent();
+        out.printIndent();
+        out.println("Throughput           : "+ getThroughputKps() +" k/s and " + getThroughputRps() +" records/s" );
+        out.printIndent();
+        out.println("Latency with force   : "+ getAvgSyncedLatencyMs() +" ms"  );
+        out.printIndent();
+        out.println("Latency without force: "+ getAvgUnSyncedLatencyMs() +" ms"  );
+
+        out.printIndent();
+        out.println("Raw Stats {");
+        out.incrementIndent();
+                
+        out.printIndent();
+        out.println(writeRecordsCounter);
+        out.printIndent();
+        out.println(writeBytesCounter);
+        out.printIndent();
+        out.println(writeLatency);
+        out.incrementIndent();
+        out.printIndent();
+        out.println(synchedWriteLatency);
+        out.printIndent();
+        out.println(unsynchedWriteLatency);
+        out.decrementIndent();
+
+        out.printIndent();
+        out.println(readBytesCounter);
+        
+        out.printIndent();
+        out.println(readLatency);        
+        out.decrementIndent();
+        out.printIndent();
+        out.println("}");
+        
+        out.decrementIndent();
+        out.printIndent();
+        out.println("}");
+
+    }
+
+    /**
+     * Dumps the stats to a String.
+     * 
+     * @see java.lang.Object#toString()
+     */
+	public String toString() {
+		if( detailedStats ) {
+			StringWriter w = new StringWriter();
+			PrintWriter pw = new PrintWriter(w);		
+			dump(new IndentPrinter(pw, "  "));
+			return w.getBuffer().toString();
+		} else {
+			StringWriter w = new StringWriter();
+			PrintWriter pw = new PrintWriter(w);
+			IndentPrinter out = new IndentPrinter(pw, "  ");
+	        out.println("Throughput           : "+ getThroughputKps() +" k/s and " + getThroughputRps() +" records/s");
+	        out.printIndent();
+	        out.println("Latency with force   : "+getAvgSyncedLatencyMs()+" ms"  );
+	        out.printIndent();
+	        out.println("Latency without force: "+getAvgUnSyncedLatencyMs()+" ms"  );
+			return w.getBuffer().toString();			
+		}
+    }
+
+	/**
+	 * @param detailedStats true if details stats should be displayed by <code>toString()</code> and <code>dump</code>
+	 * @return
+	 */
+	public JournalStatsFilter enableDetailedStats(boolean detailedStats) {		
+		this.detailedStats = detailedStats;
+		return this;
+	}
+
+	/**
+	 * Gets the average throughput in k/s.
+	 * 
+	 * @return the average throughput in k/s.
+	 */
+	public double getThroughputKps() {
+		 long totalTime = writeBytesCounter.getLastSampleTime()-writeBytesCounter.getStartTime(); 
+		 return (((double)writeBytesCounter.getCount()/(double)totalTime)/(double)1024)*1000;
+	}
+
+	/**
+	 * Gets the average throughput in records/s.
+	 * 
+	 * @return the average throughput in records/s.
+	 */
+	public double getThroughputRps() {
+		 long totalTime = writeRecordsCounter.getLastSampleTime()-writeRecordsCounter.getStartTime(); 
+		 return (((double)writeRecordsCounter.getCount()/(double)totalTime))*1000;
+	}
+
+	/**
+	 * Gets the average number of writes done per second
+	 * 
+	 * @return the average number of writes in w/s.
+	 */
+	public double getWritesPerSecond() {
+		 return writeLatency.getAveragePerSecond();
+	}
+
+	/**
+	 * Gets the average sync write latency in ms.
+	 * 
+	 * @return the average sync write latency in ms.
+	 */
+	public double getAvgSyncedLatencyMs() {
+		return synchedWriteLatency.getAverageTime();
+	}
+
+	/**
+	 * Gets the average non sync write latency in ms.
+	 * 
+	 * @return the average non sync write latency in ms.
+	 */
+	public double getAvgUnSyncedLatencyMs() {
+		return unsynchedWriteLatency.getAverageTime();
+	}
+	
+	/**
+	 * Resets the stats sample.
+	 */
+	public void reset() {
+		writeLatency.reset(); 
+		writeBytesCounter.reset();
+		writeRecordsCounter.reset();
+		synchedWriteLatency.reset(); 
+		unsynchedWriteLatency.reset(); 	
+		readLatency.reset(); 
+		readBytesCounter.reset();
+	}
 }

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/JournalStatsFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/DataStruturesTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/DataStruturesTest.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/DataStruturesTest.java (original)
+++ incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/DataStruturesTest.java Tue Feb 21 15:12:56 2006
@@ -1,53 +1,53 @@
-/**
- *
- * Copyright 2005-2006 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.activeio.journal.active;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-
-import org.apache.activeio.journal.active.Location;
-
-import junit.framework.TestCase;
-
-/**
- * Tests the data structures used JournalImpl
- * 
- * @version $Revision: 1.1 $
- */
-public class DataStruturesTest extends TestCase {
-        
-    synchronized public void testRecordLocationImplComparison() throws IOException {
-        Location l1 = new Location(0, 1); 
-        Location l2 = new Location(0, 2);
-        Location l3 = new Location(0, 3);
-
-        assertTrue( l1.compareTo(l2)<0 );
-        
-        // Sort them using a list.  Put them in the wrong order.
-        ArrayList l = new ArrayList();
-        l.add(l2);
-        l.add(l3);
-        l.add(l1);        
-        Collections.sort(l);
-        
-        // Did they get sorted to the correct order?
-        assertSame( l.get(0), l1 );
-        assertSame( l.get(1), l2 );
-        assertSame( l.get(2), l3 );
-    }
-}
+/**
+ *
+ * Copyright 2005-2006 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.activeio.journal.active;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+
+import org.apache.activeio.journal.active.Location;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the data structures used JournalImpl
+ * 
+ * @version $Revision: 1.1 $
+ */
+public class DataStruturesTest extends TestCase {
+        
+    synchronized public void testRecordLocationImplComparison() throws IOException {
+        Location l1 = new Location(0, 1); 
+        Location l2 = new Location(0, 2);
+        Location l3 = new Location(0, 3);
+
+        assertTrue( l1.compareTo(l2)<0 );
+        
+        // Sort them using a list.  Put them in the wrong order.
+        ArrayList l = new ArrayList();
+        l.add(l2);
+        l.add(l3);
+        l.add(l1);        
+        Collections.sort(l);
+        
+        // Did they get sorted to the correct order?
+        assertSame( l.get(0), l1 );
+        assertSame( l.get(1), l2 );
+        assertSame( l.get(2), l3 );
+    }
+}

Propchange: incubator/activemq/trunk/activeio/activeio-core/src/test/java/org/apache/activeio/journal/active/DataStruturesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message