use of org.apache.qpid.server.logging.LogMessage in project qpid-broker-j by apache.
the class ProducerFlowControlOverflowPolicyHandlerTest method testCheckOverflowResumesFlowWhenUnderfullMessages.
public void testCheckOverflowResumesFlowWhenUnderfullMessages() throws Exception {
AMQPSession<?, ?> session = mock(AMQPSession.class);
when(_queue.getQueueDepthMessages()).thenReturn(11);
when(_queue.getMaximumQueueDepthMessages()).thenReturn(10L);
checkOverflow(session);
verify(session, times(1)).block(_queue);
LogMessage overfullMessage = QueueMessages.OVERFULL(0, -1, 11, 10);
verify(_eventLogger).message(same(_subject), argThat(new LogMessageMatcher(overfullMessage)));
assertTrue("Flow should be stopped", _producerFlowControlOverflowPolicyHandler.isQueueFlowStopped());
when(_queue.getQueueDepthMessages()).thenReturn(8);
_producerFlowControlOverflowPolicyHandler.checkOverflow(null);
verify(session, times(1)).unblock(_queue);
assertFalse("Flow should not be stopped", _producerFlowControlOverflowPolicyHandler.isQueueFlowStopped());
LogMessage underfullMessage = QueueMessages.UNDERFULL(0, -1, 8, 8);
verify(_eventLogger).message(same(_subject), argThat(new LogMessageMatcher(underfullMessage)));
verifyNoMoreInteractions(_eventLogger);
verifyNoMoreInteractions(session);
}
use of org.apache.qpid.server.logging.LogMessage in project qpid-broker-j by apache.
the class RingOverflowPolicyHandlerTest method testCheckOverflowWhenOverfullBytes.
public void testCheckOverflowWhenOverfullBytes() throws Exception {
QueueEntry lastEntry = createLastEntry();
when(_queue.getLeastSignificantOldestEntry()).thenReturn(lastEntry, (QueueEntry) null);
when(_queue.getQueueDepthBytes()).thenReturn(10L, 4L);
when(_queue.getMaximumQueueDepthBytes()).thenReturn(5L);
when(_queue.getQueueDepthMessages()).thenReturn(3, 1);
_ringOverflowPolicyHandler.checkOverflow(null);
verify(_queue).deleteEntry(lastEntry);
LogMessage dropped = QueueMessages.DROPPED(1L, 4, 1, 5, -1);
verify(_eventLogger).message(same(_subject), argThat(new LogMessageMatcher(dropped)));
verifyNoMoreInteractions(_eventLogger);
}
use of org.apache.qpid.server.logging.LogMessage in project qpid-broker-j by apache.
the class PortMessages method CONNECTION_REJECTED_CLOSED.
/**
* Log a Port message of the Format:
* <pre>PRT-1008 : Connection from {0} rejected. Port closed.</pre>
* Optional values are contained in [square brackets] and are numbered
* sequentially in the method call.
*/
public static LogMessage CONNECTION_REJECTED_CLOSED(String param1) {
String rawMessage = _messages.getString("CONNECTION_REJECTED_CLOSED");
final Object[] messageArguments = { param1 };
// Create a new MessageFormat to ensure thread safety.
// Sharing a MessageFormat and using applyPattern is not thread safe
MessageFormat formatter = new MessageFormat(rawMessage, _currentLocale);
final String message = formatter.format(messageArguments);
return new LogMessage() {
@Override
public String toString() {
return message;
}
@Override
public String getLogHierarchy() {
return CONNECTION_REJECTED_CLOSED_LOG_HIERARCHY;
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final LogMessage that = (LogMessage) o;
return getLogHierarchy().equals(that.getLogHierarchy()) && toString().equals(that.toString());
}
@Override
public int hashCode() {
int result = toString().hashCode();
result = 31 * result + getLogHierarchy().hashCode();
return result;
}
};
}
use of org.apache.qpid.server.logging.LogMessage in project qpid-broker-j by apache.
the class PortMessages method CONNECTION_REJECTED_TOO_MANY.
/**
* Log a Port message of the Format:
* <pre>PRT-1005 : Connection from {0} rejected. Maximum connection count ({1, number}) for this port already reached.</pre>
* Optional values are contained in [square brackets] and are numbered
* sequentially in the method call.
*/
public static LogMessage CONNECTION_REJECTED_TOO_MANY(String param1, Number param2) {
String rawMessage = _messages.getString("CONNECTION_REJECTED_TOO_MANY");
final Object[] messageArguments = { param1, param2 };
// Create a new MessageFormat to ensure thread safety.
// Sharing a MessageFormat and using applyPattern is not thread safe
MessageFormat formatter = new MessageFormat(rawMessage, _currentLocale);
final String message = formatter.format(messageArguments);
return new LogMessage() {
@Override
public String toString() {
return message;
}
@Override
public String getLogHierarchy() {
return CONNECTION_REJECTED_TOO_MANY_LOG_HIERARCHY;
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final LogMessage that = (LogMessage) o;
return getLogHierarchy().equals(that.getLogHierarchy()) && toString().equals(that.toString());
}
@Override
public int hashCode() {
int result = toString().hashCode();
result = 31 * result + getLogHierarchy().hashCode();
return result;
}
};
}
use of org.apache.qpid.server.logging.LogMessage in project qpid-broker-j by apache.
the class PortMessages method CREATE.
/**
* Log a Port message of the Format:
* <pre>PRT-1001 : Create "{0}"</pre>
* Optional values are contained in [square brackets] and are numbered
* sequentially in the method call.
*/
public static LogMessage CREATE(String param1) {
String rawMessage = _messages.getString("CREATE");
final Object[] messageArguments = { param1 };
// Create a new MessageFormat to ensure thread safety.
// Sharing a MessageFormat and using applyPattern is not thread safe
MessageFormat formatter = new MessageFormat(rawMessage, _currentLocale);
final String message = formatter.format(messageArguments);
return new LogMessage() {
@Override
public String toString() {
return message;
}
@Override
public String getLogHierarchy() {
return CREATE_LOG_HIERARCHY;
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final LogMessage that = (LogMessage) o;
return getLogHierarchy().equals(that.getLogHierarchy()) && toString().equals(that.toString());
}
@Override
public int hashCode() {
int result = toString().hashCode();
result = 31 * result + getLogHierarchy().hashCode();
return result;
}
};
}
Aggregations