App Engine Java SDK version 1.7.0
[gae.git] / java / src / main / com / google / appengine / api / datastore / DatastoreAttributes.java
blobcff54d4dc540282df1ac7d6b9e1dc3274b4a8f19
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 ParsedAppId identity = appIdentityService.parseFullAppId(DatastoreApiHelper.getCurrentAppId());
30 datastoreType = identity.getPartition().isEmpty() ?
31 DatastoreType.MASTER_SLAVE : DatastoreType.HIGH_REPLICATION;
34 /**
35 * Gets the datastore type.
37 * Only guaranteed to return something other than {@link
38 * DatastoreType#UNKNOWN} when running in production and querying the current
39 * app.
41 public DatastoreType getDatastoreType() {
42 return datastoreType;