/// <summary>
        /// Override to submit a task to use the thread pool given to the constructor.
        /// Also wrap the supplied onData, onTimeout and onNetworkNack callbacks in an
        /// outer callback which submits a task to the thread pool to call the supplied
        /// callback. See Face.expressInterest for calling details.
        /// </summary>
        ///
        public override long expressInterest(Interest interest_0, OnData onData,
				OnTimeout onTimeout, OnNetworkNack onNetworkNack,
				WireFormat wireFormat_1)
        {
            long pendingInterestId_2 = node_.getNextEntryId();

            // Wrap callbacks to submit to the thread pool.
            OnData finalOnData_3 = onData;
            OnData onDataSubmit_4 = new ThreadPoolFace.Anonymous_C14 (this, finalOnData_3);

            OnTimeout finalOnTimeout_5 = onTimeout;
            OnTimeout onTimeoutSubmit_6 = (onTimeout == null) ? null
                    : new ThreadPoolFace.Anonymous_C13 (this, finalOnTimeout_5);

            OnNetworkNack finalOnNetworkNack_7 = onNetworkNack;
            OnNetworkNack onNetworkNackSubmit_8 = (onNetworkNack == null) ? null
                    : new ThreadPoolFace.Anonymous_C12 (this, finalOnNetworkNack_7);

            // Make an interest copy as required by Node.expressInterest.
            Interest interestCopy_9 = new Interest(interest_0);
            threadPool_.submit(new ThreadPoolFace.Anonymous_C11 (this, onNetworkNackSubmit_8, onDataSubmit_4,
                    interestCopy_9, onTimeoutSubmit_6, pendingInterestId_2, wireFormat_1));

            return pendingInterestId_2;
        }
            public override long expressInterest(Interest interest, OnData onData,
                                                 OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                                 WireFormat wireFormat)
            {
                try {
                    Assert.AssertEquals(3, interest.getLink().getDelegations().size());
                } catch (EncodingException ex) {
                    Assert.Fail("Error in getLink: " + ex);
                }

                if (interest.matchesName(contentData_.getName()))
                {
                    contentCount_[0] = 1;
                    onData.onData(interest, contentData_);
                }
                else if (interest.matchesName(cKeyData_.getName()))
                {
                    cKeyCount_[0] = 1;
                    onData.onData(interest, cKeyData_);
                }
                else if (interest.matchesName(dKeyData_.getName()))
                {
                    dKeyCount_[0] = 1;
                    onData.onData(interest, dKeyData_);
                }
                else
                {
                    onTimeout.onTimeout(interest);
                }

                return(0);
            }
Beispiel #3
0
        /// <summary>
        /// Override to submit a task to use the thread pool given to the constructor.
        /// Also wrap the supplied onData, onTimeout and onNetworkNack callbacks in an
        /// outer callback which submits a task to the thread pool to call the supplied
        /// callback. See Face.expressInterest for calling details.
        /// </summary>
        ///
        public override long expressInterest(Interest interest_0, OnData onData,
                                             OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                             WireFormat wireFormat_1)
        {
            long pendingInterestId_2 = node_.getNextEntryId();

            // Wrap callbacks to submit to the thread pool.
            OnData finalOnData_3  = onData;
            OnData onDataSubmit_4 = new ThreadPoolFace.Anonymous_C14(this, finalOnData_3);

            OnTimeout finalOnTimeout_5  = onTimeout;
            OnTimeout onTimeoutSubmit_6 = (onTimeout == null) ? null
                                        : new ThreadPoolFace.Anonymous_C13(this, finalOnTimeout_5);

            OnNetworkNack finalOnNetworkNack_7  = onNetworkNack;
            OnNetworkNack onNetworkNackSubmit_8 = (onNetworkNack == null) ? null
                                        : new ThreadPoolFace.Anonymous_C12(this, finalOnNetworkNack_7);

            // Make an interest copy as required by Node.expressInterest.
            Interest interestCopy_9 = new Interest(interest_0);

            threadPool_.submit(new ThreadPoolFace.Anonymous_C11(this, onNetworkNackSubmit_8, interestCopy_9,
                                                                onDataSubmit_4, pendingInterestId_2, wireFormat_1, onTimeoutSubmit_6));

            return(pendingInterestId_2);
        }
            public override long expressInterest(Interest interest, OnData onData,
                                                 OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                                 WireFormat wireFormat)
            {
                if (interest.matchesName(contentData_.getName()))
                {
                    contentCount_[0] = 1;
                    onData.onData(interest, contentData_);
                }
                else if (interest.matchesName(cKeyData_.getName()))
                {
                    cKeyCount_[0] = 1;
                    onData.onData(interest, cKeyData_);
                }
                else if (interest.matchesName(dKeyData_.getName()))
                {
                    dKeyCount_[0] = 1;
                    onData.onData(interest, dKeyData_);
                }
                else
                {
                    onTimeout.onTimeout(interest);
                }

                return(0);
            }
