Package com.google.appengine.api.datastore

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


    q.addFilter(Entity.KEY_RESERVED_PROPERTY, Query.FilterOperator.IN, childKeys);
    for (Query.SortPredicate sp : getSortPredicates()) {
      q.addSort(sp.getPropertyName(), sp.getDirection());
    }

    DatastoreServiceConfig config = storeMgr.getDefaultDatastoreServiceConfigForReads();
    DatastoreService ds = DatastoreServiceFactoryInternal.getDatastoreService(config);

    Utils.Function<Entity, Object> func = new Utils.Function<Entity, java.lang.Object>() {
      @Override
      public Object apply(Entity from) {
View Full Code Here


    // TODO Don't bother with this if using latest storage version (but update tests too)
    // Not storing element keys in owner, so need to update the index property of following objects
    if (orderMapping != null) {
      // need to shift indexes of following elements down
      DatastoreServiceConfig config = storeMgr.getDefaultDatastoreServiceConfigForReads();
      DatastoreService service = DatastoreServiceFactoryInternal.getDatastoreService(config);
      AbstractClassMetaData acmd = elementCmd;
      String kind =
        storeMgr.getIdentifierFactory().newDatastoreContainerIdentifier(acmd).getIdentifierName();
      Query q = new Query(kind);
View Full Code Here

          return null;
        }

        List<Key> keys = (List<Key>)value;
        Key indexKey = keys.get(index);
        DatastoreServiceConfig config = storeMgr.getDefaultDatastoreServiceConfigForReads();
        DatastoreService ds = DatastoreServiceFactoryInternal.getDatastoreService(config);
        try {
          return EntityUtils.entityToPojo(ds.get(indexKey), elementCmd, clr, ec, false, ec.getFetchPlan());
        } catch (EntityNotFoundException enfe) {
          throw new NucleusDataStoreException("Could not determine entity for index=" + index + " with key=" + indexKey, enfe);
View Full Code Here

      q.addFilter(
          Entity.KEY_RESERVED_PROPERTY, Query.FilterOperator.GREATER_THAN_OR_EQUAL, keys.get(0));
      q.addFilter(
          Entity.KEY_RESERVED_PROPERTY, Query.FilterOperator.LESS_THAN_OR_EQUAL, keys.get(keys.size() - 1));
      q.addSort(Entity.KEY_RESERVED_PROPERTY, Query.SortDirection.DESCENDING);
      DatastoreServiceConfig config = storeMgr.getDefaultDatastoreServiceConfigForReads();
      DatastoreService service = DatastoreServiceFactoryInternal.getDatastoreService(config);
      int[] indices = new int[keys.size()];
      int index = 0;
      for (Entity e : service.prepare(service.getCurrentTransaction(null), q).asIterable()) {
        if (keySet.contains(e.getKey())) {
View Full Code Here

      // Owned relation in earlier storage version so use parentKey to determine membership of list (only present once)
      if (elementKey.getParent() == null) {
        throw new NucleusUserException("Element primary-key does not have a parent.");
      }

      DatastoreServiceConfig config = storeMgr.getDefaultDatastoreServiceConfigForReads();
      DatastoreService service = DatastoreServiceFactoryInternal.getDatastoreService(config);
      try {
        Entity e = service.get(elementKey);
        Long indexVal = (Long) orderMapping.getObject(ec, e, new int[1]);
        if (indexVal == null) {
View Full Code Here

   * @return The result of executing the query.
   */
  public Object performExecute(QueryData qd) {

    // Obtain DatastoreService
    DatastoreServiceConfig config = getStoreManager().getDefaultDatastoreServiceConfigForReads();
    if (query.getDatastoreReadTimeoutMillis() > 0) {
      // config wants the timeout in seconds
      config.deadline(query.getDatastoreReadTimeoutMillis() / 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);

    // Execute the most appropriate type of query
View Full Code Here

    return createDatastoreServiceConfigPrototype(persistenceConfig, PropertyNames.PROPERTY_DATASTORE_WRITE_TIMEOUT);
  }

  private DatastoreServiceConfig createDatastoreServiceConfigPrototype(
      PersistenceConfiguration persistenceConfiguration, String... timeoutProps) {
    DatastoreServiceConfig datastoreServiceConfig = DatastoreServiceConfig.Builder.withDefaults();

    for (String timeoutProp : timeoutProps) {
      int defaultDeadline = persistenceConfiguration.getIntProperty(timeoutProp);
      if (defaultDeadline > 0) {
        datastoreServiceConfig.deadline(defaultDeadline / 1000d);
      }
    }
    String defaultReadConsistencyStr = persistenceConfiguration.getStringProperty(
        DATASTORE_READ_CONSISTENCY_PROPERTY);
    if (defaultReadConsistencyStr != null) {
      try {
        datastoreServiceConfig.readPolicy(new ReadPolicy(Consistency.valueOf(defaultReadConsistencyStr)));
      } catch (IllegalArgumentException iae) {
        throw new NucleusFatalUserException(
            "Illegal value for " + DATASTORE_READ_CONSISTENCY_PROPERTY +
            ".  Valid values are " + Arrays.toString(Consistency.values()));
      }
View Full Code Here

    return typeConversionUtils;
  }

  // visible for testing
  static DatastoreServiceConfig copyDatastoreServiceConfig(DatastoreServiceConfig config) {
    DatastoreServiceConfig newConfig = DatastoreServiceConfig.Builder.
        withImplicitTransactionManagementPolicy(config.getImplicitTransactionManagementPolicy()).
        readPolicy(config.getReadPolicy());

    if (config.getDeadline() != null) {
      newConfig.deadline(config.getDeadline());
    }
    return newConfig;
  }
View Full Code Here

        new ArrayList<ManagedConnectionResourceListener>();
    private final XAResource datastoreXAResource;

    DatastoreManagedConnection(StoreManager storeMgr, boolean autoCreateTransaction) {
      DatastoreManager datastoreManager = (DatastoreManager) storeMgr;
      DatastoreServiceConfig config = datastoreManager.getDefaultDatastoreServiceConfigForWrites();
      DatastoreService datastoreService = DatastoreServiceFactoryInternal.getDatastoreService(config);
      if (NucleusLogger.CONNECTION.isDebugEnabled()) {
        if (datastoreService instanceof WrappedDatastoreService) {
          NucleusLogger.CONNECTION.debug("Created ManagedConnection using DatastoreService = " +
              ((WrappedDatastoreService)datastoreService).getDelegate());
View Full Code Here

*/
public class JPADatastoreServiceConfigTest extends JPATestCase {

  public void testDefaultStorageVersion() {
    DatastoreManager storeMgr = (DatastoreManager) getExecutionContext().getStoreManager();
    DatastoreServiceConfig config = storeMgr.getDefaultDatastoreServiceConfigForReads();
    DatastoreServiceConfig defaultConfig = DatastoreServiceConfig.Builder.withDefaults();
    assertEquals(defaultConfig.getDeadline(), config.getDeadline());
    assertEquals(defaultConfig.getReadPolicy(), config.getReadPolicy());
  }
View Full Code Here

TOP

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

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.