當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。