Beispiel #5
0
        /// <summary>
        /// Override to submit a task to use the thread pool given to the constructor.
        /// Also wrap the supplied onData, onTimeout and onNetworkNack callbacks in an
        /// outer callback which submits a task to the thread pool to call the supplied
        /// callback. See Face.expressInterest for calling details. We make a separate
        /// expressInterest overload for supplying a Name vs. Interest to avoid making
        /// multiple copies of the Interest.
        /// </summary>
        ///
        public override long expressInterest(Name name, Interest interestTemplate,
                                             OnData onData, OnTimeout onTimeout,
                                             OnNetworkNack onNetworkNack, WireFormat wireFormat_0)
        {
            long pendingInterestId_1 = node_.getNextEntryId();

            // Wrap callbacks to submit to the thread pool.
            OnData finalOnData_2  = onData;
            OnData onDataSubmit_3 = new ThreadPoolFace.Anonymous_C10(this, finalOnData_2);

            OnTimeout finalOnTimeout_4  = onTimeout;
            OnTimeout onTimeoutSubmit_5 = (onTimeout == null) ? null
                                        : new ThreadPoolFace.Anonymous_C9(this, finalOnTimeout_4);

            OnNetworkNack finalOnNetworkNack_6  = onNetworkNack;
            OnNetworkNack onNetworkNackSubmit_7 = (onNetworkNack == null) ? null
                                        : new ThreadPoolFace.Anonymous_C8(this, finalOnNetworkNack_6);

            // Make an interest copy as required by Node.expressInterest.
            Interest interestCopy_8 = net.named_data.jndn.Face.getInterestCopy(name, interestTemplate);

            threadPool_.submit(new ThreadPoolFace.Anonymous_C7(this, onTimeoutSubmit_5, onDataSubmit_3, interestCopy_8,
                                                               wireFormat_0, pendingInterestId_1, onNetworkNackSubmit_7));

            return(pendingInterestId_1);
        }
Beispiel #6
0
            public void processInterest(Interest interest, OnData onData,
                                        OnTimeout onTimeout, OnNetworkNack onNetworkNack)
            {
                NetworkNack networkNack = new NetworkNack();

                networkNack.setReason(net.named_data.jndn.NetworkNack.Reason.NO_ROUTE);

                onNetworkNack.onNetworkNack(interest, networkNack);
            }
Beispiel #7
0
            public override long expressInterest(Interest interest, OnData onData,
                                                 OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                                 WireFormat wireFormat)
            {
                Assert.AssertEquals(expectedInterest_, interest.getName());
                ++timeoutCount_[0];
                onTimeout.onTimeout(interest);

                return(0);
            }
Beispiel #8
0
 /// <summary>
 /// Create a new Entry with the given fields. Note: You should not call this
 /// directly but call PendingInterestTable.add.
 /// </summary>
 ///
 public Entry(long pendingInterestId, Interest interest, OnData onData,
              OnTimeout onTimeout, OnNetworkNack onNetworkNack)
 {
     this.isRemoved_    = false;
     pendingInterestId_ = pendingInterestId;
     interest_          = interest;
     onData_            = onData;
     onTimeout_         = onTimeout;
     onNetworkNack_     = onNetworkNack;
 }
Beispiel #9
0
 public Anonymous_C3(Node paramouter_Node, Interest interestCopy_0,
                     OnData onData_1, WireFormat wireFormat_2, OnTimeout onTimeout_3,
                     long pendingInterestId_4, Face face_5, OnNetworkNack onNetworkNack_6)
 {
     this.interestCopy      = interestCopy_0;
     this.onData            = onData_1;
     this.wireFormat        = wireFormat_2;
     this.onTimeout         = onTimeout_3;
     this.pendingInterestId = pendingInterestId_4;
     this.face          = face_5;
     this.onNetworkNack = onNetworkNack_6;
     this.outer_Node    = paramouter_Node;
 }
Beispiel #10
0
 public void processInterest(Interest interest, OnData onData,
                             OnTimeout onTimeout, OnNetworkNack onNetworkNack)
 {
     if (interest.getName().isPrefixOf(expiredCertificate.getName()))
     {
         onData.onData(interest, expiredCertificate);
     }
     else
     {
         originalProcessInterest.processInterest(interest, onData,
                                                 onTimeout, onNetworkNack);
     }
 }
