Examples of PutRequest


Examples of com.google.apphosting.api.DatastorePb.PutRequest

            Iterable<EntityProto> entities) {
        if (entities == null) {
            throw new NullPointerException(
                "The entities parameter must not be null.");
        }
        PutRequest req = createPutRequest(tx);
        int totalSize = 0;
        for (EntityProto e : entities) {
            int size = e.encodingSize();
            if ((totalSize != 0 && totalSize + size + EXTRA_SIZE > MAX_ENTITY_SIZE)
                || req.entitySize() >= MAX_NUMBER_OF_ENTITIES) {
                putUsingLowerApi(req);
                req = createPutRequest(tx);
                totalSize = 0;
            }
            req.addEntity(e);
            totalSize += size + EXTRA_SIZE;
        }
        if (req.entitySize() > 0) {
            putUsingLowerApi(req);
        }
    }
View Full Code Here

Examples of com.google.apphosting.api.DatastorePb.PutRequest

     * @param tx
     *            the transaction
     * @return a request for put
     */
    protected static PutRequest createPutRequest(Transaction tx) {
        PutRequest req = new PutRequest();
        if (tx != null) {
            DatastorePb.Transaction tx2 = new DatastorePb.Transaction();
            tx2.setHandle(Long.valueOf(tx.getId()));
            tx2.setApp(ApiProxy.getCurrentEnvironment().getAppId());
            req.setTransaction(tx2);
        }
        return req;
    }
View Full Code Here

