java.nio.channels.NotYetBoundException#com.sun.nio.sctp.Association源码实例Demo

下面列出了java.nio.channels.NotYetBoundException#com.sun.nio.sctp.Association 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-8-source   文件: SctpMultiChannelImpl.java
@Override
public Set<SocketAddress> getRemoteAddresses(Association association)
        throws IOException {
    synchronized (stateLock) {
        checkAssociation(association);
        if (!isOpen())
            throw new ClosedChannelException();

        try {
            return SctpNet.getRemoteAddresses(fdVal, association.associationID());
        } catch (SocketException se) {
            /* a valid association should always have remote addresses */
            Set<SocketAddress> addrs = associationMap.get(association);
            return addrs != null ? addrs : Collections.<SocketAddress>emptySet();
        }
    }
}
 
源代码2 项目: openjdk-8   文件: SctpMultiChannelImpl.java
@Override
public SctpChannel branch(Association association)
        throws IOException {
    synchronized (stateLock) {
        checkAssociation(association);
        if (!isOpen())
            throw new ClosedChannelException();

        FileDescriptor bFd = SctpNet.branch(fdVal,
                                            association.associationID());
        /* successfully branched, we can now remove it from assoc list */
        removeAssociation(association);

        return new SctpChannelImpl(provider(), bFd, association);
    }
}
 
源代码3 项目: jdk8u-jdk   文件: SctpMultiChannelImpl.java
@Override
public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
                                      T value,
                                      Association association)
        throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!(supportedOptions().contains(name)))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    synchronized (stateLock) {
        if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
                name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
            checkAssociation(association);
        }
        if (!isOpen())
            throw new ClosedChannelException();

        int assocId = association == null ? 0 : association.associationID();
        SctpNet.setSocketOption(fdVal, name, value, assocId);
    }
    return this;
}
 
源代码4 项目: TencentKona-8   文件: Send.java
@Override
public HandlerResult handleNotification(
        AssociationChangeNotification notification, Void attachment) {
    AssocChangeEvent event = notification.event();
    Association association = notification.association();
    debug("AssociationChangeNotification");
    debug("  Association: " + notification.association());
    debug("  Event: " + event);

    if (event.equals(AssocChangeEvent.COMM_UP))
        receivedCommUp = true;

    this.maxInStreams = association.maxInboundStreams();
    this.maxOutStreams = association.maxOutboundStreams();

    return HandlerResult.RETURN;
}
 
源代码5 项目: jdk8u-dev-jdk   文件: SctpMultiChannelImpl.java
@Override
@SuppressWarnings("unchecked")
public <T> T getOption(SctpSocketOption<T> name, Association association)
        throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    synchronized (stateLock) {
        if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
                name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
            checkAssociation(association);
        }
        if (!isOpen())
            throw new ClosedChannelException();

        int assocId = association == null ? 0 : association.associationID();
        return (T)SctpNet.getSocketOption(fdVal, name, assocId);
    }
}
 
源代码6 项目: openjdk-jdk9   文件: SctpChannelImpl.java
/**
 * Constructor for sockets obtained from branching
 */
public SctpChannelImpl(SelectorProvider provider,
                       FileDescriptor fd,
                       Association association)
        throws IOException {
    super(provider);
    this.fd = fd;
    this.fdVal = IOUtil.fdVal(fd);
    this.state = ChannelState.CONNECTED;
    port = (Net.localAddress(fd)).getPort();

    if (association != null) { /* branched */
        this.association = association;
    } else { /* obtained from server channel */
        /* Receive COMM_UP */
        ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
        try {
            receive(buf, null, null, true);
        } finally {
            Util.releaseTemporaryDirectBuffer(buf);
        }
    }
}
 
源代码7 项目: dragonwell8_jdk   文件: SctpMultiChannelImpl.java
@Override
public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
                                      T value,
                                      Association association)
        throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!(supportedOptions().contains(name)))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    synchronized (stateLock) {
        if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
                name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
            checkAssociation(association);
        }
        if (!isOpen())
            throw new ClosedChannelException();

        int assocId = association == null ? 0 : association.associationID();
        SctpNet.setSocketOption(fdVal, name, value, assocId);
    }
    return this;
}
 
源代码8 项目: hottub   文件: SctpMultiChannelImpl.java
@Override
public HandlerResult handleNotification(
        AssociationChangeNotification not, Object unused) {
    AssociationChange sac = (AssociationChange) not;

    /* Update map to reflect change in association */
    switch (not.event()) {
        case COMM_UP :
            Association newAssociation = new AssociationImpl
               (sac.assocId(), sac.maxInStreams(), sac.maxOutStreams());
            addAssociation(newAssociation);
            break;
        case SHUTDOWN :
        case COMM_LOST :
        //case RESTART: ???
            /* mark association for removal after user handler invoked*/
            associationToRemove.set(lookupAssociation(sac.assocId()));
    }
    return HandlerResult.CONTINUE;
}
 
