Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / datastore / DatastoreAttributes.java
blobeab675de861b8ffc448f97a5722722c3b44a188e
1 // Copyright 2010 Google Inc. All Rights Reserved.
3 package com.google.appengine.api.datastore;
5 import com.google.appengine.api.appidentity.AppIdentityService;
6 import com.google.appengine.api.appidentity.AppIdentityService.ParsedAppId;
7 import com.google.appengine.api.appidentity.AppIdentityServiceFactory;
9 /**
10 * Attributes of a datastore.
13 public final class DatastoreAttributes {
14 /**
15 * Indicates the type of datastore being used.
18 public enum DatastoreType {
19 UNKNOWN,
20 MASTER_SLAVE,
21 HIGH_REPLICATION,
24 private final DatastoreType datastoreType;
25 private static final AppIdentityService appIdentityService =
26 AppIdentityServiceFactory.getAppIdentityService();
28 DatastoreAttributes() {
29 this(DatastoreApiHelper.getCurrentAppId());
32 DatastoreAttributes(String appId) {
33 ParsedAppId identity = appIdentityService.parseFullAppId(appId);
34 datastoreType = identity.getPartition().isEmpty() ?
35 DatastoreType.MASTER_SLAVE : DatastoreType.HIGH_REPLICATION;
38 /**
39 * Gets the datastore type.
41 * Only guaranteed to return something other than {@link
42 * DatastoreType#UNKNOWN} when running in production and querying the current
43 * app.
45 public DatastoreType getDatastoreType() {
46 return datastoreType;