当前位置: 首页>>代码示例>>Java>>正文


Java Consistency类代码示例

本文整理汇总了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;
}
 
开发者ID:LabPLC,项目名称:MapatonAPI,代码行数:25,代码来源:TrailsHandler.java

示例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;
		
	}
 
开发者ID:LabPLC,项目名称:MapatonAPI,代码行数:26,代码来源:TrailsHandler.java

示例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());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:26,代码来源:ConfigTest.java

示例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;
}
 
开发者ID:LabPLC,项目名称:MapatonAPI,代码行数:24,代码来源:TrailsHandler.java

示例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;
}
 
开发者ID:LabPLC,项目名称:MapatonAPI,代码行数:24,代码来源:TrailsHandler.java

示例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;
}
 
开发者ID:LabPLC,项目名称:MapatonAPI,代码行数:33,代码来源:TrailsHandler.java

示例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;
}
 
开发者ID:LabPLC,项目名称:MapatonAPI,代码行数:34,代码来源:TrailsHandler.java

示例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;
}
 
开发者ID:LabPLC,项目名称:MapatonAPI,代码行数:34,代码来源:TrailsHandler.java

示例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;
}
 
开发者ID:LabPLC,项目名称:MapatonAPI,代码行数:27,代码来源:TrailsHandler.java

示例10: ofy

import com.google.appengine.api.datastore.ReadPolicy.Consistency; //导入依赖的package包/类
public static Objectify ofy() {
     return ObjectifyService.ofy()
.consistency(Consistency.STRONG);
 }
 
开发者ID:andryfailli,项目名称:teampot,代码行数:5,代码来源:OfyService.java


注:本文中的com.google.appengine.api.datastore.ReadPolicy.Consistency类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。