Examples of com.google.apphosting.api.DatastorePb.PutRequest

        if (entities == null) {
            throw new NullPointerException(
                "The entities parameter must not be null.");
        }
        for (Entity entity : entities) {
            PutRequest putReq = new PutRequest();
            List<Blob> putList =
                (List<Blob>) entity.getProperty(PUT_LIST_PROPERTY);
            List<Key> deleteList =
                (List<Key>) entity.getProperty(DELETE_LIST_PROPERTY);
            List<Entity> putEntities = new ArrayList<Entity>();
            if (putList != null) {
                for (Blob blob : putList) {
                    EntityProto proto = putReq.addEntity();
                    proto.mergeFrom(blob.getBytes());
                    putEntities.add(EntityTranslator.createFromPb(proto));
                }
            }
            if (putEntities.size() > 0) {
View Full Code Here

Examples of com.google.apphosting.api.DatastorePb.PutRequest

   *
   * @return A {@link Future} that provides the results of the operation.
   */
  private Future<List<Key>> doBatchPutBySize( Transaction txn,
      final Iterable<Entity> entities) {
    PutRequest baseReq = new PutRequest();
    if (txn != null) {
      TransactionImpl.ensureTxnActive(txn);
      baseReq.setTransaction(localTxnToRemoteTxn(txn));
    }
    final int baseEncodedReqSize = baseReq.encodingSize();
    final List<Future<PutResponse>> futures = new ArrayList<Future<PutResponse>>();
    int encodedReqSize = baseEncodedReqSize;
    PutRequest req = baseReq.clone();
    for (Entity entity : entities) {
      EntityProto proto = EntityTranslator.convertToPb(entity);
      int encodedEntitySize = Protocol.stringSize(proto.encodingSize()) + 1;
      if (getDatastoreServiceConfig().exceedsWriteLimits(
          req.entitySize() + 1, encodedReqSize + encodedEntitySize)) {
        futures.add(makeAsyncCall(apiConfig, "Put", req, new PutResponse()));
        encodedReqSize = baseEncodedReqSize;
        req = baseReq.clone();
      }

      encodedReqSize += encodedEntitySize;
      req.addEntity(proto);
    }

    if (req.entitySize() > 0) {
      futures.add(makeAsyncCall(apiConfig, "Put", req, new PutResponse()));
    }

    return registerInTransaction(txn,
        new IteratingAggregateFuture<PutResponse, Entity, List<Key>>(futures) {
View Full Code Here

Examples of com.google.apphosting.api.DatastorePb.PutRequest

    @Test
    public void datastorePutAsync() throws Exception {
        tester.setUp();
        Environment env = ApiProxy.getCurrentEnvironment();
        Delegate<Environment> delegate = ApiProxy.getDelegate();
        PutRequest reqPb = new PutRequest();
        reqPb.addEntity(EntityTranslator.convertToPb(new Entity("Hoge")));
        Future<byte[]> future =
            delegate.makeAsyncCall(
                env,
                AppEngineTester.DATASTORE_SERVICE,
                AppEngineTester.PUT_METHOD,
                reqPb.toByteArray(),
                new ApiConfig());
        future.get();
        assertThat(tester.count("Hoge"), is(1));
        tester.tearDown();
        ApiProxy.setDelegate(AppEngineTester.apiProxyLocalImpl);
View Full Code Here

Examples of com.google.apphosting.api.DatastorePb.PutRequest

        if (entities == null) {
            throw new NullPointerException(
                "The entities parameter must not be null.");
        }
        for (Entity entity : entities) {
            PutRequest putReq = new PutRequest();
            List<Blob> putList =
                (List<Blob>) entity.getProperty(PUT_LIST_PROPERTY);
            List<Key> deleteList =
                (List<Key>) entity.getProperty(DELETE_LIST_PROPERTY);
            List<Entity> putEntities = new ArrayList<Entity>();
            if (putList != null) {
                for (Blob blob : putList) {
                    EntityProto proto = putReq.addEntity();
                    proto.mergeFrom(blob.getBytes());
                    putEntities.add(EntityTranslator.createFromPb(proto));
                }
            }
            if (putEntities.size() > 0) {
View Full Code Here

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

  }

  @Override
  protected Future<List<Key>> doBatchPut( Transaction txn,
      final List<Entity> entities) {
    PutRequest baseReq = new PutRequest();
    if (txn != null) {
      TransactionImpl.ensureTxnActive(txn);
      baseReq.setTransaction(InternalTransactionV3.localTxnToRemoteTxn(txn));
    }
    boolean group = !baseReq.hasTransaction();
    List<Integer> order = Lists.newArrayListWithCapacity(entities.size());
    Iterator<PutRequest> batches = putBatcher.getBatches(entities, baseReq,
        baseReq.getSerializedSize(), group, order);
    List<Future<PutResponse>> futures = putBatcher.makeCalls(batches);

    return registerInTransaction(txn,
        new ReorderingMultiFuture<PutResponse, List<Key>>(futures, order) {
          @Override
View Full Code Here

Examples of com.google.nigori.common.NigoriMessages.PutRequest

        .setAuth(authenticateRequestAsProtobuf(serverName, signer, REQUEST_PUT, index, revision, value))
        .setKey(ByteString.copyFrom(index))
        .setRevision(ByteString.copyFrom(revision))
        .setValue(ByteString.copyFrom(value));

    PutRequest req = reqBuilder.build();

    return req;
  }
View Full Code Here

Examples of com.google.nigori.common.NigoriMessages.PutRequest

        JsonConversionException, IOException, UnauthorisedException {
      String json = getJsonAsString(req, maxJsonQueryLength);
      if (DEBUG_JSON) {
        System.out.println(json);
      }
      PutRequest request = MessageLibrary.putRequestFromJson(json);

      if (!protocol.put(request)) {
        throw new ServletException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
            "Internal storage error for key "
                + Base64.encodeBase64String(request.getKey().toByteArray()));
      }

      emptyBody(resp);
    }
View Full Code Here

Examples of com.hazelcast.multimap.impl.client.PutRequest

    @Test
    public void testPut() throws IOException {
        MultiMap<Object, Object> mm = getMultiMap();

        final SimpleClient client = getClient();
        client.send(new PutRequest(name, ss.toData("key1"), ss.toData("value1"), -1, getThreadId()));
        boolean result = (Boolean) client.receive();
        assertTrue(result);
        assertEquals("value1", mm.get("key1").iterator().next());

        client.send(new PutRequest(name, ss.toData("key1"), ss.toData("value1"), -1, getThreadId()));
        result = (Boolean) client.receive();
        assertFalse(result);

        assertEquals(1, mm.size());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.