AWS CLIのインストールと設定

AWS CLIのインストール

# rpm -ivh http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# yum --enablerepo=epel update epel-release
# yum search python-pip
# yum install python-pip
# pip install awscli

AWS CLIの設定

$ aws configure                                                                                    
AWS Access Key ID [********************]: <アクセスキーを入力しEnter>
AWS Secret Access Key [********************]: <シークレットアクセスキーを入力しEnter>
Default region name [ap-northeast-1]: <Enter>
Default output format [None]: <Enter>

設定内容の確認
~/.aws/config

[default]
aws_access_key_id = <アクセスキー>
aws_secret_key = <シークレットアクセスキー>
region = ap-northeast-1

Google App Engine(Java)のデプロイエラー

Googleからメールが来て、pleiades 3.7で久々にGoogle App Engineのデプロイを行ったら以下のエラーが出力された。

Preparing to deploy:
Created staging directory at: 'C:\Users\Chloe\AppData\Local\Temp\appcfg8759974391667459604.tmp'
Scanning for jsp files.
Compiling jsp files.
java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE.

同様の現象の遭遇している人は多いようで、
以下のページ参考し、JDKを入れて設定し直せば解決するらしい。
http://stackoverflow.com/questions/19168082/eclipse-appengine-java-lang-runtimeexception-cannot-get-the-system-java-compi


ただ、自分の場合、
最後のeclipse.iniに以下のようにパスを設定したが

C:\Program Files (x86)\Java\jdk1.7.0_51\bin\javaw.exe

以下のダイアログが出て起動せず

結局、pleiades内のパスに設定してたら起動でき、デプロイもできた。

D:\pleiades-java\java\7\bin\java.exe



※ちなみに、Googleから来たメールの内容は以下の通りです。

Updates to Cloud Platform Terms of Service

Dear Google App Engine customers,

You are receiving this notification because you are listed as an admin of the following app(s):


Our goal is to make it easier for Google Cloud Platform customers to find and understand Terms of Service, Deprecation Policy and Service Level Agreements, covering all current and future Cloud Platform products and services.

The Google Cloud Platform team would like to make sure you are aware of some changes we've recently made to the Google App Engine Terms of Service (ToS) as well as how and where we communicate Deprecation Policy and Service Level Agreement (SLA) information to our users.

We have written the Google Cloud Platform Terms of Service to include Google App Engine, thereby replacing the Google App Engine Terms of Service.

One important change for App Engine customers is that material changes that Google makes to the Terms of Service will become effective 30 days after posting the updates for App Engine customers to review (previously it was 90 days). A summary of changes can be reviewed at the following URL: https://developers.google.com/cloud/terms/terms-change-summary

We have also consolidated all Deprecation Policy information into a single URL that explicitly lists Cloud Platform products, versions, features, and functionality that are subject to the Deprecation Policy as well as any products, versions, features, or functionality that are excluded from the Deprecation Policy. The consolidated URL is: https://developers.google.com/cloud/terms/deprecation

Finally, we have updated our Service Level Agreements to clarify and unify them, include provisions for Cloud Platform Resellers, and modified our SLA Exclusions so that features and services designated as experimental, limited preview, or preview are excluded from the SLA unless otherwise set forth in the documentation for that feature or service. You can view the updated SLA at the following URL: https://developers.google.com/appengine/sla

These changes will apply to your account starting May 1, 2014. We hope they will make it easier for you to find and understand this important information.

Sincerely,

    • The Google Cloud Platform team
        • © 2014 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043

You have received this mandatory email service announcement to update you about important changes to Google Cloud Platform or your account.

RDS(MySQL)のバイナリログ保持期間設定

RDS(MySQL)ではパラメータexpire_logs_daysを設定できず、
デフォルトの状態だと5分程度でバイナリログが削除されてしまう。

RDSのバイナリログ保持期間設定はストアドで行うようになっている。
以下のストアドを実行すると24時間まで保存できるようになる。

mysql> call mysql.rds_set_configuration('binlog retention hours', 24);

参考ページ
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_LogAccess.Concepts.MySQL.html

 Selenium IDEで生成したテストケースでファイルをダウンロードする

