Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.ReadPolicy


      // 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


  /**
   * 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

        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" +
                            "\n----------------------------------" +
View Full Code Here

  @Provides
  DatastoreService provideDatastore(@DatastoreTimeoutMillis long datastoreTimeoutMillis) {
    return DatastoreServiceFactory.getDatastoreService(DatastoreServiceConfig.Builder
        .withDeadline(datastoreTimeoutMillis * 1000.0)
        .implicitTransactionManagementPolicy(ImplicitTransactionManagementPolicy.NONE)
        .readPolicy(new ReadPolicy(ReadPolicy.Consistency.STRONG)));
  }
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

    }
    String defaultReadConsistencyStr = persistenceConfiguration.getStringProperty(
        DATASTORE_READ_CONSISTENCY_PROPERTY);
    if (defaultReadConsistencyStr != null) {
      try {
        datastoreServiceConfig.readPolicy(new ReadPolicy(Consistency.valueOf(defaultReadConsistencyStr)));
      } catch (IllegalArgumentException iae) {
        throw new FatalNucleusUserException(
            "Illegal value for " + DATASTORE_READ_CONSISTENCY_PROPERTY +
            ".  Valid values are " + Arrays.toString(Consistency.values()));
      }
View Full Code Here

      // 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

TOP

Related Classes of com.google.appengine.api.datastore.ReadPolicy

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.