Sparkプログラミング ~ IntelliJ IDEAのインストール ~

Spark事始め
#事始めではないが、Learning Spark の日本語訳も発売されたことだし、ちょいちょいSparkネタを残しておこう。
#いままでやったことはそのうち整理していく予定

ScalaでSparkプログラミングするにはIntelliJがおすすめようなので気分転換がてらしばらく使って見ることにする。

の前に、brewでいろいろ探してたら、なんかエラーでたのでその備忘メモ

Error: GitHub API rate limit exceeded for 114.170.237.217. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)

Try again in 39 minutes 13 seconds, or create an personal access token:

  https://github.com/settings/tokens

and then set the token as: HOMEBREW_GITHUB_API_TOKEN

言われた通り、githubにいってtokenを生成して、~/.bash_profileに追加

export HOMEBREW_GITHUB_API_TOKEN=ed4aexxxxxxxxxxxxxxxxxxxxxxx

$ exec -l $SHELL

caskroomのversionsがあったので一応tapしとく
https://github.com/caskroom/homebrew-versions

$ brew tap caskroom/versions

インストール

$ brew cask search intellij
==> Partial matches
intellij-idea			   intellij-idea-ce		      intellij-idea-ce-eap		 intellij-idea-eap		    intellij-idea13
intellij-idea-bundled-jdk	   intellij-idea-ce-bundled-jdk	      intellij-idea-ce13		 intellij-idea12

$ brew cask info intellij-idea-ce
intellij-idea-ce: 14.1.4
IntelliJ IDEA Community Edition
https://www.jetbrains.com/idea/
Not installed
https://github.com/caskroom/homebrew-cask/blob/master/Casks/intellij-idea-ce.rb
==> Contents
  IntelliJ IDEA 14 CE.app (app)

$ brew cask install intellij-idea-ce
==> Downloading https://download.jetbrains.com/idea/ideaIC-14.1.4.dmg
######################################################################## 100.0%
==> Symlinking App 'IntelliJ IDEA 14 CE.app' to '/Users/hiroki/Applications/IntelliJ IDEA 14 CE.app'
🍺  intellij-idea-ce staged at '/opt/homebrew-cask/Caskroom/intellij-idea-ce/14.1.4' (1536 files, 366M)

~/ApplicationsにあるIntelliJ IDEA 14 CE.appを起動

f:id:hiropppee:20150819231529p:plain

なんかでて、立ち上がらない、言われたとおり Java for OS X 2014-001 をインストール、今のとこjava6で動かすのが無難らしい

IDE doesn't start after updating to Mac OS Yosemite or Mavericks – JetBrains Support

とりあえず、Sparkのソースをインポートしてみる

$ git clone https://github.com/apache/spark.git
$ cd spark
$ git checkout -b 1.4.1 refs/tags/v1.4.1

IntelliJを起動、Scalaプラグインを入れる。

  1. Import Project -> チェックアウトしたSparkを選択して次
  2. Import project from external model で [Maven] を選択して次
  3. Import Maven projects automatically にチェックを追加して次
  4. Select profilesは、勉強用のSparkコンテナに合わせて [scala-2.10] [yarn] [sbt] [hadoop-2.6] を選択して次
  5. Select Maven projects to import はそのまま次
  6. JDKを追加、インストール済のjdk1.8.0_40.jdkにしとく、次
  7. Project name、Project file locationはそのまま、終了

f:id:hiropppee:20150820004839p:plain