Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix trie match bug and bytesMetrics bug #479

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
BytesMetrics metrics = ctx.channel().attr(ATTR_KEY_METRICS).get();
metrics.incrementWrote(((ByteBuf) msg).writableBytes());
metrics.incrementWrote(((ByteBuf) msg).readableBytes());
ctx.write(msg, promise).addListener(CLOSE_ON_FAILURE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface IVisitor<T> {
T getResult();
}

private static final Token ROOT = new Token("root");
private static final Token ROOT = new Token("+root");
ilylia marked this conversation as resolved.
Show resolved Hide resolved
private static final INode NO_PARENT = null;

private enum Action {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public void testMatchSimple() {

assertThat(sut.matchWithoutQosSharpening(asTopic("/finance"))).contains(slashFinanceSub);
assertThat(sut.matchWithoutQosSharpening(asTopic("/"))).contains(slashSub);

Subscription rootSub = clientSubOnTopic("TempSensor1", "root");
sut.add(rootSub);
assertThat(sut.matchWithoutQosSharpening(asTopic("root"))).contains(rootSub);
}

@Test
Expand All @@ -67,6 +71,10 @@ public void testMatchSimpleMulti() {
Subscription financeAnySub = clientSubOnTopic("TempSensor1", "finance/#");
sut.add(financeAnySub);
assertThat(sut.matchWithoutQosSharpening(asTopic("finance"))).containsExactlyInAnyOrder(financeAnySub, anySub);

Subscription rootSub = clientSubOnTopic("TempSensor1", "root/#");
sut.add(rootSub);
assertThat(sut.matchWithoutQosSharpening(asTopic("root/test"))).contains(rootSub);
}

@Test
Expand Down Expand Up @@ -168,6 +176,11 @@ public void rogerLightTopicMatches() {
assertMatch("foo//+", "foo//bar");
assertMatch("foo/+/+/baz", "foo///baz");
assertMatch("foo/bar/+", "foo/bar/");

assertMatch("root//bar", "root//bar");
assertMatch("root//+", "root//bar");
assertMatch("foo/+/+/root", "foo///root");
assertMatch("foo/root/+", "foo/root/");
}

private void assertMatch(String s, String t) {
Expand Down
6 changes: 2 additions & 4 deletions distribution/src/main/scripts/moquette.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ echo " \_| |_/\___/ \__, |\__,_|\___|\__|\__\___| \_| |_/\_/\_\ \_/ \_/ "
echo " | | "
echo " |_| "
echo " "
echo " version: 0..13-SNAPSHOT "
echo " version: 0.13-SNAPSHOT "


cd "$(dirname "$0")"

# resolve links - $0 may be a softlink
PRG="$0"

Expand All @@ -39,7 +37,7 @@ PRGDIR=`dirname "$PRG"`
export MOQUETTE_HOME

# Set JavaHome if it exists
if [ -f "${JAVA_HOME}/bin/java" ]; then
if [ -f "${JAVA_HOME}/bin/java" ]; then
JAVA=${JAVA_HOME}/bin/java
else
JAVA=java
Expand Down