Beispiel #11
0
 public Anonymous_C7(ThreadPoolFace paramouter_ThreadPoolFace,
                     OnTimeout onTimeoutSubmit_0, OnData onDataSubmit_1,
                     Interest interestCopy_2, WireFormat wireFormat_3,
                     long pendingInterestId_4, OnNetworkNack onNetworkNackSubmit_5)
 {
     this.onTimeoutSubmit      = onTimeoutSubmit_0;
     this.onDataSubmit         = onDataSubmit_1;
     this.interestCopy         = interestCopy_2;
     this.wireFormat           = wireFormat_3;
     this.pendingInterestId    = pendingInterestId_4;
     this.onNetworkNackSubmit  = onNetworkNackSubmit_5;
     this.outer_ThreadPoolFace = paramouter_ThreadPoolFace;
 }
Beispiel #12
0
            public override long expressInterest(Interest interest, OnData onData,
                                                 OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                                 WireFormat wireFormat)
            {
                ++expressInterestCallCount_[0];

                Name interestName = new Name(interest.getName());

                interestName.append(timeMarker_);
                Assert.AssertEquals(true, outer_TestProducer.encryptionKeys.Contains(interestName));
                onData.onData(interest, (Data)ILOG.J2CsMapping.Collections.Collections.Get(outer_TestProducer.encryptionKeys, interestName));

                return(0);
            }
            public void processInterest(Interest interest, OnData onData,
                                        OnTimeout onTimeout, OnNetworkNack onNetworkNack)
            {
                CertificateV2 certificate = outer_ValidatorFixture.cache_.find(interest);

                if (certificate != null)
                {
                    onData.onData(interest, certificate);
                }
                else
                {
                    onTimeout.onTimeout(interest);
                }
            }
Beispiel #14
0
            public override long expressInterest(Interest interest, OnData onData,
                                                 OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                                 WireFormat wireFormat)
            {
                Assert.AssertEquals(expectedInterest_, interest.getName());
                try {
                    Assert.AssertEquals(3, interest.getLink().getDelegations().size());
                } catch (EncodingException ex) {
                    Assert.Fail("Error in getLink: " + ex);
                }
                ++timeoutCount_[0];
                onTimeout.onTimeout(interest);

                return(0);
            }
        public PendingInterestTable.Entry add(long pendingInterestId,
				Interest interestCopy, OnData onData, OnTimeout onTimeout,
				OnNetworkNack onNetworkNack)
        {
            int removeRequestIndex = removeRequests_.indexOf(pendingInterestId);
            if (removeRequestIndex >= 0) {
                // removePendingInterest was called with the pendingInterestId returned by
                //   expressInterest before we got here, so don't add a PIT entry.
                ILOG.J2CsMapping.Collections.Collections.RemoveAt(removeRequests_,removeRequestIndex);
                return null;
            }

            PendingInterestTable.Entry  entry = new PendingInterestTable.Entry (pendingInterestId, interestCopy, onData,
                    onTimeout, onNetworkNack);
            ILOG.J2CsMapping.Collections.Collections.Add(table_,entry);
            return entry;
        }
Beispiel #16
0
        public PendingInterestTable.Entry  add(long pendingInterestId,
                                               Interest interestCopy, OnData onData, OnTimeout onTimeout,
                                               OnNetworkNack onNetworkNack)
        {
            int removeRequestIndex = removeRequests_.indexOf(pendingInterestId);

            if (removeRequestIndex >= 0)
            {
                // removePendingInterest was called with the pendingInterestId returned by
                //   expressInterest before we got here, so don't add a PIT entry.
                ILOG.J2CsMapping.Collections.Collections.RemoveAt(removeRequests_, removeRequestIndex);
                return(null);
            }

            PendingInterestTable.Entry entry = new PendingInterestTable.Entry(pendingInterestId, interestCopy, onData,
                                                                              onTimeout, onNetworkNack);
            ILOG.J2CsMapping.Collections.Collections.Add(table_, entry);
            return(entry);
        }
            /// <summary>
            /// If processInterest_ is not null, call
            /// processInterest_.processInterest(interest, onData, onTimeout, onNetworkNack)
            /// which must call one of the callbacks to simulate the response. Otherwise,
            /// just call onTimeout(interest) to simulate a timeout. This adds a copy of
            /// the interest to sentInterests_ .
            /// </summary>
            ///
            public override long expressInterest(Interest interest, OnData onData,
                                                 OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                                 WireFormat wireFormat)
            {
                // Makes a copy of the interest.
                ILOG.J2CsMapping.Collections.Collections.Add(sentInterests_, new Interest(interest));

                if (processInterest_ != null)
                {
                    processInterest_.processInterest(interest, onData, onTimeout,
                                                     onNetworkNack);
                }
                else
                {
                    onTimeout.onTimeout(interest);
                }

                return(0);
            }
