@@ -3,6 +3,7 @@ package com.ibm.ibmos2spark
3
3
import scala .collection .mutable .HashMap
4
4
import org .apache .spark .SparkContext
5
5
6
+ val DEFAULT_SERVICE_NAME = " service"
6
7
7
8
object urlbuilder {
8
9
def swifturl2d (name : String , container_name : String , object_name : String ): String = {
@@ -155,7 +156,7 @@ class bluemix(sc: SparkContext, name: String, creds: HashMap[String, String],
155
156
Warning: creating a new instance of this class would overwrite the existing
156
157
spark hadoop configs if set before if used with the same spark context instance.
157
158
*/
158
- class CloudObjectStorage (sc : SparkContext , credentials : HashMap [String , String ], cosId : String = " " ) {
159
+ class CloudObjectStorage (sc : SparkContext , credentials : HashMap [String , String ], configurationName : String = " " ) {
159
160
160
161
// check if all credentials are available
161
162
val requiredValues = Array (" endPoint" , " accessKey" , " secretKey" )
@@ -167,16 +168,22 @@ class CloudObjectStorage(sc: SparkContext, credentials: HashMap[String, String],
167
168
168
169
// set config
169
170
val hadoopConf = sc.hadoopConfiguration
170
- val prefix = " fs.s3d.service"
171
+ val prefix = " fs.cos." + getConfigurationName()
172
+
171
173
hadoopConf.set(prefix + " .endpoint" , credentials(" endPoint" ))
172
174
hadoopConf.set(prefix + " .access.key" , credentials(" accessKey" ))
173
175
hadoopConf.set(prefix + " .secret.key" , credentials(" secretKey" ))
174
176
175
- def getCosId () : String = {
176
- return cosId
177
+ private def getConfigurationName () : String = {
178
+ if (configurationName != " " ) {
179
+ return configurationName
180
+ } else {
181
+ return DEFAULT_SERVICE_NAME
182
+ }
177
183
}
178
184
179
185
def url (bucketName : String , objectName : String ) : String = {
180
- return " s3d://" + bucketName + " .service/" + objectName
186
+ var serviceName = getConfigurationName()
187
+ return " cos://" + bucketName + " ." + serviceName + " /" + objectName
181
188
}
182
189
}
0 commit comments