源代码9 项目: jdk8u_jdk   文件: SctpMultiChannelImpl.java
@Override
public SctpChannel branch(Association association)
        throws IOException {
    synchronized (stateLock) {
        checkAssociation(association);
        if (!isOpen())
            throw new ClosedChannelException();

        FileDescriptor bFd = SctpNet.branch(fdVal,
                                            association.associationID());
        /* successfully branched, we can now remove it from assoc list */
        removeAssociation(association);

        return new SctpChannelImpl(provider(), bFd, association);
    }
}
 
源代码10 项目: openjdk-8-source   文件: SctpMultiChannelImpl.java
@Override
public SctpChannel branch(Association association)
        throws IOException {
    synchronized (stateLock) {
        checkAssociation(association);
        if (!isOpen())
            throw new ClosedChannelException();

        FileDescriptor bFd = SctpNet.branch(fdVal,
                                            association.associationID());
        /* successfully branched, we can now remove it from assoc list */
        removeAssociation(association);

        return new SctpChannelImpl(provider(), bFd, association);
    }
}
 
源代码11 项目: hottub   文件: SctpMultiChannelImpl.java
@Override
public Set<SocketAddress> getRemoteAddresses(Association association)
        throws IOException {
    synchronized (stateLock) {
        checkAssociation(association);
        if (!isOpen())
            throw new ClosedChannelException();

        try {
            return SctpNet.getRemoteAddresses(fdVal, association.associationID());
        } catch (SocketException se) {
            /* a valid association should always have remote addresses */
            Set<SocketAddress> addrs = associationMap.get(association);
            return addrs != null ? addrs : Collections.<SocketAddress>emptySet();
        }
    }
}
 
源代码12 项目: hottub   文件: SctpMultiChannelImpl.java
@Override
public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
                                      T value,
                                      Association association)
        throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!(supportedOptions().contains(name)))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    synchronized (stateLock) {
        if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
                name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
            checkAssociation(association);
        }
        if (!isOpen())
            throw new ClosedChannelException();

        int assocId = association == null ? 0 : association.associationID();
        SctpNet.setSocketOption(fdVal, name, value, assocId);
    }
    return this;
}
 
源代码13 项目: jdk8u-jdk   文件: SctpChannelImpl.java
/**
 * Constructor for sockets obtained from branching
 */
public SctpChannelImpl(SelectorProvider provider,
                       FileDescriptor fd,
                       Association association)
        throws IOException {
    super(provider);
    this.fd = fd;
    this.fdVal = IOUtil.fdVal(fd);
    this.state = ChannelState.CONNECTED;
    port = (Net.localAddress(fd)).getPort();

    if (association != null) { /* branched */
        this.association = association;
    } else { /* obtained from server channel */
        /* Receive COMM_UP */
        ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
        try {
            receive(buf, null, null, true);
        } finally {
            Util.releaseTemporaryDirectBuffer(buf);
        }
    }
}
 
源代码14 项目: TencentKona-8   文件: SctpMultiChannelImpl.java
@Override
public Set<SocketAddress> getRemoteAddresses(Association association)
        throws IOException {
    synchronized (stateLock) {
        checkAssociation(association);
        if (!isOpen())
            throw new ClosedChannelException();

        try {
            return SctpNet.getRemoteAddresses(fdVal, association.associationID());
        } catch (SocketException se) {
            /* a valid association should always have remote addresses */
            Set<SocketAddress> addrs = associationMap.get(association);
            return addrs != null ? addrs : Collections.<SocketAddress>emptySet();
        }
    }
}
 
源代码15 项目: TencentKona-8   文件: SctpMultiChannelImpl.java
@Override
@SuppressWarnings("unchecked")
public <T> T getOption(SctpSocketOption<T> name, Association association)
        throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    synchronized (stateLock) {
        if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
                name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
            checkAssociation(association);
        }
        if (!isOpen())
            throw new ClosedChannelException();

        int assocId = association == null ? 0 : association.associationID();
        return (T)SctpNet.getSocketOption(fdVal, name, assocId);
    }
}
 
源代码16 项目: TencentKona-8   文件: SctpMultiChannelImpl.java
@Override
public SctpChannel branch(Association association)
        throws IOException {
    synchronized (stateLock) {
        checkAssociation(association);
        if (!isOpen())
            throw new ClosedChannelException();

        FileDescriptor bFd = SctpNet.branch(fdVal,
                                            association.associationID());
        /* successfully branched, we can now remove it from assoc list */
        removeAssociation(association);

        return new SctpChannelImpl(provider(), bFd, association);
    }
}
 
源代码17 项目: jdk8u-jdk   文件: SctpMultiChannelImpl.java
private void removeAssociation(Association association) {
    synchronized (stateLock) {
        int assocId = association.associationID();
        Set<SocketAddress> addresses = null;

         try {
            addresses = SctpNet.getRemoteAddresses(fdVal, assocId);
        } catch (IOException unused) {
            /* OK, determining connected addresses may not be possible
             * shutdown, connection lost, etc */
        }

        Set<Association> assocs = associationMap.keySet();
        for (Association a : assocs) {
            if (a.associationID() == assocId) {
                associationMap.remove(a);
                break;
            }
        }
        if (addresses != null) {
            for (SocketAddress addr : addresses)
                addressMap.remove(addr);
        } else {
            /* We cannot determine the connected addresses */
            Set<java.util.Map.Entry<SocketAddress, Association>> addrAssocs =
                    addressMap.entrySet();
            Iterator<Entry<SocketAddress, Association>> iterator = addrAssocs.iterator();
            while (iterator.hasNext()) {
                Entry<SocketAddress, Association> entry = iterator.next();
                if (entry.getValue().equals(association)) {
                    iterator.remove();
                }
            }
        }
    }
}
 
