Skip to content

Commit 3557a4f

Browse files
committed
set up hadoop config
1 parent 917cfd3 commit 3557a4f

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

r/sparkr/R/osconfig.R

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,33 @@ CloudObjectStorage <- setRefClass("CloudObjectStorage",
140140
# bind config name
141141
.self$configName = configurationName
142142

143-
# set prefix for hadoop config
143+
# set up hadoop config
144144
prefix = paste("fs.cos", getConfigName(), sep='.')
145145
hConf = SparkR:::callJMethod(sparkContext, "hadoopConfiguration")
146+
146147
SparkR:::callJMethod(hConf, "set", paste(prefix, "endpoint", sep='.'), credentials['endpoint'][[1]])
147-
SparkR:::callJMethod(hConf, "set", paste(prefix, "access.key", sep='.'), credentials['accessKey'][[1]])
148-
SparkR:::callJMethod(hConf, "set", paste(prefix, "secret.key", sep='.'), credentials['secretKey'][[1]])
148+
149+
if (cosType == "softlayer_cos") {
150+
# softlayer COS case
151+
SparkR:::callJMethod(hConf, "set", paste(prefix, "access.key", sep='.'), credentials['accessKey'][[1]])
152+
SparkR:::callJMethod(hConf, "set", paste(prefix, "secret.key", sep='.'), credentials['secretKey'][[1]])
153+
} else if (cosType == "bluemix_cos") {
154+
# bluemix COS case
155+
SparkR:::callJMethod(hConf, "set", paste(prefix, "iam.service.id", sep='.'), credentials['serviceId'][[1]])
156+
if (authMethod == "api_key") {
157+
SparkR:::callJMethod(hConf, "set", paste(prefix, "iam.api.key", sep='.'), credentials['apiKey'][[1]])
158+
} else if (authMethod == "iam_token") {
159+
SparkR:::callJMethod(hConf, "set", paste(prefix, "iam.token", sep='.'), credentials['iamToken'][[1]])
160+
}
161+
162+
if ("iamServiceEndpoint" %in% credentials {
163+
SparkR:::callJMethod(hConf, "set", paste(prefix, "iam.endpoint", sep='.'), credentials['iamServiceEndpoint'][[1]])
164+
}
165+
166+
if ("v2SignerType" %in% credentials) {
167+
SparkR:::callJMethod(hConf, "set", paste(prefix, "v2.signer.type", sep='.'), credentials['v2SignerType'][[1]])
168+
}
169+
}
149170
},
150171

151172
getConfigName = function() {
@@ -164,7 +185,6 @@ CloudObjectStorage <- setRefClass("CloudObjectStorage",
164185
stop("Invalid input: missing required input [" + key + "]!")
165186
}
166187
}
167-
168188
},
169189

170190
get_required_key_array = function (cosType, authMethod) {

0 commit comments

Comments
 (0)