Skip to content
This repository has been archived by the owner on Oct 31, 2019. It is now read-only.

Commit

Permalink
Update tutorial.R
Browse files Browse the repository at this point in the history
Fix to Hive and Spark functions
  • Loading branch information
Alanwe committed Jun 14, 2017
1 parent 2dd1cd8 commit 74906b4
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 593 deletions.
4 changes: 2 additions & 2 deletions R/AzureHDI.R
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ azureCreateHDI <- function(azureActiveContext, resourceGroup, location,
#' @family HDInsight functions
#' @export
azureResizeHDI <- function(azureActiveContext, clustername,
role = c("worker", "head", "edge"),
role = c("workernode", "headnode", "edgenode"),
size = 2, mode = c("Sync", "Async"), subscriptionID,
resourceGroup, verbose = FALSE) {

Expand All @@ -267,7 +267,7 @@ azureResizeHDI <- function(azureActiveContext, clustername,

assert_that(is_resource_group(resourceGroup))
assert_that(is_clustername(clustername))
assert_that(is.integer(size))
assert_that(is.integer(as.integer(size)))

role <- match.arg(role)
mode <- match.arg(mode)
Expand Down
18 changes: 11 additions & 7 deletions R/AzureHive.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@ azureHiveStatus <- function(azureActiveContext, clustername, hdiAdmin,
if (!length(HP)) {
stop("Error: No Valid hdiPassword provided")
}

verbosity <- set_verbosity(verbose)

azureActiveContext$hdiAdmin <- HA
azureActiveContext$hdiPassword <- HP
azureActiveContext$clustername <- CN

cat(HA)
cat(HP)

uri <- paste0("https://", CN, ".azurehdinsight.net/templeton/v1/status")

r <- GET(URL, add_headers(.headers = c(`Content-type` = "application/json")),
cat(uri)
r <- GET(uri, add_headers(.headers = c(`Content-type` = "application/json")),
authenticate(HA, HP), verbosity)
if (status_code(r) != 200 && status_code(r) != 201) {
stop(paste0("Error: Return code(", status_code(r), ")"))
Expand Down Expand Up @@ -130,9 +134,9 @@ azureHiveSQL <- function(azureActiveContext, CMD, clustername, hdiAdmin,
if (DUR < 5)
DUR <- DUR + 1
if (df$status$state == "PREP")
message("P")
message("P",appendLF = FALSE)
if (df$status$state == "RUNNING")
message("R")
message("R",appendLF = FALSE)
# print(df$status$state)

r <- GET(URL, add_headers(.headers = c(`Content-type` = "application/json")),
Expand All @@ -142,9 +146,9 @@ azureHiveSQL <- function(azureActiveContext, CMD, clustername, hdiAdmin,
df <- fromJSON(rl)
}
if (df$status$state == "SUCCEEDED")
message("S")
message("S",appendLF = FALSE)
if (df$status$state == "FAILED")
message("F")
message("F",appendLF = FALSE)

STATE <- df$status$state
message("Finished Running statement: ", Sys.time())
Expand Down
12 changes: 8 additions & 4 deletions R/AzureSpark.R
Original file line number Diff line number Diff line change
Expand Up @@ -276,21 +276,25 @@ azureSparkCMD <- function(azureActiveContext, CMD, clustername, hdiAdmin,
sep = "")
# print(URL)
message(paste("CMD Running: ", Sys.time()))
message("Running(R), Completed(C)")
message("Running(R) Waiting(W) Completed(C)")

while (df$state == "running") {
while (df$state == "running" || df$state == "waiting") {
Sys.sleep(DUR)
if (DUR < 5)
DUR <- DUR + 1
message("R")
if (df$state == "running")
message("R",appendLF = FALSE)
if (df$state == "waiting")
message("W",appendLF = FALSE)

r <- GET(URL, add_headers(.headers = c(`Content-type` = "application/json")),
authenticate(HA, HP))
rl <- content(r, "text", encoding = "UTF-8")
rh <- headers(r)
df <- fromJSON(rl)

}
message("C")
message("C",appendLF = FALSE)
message("Finished Running statement: ", Sys.time())
RET <- df$output$data[1]
# rownames(RET) <- 'Return Value'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

To get started with this package, see the vignettes:

* [Tutorial](http://htmlpreview.github.io/?https://github.com/Microsoft/AzureSMR/blob/master/vignettes/tutorial.html)
* [Getting Authenticated](http://htmlpreview.github.io/?https://github.com/Microsoft/AzureSMR/blob/master/vignettes/Authentication.html)
* [Tutorial](http://htmlpreview.github.io/?https://github.com/Microsoft/AzureSMR/blob/master/inst/doc/tutorial.html)
* [Getting Authenticated](http://htmlpreview.github.io/?https://github.com/Microsoft/AzureSMR/blob/master/inst/doc/Authentication.html)

To access the package help, just type `?AzureSMR` into your code editor.

Expand Down
5 changes: 5 additions & 0 deletions inst/examples/example_azureDeleteHDI.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
\dontrun{
library(AzureSMR)

azureDeleteHDI(asc, clustername = "azuresmrclustername")
}
4 changes: 0 additions & 4 deletions vignettes/Authentication.R

This file was deleted.

5 changes: 2 additions & 3 deletions vignettes/Authentication.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ To apply access control azToken Resource Group

16. Identify the resource group you will associate with this application.

17. Choose the Users menu item from the Resource scope.
17. Choose the Access Control(IAM) menu item from the Resource scope.

18. In the resulting scope click the `+ Add` button.

Expand All @@ -62,7 +62,7 @@ Alternatively you can access control azToken Subscription Level

16. Identify the Subscription you will associate with this application.

17. Choose the Users(access) menu item.
17. Choose the Access Control(IAM) menu item.

18. In the resulting scope click the + Add button.

Expand All @@ -71,7 +71,6 @@ Alternatively you can access control azToken Subscription Level
20. Select the resulting list item for that App then click Select in that scope then OK in the "Add access" scope. The user will be added to the list.



That is all. You can test this by trying:

```{r, eval = FALSE}
Expand Down
136 changes: 0 additions & 136 deletions vignettes/Authentication.html

This file was deleted.

Loading

0 comments on commit 74906b4

Please sign in to comment.