Search in sources :

Example 1 with Identifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Identifier in project cxf by apache.

the class RMCaptureOutInterceptor method handle.

protected void handle(Message msg) throws SequenceFault, RMException {
    AddressingProperties maps = ContextUtils.retrieveMAPs(msg, false, true, false);
    if (null == maps) {
        LogUtils.log(LOG, Level.WARNING, "MAPS_RETRIEVAL_FAILURE_MSG");
        return;
    }
    if (Boolean.TRUE.equals(msg.get(RMMessageConstants.RM_RETRANSMISSION))) {
        return;
    }
    if (isRuntimeFault(msg)) {
        LogUtils.log(LOG, Level.WARNING, "RUNTIME_FAULT_MSG");
        // in case of a SequenceFault or other WS-RM related fault, set action appropriately.
        // the received inbound maps is available to extract some values in case if needed.
        Throwable cause = msg.getContent(Exception.class).getCause();
        if (cause instanceof SequenceFault || cause instanceof RMException) {
            maps.getAction().setValue(getAddressingNamespace(maps) + "/fault");
        }
        return;
    }
    Source source = getManager().getSource(msg);
    RMConfiguration config = getManager().getEffectiveConfiguration(msg);
    String wsaNamespace = config.getAddressingNamespace();
    String rmNamespace = config.getRMNamespace();
    ProtocolVariation protocol = ProtocolVariation.findVariant(rmNamespace, wsaNamespace);
    RMContextUtils.setProtocolVariation(msg, protocol);
    maps.exposeAs(wsaNamespace);
    String action = null;
    if (null != maps.getAction()) {
        action = maps.getAction().getValue();
    }
    // make sure we use the appropriate namespace
    maps.exposeAs(wsaNamespace);
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Action: " + action);
    }
    boolean isApplicationMessage = !RMContextUtils.isRMProtocolMessage(action);
    boolean isPartialResponse = MessageUtils.isPartialResponse(msg);
    RMConstants constants = protocol.getConstants();
    boolean isLastMessage = RM10Constants.CLOSE_SEQUENCE_ACTION.equals(action);
    RMProperties rmpsOut = RMContextUtils.retrieveRMProperties(msg, true);
    if (null == rmpsOut) {
        rmpsOut = new RMProperties();
        rmpsOut.exposeAs(protocol.getWSRMNamespace());
        RMContextUtils.storeRMProperties(msg, rmpsOut, true);
    }
    // Activate process response for oneWay
    if (msg.getExchange().isOneWay()) {
        msg.getExchange().put(Message.PROCESS_ONEWAY_RESPONSE, true);
    }
    RMProperties rmpsIn = null;
    Identifier inSeqId = null;
    long inMessageNumber = 0;
    if (isApplicationMessage) {
        rmpsIn = RMContextUtils.retrieveRMProperties(msg, false);
        if (null != rmpsIn && null != rmpsIn.getSequence()) {
            inSeqId = rmpsIn.getSequence().getIdentifier();
            inMessageNumber = rmpsIn.getSequence().getMessageNumber();
        }
        ContextUtils.storeDeferUncorrelatedMessageAbort(msg);
    }
    Map<?, ?> invocationContext = (Map<?, ?>) msg.get(Message.INVOCATION_CONTEXT);
    if ((isApplicationMessage || (isLastMessage && invocationContext != null)) && !isPartialResponse) {
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("inbound sequence: " + (null == inSeqId ? "null" : inSeqId.getValue()));
        }
        // get the current sequence, requesting the creation of a new one if necessary
        synchronized (source) {
            SourceSequence seq = null;
            if (isLastMessage) {
                seq = (SourceSequence) invocationContext.get(SourceSequence.class.getName());
            } else {
                seq = getManager().getSequence(inSeqId, msg, maps);
            }
            assert null != seq;
            // increase message number and store a sequence type object in
            // context
            seq.nextMessageNumber(inSeqId, inMessageNumber, isLastMessage);
            if (Boolean.TRUE.equals(msg.getContextualProperty(RMManager.WSRM_LAST_MESSAGE_PROPERTY))) {
                // mark the message as the last one
                seq.setLastMessage(true);
            }
            rmpsOut.setSequence(seq);
            if (seq.isLastMessage()) {
                source.setCurrent(null);
            }
        }
    } else if (!MessageUtils.isRequestor(msg) && constants.getCreateSequenceAction().equals(action)) {
        maps.getAction().setValue(constants.getCreateSequenceResponseAction());
    } else if (isPartialResponse && action == null && isResponseToAction(msg, constants.getSequenceAckAction())) {
        Collection<SequenceAcknowledgement> acks = rmpsIn != null ? rmpsIn.getAcks() : null;
        if (acks != null && acks.size() == 1) {
            SourceSequence ss = source.getSequence(acks.iterator().next().getIdentifier());
            if (ss != null && ss.allAcknowledged()) {
                setAction(maps, constants.getTerminateSequenceAction());
                setTerminateSequence(msg, ss.getIdentifier(), protocol);
                msg.remove(Message.EMPTY_PARTIAL_RESPONSE_MESSAGE);
                // removing this sequence now. See the comment in SourceSequence.setAcknowledged()
                source.removeSequence(ss);
            }
        }
    }
    // capture message if retransmission possible
    if (isApplicationMessage && !isPartialResponse) {
        OutputStream os = msg.getContent(OutputStream.class);
        // message until connection is setup
        if (!(os instanceof WriteOnCloseOutputStream)) {
            WriteOnCloseOutputStream cached = new WriteOnCloseOutputStream(os);
            msg.setContent(OutputStream.class, cached);
            os = cached;
        }
        getManager().initializeInterceptorChain(msg);
        // doneCaptureMessage(msg);
        captureMessage(msg);
    } else if (isLastMessage) {
        // got either the rm11 CS or the rm10 empty LM
        RMStore store = getManager().getStore();
        if (null != store) {
            store.persistOutgoing(rmpsOut.getSourceSequence(), null);
        }
    }
}
Also used : WriteOnCloseOutputStream(org.apache.cxf.io.WriteOnCloseOutputStream) WriteOnCloseOutputStream(org.apache.cxf.io.WriteOnCloseOutputStream) OutputStream(java.io.OutputStream) CachedOutputStream(org.apache.cxf.io.CachedOutputStream) RMStore(org.apache.cxf.ws.rm.persistence.RMStore) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) Map(java.util.Map)

