summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Donald Kennedy <grkvlt@apache.org>2010-10-03 16:02:42 +0000
committerAndrew Donald Kennedy <grkvlt@apache.org>2010-10-03 16:02:42 +0000
commita3625d8ed5d7edfbd41acf38130d3f574f1c0aa5 (patch)
tree60f8230476e27245ec190a402274f077fff0e3c4
parenta5b1a1073e2596da8b5fbcd24769aec87107d212 (diff)
downloadqpid-python-a3625d8ed5d7edfbd41acf38130d3f574f1c0aa5.tar.gz
QPID-2839 Add channel (CHN) Operational Loggin on 0-10
Committed patch from SorinS <ssuciu@gmail.com> git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1003985 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java26
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java2
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java4
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java50
-rwxr-xr-xqpid/java/test-profiles/Java010Excludes4
5 files changed, 58 insertions, 28 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java
index 71add9c097..c53f65f302 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/transport/ServerSession.java
@@ -33,7 +33,9 @@ import org.apache.qpid.server.configuration.ConnectionConfig;
import org.apache.qpid.server.configuration.SessionConfig;
import org.apache.qpid.server.configuration.SessionConfigType;
import org.apache.qpid.server.logging.LogSubject;
-import org.apache.qpid.server.logging.subjects.ConnectionLogSubject;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.actors.GenericActor;
+import org.apache.qpid.server.logging.messages.ChannelMessages;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.BaseQueue;
@@ -55,6 +57,7 @@ import org.apache.qpid.transport.Range;
import org.apache.qpid.transport.RangeSet;
import org.apache.qpid.transport.Session;
import org.apache.qpid.transport.SessionDelegate;
+import org.apache.qpid.transport.Session.State;
import java.lang.ref.WeakReference;
import java.security.Principal;
@@ -121,6 +124,16 @@ public class ServerSession extends Session implements PrincipalHolder, SessionCo
this(connection, delegate, name, expiry, ((ServerConnection)connection).getConfig());
}
+ protected void setState(State state)
+ {
+ super.setState(state);
+
+ if (state == State.OPEN)
+ {
+ GenericActor.getInstance(this).message(ChannelMessages.CREATE());
+ }
+ }
+
public ServerSession(Connection connection, SessionDelegate delegate, Binary name, long expiry, ConnectionConfig connConfig)
{
super(connection, delegate, name, expiry);
@@ -337,7 +350,8 @@ public class ServerSession extends Session implements PrincipalHolder, SessionCo
{
task.doTask(this);
}
-
+
+ CurrentActor.get().message(getLogSubject(), ChannelMessages.CLOSE());
}
@Override
@@ -590,10 +604,12 @@ public class ServerSession extends Session implements PrincipalHolder, SessionCo
public String toLogString()
{
return " [" +
- MessageFormat.format(CHANNEL_FORMAT, getId().toString(), getClientID(),
+ MessageFormat.format(CHANNEL_FORMAT,
+ getConnection().getConnectionId(),
+ getClientID(),
((ProtocolEngine) _connectionConfig).getRemoteAddress().toString(),
- this.getVirtualHost().getName(),
- this.getChannel())
+ getVirtualHost().getName(),
+ getChannel())
+ "] ";
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
index 174dc54a72..fa3c1737a7 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
@@ -404,7 +404,7 @@ public class Connection extends ConnectionInvoker
{
synchronized (lock)
{
- for (int i = 0; i < getChannelMax(); i++)
+ for (int i = 1; i <= getChannelMax(); i++)
{
if (!channels.containsKey(i))
{
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java
index 257f1e495a..eba46e9b1b 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Session.java
@@ -58,7 +58,7 @@ public class Session extends SessionInvoker
private static final Logger log = Logger.get(Session.class);
- enum State { NEW, DETACHED, RESUMING, OPEN, CLOSING, CLOSED }
+ public enum State { NEW, DETACHED, RESUMING, OPEN, CLOSING, CLOSED }
static class DefaultSessionListener implements SessionListener
{
@@ -187,7 +187,7 @@ public class Session extends SessionInvoker
}
}
- void setState(State state)
+ protected void setState(State state)
{
synchronized (commands)
{
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
index 0e7f4aa166..bd9b18d848 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java
@@ -64,27 +64,34 @@ public class ChannelLoggingTest extends AbstractTestLogging
// Test that calling session.close gives us the expected output
((AMQConnection)connection).createSession(false, Session.AUTO_ACKNOWLEDGE,PREFETCH);
- // Wait to ensure that the CHN-1004 message is logged
- waitForMessage("CHN-1004");
+ // Wait to ensure that the CHN-1001 message is logged
+ waitForMessage("CHN-1001");
- List<String> results = findMatches(CHANNEL_PREFIX);
+ List<String> results = findMatches("CHN-1001");
// Validation
-
- assertEquals("CHN messages not logged", 2, results.size());
+ assertEquals("CHN-1001 messages not logged", 1, results.size());
String log = getLogMessage(results, 0);
// MESSAGE [con:0(guest@anonymous(3273383)/test)/ch:1] CHN-1001 : Create
- //1 & 2
validateMessageID("CHN-1001", log);
assertEquals("Incorrect Channel in actor:"+fromActor(log), 1, getChannelID(fromActor(log)));
- log = getLogMessage(results, 1);
- // MESSAGE [con:0(guest@anonymous(3273383)/test)/ch:1] CHN-1004 : Prefetch Size (bytes) {0,number} : Count {1,number}
- //1 & 2
- validateMessageID("CHN-1004", log);
- assertEquals("Incorrect Channel in actor:"+fromActor(log), 1, getChannelID(fromActor(log)));
- assertTrue("Prefetch Count not correct",getMessageString(fromMessage(log)).endsWith("Count "+PREFETCH));
+ if (isBroker08())
+ {
+ // Wait to ensure that the CHN-1004 message is logged
+ waitForMessage("CHN-1004");
+
+ results = findMatches("CHN-1004");
+
+ // Validation
+ assertEquals("CHN-1004 messages not logged", 1, results.size());
+ log = getLogMessage(results, 0);
+ // MESSAGE [con:0(guest@anonymous(3273383)/test)/ch:1] CHN-1004 : Prefetch Size (bytes) {0,number} : Count {1,number}
+ validateMessageID("CHN-1004", log);
+ assertEquals("Incorrect Channel in actor:"+fromActor(log), 1, getChannelID(fromActor(log)));
+ assertTrue("Prefetch Count not correct",getMessageString(fromMessage(log)).endsWith("Count "+PREFETCH));
+ }
connection.close();
}
@@ -276,9 +283,11 @@ public class ChannelLoggingTest extends AbstractTestLogging
Connection connection = getConnection();
// Create a session and then close it
- connection.createSession(false, Session.AUTO_ACKNOWLEDGE).close();
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ waitForMessage("CHN-1001");
// Wait to ensure that the CHN-1003 message is logged
+ session.close();
waitForMessage("CHN-1003");
List<String> results = findMatches(CHANNEL_PREFIX);
@@ -291,11 +300,14 @@ public class ChannelLoggingTest extends AbstractTestLogging
private void validateChannelClose(List<String> results)
{
- String log = getLogMessageFromEnd(results, 0);
-
- validateMessageID("CHN-1003", log);
- assertEquals("Message should be Close", "Close",getMessageString(fromMessage(log)));
- assertEquals("Incorrect Channel ID closed.", 1, getChannelID(fromActor(log)));
- assertEquals("Incorrect Channel ID closed.", 1, getChannelID(fromSubject(log)));
+ String open = getLogMessage(results, 0);
+ String close = getLogMessageFromEnd(results, 0);
+
+ validateMessageID("CHN-1001", open);
+ validateMessageID("CHN-1003", close);
+ assertEquals("Message should be Close", "Close", getMessageString(fromMessage(close)));
+ assertEquals("Incorrect Channel ID closed", 1, getChannelID(fromSubject(close)));
+ assertEquals("Channel IDs should be the same", getChannelID(fromActor(open)), getChannelID(fromSubject(close)));
+ assertEquals("Connection IDs should be the same", getConnectionID(fromActor(open)), getConnectionID(fromSubject(close)));
}
} \ No newline at end of file
diff --git a/qpid/java/test-profiles/Java010Excludes b/qpid/java/test-profiles/Java010Excludes
index 44b9cff9d8..6c3064f650 100755
--- a/qpid/java/test-profiles/Java010Excludes
+++ b/qpid/java/test-profiles/Java010Excludes
@@ -26,7 +26,9 @@ org.apache.qpid.server.logging.AccessControlLoggingTest#*
org.apache.qpid.server.logging.AlertingTest#*
org.apache.qpid.server.logging.BindingLoggingTest#*
org.apache.qpid.server.logging.BrokerLoggingTest#*
-org.apache.qpid.server.logging.ChannelLoggingTest#*
+org.apache.qpid.server.logging.ChannelLoggingTest#testChannelStartsFlowStopped
+org.apache.qpid.server.logging.ChannelLoggingTest#testChannelStartConsumerFlowStarted
+org.apache.qpid.server.logging.ChannelLoggingTest#testChannelStartConsumerFlowStarted
org.apache.qpid.server.logging.DerbyMessageStoreLoggingTest#*
org.apache.qpid.server.logging.DurableQueueLoggingTest#*
org.apache.qpid.server.logging.ExchangeLoggingTest#*