public void registerInsert(
      final SendableRequest req, boolean persistent, boolean regmeOnly, ObjectContainer container) {
    if (!isInsertScheduler)
      throw new IllegalArgumentException("Adding a SendableInsert to a request scheduler!!");
    if (persistent) {
      if (regmeOnly) {
        long bootID = 0;
        boolean queueFull = jobRunner.getQueueSize(NativeThread.NORM_PRIORITY) >= QUEUE_THRESHOLD;
        if (!queueFull) bootID = this.node.bootID;
        final RegisterMe regme =
            new RegisterMe(req, req.getPriorityClass(container), schedCore, null, bootID);
        container.store(regme);
        if (logMINOR) Logger.minor(this, "Added insert RegisterMe: " + regme);
        if (!queueFull) {
          try {
            jobRunner.queue(
                new DBJob() {

                  @Override
                  public boolean run(ObjectContainer container, ClientContext context) {
                    container.delete(regme);
                    if (req.isCancelled(container)) {
                      if (logMINOR) Logger.minor(this, "Request already cancelled");
                      return false;
                    }
                    if (container.ext().isActive(req))
                      Logger.error(this, "ALREADY ACTIVE: " + req + " in delayed insert register");
                    container.activate(req, 1);
                    registerInsert(req, true, false, container);
                    container.deactivate(req, 1);
                    return true;
                  }

                  @Override
                  public String toString() {
                    return "registerInsert";
                  }
                },
                NativeThread.NORM_PRIORITY,
                false);
          } catch (DatabaseDisabledException e) {
            // Impossible, we are already on the database thread.
          }
        } else {
          schedCore.rerunRegisterMeRunner(jobRunner);
        }
        container.deactivate(req, 1);
        return;
      }
      schedCore.innerRegister(req, random, container, clientContext, null);
      starter.wakeUp();
    } else {
      schedTransient.innerRegister(req, random, null, clientContext, null);
      starter.wakeUp();
    }
  }
  void finishRegister(
      final SendableGet[] getters,
      boolean persistent,
      ObjectContainer container,
      final boolean anyValid,
      final DatastoreCheckerItem reg) {
    if (logMINOR)
      Logger.minor(
          this,
          "finishRegister for "
              + getters
              + " anyValid="
              + anyValid
              + " reg="
              + reg
              + " persistent="
              + persistent);
    if (isInsertScheduler) {
      IllegalStateException e = new IllegalStateException("finishRegister on an insert scheduler");
      for (int i = 0; i < getters.length; i++) {
        if (persistent) container.activate(getters[i], 1);
        getters[i].internalError(e, this, container, clientContext, persistent);
        if (persistent) container.deactivate(getters[i], 1);
      }
      throw e;
    }
    if (persistent) {
      // Add to the persistent registration queue
      if (!databaseExecutor.onThread()) {
        throw new IllegalStateException("Not on database thread!");
      }
      if (persistent) container.activate(getters, 1);
      if (logMINOR) Logger.minor(this, "finishRegister() for " + getters);
      if (anyValid) {
        boolean wereAnyValid = false;
        for (int i = 0; i < getters.length; i++) {
          SendableGet getter = getters[i];
          container.activate(getter, 1);
          // Just check isCancelled, we have already checked the cooldown.
          if (!(getter.isCancelled(container))) {
            wereAnyValid = true;
            if (!getter.preRegister(container, clientContext, true)) {
              schedCore.innerRegister(getter, random, container, clientContext, getters);
            }
          } else getter.preRegister(container, clientContext, false);
        }
        if (!wereAnyValid) {
          Logger.normal(this, "No requests valid: " + getters);
        }
      } else {
        Logger.normal(this, "No valid requests passed in: " + getters);
      }
      if (reg != null) container.delete(reg);
      queueFillRequestStarterQueue(true);
    } else {
      // Register immediately.
      for (int i = 0; i < getters.length; i++) {

        if ((!anyValid) || getters[i].isCancelled(null)) {
          getters[i].preRegister(container, clientContext, false);
          continue;
        } else {
          if (getters[i].preRegister(container, clientContext, true)) continue;
        }
        if (!getters[i].isCancelled(null))
          schedTransient.innerRegister(getters[i], random, null, clientContext, getters);
      }
      starter.wakeUp();
    }
  }