Improved dump of ManagedSelector.
Now also dumping the actions. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
918cf625cc
commit
131f46df64
|
@ -28,6 +28,7 @@ import java.nio.channels.SelectionKey;
|
||||||
import java.nio.channels.Selector;
|
import java.nio.channels.Selector;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -40,6 +41,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||||
import org.eclipse.jetty.util.component.Dumpable;
|
import org.eclipse.jetty.util.component.Dumpable;
|
||||||
|
import org.eclipse.jetty.util.component.DumpableCollection;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.util.thread.ExecutionStrategy;
|
import org.eclipse.jetty.util.thread.ExecutionStrategy;
|
||||||
|
@ -226,29 +228,23 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String dump()
|
|
||||||
{
|
|
||||||
super.dump();
|
|
||||||
return ContainerLifeCycle.dump(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dump(Appendable out, String indent) throws IOException
|
public void dump(Appendable out, String indent) throws IOException
|
||||||
{
|
{
|
||||||
|
super.dump(out, indent);
|
||||||
Selector selector = _selector;
|
Selector selector = _selector;
|
||||||
if (selector == null || !selector.isOpen())
|
if (selector != null && selector.isOpen())
|
||||||
dumpBeans(out, indent);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
final ArrayList<Object> dump = new ArrayList<>(selector.keys().size() * 2);
|
List<Runnable> actions;
|
||||||
DumpKeys dumpKeys = new DumpKeys(dump);
|
try (Locker.Lock lock = _locker.lock())
|
||||||
|
{
|
||||||
|
actions = new ArrayList<>(_actions);
|
||||||
|
}
|
||||||
|
List<Object> keys = new ArrayList<>(selector.keys().size());
|
||||||
|
DumpKeys dumpKeys = new DumpKeys(keys);
|
||||||
submit(dumpKeys);
|
submit(dumpKeys);
|
||||||
dumpKeys.await(5, TimeUnit.SECONDS);
|
dumpKeys.await(5, TimeUnit.SECONDS);
|
||||||
if (dump.isEmpty())
|
dump(out, indent, Arrays.asList(new DumpableCollection("keys", keys), new DumpableCollection("actions", actions)));
|
||||||
dumpBeans(out, indent);
|
|
||||||
else
|
|
||||||
dumpBeans(out, indent, dump);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,7 +508,7 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
|
||||||
}
|
}
|
||||||
catch (Throwable x)
|
catch (Throwable x)
|
||||||
{
|
{
|
||||||
_dumps.add(String.format("SelectionKey@%x[%s]", key.hashCode(), x));
|
_dumps.add(String.format("SelectionKey@%x[%s]->%s", key.hashCode(), x, key.attachment()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -660,13 +660,10 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
|
||||||
int size = _beans.size();
|
int size = _beans.size();
|
||||||
for (Collection<?> c : collections)
|
for (Collection<?> c : collections)
|
||||||
size += c.size();
|
size += c.size();
|
||||||
if (size == 0)
|
|
||||||
return;
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Bean b : _beans)
|
for (Bean b : _beans)
|
||||||
{
|
{
|
||||||
i++;
|
++i;
|
||||||
|
|
||||||
switch(b._managed)
|
switch(b._managed)
|
||||||
{
|
{
|
||||||
case POJO:
|
case POJO:
|
||||||
|
@ -697,20 +694,15 @@ public class ContainerLifeCycle extends AbstractLifeCycle implements Container,
|
||||||
else
|
else
|
||||||
dumpObject(out, b._bean);
|
dumpObject(out, b._bean);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i<size)
|
|
||||||
out.append(indent).append(" |\n");
|
|
||||||
|
|
||||||
for (Collection<?> c : collections)
|
for (Collection<?> c : collections)
|
||||||
{
|
{
|
||||||
for (Object o : c)
|
for (Object o : c)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
out.append(indent).append(" +> ");
|
out.append(indent).append(" +> ");
|
||||||
|
|
||||||
if (o instanceof Dumpable)
|
if (o instanceof Dumpable)
|
||||||
((Dumpable)o).dump(out, indent + (i == size ? " " : " | "));
|
((Dumpable)o).dump(out, indent + (i == size ? " " : " | "));
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue