Package com.google.apphosting.datastore.DatastoreV3Pb

Examples of com.google.apphosting.datastore.DatastoreV3Pb.AllocateIdsResponse


    final AppIdNamespace appIdNamespace = datastoreServiceConfig.getAppIdNamespace();
    Reference allocateIdsRef = buildAllocateIdsRef(parent, kind, appIdNamespace);
    AllocateIdsRequest req =
        new AllocateIdsRequest().setSize(num).setModelKey(allocateIdsRef);
    AllocateIdsResponse resp = new AllocateIdsResponse();
    Future<AllocateIdsResponse> future = makeAsyncCall(apiConfig, Method.AllocateIds, req, resp);
    return new FutureWrapper<AllocateIdsResponse, KeyRange>(future) {
      @Override
      protected KeyRange wrap(AllocateIdsResponse resp) throws Exception {
        return new KeyRange(parent, kind, resp.getStart(), resp.getEnd(), appIdNamespace);
      }

      @Override
      protected Throwable convertException(Throwable cause) {
        return cause;
View Full Code Here


    long end = range.getEnd().getId();

    AllocateIdsRequest req = new AllocateIdsRequest()
        .setModelKey(AsyncDatastoreServiceImpl.buildAllocateIdsRef(parent, kind, null))
        .setMax(end);
    AllocateIdsResponse resp = new AllocateIdsResponse();
    Future<AllocateIdsResponse> future = makeAsyncCall(apiConfig, Method.AllocateIds, req, resp);
    return new FutureWrapper<AllocateIdsResponse, KeyRangeState>(future) {
      @SuppressWarnings("deprecation")
      @Override
      protected KeyRangeState wrap(AllocateIdsResponse resp) throws Exception {
        Query query = new Query(kind).setKeysOnly();
        query.addFilter(
            Entity.KEY_RESERVED_PROPERTY, FilterOperator.GREATER_THAN_OR_EQUAL, range.getStart());
        query.addFilter(
            Entity.KEY_RESERVED_PROPERTY, FilterOperator.LESS_THAN_OR_EQUAL, range.getEnd());
        List<Entity> collision = prepare(query).asList(withLimit(1));

        if (!collision.isEmpty()) {
          return KeyRangeState.COLLISION;
        }

        boolean raceCondition = start < resp.getStart();
        return raceCondition ? KeyRangeState.CONTENTION : KeyRangeState.EMPTY;
      }

      @Override
      protected Throwable convertException(Throwable cause) {
View Full Code Here

TOP

Related Classes of com.google.apphosting.datastore.DatastoreV3Pb.AllocateIdsResponse

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.