@@ -126,17 +126,12 @@ bluemix <- setRefClass("bluemix",
126
126
# '
127
127
# ' configurationName: string identifies the configurations that has been
128
128
# ' set.
129
- # ' When using this from a IBM Spark service instance that
130
- # ' is configured to connect to particular Bluemix object store
131
- # ' instances, the values for these credentials can be obtained
132
- # ' by clicking on the 'insert to code' link just below a data
133
- # ' source.
134
129
# ' @export CloudObjectStorage
135
130
# ' @exportClass CloudObjectStorage
136
131
CloudObjectStorage <- setRefClass(" CloudObjectStorage" ,
137
132
fields = list (configName = " character" ),
138
133
methods = list (
139
- initialize = function (... , sparkContext , credentials , configurationName ) {
134
+ initialize = function (... , sparkContext , credentials , configurationName = " " ) {
140
135
141
136
142
137
if (is.null(credentials [" endpoint" ][[1 ]])) {
@@ -151,20 +146,27 @@ CloudObjectStorage <- setRefClass("CloudObjectStorage",
151
146
stop(" Attribute secretKey in credentials is missing!" )
152
147
}
153
148
149
+ # bind config name
154
150
.self $ configName = configurationName
155
- prefix = " fs.s3d.service"
151
+
152
+ # set prefix for hadoop config
153
+ prefix = paste(" fs.cos" , getConfigName(), sep = ' .' )
156
154
hConf = SparkR ::: callJMethod(sparkContext , " hadoopConfiguration" )
157
155
SparkR ::: callJMethod(hConf , " set" , paste(prefix , " endpoint" , sep = ' .' ), credentials [' endpoint' ][[1 ]])
158
156
SparkR ::: callJMethod(hConf , " set" , paste(prefix , " access.key" , sep = ' .' ), credentials [' accessKey' ][[1 ]])
159
157
SparkR ::: callJMethod(hConf , " set" , paste(prefix , " secret.key" , sep = ' .' ), credentials [' secretKey' ][[1 ]])
160
158
},
161
159
162
160
getConfigName = function () {
163
- return (.self $ configName )
161
+ if (.self $ configName != " " ) {
162
+ return (.self $ configName )
163
+ }
164
+ return (" service" )
164
165
},
165
166
166
- url = function (bucketName , objectName ){
167
- return (paste(" s3d://" , bucketName , " .service/" , objectName , sep = " " ))
167
+ url = function (bucketName , objectName ) {
168
+ serviceName = getConfigName()
169
+ return (paste(" cos://" , bucketName , " ." , serviceName , " /" , objectName , sep = " " ))
168
170
}
169
171
)
170
172
)
0 commit comments