Example 2 with Identifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Identifier in project cxf by apache.

the class RedeliveryQueueImpl method purgeDelivered.

protected void purgeDelivered(RedeliverCandidate candidate) {
    RMProperties rmps = RMContextUtils.retrieveRMProperties(candidate.getMessage(), false);
    SequenceType st = rmps.getSequence();
    Identifier sid = st.getIdentifier();
    String key = sid.getValue();
    synchronized (this) {
        List<RedeliverCandidate> sequenceCandidates = getSequenceCandidates(key);
        if (null != sequenceCandidates) {
            // TODO use a constant op instead of this inefficient linear op
            sequenceCandidates.remove(candidate);
            undeliveredCount--;
        }
        if (sequenceCandidates.isEmpty()) {
            candidates.remove(sid.getValue());
        }
    }
    LOG.fine("Purged delivered message.");
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) RMProperties(org.apache.cxf.ws.rm.RMProperties)

Example 3 with Identifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Identifier in project cxf by apache.

the class RedeliveryQueueImpl method cacheUndelivered.

/**
 * Accepts a new resend candidate.
 *
 * @param ctx the message context.
 * @return ResendCandidate
 */
protected RedeliverCandidate cacheUndelivered(Message message) {
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false);
    SequenceType st = rmps.getSequence();
    Identifier sid = st.getIdentifier();
    String key = sid.getValue();
    RedeliverCandidate candidate = null;
    synchronized (this) {
        List<RedeliverCandidate> sequenceCandidates = getSequenceCandidates(key);
        if (null == sequenceCandidates) {
            sequenceCandidates = new ArrayList<>();
            candidates.put(key, sequenceCandidates);
        }
        candidate = getRedeliverCandidate(st, sequenceCandidates);
        if (candidate == null) {
            candidate = new RedeliverCandidate(message);
            if (isSequenceSuspended(key)) {
                candidate.suspend();
            }
            sequenceCandidates.add(candidate);
            undeliveredCount++;
        }
    }
    LOG.fine("Cached undelivered message.");
    return candidate;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) RMProperties(org.apache.cxf.ws.rm.RMProperties)

Example 4 with Identifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Identifier in project cxf by apache.

the class RetransmissionQueueImpl method cacheUnacknowledged.

/**
 * Accepts a new resend candidate.
 *
 * @param ctx the message context.
 * @return ResendCandidate
 */
protected ResendCandidate cacheUnacknowledged(Message message) {
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, true);
    SequenceType st = rmps.getSequence();
    Identifier sid = st.getIdentifier();
    String key = sid.getValue();
    ResendCandidate candidate = null;
    synchronized (this) {
        List<ResendCandidate> sequenceCandidates = getSequenceCandidates(key);
        if (null == sequenceCandidates) {
            sequenceCandidates = new ArrayList<>();
            candidates.put(key, sequenceCandidates);
        }
        candidate = createResendCandidate(message);
        if (isSequenceSuspended(key)) {
            candidate.suspend();
        }
        sequenceCandidates.add(candidate);
        unacknowledgedCount++;
    }
    LOG.fine("Cached unacknowledged message.");
    try {
        RMEndpoint rme = manager.getReliableEndpoint(message);
        rme.handleAccept(key, st.getMessageNumber(), message);
    } catch (RMException e) {
        LOG.log(Level.WARNING, "Could not find reliable endpoint for message");
    }
    return candidate;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) RMEndpoint(org.apache.cxf.ws.rm.RMEndpoint) RMProperties(org.apache.cxf.ws.rm.RMProperties) RMException(org.apache.cxf.ws.rm.RMException)

Example 5 with Identifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Identifier in project cxf by apache.

the class DestinationSequenceTest method testEqualsAndHashCode.

@Test
public void testEqualsAndHashCode() {
    DestinationSequence seq = new DestinationSequence(id, ref, destination, ProtocolVariation.RM10WSA200408);
    DestinationSequence otherSeq = null;
    assertTrue(!seq.equals(otherSeq));
    otherSeq = new DestinationSequence(id, ref, destination, ProtocolVariation.RM10WSA200408);
    assertEquals(seq, otherSeq);
    assertEquals(seq.hashCode(), otherSeq.hashCode());
    Identifier otherId = factory.createIdentifier();
    otherId.setValue("otherSeq");
    otherSeq = new DestinationSequence(otherId, ref, destination, ProtocolVariation.RM10WSA200408);
    assertTrue(!seq.equals(otherSeq));
    assertTrue(seq.hashCode() != otherSeq.hashCode());
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Test(org.junit.Test)

Aggregations

Identifier (org.apache.cxf.ws.rm.v200702.Identifier)72 ArrayList (java.util.ArrayList)57 BigInteger (java.math.BigInteger)55 Test (org.junit.Test)52 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)35 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)30 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)29 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)25 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)23 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)19 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)19 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)16 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)14 List (java.util.List)13 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)13 VpnInterfaceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)13 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)12 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)11 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)10 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)10