Package com.sun.nio.sctp.AssociationChangeNotification

Examples of com.sun.nio.sctp.AssociationChangeNotification.AssocChangeEvent


                if (logger.isInfoEnabled()) {
                  logger.info(String.format("Connected %s", association));
                }

                if (association.getIpChannelType() == IpChannelType.TCP) {
                  AssocChangeEvent ace = AssocChangeEvent.COMM_UP;
                  AssociationChangeNotification2 acn = new AssociationChangeNotification2(ace);
                  association.associationHandler.handleNotification(acn, association);
                }

                break;
              }
            }
          }

          if (provisioned)
            break;
        }// for (SocketAddress sockAdd : socAddresses)

        if (!provisioned && srv.isAcceptAnonymousConnections() && this.management.getServerListener() != null) {
          // the server accepts anonymous connections

          // checking for limit of concurrent connections
          if (srvv.getMaxConcurrentConnectionsCount() > 0 && srvv.anonymAssociations.size() >= srvv.getMaxConcurrentConnectionsCount()) {
            logger.warn(String.format("Incoming anonymous connection is rejected because of too many active connections to Server=%s", srv));
            try {
              socketChannel.close();
            } catch (Exception ee) {
            }
            return;
          }
         
          provisioned = true;
         
          AssociationImpl anonymAssociation = new AssociationImpl(firstInetAddress.getHostAddress(), firstPort, srv.getName(),
              srv.getIpChannelType(), srvv);
          anonymAssociation.setManagement(this.management);
          anonymAssociation.setSocketChannel(socketChannel);

          // Accept the connection and make it
          // non-blocking
          socketChannel.configureBlocking(false);

          try {
            this.management.getServerListener().onNewRemoteConnection(srv, anonymAssociation);
          } catch (Throwable e) {
            logger.warn(String.format("Exception when invoking ServerListener.onNewRemoteConnection() Ass=%s", anonymAssociation), e);
            try {
              socketChannel.close();
            } catch (Exception ee) {
            }
            return;
          }

          if (!anonymAssociation.isStarted()) {
            // connection is rejected
            logger.info(String.format("Rejected anonymous %s", anonymAssociation));
            try {
              socketChannel.close();
            } catch (Exception ee) {
            }
            return;
          }

          // Register the new SocketChannel with our Selector,
          // indicating we'd like to be notified when there's data
          // waiting to be read
          SelectionKey key1 = socketChannel.register(this.selector, SelectionKey.OP_READ);
          key1.attach(anonymAssociation);

          if (logger.isInfoEnabled()) {
            logger.info(String.format("Accepted anonymous %s", anonymAssociation));
          }

          if (anonymAssociation.getIpChannelType() == IpChannelType.TCP) {
            AssocChangeEvent ace = AssocChangeEvent.COMM_UP;
            AssociationChangeNotification2 acn = new AssociationChangeNotification2(ace);
            anonymAssociation.associationHandler.handleNotification(acn, anonymAssociation);
          }
        }
      }
View Full Code Here


      }

      // Register an interest in writing on this channel
      key.interestOps(SelectionKey.OP_READ);

      AssocChangeEvent ace = AssocChangeEvent.COMM_UP;
      AssociationChangeNotification2 acn = new AssociationChangeNotification2(ace);
      association.associationHandler.handleNotification(acn, association);

    } catch (Exception e) {
      logger.error(String.format("Exception while finishing connection for Association=%s", association.getName()), e);
View Full Code Here

TOP

Related Classes of com.sun.nio.sctp.AssociationChangeNotification.AssocChangeEvent

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.