Skip to content

Commit 0f3ff58

Browse files
committed
Add multiple config support and use cos scheme
1 parent f857cca commit 0f3ff58

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

r/sparkr/R/osconfig.R

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ bluemix <- setRefClass("bluemix",
136136
CloudObjectStorage <- setRefClass("CloudObjectStorage",
137137
fields=list(configName="character"),
138138
methods=list(
139-
initialize = function(..., sparkContext, credentials, configurationName){
139+
initialize = function(..., sparkContext, credentials, configurationName="") {
140140

141141

142142
if (is.null(credentials["endpoint"][[1]])) {
@@ -151,20 +151,27 @@ CloudObjectStorage <- setRefClass("CloudObjectStorage",
151151
stop("Attribute secretKey in credentials is missing!")
152152
}
153153

154+
# bind config name
154155
.self$configName = configurationName
155-
prefix = "fs.s3d.service"
156+
157+
# set prefix for hadoop config
158+
prefix = paste("fs.cos", getConfigName(), sep='.')
156159
hConf = SparkR:::callJMethod(sparkContext, "hadoopConfiguration")
157160
SparkR:::callJMethod(hConf, "set", paste(prefix, "endpoint", sep='.'), credentials['endpoint'][[1]])
158161
SparkR:::callJMethod(hConf, "set", paste(prefix, "access.key", sep='.'), credentials['accessKey'][[1]])
159162
SparkR:::callJMethod(hConf, "set", paste(prefix, "secret.key", sep='.'), credentials['secretKey'][[1]])
160163
},
161164

162165
getConfigName = function() {
163-
return (.self$configName)
166+
if (.self$configName != "") {
167+
return (.self$configName)
168+
}
169+
return ("service")
164170
},
165171

166-
url = function(bucketName, objectName){
167-
return(paste("s3d://", bucketName, ".service/", objectName, sep = ""))
172+
url = function(bucketName, objectName) {
173+
serviceName = getConfigName()
174+
return (paste("cos://", bucketName, ".", serviceName, "/", objectName, sep = ""))
168175
}
169176
)
170177
)

0 commit comments

Comments
 (0)