Skip to content

Commit 0792d63

Browse files
committed
extend params for COS class and add validation function
1 parent 3f7b519 commit 0792d63

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

scala/src/main/scala/Osconfig.scala

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,13 @@ class bluemix(sc: SparkContext, name: String, creds: HashMap[String, String],
149149
multiple configurations to different Object Storage accounts.
150150
if a configuration name is not passed the default one will be used "service".
151151
*/
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)
153158

154-
// check if all credentials are available
155159
val requiredValues = Array("endPoint", "accessKey", "secretKey")
156160
for ( key <- requiredValues ) {
157161
if (!credentials.contains(key)) {
@@ -161,22 +165,26 @@ class CloudObjectStorage(sc: SparkContext, credentials: HashMap[String, String],
161165

162166
// set config
163167
val hadoopConf = sc.hadoopConfiguration
164-
val prefix = "fs.cos." + getConfigurationName()
168+
val prefix = "fs.cos." + _getConfigurationName()
165169

166170
hadoopConf.set(prefix + ".endpoint", credentials("endPoint"))
167171
hadoopConf.set(prefix + ".access.key", credentials("accessKey"))
168172
hadoopConf.set(prefix + ".secret.key", credentials("secretKey"))
169173

170-
private def getConfigurationName() : String = {
174+
private def _getConfigurationName() : String = {
171175
if (configurationName != "") {
172176
return configurationName
173177
} else {
174178
return globalVariables.DEFAULT_SERVICE_NAME
175179
}
176180
}
177181

182+
private def _validate_credentials() {
183+
184+
}
185+
178186
def url(bucketName: String, objectName: String) : String = {
179-
var serviceName = getConfigurationName()
187+
var serviceName = _getConfigurationName()
180188
return "cos://" + bucketName + "." + serviceName + "/" + objectName
181189
}
182190
}

0 commit comments

Comments
 (0)