Beispiel #18
0
            public override long expressInterest(Interest interest, OnData onData,
                                                 OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                                 WireFormat wireFormat)
            {
                Assert.AssertEquals(expectedInterest_, interest.getName());

                bool gotInterestName = false;
                Name interestName    = null;

                for (int i = 0; i < 3; ++i)
                {
                    interestName = new Name(interest.getName());
                    if (i == 0)
                    {
                        interestName.append(timeMarkerFirstHop_);
                    }
                    else if (i == 1)
                    {
                        interestName.append(timeMarkerSecondHop_);
                    }
                    else if (i == 2)
                    {
                        interestName.append(timeMarkerThirdHop_);
                    }

                    // matchesName will check the Exclude.
                    if (interest.matchesName(interestName))
                    {
                        gotInterestName = true;
                        ++requestCount_[0];
                        break;
                    }
                }

                if (gotInterestName)
                {
                    onData.onData(interest,
                                  (Data)ILOG.J2CsMapping.Collections.Collections.Get(outer_TestProducer.encryptionKeys, interestName));
                }

                return(0);
            }
        public override long expressInterest(Interest interest, OnData onData,
                                             OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                             WireFormat wireFormat)
        {
            // Make a copy of the interest.
            ILOG.J2CsMapping.Collections.Collections.Add(sentInterests_, new Interest(interest));

            Data data = storage_.find(interest);

            if (data != null)
            {
                ILOG.J2CsMapping.Collections.Collections.Add(sentData_, new Data(data));
                onData.onData(interest, data);
            }
            else
            {
                onTimeout.onTimeout(interest);
            }

            return(0);
        }
Beispiel #20
0
        /// <summary>
        /// Do the work of expressInterest once we know we are connected. Add the entry
        /// to the PIT, encode and send the interest.
        /// </summary>
        ///
        /// <param name="pendingInterestId"></param>
        /// <param name="interestCopy"></param>
        /// <param name="onData"></param>
        /// <param name="onTimeout"></param>
        /// <param name="onNetworkNack"></param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <param name="face"></param>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        internal void expressInterestHelper(long pendingInterestId,
                                            Interest interestCopy, OnData onData, OnTimeout onTimeout,
                                            OnNetworkNack onNetworkNack, WireFormat wireFormat, Face face)
        {
            PendingInterestTable.Entry pendingInterest = pendingInterestTable_
                                                         .add(pendingInterestId, interestCopy, onData, onTimeout,
                                                              onNetworkNack);
            if (pendingInterest == null)
            {
                // removePendingInterest was already called with the pendingInterestId.
                return;
            }

            if (onTimeout != null ||
                interestCopy.getInterestLifetimeMilliseconds() >= 0.0d)
            {
                // Set up the timeout.
                double delayMilliseconds = interestCopy
                                           .getInterestLifetimeMilliseconds();
                if (delayMilliseconds < 0.0d)
                {
                    // Use a default timeout delay.
                    delayMilliseconds = 4000.0d;
                }

                face.callLater(delayMilliseconds, new Node.Anonymous_C0(this, pendingInterest));
            }

            // Special case: For timeoutPrefix_ we don't actually send the interest.
            if (!timeoutPrefix_.match(interestCopy.getName()))
            {
                Blob encoding = interestCopy.wireEncode(wireFormat);
                if (encoding.size() > getMaxNdnPacketSize())
                {
                    throw new Exception(
                              "The encoded interest size exceeds the maximum limit getMaxNdnPacketSize()");
                }
                transport_.send(encoding.buf());
            }
        }
Beispiel #21
0
            public void processInterest(Interest interest, OnData onData,
                                        OnTimeout onTimeout, OnNetworkNack onNetworkNack)
            {
                try {
                    // Create another key for the same identity and sign it properly.
                    PibKey parentKey = outer_TestValidator.fixture_.keyChain_
                                       .createKey(outer_TestValidator.fixture_.subIdentity_);
                    PibKey requestedKey = outer_TestValidator.fixture_.subIdentity_.getKey(interest
                                                                                           .getName());

                    // Copy the Name.
                    Name certificateName = new Name(requestedKey.getName());
                    certificateName.append("looper").appendVersion(1);
                    CertificateV2 certificate = new CertificateV2();
                    certificate.setName(certificateName);

                    // Set the MetaInfo.
                    certificate.getMetaInfo().setType(net.named_data.jndn.ContentType.KEY);
                    // Set the freshness period to one hour.
                    certificate.getMetaInfo().setFreshnessPeriod(3600 * 1000.0d);

                    // Set the content.
                    certificate.setContent(requestedKey.getPublicKey());

                    // Set SigningInfo.
                    SigningInfo                             // Set SigningInfo.
                        paras = new SigningInfo(parentKey);
                    // Validity period from 10 days before to 10 days after now.
                    double now = net.named_data.jndn.util.Common.getNowMilliseconds();
                    paras.setValidityPeriod(new ValidityPeriod(now - 10 * 24
                                                               * 3600 * 1000.0d, now + 10 * 24 * 3600 * 1000.0d));

                    outer_TestValidator.fixture_.keyChain_.sign(certificate, paras);
                    onData.onData(interest, certificate);
                } catch (Exception ex) {
                    Assert.Fail("Error in InfiniteCertificateChain: " + ex);
                }
            }
