Example #1
0
  /**
   * Locate the right sibling for this index partition.
   *
   * <p>Note: default key/val serializers are used.
   *
   * @return The locator for the right sibling -or- <code>null</code> if no right sibling could be
   *     found (which is an error).
   * @todo This does not have to be a batch lookup any more. It could use the {@link
   *     ClientIndexView} class.
   */
  private PartitionLocator getRightSiblingLocator(
      final String scaleOutIndexName, final long lastCommitTime) {

    final BatchLookup op =
        BatchLookupConstructor.INSTANCE.newInstance(
            0 /* fromIndex */,
            1 /* toIndex */,
            new byte[][] {vmd.pmd.getRightSeparatorKey()},
            null /* vals */);

    final ResultBuffer resultBuffer;
    try {

      resultBuffer =
          (ResultBuffer)
              resourceManager
                  .getFederation()
                  .getMetadataService()
                  .submit(
                      TimestampUtility.asHistoricalRead(lastCommitTime),
                      MetadataService.getMetadataIndexName(scaleOutIndexName),
                      op)
                  .get();

    } catch (Exception e) {

      log.error("Could not locate rightSiblings: index=" + scaleOutIndexName, e);

      return null;
    }

    // the locator for the rightSibling.
    return (PartitionLocator) SerializerUtil.deserialize(resultBuffer.getValues().get(0));
  }
Example #2
0
  /**
   * Utility to return a ByteBuffer containing the external version of the object.
   *
   * @return The {@link ByteBuffer}. The position will be zero. The limit will be the #of bytes in
   *     the serialized object.
   */
  private ByteBuffer bufferObject(final Object obj) throws IOException {

    // Note: pos=0; limit=capacity=length.
    return ByteBuffer.wrap(SerializerUtil.serialize(obj));
  }