当前位置: 首页>>代码示例>>Java>>正文


Java Association类代码示例

本文整理汇总了Java中com.sun.nio.sctp.Association的典型用法代码示例。如果您正苦于以下问题:Java Association类的具体用法?Java Association怎么用?Java Association使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Association类属于com.sun.nio.sctp包,在下文中一共展示了Association类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getOption

import com.sun.nio.sctp.Association; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:SctpMultiChannelImpl.java

示例2: setOption

import com.sun.nio.sctp.Association; //导入依赖的package包/类
@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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:SctpMultiChannelImpl.java

示例3: handleNotification

import com.sun.nio.sctp.Association; //导入依赖的package包/类
@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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:SctpMultiChannelImpl.java

示例4: addAssociation

import com.sun.nio.sctp.Association; //导入依赖的package包/类
private void addAssociation(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 */
        }

        associationMap.put(association, addresses);
        if (addresses != null) {
            for (SocketAddress addr : addresses)
                addressMap.put(addr, association);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:SctpMultiChannelImpl.java

示例5: getRemoteAddresses

import com.sun.nio.sctp.Association; //导入依赖的package包/类
@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();
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:SctpMultiChannelImpl.java

示例6: branch

import com.sun.nio.sctp.Association; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:SctpMultiChannelImpl.java

示例7: SctpChannelImpl

import com.sun.nio.sctp.Association; //导入依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:SctpChannelImpl.java

示例8: handleNotification

import com.sun.nio.sctp.Association; //导入依赖的package包/类
@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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:Send.java

示例9: MessageInfoImpl

import com.sun.nio.sctp.Association; //导入依赖的package包/类
public MessageInfoImpl(Association association,
                       SocketAddress address,
                       int streamNumber) {
    this.association = association;
    this.address = address;
    this.streamNumber = streamNumber;
    bytes = 0;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:MessageInfoImpl.java

示例10: associations

import com.sun.nio.sctp.Association; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:SctpMultiChannelImpl.java

示例11: checkAssociation

import com.sun.nio.sctp.Association; //导入依赖的package包/类
/**
 * @throws  IllegalArgumentException
 *          If the given association is not controlled by this channel
 *
 * @return  {@code true} if, and only if, the given association is one
 *          of the current associations controlled by this channel
 */
private boolean checkAssociation(Association messageAssoc) {
    synchronized (stateLock) {
        for (Association association : associationMap.keySet()) {
            if (messageAssoc.equals(association)) {
                return true;
            }
        }
    }
    throw new IllegalArgumentException(
          "Given Association is not controlled by this channel");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:SctpMultiChannelImpl.java

示例12: removeAssociation

import com.sun.nio.sctp.Association; //导入依赖的package包/类
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();
                }
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:SctpMultiChannelImpl.java

示例13: checkAssociation

import com.sun.nio.sctp.Association; //导入依赖的package包/类
private void checkAssociation(Association sendAssociation) {
    synchronized (stateLock) {
        if (sendAssociation != null && !sendAssociation.equals(association)) {
            throw new IllegalArgumentException(
                    "Cannot send to another association");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:SctpChannelImpl.java

示例14: association

import com.sun.nio.sctp.Association; //导入依赖的package包/类
@Override
public Association association() throws ClosedChannelException {
    synchronized (stateLock) {
        if (!isOpen())
            throw new ClosedChannelException();
        if (!isConnected())
            return null;

        return association;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:SctpChannelImpl.java

示例15: lookupAssociation

import com.sun.nio.sctp.Association; //导入依赖的package包/类
private Association lookupAssociation(int assocId) {
    /* Lookup the association in our internal map */
    synchronized (stateLock) {
        Set<Association> assocs = associationMap.keySet();
        for (Association a : assocs) {
            if (a.associationID() == assocId) {
                return a;
            }
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:SctpMultiChannelImpl.java


注:本文中的com.sun.nio.sctp.Association类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。