Пример #1
0
  public final boolean isEmptyWriteSet() {

    if (readOnly) return true;

    lock.lock();

    try {

      final Iterator<ILocalBTreeView> itr = indices.values().iterator();

      while (itr.hasNext()) {

        final IsolatedFusedView ndx = (IsolatedFusedView) itr.next();

        if (!ndx.isEmptyWriteSet()) {

          // At least one isolated index was written on.

          return false;
        }
      }

      return true;

    } finally {

      lock.unlock();
    }
  }
Пример #2
0
    public Void call() throws Exception {

      if (log.isInfoEnabled()) log.info("Writing checkpoint: " + name);

      try {

        /*
         * Note: this is the live version of the named index. We need to
         * merge down onto the live version of the index, not onto some
         * historical state.
         */

        final AbstractBTree[] sources = resourceManager.getIndexSources(name, UNISOLATED);

        if (sources == null) {

          /*
           * Note: This should not happen since we just validated the
           * index.
           */

          throw new AssertionError();
        }

        /*
         * Copy the validated write set for this index down onto the
         * corresponding unisolated index, updating version counters, delete
         * markers, and values as necessary in the unisolated index.
         */

        isolated.mergeDown(revisionTime, sources);

        /*
         * Write a checkpoint so that everything is on the disk. This
         * reduces both the latency for the commit and the possibilities for
         * error.
         */

        isolated.getWriteSet().writeCheckpoint();

      } catch (Throwable t) {

        // adds the name to the stack trace.
        throw new RuntimeException("Could not commit index: name=" + name, t);
      }

      // Done.
      return null;
    }
Пример #3
0
  /**
   * Invoked when a writable transaction prepares in order to validate its write sets (one per
   * isolated index). The default implementation is NOP.
   *
   * @return true iff the write sets were validated.
   */
  protected boolean validateWriteSets() {

    /*
     * for all isolated btrees, if(!validate()) return false;
     */

    final Iterator<Map.Entry<String, ILocalBTreeView>> itr = indices.entrySet().iterator();

    while (itr.hasNext()) {

      final Map.Entry<String, ILocalBTreeView> entry = itr.next();

      final String name = entry.getKey();

      final IsolatedFusedView isolated = (IsolatedFusedView) entry.getValue();

      /*
       * Note: this is the live version of the named index. We need to
       * validate against the live version of the index, not some
       * historical state.
       */

      final AbstractBTree[] sources = resourceManager.getIndexSources(name, UNISOLATED);

      if (sources == null) {

        log.warn("Index does not exist: " + name);

        return false;
      }

      if (!isolated.validate(sources)) {

        // Validation failed.

        if (log.isInfoEnabled()) log.info("validation failed: " + name);

        return false;
      }
    }

    return true;
  }