源代码18 项目: netty4.0.27Learn   文件: OioSctpChannel.java
@Override
public Association association() {
    try {
        return ch.association();
    } catch (IOException ignored) {
        return null;
    }
}
 
源代码19 项目: dragonwell8_jdk   文件: SctpMultiChannelImpl.java
@Override
public SctpMultiChannel shutdown(Association association)
        throws IOException {
    synchronized (stateLock) {
        checkAssociation(association);
        if (!isOpen())
            throw new ClosedChannelException();

        SctpNet.shutdown(fdVal, association.associationID());
    }
    return this;
}
 
源代码20 项目: jdk8u60   文件: SctpChannelImpl.java
private void checkAssociation(Association sendAssociation) {
    synchronized (stateLock) {
        if (sendAssociation != null && !sendAssociation.equals(association)) {
            throw new IllegalArgumentException(
                    "Cannot send to another association");
        }
    }
}
 
源代码21 项目: dragonwell8_jdk   文件: SctpChannelImpl.java
@Override
public Association association() throws ClosedChannelException {
    synchronized (stateLock) {
        if (!isOpen())
            throw new ClosedChannelException();
        if (!isConnected())
            return null;

        return association;
    }
}
 
源代码22 项目: openjdk-8   文件: SctpChannelImpl.java
@Override
public Association association() throws ClosedChannelException {
    synchronized (stateLock) {
        if (!isOpen())
            throw new ClosedChannelException();
        if (!isConnected())
            return null;

        return association;
    }
}
 
源代码23 项目: openjdk-8   文件: SctpMultiChannelImpl.java
@Override
public SctpMultiChannel shutdown(Association association)
        throws IOException {
    synchronized (stateLock) {
        checkAssociation(association);
        if (!isOpen())
            throw new ClosedChannelException();

        SctpNet.shutdown(fdVal, association.associationID());
    }
    return this;
}
 
源代码24 项目: hottub   文件: SctpMultiChannelImpl.java
private void removeAssociation(Association association) {
    synchronized (stateLock) {
        int assocId = association.associationID();
        Set<SocketAddress> addresses = null;

         try {
            addresses = SctpNet.getRemoteAddresses(fdVal, assocId);
        } catch (IOException unused) {
            /* OK, determining connected addresses may not be possible
             * shutdown, connection lost, etc */
        }

        Set<Association> assocs = associationMap.keySet();
        for (Association a : assocs) {
            if (a.associationID() == assocId) {
                associationMap.remove(a);
                break;
            }
        }
        if (addresses != null) {
            for (SocketAddress addr : addresses)
                addressMap.remove(addr);
        } else {
            /* We cannot determine the connected addresses */
            Set<java.util.Map.Entry<SocketAddress, Association>> addrAssocs =
                    addressMap.entrySet();
            Iterator<Entry<SocketAddress, Association>> iterator = addrAssocs.iterator();
            while (iterator.hasNext()) {
                Entry<SocketAddress, Association> entry = iterator.next();
                if (entry.getValue().equals(association)) {
                    iterator.remove();
                }
            }
        }
    }
}
 
源代码25 项目: jdk8u-jdk   文件: SctpChannelImpl.java
private void checkAssociation(Association sendAssociation) {
    synchronized (stateLock) {
        if (sendAssociation != null && !sendAssociation.equals(association)) {
            throw new IllegalArgumentException(
                    "Cannot send to another association");
        }
    }
}
 
源代码26 项目: openjdk-jdk8u   文件: SctpMultiChannelImpl.java
@Override
public Set<Association> associations()
        throws ClosedChannelException, NotYetBoundException {
    synchronized (stateLock) {
        if (!isOpen())
            throw new ClosedChannelException();
        if (!isBound())
            throw new NotYetBoundException();

        return Collections.unmodifiableSet(associationMap.keySet());
    }
}
 
源代码27 项目: jdk8u-dev-jdk   文件: SendFailed.java
@Override
public void setAssociation(Association association) {
    this.association = association;
}
 
源代码28 项目: jdk8u-dev-jdk   文件: SctpMultiChannelImpl.java
@Override
public Set<SocketAddress> getRemoteAddresses
        (Association association) throws IOException {
    throw new UnsupportedOperationException(message);
}
 
源代码29 项目: jdk8u-jdk   文件: MessageInfoImpl.java
@Override
public Association association() {
    return association;
}
 
源代码30 项目: jdk8u-dev-jdk   文件: SctpChannelImpl.java
@Override
public Association association() {
    throw new UnsupportedOperationException(message);
}