Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.DatastoreServiceConfig$Builder


    return executeQuery(qd, fromInclNo, toExclNo);
  }

  private Object executeQuery(QueryData qd, long fromInclNo, long toExclNo) {
    processInFilters(qd);
    DatastoreServiceConfig config = getStoreManager().getDefaultDatastoreServiceConfigForReads();
    if (query.getTimeoutMillis() > 0) {
      // config wants the timeout in seconds
      config.deadline(query.getTimeoutMillis() / 1000);
    }
    Map extensions = query.getExtensions();
    if (extensions != null && extensions.get(DatastoreManager.DATASTORE_READ_CONSISTENCY_PROPERTY) != null) {
      config.readPolicy(new ReadPolicy(
          ReadPolicy.Consistency.valueOf((String) extensions.get(DatastoreManager.DATASTORE_READ_CONSISTENCY_PROPERTY))));
    }
    DatastoreService ds = DatastoreServiceFactoryInternal.getDatastoreService(config);
    // Txns don't get started until you allocate a connection, so allocate a
    // connection before we do anything that might require a txn.
View Full Code Here


  protected ValueGenerationBlock reserveBlock(long size) {
    if (sequenceName == null) {
      // shouldn't happen
      throw new IllegalStateException("sequence name is null");
    }
    DatastoreServiceConfig config = ((DatastoreManager) storeMgr).getDefaultDatastoreServiceConfigForWrites();
    DatastoreService ds = DatastoreServiceFactoryInternal.getDatastoreService(config);
    KeyRange range = ds.allocateIds(sequenceName, size);
    // Too bad we can't pass an iterable and construct the ids
    // on demand.
    List<Long> ids = Utils.newArrayList();
View Full Code Here

  /**
   * Make a datastore service config that corresponds to our options.
   */
  protected DatastoreServiceConfig createDatastoreServiceConfig() {
    DatastoreServiceConfig cfg = DatastoreServiceConfig.Builder.withReadPolicy(new ReadPolicy(consistency));

    if (deadline != null)
      cfg.deadline(deadline);

    return cfg;
  }
View Full Code Here

    public void activateGaeEntityStore()
        throws Exception
    {
        GaeEntityStoreConfiguration conf = config.get();
        // eventually consistent reads with a 5 second deadline
        DatastoreServiceConfig configuration =
            withReadPolicy( new ReadPolicy( ReadPolicy.Consistency.valueOf( conf.readPolicy().get().toUpperCase() ) ) )
                .deadline( conf.deadline().get() );
        datastore = DatastoreServiceFactory.getDatastoreService( configuration );
        entityKind = conf.entityKind().get();
        System.out.println( "\nActivating Google App Engine Store" +
View Full Code Here

*/
@RunWith(Arquillian.class)
public class ConfigTest extends DatastoreTestBase {
    @Test
    public void testConfigBuilder() {
        DatastoreServiceConfig config = DatastoreServiceConfig.Builder.withDefaults();
        assertEquals(new ReadPolicy(Consistency.STRONG).getConsistency(), config.getReadPolicy().getConsistency());

        config = DatastoreServiceConfig.Builder.withDeadline(10);
        assertEquals(new Double(10), config.getDeadline());
        config.deadline(20);
        assertEquals(new Double(20), config.getDeadline());

        config = DatastoreServiceConfig.Builder.withImplicitTransactionManagementPolicy(ImplicitTransactionManagementPolicy.AUTO);
        assertEquals(ImplicitTransactionManagementPolicy.AUTO, config.getImplicitTransactionManagementPolicy());
        config.implicitTransactionManagementPolicy(ImplicitTransactionManagementPolicy.NONE);
        assertEquals(ImplicitTransactionManagementPolicy.NONE, config.getImplicitTransactionManagementPolicy());

        config = DatastoreServiceConfig.Builder.withMaxEntityGroupsPerRpc(5);
        assertEquals(new Integer(5), config.getMaxEntityGroupsPerRpc());
        config.maxEntityGroupsPerRpc(2);
        assertEquals(new Integer(2), config.getMaxEntityGroupsPerRpc());

        config = DatastoreServiceConfig.Builder.withReadPolicy(new ReadPolicy(Consistency.EVENTUAL));
        assertEquals(new ReadPolicy(Consistency.EVENTUAL).getConsistency(), config.getReadPolicy().getConsistency());
        config.readPolicy(new ReadPolicy(Consistency.STRONG));
        assertEquals(new ReadPolicy(Consistency.STRONG).getConsistency(), config.getReadPolicy().getConsistency());
    }
View Full Code Here

        assertEquals(new ReadPolicy(Consistency.STRONG).getConsistency(), config.getReadPolicy().getConsistency());
    }

    @Test(expected = ApiDeadlineExceededException.class)
    public void testDeadlineConfig() {
        DatastoreServiceConfig config = DatastoreServiceConfig.Builder.withDeadline(0.00001);
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService(config);
        assertNotNull(ds);
        Entity g1 = new Entity("test");
        g1.setProperty("deadline", "0.00001");
        ds.put(g1);
View Full Code Here

        ds.put(g1);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testTranManagePolicyAsyncInvalidConfig() {
        DatastoreServiceConfig config = DatastoreServiceConfig.Builder.withImplicitTransactionManagementPolicy(ImplicitTransactionManagementPolicy.AUTO);
        // Async Service does not support AUTO
        DatastoreServiceFactory.getAsyncDatastoreService(config);
    }
View Full Code Here

*/
@RunWith(Arquillian.class)
public class TxPolicyTest extends DatastoreTestBase {
    @Test
    public void testAutoPolicy() throws Exception {
        DatastoreServiceConfig config = DatastoreServiceConfig.Builder.withImplicitTransactionManagementPolicy(ImplicitTransactionManagementPolicy.AUTO);
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService(config);

        Key k1 = null;
        Transaction tx = ds.beginTransaction();
        try {
View Full Code Here

  protected ValueGenerationBlock reserveBlock(long size) {
    if (sequenceName == null) {
      // shouldn't happen
      throw new IllegalStateException("sequence name is null");
    }
    DatastoreServiceConfig config = ((DatastoreManager) storeMgr).getDefaultDatastoreServiceConfigForWrites();
    DatastoreService ds = DatastoreServiceFactoryInternal.getDatastoreService(config);
    KeyRange range = ds.allocateIds(sequenceName, size);
    // Too bad we can't pass an iterable and construct the ids
    // on demand.
    List<Long> ids = Utils.newArrayList();
View Full Code Here

    return isTransactional;
  }

  private XAResource newXAResource() {
    if (isTransactional()) {
      DatastoreServiceConfig config = ((DatastoreManager) omfContext.getStoreManager()).getDefaultDatastoreServiceConfigForWrites();
      DatastoreService datastoreService = DatastoreServiceFactoryInternal.getDatastoreService(config);
      return new DatastoreXAResource(datastoreService);
    } else {
      return new EmulatedXAResource();
    }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.datastore.DatastoreServiceConfig$Builder

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.