Beispiel #22
0
        /// <summary>
        /// Encode name as an Interest. If interestTemplate is not null, use its
        /// interest selectors.
        /// Send the Interest through the transport, read the entire response and call
        /// onData, onTimeout or onNetworkNack as described below.
        /// </summary>
        ///
        /// <param name="name">A Name for the interest. This copies the Name.</param>
        /// <param name="interestTemplate"></param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onNetworkNack">onNetworkNack.onNetworkNack(interest, networkNack) and does not call onTimeout. However, if a network Nack is received and onNetworkNack is null, do nothing and wait for the interest to time out. (Therefore, an application which does not yet process a network Nack reason treats a Nack the same as a timeout.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public virtual long expressInterest(Name name, Interest interestTemplate,
				OnData onData, OnTimeout onTimeout, OnNetworkNack onNetworkNack,
				WireFormat wireFormat)
        {
            long pendingInterestId = node_.getNextEntryId();

            // This copies the name object as required by Node.expressInterest.
            node_.expressInterest(pendingInterestId,
                    getInterestCopy(name, interestTemplate), onData, onTimeout,
                    onNetworkNack, wireFormat, this);

            return pendingInterestId;
        }
Beispiel #23
0
        /// <summary>
        /// Send the Interest through the transport, read the entire response and call
        /// onData, onTimeout or onNetworkNack as described below.
        /// </summary>
        ///
        /// <param name="interest">The Interest to send.  This copies the Interest.</param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onNetworkNack">onNetworkNack.onNetworkNack(interest, networkNack) and does not call onTimeout. However, if a network Nack is received and onNetworkNack is null, do nothing and wait for the interest to time out. (Therefore, an application which does not yet process a network Nack reason treats a Nack the same as a timeout.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public virtual long expressInterest(Interest interest, OnData onData,
				OnTimeout onTimeout, OnNetworkNack onNetworkNack,
				WireFormat wireFormat)
        {
            long pendingInterestId = node_.getNextEntryId();

            // This copies the interest as required by Node.expressInterest.
            node_.expressInterest(pendingInterestId, interest, onData, onTimeout,
                    onNetworkNack, wireFormat, this);

            return pendingInterestId;
        }
			public long expressInterest(Interest interest, OnData onData,
					OnTimeout onTimeout, OnNetworkNack onNetworkNack,
					WireFormat wireFormat) throws IOException {
            public Anonymous_C11(ThreadPoolFace paramouter_ThreadPoolFace,
						OnNetworkNack onNetworkNackSubmit_0, OnData onDataSubmit_1,
						Interest interestCopy_2, OnTimeout onTimeoutSubmit_3,
						long pendingInterestId_4, WireFormat wireFormat_5)
            {
                this.onNetworkNackSubmit = onNetworkNackSubmit_0;
                    this.onDataSubmit = onDataSubmit_1;
                    this.interestCopy = interestCopy_2;
                    this.onTimeoutSubmit = onTimeoutSubmit_3;
                    this.pendingInterestId = pendingInterestId_4;
                    this.wireFormat = wireFormat_5;
                    this.outer_ThreadPoolFace = paramouter_ThreadPoolFace;
            }
Beispiel #26
0
        /// <summary>
        /// Do the work of expressInterest once we know we are connected. Add the entry
        /// to the PIT, encode and send the interest.
        /// </summary>
        ///
        /// <param name="pendingInterestId"></param>
        /// <param name="interestCopy"></param>
        /// <param name="onData"></param>
        /// <param name="onTimeout"></param>
        /// <param name="onNetworkNack"></param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <param name="face"></param>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        internal void expressInterestHelper(long pendingInterestId,
				Interest interestCopy, OnData onData, OnTimeout onTimeout,
				OnNetworkNack onNetworkNack, WireFormat wireFormat, Face face)
        {
            PendingInterestTable.Entry pendingInterest = pendingInterestTable_
                    .add(pendingInterestId, interestCopy, onData, onTimeout,
                            onNetworkNack);
            if (pendingInterest == null)
                // removePendingInterest was already called with the pendingInterestId.
                return;

            if (onTimeout != null
                    || interestCopy.getInterestLifetimeMilliseconds() >= 0.0d) {
                // Set up the timeout.
                double delayMilliseconds = interestCopy
                        .getInterestLifetimeMilliseconds();
                if (delayMilliseconds < 0.0d)
                    // Use a default timeout delay.
                    delayMilliseconds = 4000.0d;

                face.callLater(delayMilliseconds, new Node.Anonymous_C0 (this, pendingInterest));
            }

            // Special case: For timeoutPrefix_ we don't actually send the interest.
            if (!timeoutPrefix_.match(interestCopy.getName())) {
                Blob encoding = interestCopy.wireEncode(wireFormat);
                if (encoding.size() > getMaxNdnPacketSize())
                    throw new Exception(
                            "The encoded interest size exceeds the maximum limit getMaxNdnPacketSize()");
                transport_.send(encoding.buf());
            }
        }
            public Anonymous_C12(ThreadPoolFace paramouter_ThreadPoolFace,
						OnNetworkNack finalOnNetworkNack_0)
            {
                this.finalOnNetworkNack = finalOnNetworkNack_0;
                    this.outer_ThreadPoolFace = paramouter_ThreadPoolFace;
            }
