本文整理汇总了Java中com.google.appengine.api.datastore.ReadPolicy.Consistency类的典型用法代码示例。如果您正苦于以下问题:Java Consistency类的具体用法?Java Consistency怎么用?Java Consistency使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Consistency类属于com.google.appengine.api.datastore.ReadPolicy包,在下文中一共展示了Consistency类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllValidTrailsIds
import com.google.appengine.api.datastore.ReadPolicy.Consistency; //导入依赖的package包/类
/**
* This method returns the all the trails that have been registered in the competition of MapatonCDMX
* paginated by parameter.numberOfElements and parameter.cursor to define where to start and how many elements to get.
* @author Rodrigo Cabrera ([email protected])
* @since 25 / feb / 2016
* @return The list of trails and the cursor to be able to get the next N number of elements.
* @throws TrailNotFoundException
*/
public ArrayList<Long> getAllValidTrailsIds() {
logger.debug("Getting user trails...");
ArrayList<Long> result = new ArrayList<>();
List<Key<RegisteredTrail>> trails = OfyService.ofy().cache(false)
.consistency(Consistency.STRONG).load().type(RegisteredTrail.class)
.filter("trailStatus", RegisteredTrailStatusEnum.VALID).keys().list();
for(Key<RegisteredTrail> t : trails){
result.add(t.getId());
}
return result;
}
示例2: getTrailsByStationName
import com.google.appengine.api.datastore.ReadPolicy.Consistency; //导入依赖的package包/类
public ArrayList<TrailDetails> getTrailsByStationName(SearchByKeywordParameter parameter) {
logger.debug("Getting list of statios by keyword: ");
List<Station> stations = OfyService.ofy().cache(false).consistency(Consistency.STRONG).load().type(Station.class)
.filter("name", parameter.getKeyword())
.list();
ArrayList<TrailDetails> result = new ArrayList<>();
int i = 0;
for(Station s:stations){
List<RegisteredTrail> trails = OfyService.ofy().cache(false)
.consistency(Consistency.STRONG).load().type(RegisteredTrail.class)
.filter("origin in", s.getPlatforms()).list();
for(RegisteredTrail trail : trails){
if(i < parameter.getNumberOfResults()){
i++;
result.add(new TrailDetails(trail, trail.getCreationDate()));
}
}
}
return result;
}
示例3: testConfigBuilder
import com.google.appengine.api.datastore.ReadPolicy.Consistency; //导入依赖的package包/类
@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());
}
示例4: getTrailById
import com.google.appengine.api.datastore.ReadPolicy.Consistency; //导入依赖的package包/类
/**
* This method retrieves a trail with the specified id.
* @author JJMS ([email protected])
* @since 16 / feb / 2016
* @version 1.0.0.0
* @param trailId
* The id of the trail.
* @return The trail object stored.
* @throws TrailNotFoundException
* If the trail is not registered in the data storage.
*/
public static RegisteredTrail getTrailById(Long trailId) throws TrailNotFoundException{
logger.debug("Finding mapped trail by id: " + trailId);
RegisteredTrail trail = OfyService.ofy().cache(false)
.consistency(Consistency.STRONG).load().type(RegisteredTrail.class)
.id(trailId).now();
if(trail == null){
throw new TrailNotFoundException(
"Lo sentimos, no hemos podido encontrar el recorrido que solicitaste.");
}
logger.debug("Mapped trail found: " + trail);
return trail;
}
示例5: getGenericTrailById
import com.google.appengine.api.datastore.ReadPolicy.Consistency; //导入依赖的package包/类
/**
* This method retrieves a trail with the specified id.
* @author JJMS ([email protected])
* @since 16 / feb / 2016
* @version 1.0.0.0
* @param trailId
* The id of the trail.
* @return The trail object stored.
* @throws TrailNotFoundException
* If the trail is not registered in the data storage.
*/
public static GenericTrail getGenericTrailById(Long trailId) throws TrailNotFoundException{
logger.debug("Finding mapped trail by id: " + trailId);
GenericTrail trail = OfyService.ofy().cache(false)
.consistency(Consistency.STRONG).load().type(GenericTrail.class)
.id(trailId).now();
if(trail == null){
throw new TrailNotFoundException(
"Lo sentimos, no hemos podido encontrar el recorrido que solicitaste.");
}
logger.debug("Mapped trail found: " + trail);
return trail;
}
示例6: getAllTrails
import com.google.appengine.api.datastore.ReadPolicy.Consistency; //导入依赖的package包/类
/**
* This method returns the all the trails that have been registered in the competition of MapatonCDMX
* paginated by parameter.numberOfElements and parameter.cursor to define where to start and how many elements to get.
* @author Rodrigo Cabrera ([email protected])
* @since 16 / feb / 2016
* @param parameter The object containing all the parameters for the request.
* @return The list of trails and the cursor to be able to get the next N number of elements.
* @throws TrailNotFoundException
*/
public TrailListResponse getAllTrails(CursorParameter parameter) {
logger.debug("Getting user trails...");
ArrayList<TrailDetails> result = new ArrayList<TrailDetails>();
Query<RegisteredTrail> query = OfyService.ofy().cache(false)
.consistency(Consistency.STRONG).load().type(RegisteredTrail.class);
query = CursorHelper.processCursor(query, parameter);
QueryResultIterator<RegisteredTrail> it = query.iterator();
while(it.hasNext()){
RegisteredTrail t = it.next();
result.add(new TrailDetails(t, t.getCreationDate()));
}
TrailListResponse theResult = new TrailListResponse(result, it.getCursor().toWebSafeString());
// logger.debug("Getting all trails... "+result);
return theResult;
}
示例7: getAllValidTrails
import com.google.appengine.api.datastore.ReadPolicy.Consistency; //导入依赖的package包/类
/**
* This method returns the all the trails that have been registered in the competition of MapatonCDMX
* paginated by parameter.numberOfElements and parameter.cursor to define where to start and how many elements to get.
* @author Rodrigo Cabrera ([email protected])
* @since 16 / feb / 2016
* @param parameter The object containing all the parameters for the request.
* @return The list of trails and the cursor to be able to get the next N number of elements.
* @throws TrailNotFoundException
*/
public TrailListResponse getAllValidTrails(CursorParameter parameter) {
logger.debug("Getting user trails...");
ArrayList<TrailDetails> result = new ArrayList<TrailDetails>();
Query<RegisteredTrail> query = OfyService.ofy().cache(false)
.consistency(Consistency.STRONG).load().type(RegisteredTrail.class)
.filter("trailStatus", RegisteredTrailStatusEnum.VALID);
query = CursorHelper.processCursor(query, parameter);
QueryResultIterator<RegisteredTrail> it = query.iterator();
while(it.hasNext()){
RegisteredTrail t = it.next();
result.add(new TrailDetails(t, t.getCreationDate()));
}
TrailListResponse theResult = new TrailListResponse(result, it.getCursor().toWebSafeString());
// logger.debug("Getting all trails... "+result);
return theResult;
}
示例8: getAllGtfsTrails
import com.google.appengine.api.datastore.ReadPolicy.Consistency; //导入依赖的package包/类
/**
* This method returns the all the trails that have been registered in the competition of MapatonCDMX
* paginated by parameter.numberOfElements and parameter.cursor to define where to start and how many elements to get.
* @author Rodrigo Cabrera ([email protected])
* @since 16 / feb / 2016
* @param parameter The object containing all the parameters for the request.
* @return The list of trails and the cursor to be able to get the next N number of elements.
* @throws TrailNotFoundException
*/
public TrailListResponse getAllGtfsTrails(CursorParameter parameter) {
logger.debug("Getting user trails...");
ArrayList<TrailDetails> result = new ArrayList<TrailDetails>();
Query<RegisteredTrail> query = OfyService.ofy().cache(false)
.consistency(Consistency.STRONG).load().type(RegisteredTrail.class)
.filter("gtfsStatus", RegisteredTrail.GtfsStatus.VALID);
query = CursorHelper.processCursor(query, parameter);
QueryResultIterator<RegisteredTrail> it = query.iterator();
while(it.hasNext()){
RegisteredTrail t = it.next();
result.add(new TrailDetails(t, t.getCreationDate()));
}
TrailListResponse theResult = new TrailListResponse(result, it.getCursor().toWebSafeString());
// logger.debug("Getting all trails... "+result);
return theResult;
}
示例9: getAllValidGtfsTrailsIds
import com.google.appengine.api.datastore.ReadPolicy.Consistency; //导入依赖的package包/类
/**
* This method returns the all the trails that have been registered in the competition of MapatonCDMX
* paginated by parameter.numberOfElements and parameter.cursor to define where to start and how many elements to get.
* @author Rodrigo Cabrera ([email protected])
* @since 25 / feb / 2016
* @return The list of trails and the cursor to be able to get the next N number of elements.
* @throws TrailNotFoundException
*/
public ArrayList<Long> getAllValidGtfsTrailsIds() {
logger.debug("Getting user trails...");
ArrayList<Long> result = new ArrayList<>();
List<Key<RegisteredTrail>> trails = OfyService.ofy().cache(false)
.consistency(Consistency.STRONG).load().type(RegisteredTrail.class)
.filter("gtfsStatus", RegisteredTrail.GtfsStatus.VALID).keys().list();
for(Key<RegisteredTrail> t : trails){
result.add(t.getId());
}
return result;
}
示例10: ofy
import com.google.appengine.api.datastore.ReadPolicy.Consistency; //导入依赖的package包/类
public static Objectify ofy() {
return ObjectifyService.ofy()
.consistency(Consistency.STRONG);
}