Skip to content

Commit

Permalink
Issue #1970 - ManagedSelector dump improvements.
Browse files Browse the repository at this point in the history
Code cleanups.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed Dec 28, 2017
1 parent ee133e5 commit 4febaf1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
18 changes: 7 additions & 11 deletions jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import java.util.List;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Exchanger;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -247,31 +246,28 @@ private int getActionSize()
@Override
public void dump(Appendable out, String indent) throws IOException
{
super.dump(out,indent);

Selector selector = _selector;
List<String> keys = null;
List<Runnable> actions = null;
if (selector != null && selector.isOpen())
{
DumpKeys dump = new DumpKeys();
String actionsAt;
List<Runnable> actions;
try (Locker.Lock lock = _locker.lock())
{
actionsAt = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now());
actions = new ArrayList<>(_actions);
_actions.addFirst(dump);
_selecting = false;
}
_selector.wakeup();
keys = dump.get(5, TimeUnit.SECONDS);
selector.wakeup();
List<String> keys = dump.get(5, TimeUnit.SECONDS);
String keysAt = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now());
if (keys==null)
keys = Collections.singletonList("No dump keys retrieved");
dumpBeans(out, indent, Arrays.asList(new DumpableCollection("actions@"+actionsAt, actions),
new DumpableCollection("keys@"+keysAt, keys) ));
}
else
{
super.dump(out,indent);
dump(out, indent, Arrays.asList(new DumpableCollection("actions @ "+actionsAt, actions),
new DumpableCollection("keys @ "+keysAt, keys)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@
package org.eclipse.jetty.util.component;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;

import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;

public class DumpableCollection implements Dumpable
{
private final String _name;
Expand All @@ -45,7 +41,7 @@ public String dump()
@Override
public void dump(Appendable out, String indent) throws IOException
{
out.append(_name).append("\n");
out.append(_name).append(System.lineSeparator());
if (_collection!=null)
ContainerLifeCycle.dump(out,indent,_collection);
}
Expand Down

0 comments on commit 4febaf1

Please sign in to comment.