Beispiel #28
0
 public Anonymous_C8(ThreadPoolFace paramouter_ThreadPoolFace,
                     OnNetworkNack finalOnNetworkNack_0)
 {
     this.finalOnNetworkNack   = finalOnNetworkNack_0;
     this.outer_ThreadPoolFace = paramouter_ThreadPoolFace;
 }
Beispiel #29
0
        /// <summary>
        /// Encode name as an Interest, using a default interest lifetime.
        /// Send the Interest through the transport, read the entire response and call
        /// onData, onTimeout or onNetworkNack as described below.
        /// </summary>
        ///
        /// <param name="name">A Name for the interest. This copies the Name.</param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onNetworkNack">onNetworkNack.onNetworkNack(interest, networkNack) and does not call onTimeout. However, if a network Nack is received and onNetworkNack is null, do nothing and wait for the interest to time out. (Therefore, an application which does not yet process a network Nack reason treats a Nack the same as a timeout.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public long expressInterest(Name name, OnData onData, OnTimeout onTimeout,
				OnNetworkNack onNetworkNack, WireFormat wireFormat)
        {
            return expressInterest(name, null, onData, onTimeout, onNetworkNack,
                    wireFormat);
        }
Beispiel #30
0
        /// <summary>
        /// Encode name as an Interest, using a default interest lifetime.
        /// Send the Interest through the transport, read the entire response and call
        /// onData, onTimeout or onNetworkNack as described below.
        /// This uses the default WireFormat.getDefaultWireFormat().
        /// </summary>
        ///
        /// <param name="name">A Name for the interest. This copies the Name.</param>
        /// <param name="onData">expressInterest and data is the received Data object. NOTE: You must not change the interest object - if you need to change it then make a copy. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <param name="onNetworkNack">onNetworkNack.onNetworkNack(interest, networkNack) and does not call onTimeout. However, if a network Nack is received and onNetworkNack is null, do nothing and wait for the interest to time out. (Therefore, an application which does not yet process a network Nack reason treats a Nack the same as a timeout.) NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.</param>
        /// <returns>The pending interest ID which can be used with
        /// removePendingInterest.</returns>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public long expressInterest(Name name, OnData onData, OnTimeout onTimeout,
				OnNetworkNack onNetworkNack)
        {
            return expressInterest(name, null, onData, onTimeout, onNetworkNack,
                    net.named_data.jndn.encoding.WireFormat.getDefaultWireFormat());
        }
