Package java.nio.channels.spi

Examples of java.nio.channels.spi.SelectorProvider


    private final AtomicInteger current = new AtomicInteger();
 
  public SelectorManagers(AsyncClientPolicy policy) throws AerospikeException {
    managers = new SelectorManager[policy.asyncSelectorThreads];
   
    SelectorProvider provider = SelectorProvider.provider();
   
    for (int i = 0; i < policy.asyncSelectorThreads; i++) {
      try {
        managers[i] = new SelectorManager(policy, provider);
      }
View Full Code Here


    private final AtomicInteger current = new AtomicInteger();
 
  public SelectorManagers(AsyncClientPolicy policy) throws AerospikeException {
    managers = new SelectorManager[policy.asyncSelectorThreads];
   
    SelectorProvider provider = SelectorProvider.provider();
   
    for (int i = 0; i < policy.asyncSelectorThreads; i++) {
      try {
        managers[i] = new SelectorManager(policy, provider);
      }
View Full Code Here

     */
    private synchronized SelectorInfo get(SelectableChannel channel)
                                                         throws IOException {
      SelectorInfo selInfo = null;
     
      SelectorProvider provider = channel.provider();
     
      // pick the list : rarely there is more than one provider in use.
      ProviderInfo pList = providerList;
      while (pList != null && pList.provider != provider) {
        pList = pList.next;
      }     
      if (pList == null) {
        //LOG.info("Creating new ProviderInfo : " + provider.toString());
        pList = new ProviderInfo();
        pList.provider = provider;
        pList.queue = new LinkedList<SelectorInfo>();
        pList.next = providerList;
        providerList = pList;
      }
     
      LinkedList<SelectorInfo> queue = pList.queue;
     
      if (queue.isEmpty()) {
        Selector selector = provider.openSelector();
        selInfo = new SelectorInfo();
        selInfo.selector = selector;
        selInfo.queue = queue;
      } else {
        selInfo = queue.removeLast();
View Full Code Here

                initializeTransport(transportProtocol);
            }
        }

        private void initializeTransport(TransportProtocol transportProtocol) {
            SelectorProvider selectorProvider = null;
            switch (transportProtocol) {
            case TCP:
                selectorProvider = SelectorProvider.provider();
                break;
            case UDT:
View Full Code Here

                final Class<?> providerClazz = Class.forName("sun.nio.ch.EPollSelectorProvider");
                if (providerClazz != null) {
                    try {
                        final Method method = providerClazz.getMethod("provider");
                        if (method != null) {
                            final SelectorProvider selectorProvider = (SelectorProvider) method.invoke(null);
                            if (selectorProvider != null) {
                                result = selectorProvider.openSelector();
                            }
                        }
                    }
                    catch (final Exception e) {
                        // ignore
View Full Code Here

        sourceChannel.close();
        sinkChannel.close();
    }

    private static void testReadableByteChannel(int size) throws Exception {
        SelectorProvider sp = SelectorProvider.provider();
        Pipe p = sp.openPipe();
        Pipe.SinkChannel sink = p.sink();
        Pipe.SourceChannel source = p.source();
        sink.configureBlocking(false);

        ByteBuffer outgoingdata = ByteBuffer.allocateDirect(size + 10);
View Full Code Here

                // Presumably "Too many open files"
            }
        }
    }
    static void test3() {
        SelectorProvider sp = SelectorProvider.provider();
        for (int i=0; i<11000; i++) {
            try {
                Pipe p = sp.openPipe();
            } catch (Exception e) {
                // Presumably "Too many open files"
            }
        }
    }
View Full Code Here

    public static void main(String[] args) throws Exception {

        // Load necessary classes ahead of time
        DatagramChannel dc = DatagramChannel.open();
        Exception se = new SocketException();
        SelectorProvider sp = SelectorProvider.provider();
        Pipe p = sp.openPipe();
        ServerSocketChannel ssc = ServerSocketChannel.open();

        test1();
        test2();
        test3();
View Full Code Here

    private static Random generator = new Random();

    public static void main(String[] args) throws Exception {
        for (int x=0; x<100; x++) {
            SelectorProvider sp = SelectorProvider.provider();
            Pipe p = sp.openPipe();
            Pipe.SinkChannel sink = p.sink();
            Pipe.SourceChannel source = p.source();

            ByteBuffer outgoingdata = ByteBuffer.allocateDirect(10);
            byte[] someBytes = new byte[10];
View Full Code Here

    private static Random generator = new Random();

    public static void main(String[] args) throws Exception {

        SelectorProvider sp = SelectorProvider.provider();
        Selector selector = Selector.open();
        Pipe p = sp.openPipe();
        Pipe.SinkChannel sink = p.sink();
        Pipe.SourceChannel source = p.source();

        source.configureBlocking(false);
        sink.configureBlocking(false);
View Full Code Here

TOP

Related Classes of java.nio.channels.spi.SelectorProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.