本文整理汇总了Java中com.google.appengine.api.memcache.ErrorHandlers类的典型用法代码示例。如果您正苦于以下问题:Java ErrorHandlers类的具体用法?Java ErrorHandlers怎么用?Java ErrorHandlers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ErrorHandlers类属于com.google.appengine.api.memcache包,在下文中一共展示了ErrorHandlers类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: ObjectifyStorageIo
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
ObjectifyStorageIo() {
RetryParams retryParams = new RetryParams.Builder().initialRetryDelayMillis(100)
.retryMaxAttempts(10)
.totalRetryPeriodMillis(10000).build();
if (DEBUG) {
LOG.log(Level.INFO, "RetryParams: getInitialRetryDelayMillis() = " + retryParams.getInitialRetryDelayMillis());
LOG.log(Level.INFO, "RetryParams: getRequestTimeoutMillis() = " + retryParams.getRequestTimeoutMillis());
LOG.log(Level.INFO, "RetryParams: getRetryDelayBackoffFactor() = " + retryParams.getRetryDelayBackoffFactor());
LOG.log(Level.INFO, "RetryParams: getRetryMaxAttempts() = " + retryParams.getRetryMaxAttempts());
LOG.log(Level.INFO, "RetryParams: getRetryMinAttempts() = " + retryParams.getRetryMinAttempts());
LOG.log(Level.INFO, "RetryParams: getTotalRetryPeriodMillis() = " + retryParams.getTotalRetryPeriodMillis());
}
gcsService = GcsServiceFactory.createGcsService(retryParams);
memcache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
initMotd();
}
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:17,代码来源:ObjectifyStorageIo.java
示例2: doGet
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException,
ServletException {
String path = req.getRequestURI();
if (path.startsWith("/favicon.ico")) {
return; // ignore the request for favicon.ico
}
MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
syncCache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
byte[] whoKey = "who".getBytes();
byte[] countKey = "count".getBytes();
byte[] who = (byte[]) syncCache.get(whoKey);
String whoString = who == null ? "nobody" : new String(who);
resp.getWriter().print("Previously incremented by " + whoString + "\n");
syncCache.put(whoKey, "Java".getBytes());
Long count = syncCache.increment(countKey, 1L, 0L);
resp.getWriter().print("Count incremented by Java = " + count + "\n");
}
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:22,代码来源:MemcacheBestPracticeServlet.java
示例3: countPackages
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
/**
* @return the number of packages
*/
public static int countPackages() {
final String key =
NWUtils.class.getName() + "[email protected]" +
NWUtils.getDataVersion();
MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
syncCache.setErrorHandler(ErrorHandlers
.getConsistentLogAndContinue(Level.INFO));
Integer value = (Integer) syncCache.get(key); // read from cache
if (value == null) {
ShardedCounter sc =
ShardedCounter.getOrCreateCounter("NumberOfPackages", 2);
value = sc.getCount();
if (sc.getCount() == 0) {
Objectify ofy = DefaultServlet.getObjectify();
sc.increment(ofy.query(Package.class).count());
value = sc.getCount();
}
syncCache.put(key, value); // populate cache
}
return value;
}
开发者ID:tim-lebedkov,项目名称:npackd-gae-web,代码行数:25,代码来源:NWUtils.java
示例4: doGet
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
final String uuid = request.getParameter(UpdatePositionServletImpl.PARAMETER_UUID);
if (uuid == null || uuid.trim().equals("")) {
response.sendError(HttpStatus.SC_BAD_REQUEST, "?uuid= mandatory");
}
final MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
syncCache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
final Object inMemory = syncCache.get(uuid);
if (inMemory == null) {
response.sendError(HttpStatus.SC_NOT_FOUND, "element not found");
}
final Cache cache = Cache.from(inMemory);
response.getWriter().write(cache.toString());
}
开发者ID:sylvek,项目名称:sharemyposition,代码行数:20,代码来源:RetrievePositionServletImpl.java
示例5: doGet
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException,
ServletException {
String path = req.getRequestURI();
if (path.startsWith("/favicon.ico")) {
return; // ignore the request for favicon.ico
}
// [START example]
AsyncMemcacheService asyncCache = MemcacheServiceFactory.getAsyncMemcacheService();
asyncCache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
String key = "count-async";
byte[] value;
long count = 1;
Future<Object> futureValue = asyncCache.get(key); // Read from cache.
// ... Do other work in parallel to cache retrieval.
try {
value = (byte[]) futureValue.get();
if (value == null) {
value = BigInteger.valueOf(count).toByteArray();
asyncCache.put(key, value);
} else {
// Increment value
count = new BigInteger(value).longValue();
count++;
value = BigInteger.valueOf(count).toByteArray();
// Put back in cache
asyncCache.put(key, value);
}
} catch (InterruptedException | ExecutionException e) {
throw new ServletException("Error when waiting for future value", e);
}
// [END example]
// Output content
resp.setContentType("text/plain");
resp.getWriter().print("Value is " + count + "\n");
}
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:39,代码来源:MemcacheAsyncCacheServlet.java
示例6: doGet
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException,
ServletException {
String path = req.getRequestURI();
if (path.startsWith("/favicon.ico")) {
return; // ignore the request for favicon.ico
}
MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
syncCache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
String key = "count-sync";
byte[] value;
long count = 1;
value = (byte[]) syncCache.get(key);
if (value == null) {
value = BigInteger.valueOf(count).toByteArray();
syncCache.put(key, value);
} else {
// Increment value
count = new BigInteger(value).longValue();
count++;
value = BigInteger.valueOf(count).toByteArray();
// Put back in cache
syncCache.put(key, value);
}
// Output content
resp.setContentType("text/plain");
resp.getWriter().print("Value is " + count + "\n");
}
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:31,代码来源:MemcacheSyncCacheServlet.java
示例7: getKeys
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
/**
* Returns possible cached result of a query.
*
* @param <T>
* datastore object class
* @param ofy
* Objectify
* @param q
* a query
* @param cacheSuffix
* suffix for the cache key
* @return possible cached result of the query
*/
public static <T> List<Key<T>> getKeys(Objectify ofy,
com.googlecode.objectify.Query<T> q, String cacheSuffix) {
String key = q.toString() + cacheSuffix;
MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
syncCache.setErrorHandler(ErrorHandlers
.getConsistentLogAndContinue(Level.INFO));
String value = (String) syncCache.get(key); // read from cache
List<Key<T>> result;
if (value == null) {
result = q.listKeys();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < result.size(); i++) {
if (i != 0)
sb.append(' ');
sb.append(result.get(i).getString());
}
value = sb.toString();
syncCache.put(key, value); // populate cache
} else {
List<String> keys = NWUtils.split(value, ' ');
result = new ArrayList<Key<T>>();
for (String k : keys) {
result.add(new Key<T>(k));
}
}
return result;
}
开发者ID:tim-lebedkov,项目名称:npackd-gae-web,代码行数:44,代码来源:QueryCache.java
示例8: incDataVersion
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
/**
* Increments the version of the data.
*
* @return new version number
*/
public static long incDataVersion() {
MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
syncCache.setErrorHandler(ErrorHandlers
.getConsistentLogAndContinue(Level.INFO));
Long v = syncCache.increment("DataVersion", 1L);
if (v == null) {
syncCache.put("DataVersion", 1L);
v = 1L;
}
return v;
}
开发者ID:tim-lebedkov,项目名称:npackd-gae-web,代码行数:17,代码来源:NWUtils.java
示例9: getDataVersion
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
/**
* @return current data version
*/
public static long getDataVersion() {
MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
syncCache.setErrorHandler(ErrorHandlers
.getConsistentLogAndContinue(Level.INFO));
Long v = (Long) syncCache.get("DataVersion");
if (v == null) {
syncCache.put("DataVersion", 1L);
v = 1L;
}
return v;
}
开发者ID:tim-lebedkov,项目名称:npackd-gae-web,代码行数:15,代码来源:NWUtils.java
示例10: doPost
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
final String position = request.getParameter(PARAMETER_POSITION);
final String uuid = request.getParameter(PARAMETER_UUID);
final MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
syncCache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
syncCache.put(uuid, Cache.to(position));
}
开发者ID:sylvek,项目名称:sharemyposition,代码行数:10,代码来源:UpdatePositionServletImpl.java
示例11: getBoards
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
/**
* Gets a list of all game board entities.
*
* @return non null map of board entities indexed by entity keys.
*/
private Map<Key, BoardEntity> getBoards() {
// Gets a list of all game boards from memcache.
MemcacheService cache = MemcacheServiceFactory.getMemcacheService();
cache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
@SuppressWarnings("unchecked")
Map<Key, BoardEntity> boards = (Map<Key, BoardEntity>) cache.get(ALL_BOARDS_CACHE_KEY);
// If the list wasn't in the cache then retrieve it from Datastore
// and cache it (unless the list is empty).
if (boards == null) {
boards = new HashMap<Key, BoardEntity>();
Query query = new Query(BoardEntity.KIND);
PreparedQuery preparedQuery = dataStore.prepare(query);
for (Entity board : preparedQuery.asIterable()) {
boards.put(board.getKey(), new BoardEntity(board));
}
if (boards.size() > 0) {
cache.put(ALL_BOARDS_CACHE_KEY, boards);
}
}
return boards;
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-griddler-sample-backend-java,代码行数:33,代码来源:GameService.java
示例12: create
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
@Override
public void create(HttpServletRequest request, HttpServletResponse resp)
throws IOException {
resp.setContentType("application/xml");
final String key =
this.getClass().getName() + "@" + NWUtils.getDataVersion() +
"@" + user + "@" + tag;
MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
syncCache.setErrorHandler(ErrorHandlers
.getConsistentLogAndContinue(Level.INFO));
byte[] value = (byte[]) syncCache.get(key); // read from cache
if (value == null) {
NWUtils.LOG.warning("Found no value in cache");
try {
Objectify ofy = DefaultServlet.getObjectify();
ArrayList<PackageVersion> pvs = new ArrayList<PackageVersion>();
Query<PackageVersion> q =
ofy.query(PackageVersion.class).limit(20)
.order("-lastModifiedAt");
if (user != null) {
q =
q.filter(
"lastModifiedBy =",
new User(user, user.substring(user
.indexOf('@'))));
}
if (tag != null) {
q = q.filter("tags =", tag);
}
pvs.addAll(q.list());
Document d = RepXMLPage.toXML(ofy, pvs, false, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
NWUtils.serializeXML(d, baos);
value = baos.toByteArray();
syncCache.put(key, value); // populate cache
} catch (Exception e) {
throw new IOException(e);
}
} else {
NWUtils.LOG.log(Level.WARNING, "Found value in cache {0} bytes",
value.length);
}
ServletOutputStream ros = resp.getOutputStream();
ros.write(value);
ros.close();
}
开发者ID:tim-lebedkov,项目名称:npackd-gae-web,代码行数:50,代码来源:RecentRepXMLPage.java
示例13: NotificationWorker
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
protected NotificationWorker(Queue queue) {
this.queue = queue;
cache.setErrorHandler(ErrorHandlers
.getConsistentLogAndContinue(Level.INFO));
}
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:7,代码来源:NotificationWorker.java
示例14: MemcacheSessionStore
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
public MemcacheSessionStore() {
memcache = MemcacheServiceFactory.getMemcacheService("");
memcache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:5,代码来源:MemcacheSessionStore.java
示例15: Worker
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
/**
* @constructor
*
* @param queue Task queue that needs to be processed
*/
protected Worker(Queue queue) {
this.queue = queue;
cache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
}
开发者ID:googlesamples,项目名称:io2014-codelabs,代码行数:11,代码来源:Worker.java
示例16: initMemcache
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
private static MemcacheService initMemcache() {
MemcacheService m = MemcacheServiceFactory.getMemcacheService();
m.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
return m;
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-cloud-adventure-sample-backend-java,代码行数:6,代码来源:StorageUtils.java
示例17: InvitationService
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
public InvitationService() {
cache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-griddler-sample-backend-java,代码行数:4,代码来源:InvitationService.java
示例18: PushNotificationWorker
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
/**
* @constructor
*
* @param queue Task queue that needs to be processed
*/
protected PushNotificationWorker(Queue queue) {
this.queue = queue;
cache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-ios-push-notification-sample-backend-java,代码行数:11,代码来源:PushNotificationWorker.java
示例19: getService
import com.google.appengine.api.memcache.ErrorHandlers; //导入依赖的package包/类
/**
* Get a Memcache service for specific namespace
*
* @param namespace namespace of memcache
* @return the Memcache
*/
private MemcacheService getService(String namespace) {
MemcacheService cache = MemcacheServiceFactory.getMemcacheService("alarmClock");
cache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.WARNING));
return cache;
}
开发者ID:masters-info-nantes,项目名称:myLazyClock,代码行数:12,代码来源:MyLazyClockMemcacheService.java
注:本文中的com.google.appengine.api.memcache.ErrorHandlers类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论