@SuppressWarnings("VariableDeclarationUsageDistance") @Test public void doGet_repeatedPropertyEntities_writesWidgets() throws Exception { DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); // [START exploding_index_example_3] Entity widget = new Entity("Widget"); widget.setProperty("x", Arrays.asList(1, 2, 3, 4)); widget.setProperty("y", Arrays.asList("red", "green", "blue")); widget.setProperty("date", new Date()); datastore.put(widget); // [END exploding_index_example_3] servletUnderTest.doGet(mockRequest, mockResponse); assertThat(responseWriter.toString()) .named("IndexesServlet response") .isEqualTo("Got 1 widgets.\n"); }
/** * Save Full File * * @param inputStream */ private static void saveFile(InputStream inputStream) { DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); Calendar time = Calendar.getInstance(TimeZone.getTimeZone("CET")); time.set(Calendar.HOUR_OF_DAY,0); time.set(Calendar.MINUTE,0); time.set(Calendar.SECOND,0); Date measuredAt = time.getTime(); long millis = time.getTimeInMillis(); // Entity entity = new Entity(ENTITY_TYPE_FICHEROS,millis); entity.setIndexedProperty("Date", measuredAt); entity.setUnindexedProperty("File", GlobalUtils.getString(inputStream)); // Store datastore.put(entity); }
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("text/html"); resp.getWriter().println("<html><body>"); DatastoreService datastore = DatastoreServiceFactory .getDatastoreService(); Query query = new Query("SharedList"); query.addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING); List<Entity> results = datastore.prepare(query).asList( FetchOptions.Builder.withDefaults()); for (Entity entity : results) { String email = (String) entity.getProperty("email"); String productID = (String) entity.getKey().getName(); String productName = (String) entity.getProperty("productName"); Date sharedDate = (Date) entity.getProperty("sharedDate"); resp.getWriter().println( email + " shared <a href=\"http://www.amazon.com/dp/" + productID + "\" target=\"_blank\">" + "<b>" + productName + "</b></a>!<br>"); } resp.getWriter().println("</body></html>"); }
@GET @Produces(MediaType.TEXT_XML) public List<SharedProduct> getEntitiesBrowser() { List<SharedProduct> list = new ArrayList<SharedProduct>(); DatastoreService datastore = DatastoreServiceFactory .getDatastoreService(); Query query = new Query("SharedList"); query.addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING); List<Entity> results = datastore.prepare(query).asList( FetchOptions.Builder.withDefaults()); for (Entity entity : results) { String email = (String) entity.getProperty("email"); String productID = (String) entity.getKey().getName(); String productName = (String) entity.getProperty("productName"); Date sharedDate = (Date) entity.getProperty("sharedDate"); list.add(new SharedProduct(email, productID, productName, sharedDate)); } return list; }
@GET @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public List<SharedProduct> getEntities() { List<SharedProduct> list = new ArrayList<SharedProduct>(); DatastoreService datastore = DatastoreServiceFactory .getDatastoreService(); Query query = new Query("SharedList"); query.addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING); List<Entity> results = datastore.prepare(query).asList( FetchOptions.Builder.withDefaults()); for (Entity entity : results) { String email = (String) entity.getProperty("email"); String productID = (String) entity.getKey().getName(); String productName = (String) entity.getProperty("productName"); Date sharedDate = (Date) entity.getProperty("sharedDate"); list.add(new SharedProduct(email, productID, productName, sharedDate)); } return list; }
@POST @Produces(MediaType.TEXT_HTML) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public void newSharedProduct(@FormParam("productID") String productID, @FormParam("productName") String productName, @Context HttpServletResponse servletResponse) throws Exception { UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); if (user == null) { System.out.println("Login first"); return; } DatastoreService datastore = DatastoreServiceFactory .getDatastoreService(); Entity entity = new Entity("SharedList", productID); entity.setProperty("email", user.getEmail()); entity.setProperty("productName", productName); entity.setProperty("sharedDate", new Date()); datastore.put(entity); servletResponse.getWriter().println(productName + " has been added."); servletResponse.flushBuffer(); }
@POST @Produces(MediaType.TEXT_HTML) @Consumes(MediaType.APPLICATION_JSON) public void newSharedProduct(SharedProduct product, @Context HttpServletResponse servletResponse) throws Exception { UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); if (user == null) { System.out.println("Login first"); return; } DatastoreService datastore = DatastoreServiceFactory .getDatastoreService(); Entity entity = new Entity("SharedList", product.getProductID()); entity.setProperty("email", user.getEmail()); entity.setProperty("productName", product.getProductName()); entity.setProperty("sharedDate", product.getSharedDate()); datastore.put(entity); servletResponse.getWriter().println( product.getProductName() + " has been added."); servletResponse.flushBuffer(); }
@GET @Produces(MediaType.TEXT_XML) public WishlistProduct getHTML() { DatastoreService datastore = DatastoreServiceFactory .getDatastoreService(); try { Key entKey = KeyFactory.createKey(email, productID); Entity entity = datastore.get(entKey); String productName = (String) entity.getProperty("productName"); double currentPrice = (double) entity.getProperty("currentPrice"); double lowestPrice = (double) entity.getProperty("lowestPrice"); Date lowestDate = (Date) entity.getProperty("lowestDate"); return new WishlistProduct(productID, productName, currentPrice, lowestPrice, lowestDate); } catch (EntityNotFoundException e) { throw new RuntimeException("GET: Wishlist with " + productID + " not found."); } }
@GET @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public WishlistProduct get() { DatastoreService datastore = DatastoreServiceFactory .getDatastoreService(); try { Key entKey = KeyFactory.createKey(email, productID); Entity entity = datastore.get(entKey); String productName = (String) entity.getProperty("productName"); double currentPrice = (double) entity.getProperty("currentPrice"); double lowestPrice = (double) entity.getProperty("lowestPrice"); Date lowestDate = (Date) entity.getProperty("lowestDate"); return new WishlistProduct(productID, productName, currentPrice, lowestPrice, lowestDate); } catch (EntityNotFoundException e) { throw new RuntimeException("GET: Wishlist with " + productID + " not found."); } }
@Inject MapreduceEntityCleanupAction( @Parameter("jobId") Optional<String> jobId, @Parameter("jobName") Optional<String> jobName, @Parameter("numJobsToDelete") Optional<Integer> numJobsToDelete, @Parameter("daysOld") Optional<Integer> daysOld, @Parameter("force") Optional<Boolean> force, MapreduceEntityCleanupUtil mapreduceEntityCleanupUtil, Clock clock, DatastoreService datastore, Response response) { this.jobId = jobId; this.jobName = jobName; this.numJobsToDelete = numJobsToDelete; this.daysOld = daysOld; this.force = force; this.mapreduceEntityCleanupUtil = mapreduceEntityCleanupUtil; this.clock = clock; this.datastore = datastore; this.response = response; }
@Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); String guestbookName = req.getParameter("guestbookName"); Key guestbookKey = KeyFactory.createKey("Guestbook", guestbookName); String content = req.getParameter("content"); Date date = new Date(); Entity greeting = new Entity("Greeting", guestbookKey); if (user != null) { greeting.setProperty("author_id", user.getUserId()); greeting.setProperty("author_email", user.getEmail()); } greeting.setProperty("date", date); greeting.setProperty("content", content); DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); datastore.put(greeting); resp.sendRedirect("/guestbook.jsp?guestbookName=" + guestbookName); }
@Override public void map(Entity entity) { System.out.println(entity); Long lastModificationDate = (Long) entity.getProperty("lastModificationDate"); if (lastModificationDate == null) { final DatastoreService dss = DatastoreServiceFactory.getDatastoreService(); entity.setProperty("lastModificationDate", System.currentTimeMillis()); dss.put(entity); } // incrementCounter("total entities", 1); // incrementCounter("map calls in shard " + getContext().getShardNumber(), 1); // // String name = entity.getKey().getName(); // if (name != null) { // incrementCounter("total entity key size", name.length()); // emitCharacterCounts(name); // } // // Text property = (Text) entity.getProperty("payload"); // if (property != null) { // incrementCounter("total entity payload size", property.getValue().length()); // emitCharacterCounts(property.getValue()); // } }
@Test public void readPolicy_strong_returnsAllResults() { double deadline = 5.0; ReadPolicy policy = new ReadPolicy(ReadPolicy.Consistency.STRONG); DatastoreServiceConfig datastoreConfig = DatastoreServiceConfig.Builder.withReadPolicy(policy).deadline(deadline); DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(datastoreConfig); Entity parent = new Entity("Person", "a"); Entity child = new Entity("Person", "b", parent.getKey()); datastore.put(ImmutableList.<Entity>of(parent, child)); Query q = new Query("Person").setAncestor(parent.getKey()); List<Entity> results = datastore.prepare(q).asList(FetchOptions.Builder.withDefaults()); assertThat(results).named("query results").hasSize(2); }
private static void printEntityGroupVersions(DatastoreService ds, PrintWriter writer) { Entity entity1 = new Entity("Simple"); Key key1 = ds.put(entity1); Key entityGroupKey = Entities.createEntityGroupKey(key1); // Print entity1's entity group version writer.println("version " + getEntityGroupVersion(ds, null, key1)); // Write to a different entity group Entity entity2 = new Entity("Simple"); ds.put(entity2); // Will print the same version, as entity1's entity group has not changed writer.println("version " + getEntityGroupVersion(ds, null, key1)); // Change entity1's entity group by adding a new child entity Entity entity3 = new Entity("Simple", entity1.getKey()); ds.put(entity3); // Will print a higher version, as entity1's entity group has changed writer.println("version " + getEntityGroupVersion(ds, null, key1)); }
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Error error = Error.NONE; String jsonEnd = HtmlVariable.AVAILABLE.getName(); String userId = req.getParameter(HtmlVariable.USER_ID.getName()); if(userId == null || userId.length() == 0) { error = Error.REQUIRED_USER_ID; jsonEnd = jsonEnd + "\": false }"; } else { DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); User user = UserFactory.getByUserId(datastore, null, userId); jsonEnd = (user != null) ? jsonEnd + "\": false }" : jsonEnd + "\": true }"; } String jsonStart = "{ \"" + HtmlVariable.ERROR.getName() + "\": " + error.toString() + ", \""; resp.setContentType("application/json; charset=UTF-8"); resp.getWriter().print(jsonStart + jsonEnd); }
List<String> propertiesOfKind(DatastoreService ds, String kind) { // Start with unrestricted keys-only property query Query q = new Query(Entities.PROPERTY_METADATA_KIND).setKeysOnly(); // Limit to specified kind q.setAncestor(Entities.createKindKey(kind)); // Initialize result list ArrayList<String> results = new ArrayList<String>(); //Build list of query results for (Entity e : ds.prepare(q).asIterable()) { results.add(e.getKey().getName()); } // Return result list return results; }
@Test public void kindExample_writesEntity() throws Exception { // [START kind_example] Entity employee = new Entity("Employee", "asalieri"); employee.setProperty("firstName", "Antonio"); employee.setProperty("lastName", "Salieri"); employee.setProperty("hireDate", new Date()); employee.setProperty("attendedHrTraining", true); DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); datastore.put(employee); // [END kind_example] Entity got = datastore.get(employee.getKey()); assertThat((String) got.getProperty("firstName")).named("got.firstName").isEqualTo("Antonio"); assertThat((String) got.getProperty("lastName")).named("got.lastName").isEqualTo("Salieri"); assertThat((Date) got.getProperty("hireDate")).named("got.hireDate").isNotNull(); assertThat((boolean) got.getProperty("attendedHrTraining")) .named("got.attendedHrTraining") .isTrue(); }
@Test public void creatingAnEntityInASpecificEntityGroup() throws Exception { String boardName = "my-message-board"; // [START creating_an_entity_in_a_specific_entity_group] DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); String messageTitle = "Some Title"; String messageText = "Some message."; Date postDate = new Date(); Key messageBoardKey = KeyFactory.createKey("MessageBoard", boardName); Entity message = new Entity("Message", messageBoardKey); message.setProperty("message_title", messageTitle); message.setProperty("message_text", messageText); message.setProperty("post_date", postDate); Transaction txn = datastore.beginTransaction(); datastore.put(txn, message); txn.commit(); // [END creating_an_entity_in_a_specific_entity_group] }
/** * Counts the entities returned by the specified query. * @param ds reference to the datastore service * @param query query whose results to count * @return the number of entities returned by the query */ public static int countEntities( final DatastoreService ds, final com.google.appengine.api.datastore.Query q ) { q.setKeysOnly(); final int batchSize = 1000; final FetchOptions fetchOptions = FetchOptions.Builder.withLimit( batchSize ); Cursor cursor = null; int count = 0; while ( true ) { if ( cursor != null ) fetchOptions.startCursor( cursor ); final QueryResultList< Entity > resultList = ds.prepare( q ).asQueryResultList( fetchOptions ); count += resultList.size(); if ( resultList.size() < batchSize ) return count; cursor = resultList.getCursor(); } }
@Override public void contextInitialized(ServletContextEvent event) { DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); Key key = KeyFactory.createKey(ENTITY_KIND, ENTITY_KEY); Entity entity; try { entity = datastore.get(key); } catch(EntityNotFoundException e) { entity = new Entity(key); // NOTE: it's not possible to change entities in the local server, so // it will be necessary to hardcode the API key below if you are running // it locally. entity.setProperty(ACCESS_KEY_FIELD, API_KEY); datastore.put(entity); mLogger.severe("Created fake key. Please go to App Engine admin " + "console, change its value to your API Key (the entity " + "type is '" + ENTITY_KIND + "' and its field to be changed is '" + ACCESS_KEY_FIELD + "'), then restart the server!"); } String accessKey = (String) entity.getProperty(ACCESS_KEY_FIELD); event.getServletContext().setAttribute(ATTRIBUTE_ACCESS_KEY, accessKey); }
@Test public void doGet_repeatedPropertyEntities_writesWidgets() throws Exception { //CHECKSTYLE.OFF: VariableDeclarationUsageDistance - readability DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); //CHECKSTYLE.ON: VariableDeclarationUsageDistance // [START exploding_index_example_3] Entity widget = new Entity("Widget"); widget.setProperty("x", Arrays.asList(1, 2, 3, 4)); widget.setProperty("y", Arrays.asList("red", "green", "blue")); widget.setProperty("date", new Date()); datastore.put(widget); // [END exploding_index_example_3] servletUnderTest.doGet(mockRequest, mockResponse); assertThat(responseWriter.toString()) .named("IndexesServlet response") .isEqualTo("Got 1 widgets.\n"); }
/** * A simple API client. * @param args . * @throws IOException . */ public static void main(String[] args) throws IOException { String serverString = args[0]; RemoteApiOptions options; if (serverString.equals("localhost")) { options = new RemoteApiOptions().server(serverString, 8080).useDevelopmentServerCredential(); } else { options = new RemoteApiOptions().server(serverString, 443).useApplicationDefaultCredential(); } RemoteApiInstaller installer = new RemoteApiInstaller(); installer.install(options); try { DatastoreService ds = DatastoreServiceFactory.getDatastoreService(); System.out.println("Key of new entity is " + ds.put(new Entity("Hello Remote API!"))); } finally { installer.uninstall(); } }
public static void main(String[] args) throws IOException { String serverString = args[0]; RemoteApiOptions options; if (serverString.equals("localhost")) { options = new RemoteApiOptions().server(serverString, 8080).useDevelopmentServerCredential(); } else { options = new RemoteApiOptions().server(serverString, 443).useApplicationDefaultCredential(); } RemoteApiInstaller installer = new RemoteApiInstaller(); installer.install(options); try { DatastoreService ds = DatastoreServiceFactory.getDatastoreService(); System.out.println("Key of new entity is " + ds.put(new Entity("Hello Remote API!"))); } finally { installer.uninstall(); } }
@Test public void creatingAnEntityInASpecificEntityGroup() throws Exception { String boardName = "my-message-board"; //CHECKSTYLE.OFF: VariableDeclarationUsageDistance - Increased clarity in sample // [START creating_an_entity_in_a_specific_entity_group] DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); String messageTitle = "Some Title"; String messageText = "Some message."; Date postDate = new Date(); Transaction txn = datastore.beginTransaction(); Key messageBoardKey = KeyFactory.createKey("MessageBoard", boardName); Entity message = new Entity("Message", messageBoardKey); message.setProperty("message_title", messageTitle); message.setProperty("message_text", messageText); message.setProperty("post_date", postDate); datastore.put(txn, message); txn.commit(); // [END creating_an_entity_in_a_specific_entity_group] //CHECKSTYLE.ON: VariableDeclarationUsageDistance }
@Test public void crossGroupTransactions() throws Exception { // [START cross-group_XG_transactions_using_the_Java_low-level_API] DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); TransactionOptions options = TransactionOptions.Builder.withXG(true); Transaction txn = datastore.beginTransaction(options); Entity a = new Entity("A"); a.setProperty("a", 22); datastore.put(txn, a); Entity b = new Entity("B"); b.setProperty("b", 11); datastore.put(txn, b); txn.commit(); // [END cross-group_XG_transactions_using_the_Java_low-level_API] }
@Test public void kindExample_writesEntity() throws Exception { //CHECKSTYLE.OFF: VariableDeclarationUsageDistance - Increased clarity in sample // [START kind_example] DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); Entity employee = new Entity("Employee", "asalieri"); employee.setProperty("firstName", "Antonio"); employee.setProperty("lastName", "Salieri"); employee.setProperty("hireDate", new Date()); employee.setProperty("attendedHrTraining", true); datastore.put(employee); // [END kind_example] //CHECKSTYLE.ON: VariableDeclarationUsageDistance Entity got = datastore.get(employee.getKey()); assertThat((String) got.getProperty("firstName")).named("got.firstName").isEqualTo("Antonio"); assertThat((String) got.getProperty("lastName")).named("got.lastName").isEqualTo("Salieri"); assertThat((Date) got.getProperty("hireDate")).named("got.hireDate").isNotNull(); assertThat((boolean) got.getProperty("attendedHrTraining")) .named("got.attendedHrTraining") .isTrue(); }
void printPropertyRange(DatastoreService ds, PrintWriter writer) { // Start with unrestricted keys-only property query Query q = new Query(Entities.PROPERTY_METADATA_KIND).setKeysOnly(); // Limit range q.setFilter( CompositeFilterOperator.and( new FilterPredicate( Entity.KEY_RESERVED_PROPERTY, Query.FilterOperator.GREATER_THAN_OR_EQUAL, Entities.createPropertyKey("Employee", "salary")), new FilterPredicate( Entity.KEY_RESERVED_PROPERTY, Query.FilterOperator.LESS_THAN_OR_EQUAL, Entities.createPropertyKey("Manager", "salary")))); q.addSort(Entity.KEY_RESERVED_PROPERTY, SortDirection.ASCENDING); // Print query results for (Entity e : ds.prepare(q).asIterable()) { writer.println(e.getKey().getParent().getName() + ": " + e.getKey().getName()); } }
private ArrayList<Medicion> getLastStatus(int amountData) { // Poner Key estacion + hora_muestra Calendar calendarTwoAgo = Calendar.getInstance(TimeZone.getTimeZone("CET")); calendarTwoAgo.add(Calendar.DATE, -3); Date dateTwoAgo = calendarTwoAgo.getTime(); // Prepare Query.Filter keyFilter = new Query.FilterPredicate(PROPERTY_MEASURE_DATE, Query.FilterOperator.GREATER_THAN, dateTwoAgo); Query.Filter no2Filter = new Query.FilterPredicate(PROPERTY_COMPUESTO, Query.FilterOperator.EQUAL, NO2.name()); List<Query.Filter> filterList = new ArrayList<>(); filterList.add(keyFilter); filterList.add(no2Filter); Query.Filter filter = new Query.CompositeFilter(Query.CompositeFilterOperator.AND, filterList); Query query = new Query(ENTITY_TYPE_MEDIDAS) .setFilter(filter) .addSort(PROPERTY_MEASURE_DATE , Query.SortDirection.DESCENDING); // Query DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); PreparedQuery pq = datastore.prepare(query); // Get results List<com.google.appengine.api.datastore.Entity> resultList = pq.asList(FetchOptions.Builder.withLimit(amountData)); ArrayList<Medicion> result = new ArrayList<>(); if (resultList.size()!=0) { mLogger.info("Watching " + resultList.size() + " last values of ESTADO"); for (com.google.appengine.api.datastore.Entity item : resultList){ result.add(new Medicion((Date) item.getProperty(PROPERTY_MEASURE_DATE), (String) item.getProperty(PROPERTY_AVISO), (String) item.getProperty(PROPERTY_AVISO_STATE), (String) item.getProperty(PREPERTY_AVISO_MAX_TODAY), (String) item.getProperty(PROPERTY_ESCENARIO_STATE_TODAY), (String) item.getProperty(PROPERTY_ESCENARIO_STATE_TOMORROW), (String) item.getProperty(PROPERTY_ESCENARIO_STATE_TOMORROW_MANUAL) ,isPureMadrid())); } } else { // No hay datos mLogger.info("No previous values for ESTADO"); } return result; }
/** * Gets the access key. */ protected String getKey() { com.google.appengine.api.datastore.DatastoreService datastore = DatastoreServiceFactory .getDatastoreService(); Key key = KeyFactory.createKey(ENTITY_KIND, ENTITY_KEY); String apiKey = ""; try { Entity entity = datastore.get(key); apiKey = (String) entity.getProperty(ACCESS_KEY_FIELD); } catch (EntityNotFoundException e) { mLogger.severe("Exception will retrieving the API Key" + e.toString()); } return apiKey; }
public Iterable<Entity> listRawEntity(Query q, Boolean returnKeysOnly) { DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); if (returnKeysOnly) { q.setKeysOnly(); } PreparedQuery pq = datastore.prepare(q); return pq.asIterable(); }
public void deleteAllObjects(Query query){ final DatastoreService dss=DatastoreServiceFactory.getDatastoreService(); final ArrayList<Key> keys=new ArrayList<>(); for ( final Entity entity : dss.prepare(query).asIterable(FetchOptions.Builder.withLimit(100000))) { keys.add(entity.getKey()); } dss.delete(keys); }
private static void reboxUnscheduledMessagesForCurrentUserAfterAuth(String userId) throws IOException { final Scheduler scheduler = new Scheduler(userId); final DatastoreService ds = DatastoreServiceFactory.getDatastoreService(); final Iterable<Entity> toBeProcessedScheduledMailsForCurrentUser = EntityHelper.getToBeProcessedScheduledMailsForUser(ds, userId); final List<String> scheduledMailIds = new ArrayList<String>(); for (final Entity scheduledMail : toBeProcessedScheduledMailsForCurrentUser) { scheduledMailIds.add((String) scheduledMail.getProperty(EntityConstants.ScheduledMail.Property.MAIL_ID)); } scheduler.reboxUnscheduledMessagesWithOutboxLabel(scheduledMailIds); }
@Provides DatastoreService provideDatastore(@DatastoreTimeoutMillis long datastoreTimeoutMillis) { return DatastoreServiceFactory.getDatastoreService(DatastoreServiceConfig.Builder .withDeadline(datastoreTimeoutMillis * 1000.0) .implicitTransactionManagementPolicy(ImplicitTransactionManagementPolicy.NONE) .readPolicy(new ReadPolicy(ReadPolicy.Consistency.STRONG))); }