AWS Summit – Singapore

Categories: Uncategorized; Tagged with: ; @ July 20th, 2013 22:13

1374468334

 

周四请了年假, 9点多才到.

Hands-On Labs一直有人排队, 等我11点多去拍的时候发现已经遥不可及了…最后拿了一长token卡片,  没有吃饭就闪了.

 

眼看token马上就要过去, 于是今天去https://aws.qwiklab.com 自学了一把. 输入token之后就可以setup EC2, EBS, RDS等等,  非常流畅的体验!

image

GAE Query Filter, Sort, Limit, Paging

Categories: Development Notes; Tagged with: ; @ April 20th, 2011 22:37

GAE关于Java的资料这是不多, 而且多数都要翻墙, 昨晚做个分页, 差点累死啊!

闲言碎语不多说, 上代码:

DatastoreService datastoreService = DatastoreServiceFactory.getDatastoreService();
		Query query = new Query("User");
		query.addFilter("name", FilterOperator.NOT_EQUAL, ""); // 设置Filter
		query.addSort("name", SortDirection.ASCENDING); // 要设置Sort, 则Filter的Attribute必须Sort, 且要放在其他Sort之前(Attribute要Index)
		query.addSort("ip", SortDirection.DESCENDING); // 设置Sort, 要在Filter对应Attribute的Sort之后
		PreparedQuery pq = datastoreService.prepare(query);
		List listUsers = pq.asList(FetchOptions.Builder.withLimit(2)); // 设置Limit
 
Properties in Inequality Filters Must Be Sorted before Other Sort Orders

If a query has both a filter with an inequality comparison and one or more sort orders, the query must include a sort order for the property used in the inequality, and the sort order must appear before sort orders on other properties.

This query is not valid, because it uses an inequality filter and does not order by the filtered property;

文档: http://code.google.com/appengine/docs/java/datastore/queries.html#Restrictions_on_Queries

翻不了墙的同学可以看这个 – 主要是分页: 

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.datastore.Cursor;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.FetchOptions;
import com.google.appengine.api.datastore.PreparedQuery;
import com.google.appengine.api.datastore.Query;
import com.google.appengine.api.datastore.QueryResultList;

public class ListPeopleServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
          throws ServletException, IOException {

        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        Query q = new Query("Person");
        PreparedQuery pq = datastore.prepare(q);
        int pageSize = 15;

        resp.setContentType("text/html");
        resp.getWriter().println("
    "); FetchOptions fetchOptions = FetchOptions.Builder.withLimit(pageSize); String startCursor = req.getParameter("cursor"); // If this servlet is passed a cursor parameter, let's use it if (startCursor != null) { fetchOptions.startCursor(Cursor.fromWebSafeString(startCursor)); } QueryResultList results = pq.asQueryResultList(fetchOptions); for (Entity entity : results) { resp.getWriter().println("
  • " + entity.getProperty("name") + ""); } resp.getWriter().println("
"); String cursor = results.getCursor().toWebSafeString(); // Assuming this servlet lives at '/people' resp.getWriter().println( "Next page"); } }

 

关于分页的另一篇:

Implementing Paging on Google App Engine Java (gae/j) and GWT — the query cursor way

Google app engine 设置Cron Jobs GAE设置定时任务(Java版)

Categories: Development Notes; Tagged with: ; @ April 20th, 2011 21:24

GAE的 Cron Job是通过配置文件实现的 – “Cron jobs are defined in cron.yaml (Python) or cron.xml (Java)”

Java版的cron.xml配置文件位于WEB-INFO目录下(位置同web.xml), 典型的一个:

<?xml version=”1.0″ encoding=”UTF-8″?>
<cronentries>
  <cron>
    <url>/GetIPLocation</url>
    <description>get the ip location by api every 2 minutes</description>
    <schedule>every 2 minutes</schedule>
  </cron>
</cronentries>

该任务每两分钟执行一次, GepIPLocation是一个Servlet.

时间格式举例:

every 12 hours
every 5 minutes from 10:00 to 14:00
2nd,third mon,wed,thu of march 17:00
every monday 09:00
1st monday of sep,oct,nov 17:00
every day 00:00

API地址: http://code.google.com/appengine/docs/java/config/cron.html (可能需要翻墙)

Amazon Cloud Drive – 基于S3的云存储网络硬盘, 所有用户均可免费享有5GB

Categories: Development Notes; Tagged with: ; @ April 11th, 2011 22:36

Amazon越来越给力, 年初推出免费小主机后, 基于S3的Cloud Drive竟然也有免费版可用.

The Amazon Cloud drive offers 5 GB of free online storage that you can access from any computer. If you need more storage space, paid plans are available for storage up to 1,000 GB.

我基本一直用box.net的免费版, 有权限控制, 版本控制, 协同工作等,  甚是强大, 最近被墙.

相比Box.net, Cloud Drive完全没有这么多分享合作的功能, 自己上传 自己下载, 自己用Cloud player在线听歌…

闲言碎语不多说, 上图:

image

Amazon Cloud Player:

image

Player在打开时会进行检查, 只允许米国用户使用. 打开后就可用其他网络进行播放, 速度很给力!

还可通过Amazon MP3 Uploader上传MP3,  该工具基于Adobe Air

免费版是面向所有用户开放的, 但收费服务仅对部分国家开放(见:FAQ), 价格方面: xGB就是$x每年, 如最高1000GB, $1000/年.

了解更多

Amazon EC2 Instance中使用EBS Volume – Using EBS Volume in EC2 Instance

Categories: Development Notes; Tagged with: ; @ August 17th, 2010 22:10

由于EC2的Instance关机后不会保存数据, 对于数据库一类需要存储的信息, 可储存在EBS (Elastic Block Store) Volume中. 再次创建/启动 Instance时重新挂载就可恢复原状(Instance关机有点类似于重新安装操作系统).

本文主要总结: Volume的Create/Attach/Format/Mount/UMount/Detach

image

(more…)

Older Posts



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.