Mercurial Hosting > luan
comparison src/org/eclipse/jetty/io/nio/SelectorManager.java @ 820:8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 13 Sep 2016 23:13:06 -0600 |
parents | 3428c60d7cfc |
children | 6b210bb66c63 |
comparison
equal
deleted
inserted
replaced
819:17bd0b170ed6 | 820:8e9db0bbf4f9 |
---|---|
42 import org.eclipse.jetty.io.EndPoint; | 42 import org.eclipse.jetty.io.EndPoint; |
43 import org.eclipse.jetty.util.TypeUtil; | 43 import org.eclipse.jetty.util.TypeUtil; |
44 import org.eclipse.jetty.util.component.AbstractLifeCycle; | 44 import org.eclipse.jetty.util.component.AbstractLifeCycle; |
45 import org.eclipse.jetty.util.component.AggregateLifeCycle; | 45 import org.eclipse.jetty.util.component.AggregateLifeCycle; |
46 import org.eclipse.jetty.util.component.Dumpable; | 46 import org.eclipse.jetty.util.component.Dumpable; |
47 import org.eclipse.jetty.util.log.Log; | 47 import org.slf4j.Logger; |
48 import org.eclipse.jetty.util.log.Logger; | 48 import org.slf4j.LoggerFactory; |
49 import org.eclipse.jetty.util.thread.Timeout; | 49 import org.eclipse.jetty.util.thread.Timeout; |
50 import org.eclipse.jetty.util.thread.Timeout.Task; | 50 import org.eclipse.jetty.util.thread.Timeout.Task; |
51 | 51 |
52 | 52 |
53 /* ------------------------------------------------------------ */ | 53 /* ------------------------------------------------------------ */ |
56 * NIO scheduling to scale to large numbers of connections. | 56 * NIO scheduling to scale to large numbers of connections. |
57 * <p> | 57 * <p> |
58 */ | 58 */ |
59 public abstract class SelectorManager extends AbstractLifeCycle implements Dumpable | 59 public abstract class SelectorManager extends AbstractLifeCycle implements Dumpable |
60 { | 60 { |
61 public static final Logger LOG=Log.getLogger("org.eclipse.jetty.io.nio"); | 61 public static final Logger LOG=LoggerFactory.getLogger("org.eclipse.jetty.io.nio"); |
62 | 62 |
63 private static final int __MONITOR_PERIOD=Integer.getInteger("org.eclipse.jetty.io.nio.MONITOR_PERIOD",1000).intValue(); | 63 private static final int __MONITOR_PERIOD=Integer.getInteger("org.eclipse.jetty.io.nio.MONITOR_PERIOD",1000).intValue(); |
64 private static final int __MAX_SELECTS=Integer.getInteger("org.eclipse.jetty.io.nio.MAX_SELECTS",100000).intValue(); | 64 private static final int __MAX_SELECTS=Integer.getInteger("org.eclipse.jetty.io.nio.MAX_SELECTS",100000).intValue(); |
65 private static final int __BUSY_PAUSE=Integer.getInteger("org.eclipse.jetty.io.nio.BUSY_PAUSE",50).intValue(); | 65 private static final int __BUSY_PAUSE=Integer.getInteger("org.eclipse.jetty.io.nio.BUSY_PAUSE",50).intValue(); |
66 private static final int __IDLE_TICK=Integer.getInteger("org.eclipse.jetty.io.nio.IDLE_TICK",400).intValue(); | 66 private static final int __IDLE_TICK=Integer.getInteger("org.eclipse.jetty.io.nio.IDLE_TICK",400).intValue(); |
289 { | 289 { |
290 set.doSelect(); | 290 set.doSelect(); |
291 } | 291 } |
292 catch(IOException e) | 292 catch(IOException e) |
293 { | 293 { |
294 LOG.ignore(e); | 294 LOG.trace("",e); |
295 } | 295 } |
296 catch(Exception e) | 296 catch(Exception e) |
297 { | 297 { |
298 LOG.warn(e); | 298 LOG.warn("",e); |
299 } | 299 } |
300 } | 300 } |
301 } | 301 } |
302 finally | 302 finally |
303 { | 303 { |
364 | 364 |
365 /* ------------------------------------------------------------------------------- */ | 365 /* ------------------------------------------------------------------------------- */ |
366 protected void connectionFailed(SocketChannel channel,Throwable ex,Object attachment) | 366 protected void connectionFailed(SocketChannel channel,Throwable ex,Object attachment) |
367 { | 367 { |
368 LOG.warn(ex+","+channel+","+attachment); | 368 LOG.warn(ex+","+channel+","+attachment); |
369 LOG.debug(ex); | 369 LOG.debug("",ex); |
370 } | 370 } |
371 | 371 |
372 /* ------------------------------------------------------------ */ | 372 /* ------------------------------------------------------------ */ |
373 public String dump() | 373 public String dump() |
374 { | 374 { |
508 else | 508 else |
509 throw new IllegalArgumentException(change.toString()); | 509 throw new IllegalArgumentException(change.toString()); |
510 } | 510 } |
511 catch (CancelledKeyException e) | 511 catch (CancelledKeyException e) |
512 { | 512 { |
513 LOG.ignore(e); | 513 LOG.trace("",e); |
514 } | 514 } |
515 catch (Throwable e) | 515 catch (Throwable e) |
516 { | 516 { |
517 if (isRunning()) | 517 if (isRunning()) |
518 LOG.warn(e); | 518 LOG.warn("",e); |
519 else | 519 else |
520 LOG.debug(e); | 520 LOG.debug("",e); |
521 | 521 |
522 try | 522 try |
523 { | 523 { |
524 if (ch!=null) | 524 if (ch!=null) |
525 ch.close(); | 525 ch.close(); |
526 } | 526 } |
527 catch(IOException e2) | 527 catch(IOException e2) |
528 { | 528 { |
529 LOG.debug(e2); | 529 LOG.debug("",e2); |
530 } | 530 } |
531 } | 531 } |
532 } | 532 } |
533 | 533 |
534 | 534 |
547 { | 547 { |
548 Thread.sleep(__BUSY_PAUSE); // pause to reduce impact of busy loop | 548 Thread.sleep(__BUSY_PAUSE); // pause to reduce impact of busy loop |
549 } | 549 } |
550 catch(InterruptedException e) | 550 catch(InterruptedException e) |
551 { | 551 { |
552 LOG.ignore(e); | 552 LOG.trace("",e); |
553 } | 553 } |
554 now=System.currentTimeMillis(); | 554 now=System.currentTimeMillis(); |
555 } | 555 } |
556 | 556 |
557 // workout how long to wait in select | 557 // workout how long to wait in select |
658 } | 658 } |
659 key = null; | 659 key = null; |
660 } | 660 } |
661 catch (CancelledKeyException e) | 661 catch (CancelledKeyException e) |
662 { | 662 { |
663 LOG.ignore(e); | 663 LOG.trace("",e); |
664 } | 664 } |
665 catch (Exception e) | 665 catch (Exception e) |
666 { | 666 { |
667 if (isRunning()) | 667 if (isRunning()) |
668 LOG.warn(e); | 668 LOG.warn("",e); |
669 else | 669 else |
670 LOG.ignore(e); | 670 LOG.trace("",e); |
671 | 671 |
672 try | 672 try |
673 { | 673 { |
674 if (channel!=null) | 674 if (channel!=null) |
675 channel.close(); | 675 channel.close(); |
676 } | 676 } |
677 catch(IOException e2) | 677 catch(IOException e2) |
678 { | 678 { |
679 LOG.debug(e2); | 679 LOG.debug("",e2); |
680 } | 680 } |
681 | 681 |
682 if (key != null && !(key.channel() instanceof ServerSocketChannel) && key.isValid()) | 682 if (key != null && !(key.channel() instanceof ServerSocketChannel) && key.isValid()) |
683 key.cancel(); | 683 key.cancel(); |
684 } | 684 } |
730 } | 730 } |
731 } | 731 } |
732 catch (ClosedSelectorException e) | 732 catch (ClosedSelectorException e) |
733 { | 733 { |
734 if (isRunning()) | 734 if (isRunning()) |
735 LOG.warn(e); | 735 LOG.warn("",e); |
736 else | 736 else |
737 LOG.ignore(e); | 737 LOG.trace("",e); |
738 } | 738 } |
739 catch (CancelledKeyException e) | 739 catch (CancelledKeyException e) |
740 { | 740 { |
741 LOG.ignore(e); | 741 LOG.trace("",e); |
742 } | 742 } |
743 finally | 743 finally |
744 { | 744 { |
745 _selecting=null; | 745 _selecting=null; |
746 } | 746 } |
873 Thread.sleep(10); | 873 Thread.sleep(10); |
874 } | 874 } |
875 } | 875 } |
876 catch(Exception e) | 876 catch(Exception e) |
877 { | 877 { |
878 LOG.ignore(e); | 878 LOG.trace("",e); |
879 } | 879 } |
880 | 880 |
881 // close endpoints and selector | 881 // close endpoints and selector |
882 synchronized (this) | 882 synchronized (this) |
883 { | 883 { |
894 { | 894 { |
895 endpoint.close(); | 895 endpoint.close(); |
896 } | 896 } |
897 catch(IOException e) | 897 catch(IOException e) |
898 { | 898 { |
899 LOG.ignore(e); | 899 LOG.trace("",e); |
900 } | 900 } |
901 } | 901 } |
902 } | 902 } |
903 | 903 |
904 | 904 |
909 if (selector != null) | 909 if (selector != null) |
910 selector.close(); | 910 selector.close(); |
911 } | 911 } |
912 catch (IOException e) | 912 catch (IOException e) |
913 { | 913 { |
914 LOG.ignore(e); | 914 LOG.trace("",e); |
915 } | 915 } |
916 _selector=null; | 916 _selector=null; |
917 } | 917 } |
918 } | 918 } |
919 | 919 |
963 { | 963 { |
964 latch.await(5,TimeUnit.SECONDS); | 964 latch.await(5,TimeUnit.SECONDS); |
965 } | 965 } |
966 catch(InterruptedException e) | 966 catch(InterruptedException e) |
967 { | 967 { |
968 LOG.ignore(e); | 968 LOG.trace("",e); |
969 } | 969 } |
970 | 970 |
971 AggregateLifeCycle.dump(out,indent,dump); | 971 AggregateLifeCycle.dump(out,indent,dump); |
972 } | 972 } |
973 } | 973 } |