Beispiel #31
0
        /// <summary>
        /// Send the Interest through the transport, read the entire response and call
        /// onData, onTimeout or onNetworkNack as described below.
        /// </summary>
        ///
        /// <param name="pendingInterestId"></param>
        /// <param name="interestCopy">to use.</param>
        /// <param name="onData">expressInterest and data is the received Data object.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it.</param>
        /// <param name="onNetworkNack">onNetworkNack.onNetworkNack(interest, networkNack) and does not call onTimeout. However, if a network Nack is received and onNetworkNack is null, do nothing and wait for the interest to time out.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <param name="face"></param>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public void expressInterest(long pendingInterestId,
				Interest interestCopy, OnData onData,
				OnTimeout onTimeout, OnNetworkNack onNetworkNack,
				WireFormat wireFormat, Face face)
        {
            // Set the nonce in our copy of the Interest so it is saved in the PIT.
            interestCopy.setNonce(nonceTemplate_);
            interestCopy.refreshNonce();

            if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.CONNECT_COMPLETE) {
                // We are connected. Simply send the interest without synchronizing.
                expressInterestHelper(pendingInterestId, interestCopy, onData,
                        onTimeout, onNetworkNack, wireFormat, face);
                return;
            }

             lock (onConnectedCallbacks_) {
                        // TODO: Properly check if we are already connected to the expected host.
                        if (!transport_.isAsync()) {
                            // The simple case: Just do a blocking connect and express.
                            transport_.connect(connectionInfo_, this, null);
                            expressInterestHelper(pendingInterestId, interestCopy, onData,
                                    onTimeout, onNetworkNack, wireFormat, face);
                            // Make future calls to expressInterest send directly to the Transport.
                            connectStatus_ = net.named_data.jndn.Node.ConnectStatus.CONNECT_COMPLETE;

                            return;
                        }

                        // Handle the async case.
                        if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.UNCONNECTED) {
                            connectStatus_ = net.named_data.jndn.Node.ConnectStatus.CONNECT_REQUESTED;

                            // expressInterestHelper will be called by onConnected.
                            ILOG.J2CsMapping.Collections.Collections.Add(onConnectedCallbacks_,new Node.Anonymous_C3 (this, interestCopy, onNetworkNack, face,
                                                    onTimeout, pendingInterestId, wireFormat, onData));

                            IRunnable onConnected = new Node.Anonymous_C2 (this);
                            transport_.connect(connectionInfo_, this, onConnected);
                        } else if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.CONNECT_REQUESTED) {
                            // Still connecting. add to the interests to express by onConnected.
                            ILOG.J2CsMapping.Collections.Collections.Add(onConnectedCallbacks_,new Node.Anonymous_C1 (this, interestCopy, onData, onTimeout,
                                                    onNetworkNack, wireFormat, face, pendingInterestId));
                        } else if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.CONNECT_COMPLETE)
                            // We have to repeat this check for CONNECT_COMPLETE in case the
                            // onConnected callback was called while we were waiting to enter this
                            // synchronized block.
                            expressInterestHelper(pendingInterestId, interestCopy, onData,
                                    onTimeout, onNetworkNack, wireFormat, face);
                        else
                            // Don't expect this to happen.
                            throw new Exception("Node: Unrecognized _connectStatus "
                                    + connectStatus_);
                    }
        }
            /// <summary>
            /// Create a new Entry with the given fields. Note: You should not call this
            /// directly but call PendingInterestTable.add.
            /// </summary>
            ///
            public Entry(long pendingInterestId, Interest interest, OnData onData,
					OnTimeout onTimeout, OnNetworkNack onNetworkNack)
            {
                this.isRemoved_ = false;
                pendingInterestId_ = pendingInterestId;
                interest_ = interest;
                onData_ = onData;
                onTimeout_ = onTimeout;
                onNetworkNack_ = onNetworkNack;
            }