Selenium IDERuby / RSpec / Webdriverのテストケースを生成し、rspecコマンドで実行しても、
ダウンロードダイアログが表示された状態でFireFoxが終了してしまい
ファイルがダウンロードされない。

ダウンロードダイアログが表示されないように、
セットアップ時にFireFoxのプロファイルを設定しておく。


※以下の記事を参考にさせていただきました。
Selenium 2.x Web Driverでファイルをダウンロードをする
プロフェッショナルプログラマー:Selenium with JUnit(その5 Download File)


テストケースのsetup内に以下のようにprofileの設定処理を追加。
(mimeタイプはダウンロードしたいファイルの種類に応じて適宜追加する)

selenium_download.rb

class Selenium3 < Test::Unit::TestCase

  def setup
    @ff_profile = Selenium::WebDriver::Firefox::Profile.new
    # ダウンロードするファイルの保存先フォルダが指定してあればそれを使う
    @ff_profile['browser.download.useDownloadDir'] = true
    # ダウンロードするファイルの保存先フォルダを指定
    # 0:デスクトップ
    #  1:ダウンロードフォルダ
    #  2:ダウンロードに指定された最後のフォルダ
    @ff_profile['browser.download.folderList'] = 2
    # ダウンロードダイアログを見せないようにする
    @ff_profile['browser.download.manager.showWhenStarting'] = false
    # ダウンロードフォルダ
    @ff_profile['browser.download.dir'] = '/home/footprint/'
    # 指定したmimeタイプは有無を言わさずダウンロードする
    @ff_profile['browser.helperApps.neverAsk.saveToDisk'] = 'text/plain, application/vnd.ms-excel, text/csv, application/zip, text/comma-separated-values, application/octet-stream'

    @driver = Selenium::WebDriver.for :firefox, :profile => @ff_profile
    @base_url = "http://d.hatena.ne.jp"
    @accept_next_alert = true
    @driver.manage.timeouts.implicit_wait = 30
    @verification_errors = []
  end

rspecコマンドで実行

$ rspec selenium_download.rb

TomcatでSSL

Apacheを介さずにTomcatで直接SSLを通信する方法

Apache+OpenSSL用に取得した証明書ファイルを、
PKCS#12に変換すれば、TomcatでもSSL通信が可能です。

  1. PKCS#12への変換

opensslコマンドで可能です。

$ openssl pkcs12 -export -inkey (ユーザ証明書の秘密鍵ファイル名) -in (ストリップ後のユーザ証明書ファイル名) -out (PKCS#12ファイル名) -certfile (CA証明書のファイル名)

コマンド例:

$ openssl pkcs12 -export -in cert2010.pem -inkey key2010.pem  -out keystore2010.p12 -name tomcat -CAfile sslcert2010.cer -caname root
Enter Export Password:xxxxxx
Verifying - Enter Export Password: xxxxxx
  1. server.xmlの編集

SSL通信を有効にします

<!-- Define a SSL HTTP/1.1 Connector on port 8443 -->
<Connector port="443" maxHttpHeaderSize="8192"
   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
   enableLookups="false" disableUploadTimeout="true"
   acceptCount="100" scheme="https" secure="true"
   clientAuth="false" sslProtocol="TLS"
   keystoreFile="/usr/local/ssl/keystore2010.p12"
   keystorePass="xxxxxx" keystoreType=”PKCS12” />

カーソル利用時のMemcache格納

カーソル取得のため、QueryResultListを利用している場合、
このクラスはSerializableを実装していないので、
Memcacheへそのまま格納できない。

なので、無理やりArrayListに変換に変換して対応した。
カーソルが取得できなくなるので、カーソルも別途格納。

// データベースからデータを取得
qrlst = service.prepare(qry).asQueryResultList(fetchOptions);

// ここまでの結果をカーソルにする
cursor = qrlst.getCursor();

// カーソルをBase64エンコード文字列に変換
page = cursor.toWebSafeString();

// QueryResultListからArrayListに変換
lst = new ArrayList<Entity>(qrlst);

// キャシュに保存
cache.put("Cursor:" + cacheKey, page);
cache.put("Page:" + cacheKey, lst);