Examples of MessageFilter


Examples of freenet.io.comm.MessageFilter

     */
    Logger.normal(this, "Got collision on "+myKey+" ("+uid+") sending to "+next.getPeer());
   
    headers = ((ShortBuffer) msg.getObject(DMT.BLOCK_HEADERS)).getData();
    // Wait for the data
    MessageFilter mfData = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(SSKInsertHandler.DATA_INSERT_TIMEOUT).setType(DMT.FNPSSKDataFoundData);
    Message dataMessage;
    try {
      dataMessage = node.usm.waitFor(mfData, this);
    } catch (DisconnectedException e) {
      if(logMINOR)
View Full Code Here

Examples of freenet.io.comm.MessageFilter

         * Because messages may be re-ordered, it is
         * entirely possible that we get a non-local RejectedOverload,
         * followed by an Accepted. So we must loop here.
         */
       
        MessageFilter mfAccepted = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(acceptedTimeout).setType(DMT.FNPSSKAccepted);
        MessageFilter mfRejectedLoop = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(acceptedTimeout).setType(DMT.FNPRejectedLoop);
        MessageFilter mfRejectedOverload = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(acceptedTimeout).setType(DMT.FNPRejectedOverload);
        return mfAccepted.or(mfRejectedLoop.or(mfRejectedOverload));
  }
View Full Code Here

Examples of freenet.io.comm.MessageFilter

      }
         
          // Wait for the SSKPubKeyAccepted
         
          // FIXME doubled the timeout because handling it properly would involve forking.
          MessageFilter mf1 = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(ACCEPTED_TIMEOUT*2).setType(DMT.FNPSSKPubKeyAccepted);
         
          Message newAck;
      try {
        newAck = node.usm.waitFor(mf1, this);
      } catch (DisconnectedException e) {
        if(logMINOR) Logger.minor(this, "Disconnected from "+next);
        next.noLongerRoutingTo(thisTag, false);
        routeRequests();
        return;
      }
         
          if(newAck == null) {
            handleNoPubkeyAccepted(next, thisTag);
        // Try another peer
          routeRequests();
          return;
          }
        }
       
        // We have sent them the pubkey, and the data.
        // Wait for the response.
       
    MessageFilter mf = makeSearchFilter(next, calculateTimeout(htl));
       
        while (true) {
          Message msg;
      try {
        msg = node.usm.waitFor(mf, this);
View Full Code Here

Examples of freenet.io.comm.MessageFilter

      return OFFER_STATUS.TRY_ANOTHER;
    }
  }

  private MessageFilter getOfferedKeyReplyFilter(final PeerNode pn, long timeout) {
      MessageFilter mfRO = MessageFilter.create().setSource(pn).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPRejectedOverload);
      MessageFilter mfGetInvalid = MessageFilter.create().setSource(pn).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPGetOfferedKeyInvalid);
      if(isSSK) {
        MessageFilter mfAltDF = MessageFilter.create().setSource(pn).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPSSKDataFoundHeaders);
        return mfAltDF.or(mfRO.or(mfGetInvalid));
      } else {
        MessageFilter mfDF = MessageFilter.create().setSource(pn).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPCHKDataFound);
        return mfDF.or(mfRO.or(mfGetInvalid));
      }
  }
View Full Code Here