Beispiel #33
0
        /// <summary>
        /// Send the Interest through the transport, read the entire response and call
        /// onData, onTimeout or onNetworkNack as described below.
        /// </summary>
        ///
        /// <param name="pendingInterestId"></param>
        /// <param name="interestCopy">to use.</param>
        /// <param name="onData">expressInterest and data is the received Data object.</param>
        /// <param name="onTimeout">interest given to expressInterest. If onTimeout is null, this does not use it.</param>
        /// <param name="onNetworkNack">onNetworkNack.onNetworkNack(interest, networkNack) and does not call onTimeout. However, if a network Nack is received and onNetworkNack is null, do nothing and wait for the interest to time out.</param>
        /// <param name="wireFormat">A WireFormat object used to encode the message.</param>
        /// <param name="face"></param>
        /// <exception cref="IOException">For I/O error in sending the interest.</exception>
        /// <exception cref="System.Exception">If the encoded interest size exceeds getMaxNdnPacketSize().</exception>
        public void expressInterest(long pendingInterestId,
                                    Interest interestCopy, OnData onData,
                                    OnTimeout onTimeout, OnNetworkNack onNetworkNack,
                                    WireFormat wireFormat, Face face)
        {
            // Set the nonce in our copy of the Interest so it is saved in the PIT.
            interestCopy.setNonce(nonceTemplate_);
            interestCopy.refreshNonce();

            if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.CONNECT_COMPLETE)
            {
                // We are connected. Simply send the interest without synchronizing.
                expressInterestHelper(pendingInterestId, interestCopy, onData,
                                      onTimeout, onNetworkNack, wireFormat, face);
                return;
            }

            lock (onConnectedCallbacks_) {
                // TODO: Properly check if we are already connected to the expected host.
                if (!transport_.isAsync())
                {
                    // The simple case: Just do a blocking connect and express.
                    transport_.connect(connectionInfo_, this, null);
                    expressInterestHelper(pendingInterestId, interestCopy, onData,
                                          onTimeout, onNetworkNack, wireFormat, face);
                    // Make future calls to expressInterest send directly to the Transport.
                    connectStatus_ = net.named_data.jndn.Node.ConnectStatus.CONNECT_COMPLETE;

                    return;
                }

                // Handle the async case.
                if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.UNCONNECTED)
                {
                    connectStatus_ = net.named_data.jndn.Node.ConnectStatus.CONNECT_REQUESTED;

                    // expressInterestHelper will be called by onConnected.
                    ILOG.J2CsMapping.Collections.Collections.Add(onConnectedCallbacks_, new Node.Anonymous_C3(this, interestCopy, onData, wireFormat,
                                                                                                              onTimeout, pendingInterestId, face, onNetworkNack));

                    IRunnable onConnected = new Node.Anonymous_C2(this);
                    transport_.connect(connectionInfo_, this, onConnected);
                }
                else if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.CONNECT_REQUESTED)
                {
                    // Still connecting. add to the interests to express by onConnected.
                    ILOG.J2CsMapping.Collections.Collections.Add(onConnectedCallbacks_, new Node.Anonymous_C1(this, onData, pendingInterestId, wireFormat,
                                                                                                              face, onNetworkNack, interestCopy, onTimeout));
                }
                else if (connectStatus_ == net.named_data.jndn.Node.ConnectStatus.CONNECT_COMPLETE)
                {
                    // We have to repeat this check for CONNECT_COMPLETE in case the
                    // onConnected callback was called while we were waiting to enter this
                    // synchronized block.
                    expressInterestHelper(pendingInterestId, interestCopy, onData,
                                          onTimeout, onNetworkNack, wireFormat, face);
                }
                else
                {
                    // Don't expect this to happen.
                    throw new Exception("Node: Unrecognized _connectStatus "
                                        + connectStatus_);
                }
            }
        }
        /// <summary>
        /// Override to submit a task to use the thread pool given to the constructor.
        /// Also wrap the supplied onData, onTimeout and onNetworkNack callbacks in an
        /// outer callback which submits a task to the thread pool to call the supplied
        /// callback. See Face.expressInterest for calling details. We make a separate
        /// expressInterest overload for supplying a Name vs. Interest to avoid making
        /// multiple copies of the Interest.
        /// </summary>
        ///
        public override long expressInterest(Name name, Interest interestTemplate,
				OnData onData, OnTimeout onTimeout,
				OnNetworkNack onNetworkNack, WireFormat wireFormat_0)
        {
            long pendingInterestId_1 = node_.getNextEntryId();

            // Wrap callbacks to submit to the thread pool.
            OnData finalOnData_2 = onData;
            OnData onDataSubmit_3 = new ThreadPoolFace.Anonymous_C10 (this, finalOnData_2);

            OnTimeout finalOnTimeout_4 = onTimeout;
            OnTimeout onTimeoutSubmit_5 = (onTimeout == null) ? null
                    : new ThreadPoolFace.Anonymous_C9 (this, finalOnTimeout_4);

            OnNetworkNack finalOnNetworkNack_6 = onNetworkNack;
            OnNetworkNack onNetworkNackSubmit_7 = (onNetworkNack == null) ? null
                    : new ThreadPoolFace.Anonymous_C8 (this, finalOnNetworkNack_6);

            // Make an interest copy as required by Node.expressInterest.
            Interest interestCopy_8 = net.named_data.jndn.Face.getInterestCopy(name, interestTemplate);
            threadPool_.submit(new ThreadPoolFace.Anonymous_C7 (this, onDataSubmit_3, onTimeoutSubmit_5, interestCopy_8,
                    onNetworkNackSubmit_7, wireFormat_0, pendingInterestId_1));

            return pendingInterestId_1;
        }
Beispiel #35
0
            public Anonymous_C3(Node paramouter_Node, Interest interestCopy_0,
						OnNetworkNack onNetworkNack_1, Face face_2, OnTimeout onTimeout_3,
						long pendingInterestId_4, WireFormat wireFormat_5, OnData onData_6)
            {
                this.interestCopy = interestCopy_0;
                    this.onNetworkNack = onNetworkNack_1;
                    this.face = face_2;
                    this.onTimeout = onTimeout_3;
                    this.pendingInterestId = pendingInterestId_4;
                    this.wireFormat = wireFormat_5;
                    this.onData = onData_6;
                    this.outer_Node = paramouter_Node;
            }