Package freenet.node

Examples of freenet.node.SendableGet


    if(KILL_BLOCKS != 0)
      random = new MersenneTwister();
    else
      random = null;
    Key[] keys = null;
    SendableGet getter = null;
    ClientRequestScheduler sched = null;
    BlockSet blocks = null;
    boolean waited = false;
    synchronized(this) {
      while(true) {
        for(short prio = 0;prio<queue.length;prio++) {
            QueueItem trans;
          if((trans = queue[prio].pollFirst()) != null) {
            keys = trans.keys;
            getter = trans.getter;
            // sched assigned out of loop
            blocks = trans.blockSet;
            if(logMINOR)
              Logger.minor(this, "Checking transient request "+getter+" prio "+prio+" of "+queue[prio].size());
            break;
          }
        }
        if(keys != null)
          break;
        if(logMINOR) Logger.minor(this, "Waiting for more transient requests");
        waited = true;
        try {
          // Wait for anything.
          wait(SECONDS.toMillis(100));
        } catch (InterruptedException e) {
          // Ok
        }
      }
    }
    sched = getter.getScheduler(context);
    boolean anyValid = false;
    for(Key key : keys) {
      if(random != null) {
        if(random.nextInt(RESET_COUNTER) < KILL_BLOCKS) {
          anyValid = true;
          continue;
        }
      }
      KeyBlock block;
      if(blocks != null)
        block = blocks.get(key);
      else
        block = node.fetch(key, true, true, false, false, null);
      if(block != null) {
        if(logMINOR) Logger.minor(this, "Found key");
        if(key instanceof NodeSSK)
          sched.tripPendingKey(block);
        else // CHK
          sched.tripPendingKey(block);
      } else {
        anyValid = true;
      }
//      synchronized(this) {
//        keysToCheck[priority].remove(key);
//      }
    }
    if(logMINOR) Logger.minor(this, "Checked "+keys.length+" keys");
    if(getter.persistent()) {
      final SendableGet get = getter;
      final ClientRequestScheduler scheduler = sched;
      final boolean valid = anyValid;
      try {
        context.jobRunner.queue(new PersistentJob() {

          @Override
          public boolean run(ClientContext context) {
            try {
              scheduler.finishRegister(new SendableGet[] { get }, true, valid);
            } catch (Throwable t) {
              Logger.error(this, "Failed to register "+get+": "+t, t);
              try {
                get.onFailure(new LowLevelGetException(LowLevelGetException.INTERNAL_ERROR, "Internal error: "+t, t), null, context);
              } catch (Throwable t1) {
                Logger.error(this, "Failed to fail: "+t, t);
              }
            }
            return false;
View Full Code Here


    context.getSskFetchScheduler(realTimeFlag).schedTransient.removePendingKeys((KeyListener)this);
    USKAttempt[] attempts;
    USKAttempt[] polling;
    DBRAttempt[] atts;
    uskManager.onFinished(this);
    SendableGet storeChecker;
    Bucket data;
    synchronized(this) {
      if(cancelled) Logger.error(this, "Already cancelled "+this);
      if(completed) Logger.error(this, "Already completed "+this);
      cancelled = true;
      attempts = runningAttempts.values().toArray(new USKAttempt[runningAttempts.size()]);
      polling = pollingAttempts.values().toArray(new USKAttempt[pollingAttempts.size()]);
      atts = dbrAttempts.toArray(new DBRAttempt[dbrAttempts.size()]);
      attemptsToStart.clear();
      runningAttempts.clear();
      pollingAttempts.clear();
      dbrAttempts.clear();
      storeChecker = runningStoreChecker;
      runningStoreChecker = null;
      data = lastRequestData;
      lastRequestData = null;
    }
    for(USKAttempt attempt: attempts)
      attempt.cancel(context);
    for(USKAttempt p: polling)
      p.cancel(context);
    for(DBRAttempt a : atts)
      a.cancel(context);
    if(storeChecker != null)
      // Remove from the store checker queue.
      storeChecker.unregister(context, storeChecker.getPriorityClass());
    if(data != null)
        data.free();
  }
View Full Code Here

      boolean ignoreStore;
      boolean canWriteClientCache;
      boolean forkOnCacheable;
      boolean realTimeFlag;
      if(req instanceof SendableGet) {
        SendableGet sg = (SendableGet) req;
        FetchContext ctx = sg.getContext();
        localRequestOnly = ctx.localRequestOnly;
        ignoreStore = ctx.ignoreStore;
        canWriteClientCache = ctx.canWriteClientCache;
        realTimeFlag = sg.realTimeFlag();
        forkOnCacheable = false;
      } else {
        localRequestOnly = false;
        if(req instanceof SendableInsert) {
          canWriteClientCache = ((SendableInsert)req).canWriteClientCache();
View Full Code Here

TOP

Related Classes of freenet.node.SendableGet

Copyright © 2018 www.massapicom. 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.