Examples of freenet.io.comm.MessageFilter

        Logger.minor(this, "Node "+pn+" rejected FNPGetOfferedKey as invalid with reason "+reply.getShort(DMT.REASON));
      return OFFER_STATUS.TRY_ANOTHER;
    } else if(reply.getSpec() == DMT.FNPSSKDataFoundHeaders) {
      byte[] headers = ((ShortBuffer) reply.getObject(DMT.BLOCK_HEADERS)).getData();
      // Wait for the data
      MessageFilter mfData = MessageFilter.create().setSource(pn).setField(DMT.UID, uid).setTimeout(getOfferedTimeout).setType(DMT.FNPSSKDataFoundData);
      Message dataMessage;
      try {
        dataMessage = node.usm.waitFor(mfData, this);
      } catch (DisconnectedException e) {
        if(logMINOR)
          Logger.minor(this, "Disconnected: "+pn+" getting data for offer for "+key);
        return OFFER_STATUS.TRY_ANOTHER;
      }
      if(dataMessage == null) {
        Logger.error(this, "Got headers but not data from "+pn+" for offer for "+key+" on "+this);
        return OFFER_STATUS.TRY_ANOTHER;
      }
      byte[] sskData = ((ShortBuffer) dataMessage.getObject(DMT.DATA)).getData();
      if(pubKey == null) {
        MessageFilter mfPK = MessageFilter.create().setSource(pn).setField(DMT.UID, uid).setTimeout(getOfferedTimeout).setType(DMT.FNPSSKPubKey);
        Message pk;
        try {
          pk = node.usm.waitFor(mfPK, this);
        } catch (DisconnectedException e) {
          if(logMINOR)
View Full Code Here

Examples of freenet.io.comm.MessageFilter

     * FNPAccepted - continue
     * FNPRejectedLoop - go to another node
     * FNPRejectedOverload - propagate back to source, go to another node if local
     */
   
    MessageFilter mfAccepted = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(acceptedTimeout).setType(DMT.FNPAccepted);
    MessageFilter mfRejectedLoop = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(acceptedTimeout).setType(DMT.FNPRejectedLoop);
    MessageFilter mfRejectedOverload = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(acceptedTimeout).setType(DMT.FNPRejectedOverload);
   
    // mfRejectedOverload must be the last thing in the or
    // So its or pointer remains null
    // Otherwise we need to recreate it below
    return mfAccepted.or(mfRejectedLoop.or(mfRejectedOverload));
View Full Code Here

Examples of freenet.io.comm.MessageFilter

    // Otherwise we need to recreate it below
    return mfAccepted.or(mfRejectedLoop.or(mfRejectedOverload));
  }

  private MessageFilter createMessageFilter(int timeout, PeerNode next) {
    MessageFilter mfDNF = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPDataNotFound);
    MessageFilter mfRF = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPRecentlyFailed);
    MessageFilter mfRouteNotFound = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPRouteNotFound);
    MessageFilter mfRejectedOverload = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPRejectedOverload);
   
    MessageFilter mf = mfDNF.or(mfRF.or(mfRouteNotFound.or(mfRejectedOverload)));
    if(!isSSK) {
      MessageFilter mfRealDFCHK = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPCHKDataFound);
      mf = mfRealDFCHK.or(mf);
    } else {
      MessageFilter mfPubKey = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPSSKPubKey);
      MessageFilter mfDFSSKHeaders = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPSSKDataFoundHeaders);
      MessageFilter mfDFSSKData = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPSSKDataFoundData);
      mf = mfPubKey.or(mfDFSSKHeaders.or(mfDFSSKData.or(mf)));
    }
    return mf;
  }
View Full Code Here

Examples of freenet.io.comm.MessageFilter

    final short htl = this.htl;
    origTag.handlingTimeout(next);

    long timeout = MINUTES.toMillis(1);

    MessageFilter mf = makeAcceptedRejectedFilter(next, timeout, origTag);
    try {
      node.usm.addAsyncFilter(mf, new SlowAsyncMessageFilterCallback() {

        @Override
        public void onMatched(Message m) {
View Full Code Here

Examples of freenet.io.comm.MessageFilter

   
    public void schedule() {
          long now = System.currentTimeMillis();
          int timeout = (int)(Math.min(Integer.MAX_VALUE, deadline - now));
          if(timeout >= 0) {
            MessageFilter mf = createMessageFilter(timeout, waitingFor);
            try {
              node.usm.addAsyncFilter(mf, this, RequestSender.this);
            } catch (DisconnectedException e) {
              onDisconnect(lastNode);
            }
View Full Code Here

Examples of freenet.io.comm.MessageFilter

  @Override
  protected MessageFilter makeAcceptedRejectedFilter(PeerNode next, long acceptedTimeout, UIDTag tag) {
    // Use the right UID here, in case we fork on cacheable.
    final long uid = tag.uid;
        MessageFilter mfAccepted = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(acceptedTimeout).setType(DMT.FNPAccepted);
        MessageFilter mfRejectedLoop = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(acceptedTimeout).setType(DMT.FNPRejectedLoop);
        MessageFilter mfRejectedOverload = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(acceptedTimeout).setType(DMT.FNPRejectedOverload);
       
        // mfRejectedOverload must be the last thing in the or
        // So its or pointer remains null
        // Otherwise we need to recreate it below
        mfRejectedOverload.clearOr();
        return mfAccepted.or(mfRejectedLoop.or(mfRejectedOverload));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.