@@ -149,9 +149,13 @@ class bluemix(sc: SparkContext, name: String, creds: HashMap[String, String],
149
149
multiple configurations to different Object Storage accounts.
150
150
if a configuration name is not passed the default one will be used "service".
151
151
*/
152
- class CloudObjectStorage (sc : SparkContext , credentials : HashMap [String , String ], configurationName : String = " " ) {
152
+ class CloudObjectStorage (sc : SparkContext , credentials : HashMap [String , String ],
153
+ configurationName : String = " " , cos_type= " softlayer_cos" ,
154
+ auth_method= " api_key" ) {
155
+
156
+ // check for valid credentials
157
+ _validate_credentials(credentials, cos_type, auth_method)
153
158
154
- // check if all credentials are available
155
159
val requiredValues = Array (" endPoint" , " accessKey" , " secretKey" )
156
160
for ( key <- requiredValues ) {
157
161
if (! credentials.contains(key)) {
@@ -161,22 +165,26 @@ class CloudObjectStorage(sc: SparkContext, credentials: HashMap[String, String],
161
165
162
166
// set config
163
167
val hadoopConf = sc.hadoopConfiguration
164
- val prefix = " fs.cos." + getConfigurationName ()
168
+ val prefix = " fs.cos." + _getConfigurationName ()
165
169
166
170
hadoopConf.set(prefix + " .endpoint" , credentials(" endPoint" ))
167
171
hadoopConf.set(prefix + " .access.key" , credentials(" accessKey" ))
168
172
hadoopConf.set(prefix + " .secret.key" , credentials(" secretKey" ))
169
173
170
- private def getConfigurationName () : String = {
174
+ private def _getConfigurationName () : String = {
171
175
if (configurationName != " " ) {
172
176
return configurationName
173
177
} else {
174
178
return globalVariables.DEFAULT_SERVICE_NAME
175
179
}
176
180
}
177
181
182
+ private def _validate_credentials () {
183
+
184
+ }
185
+
178
186
def url (bucketName : String , objectName : String ) : String = {
179
- var serviceName = getConfigurationName ()
187
+ var serviceName = _getConfigurationName ()
180
188
return " cos://" + bucketName + " ." + serviceName + " /" + objectName
181
189
}
182
190
}
0 commit comments