datahub/wherehows-api/app/dao/MySQLDataSource.java
Mars Lan 5f5c0937d1 Rename web, backend-service (#490)
* Rename web to wherehows-api and update README.

* Rename backend-service to wherehows-backend

* Rename metadata-etl to wherehows-etl

* Rename hadoop-dataset-extractor-standalone to wherehows-hadoop
2017-07-10 13:42:56 -07:00

62 lines
2.7 KiB
Java

/**
* Copyright 2015 LinkedIn Corp. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
package dao;
import org.apache.commons.lang3.StringUtils;
import play.Play;
public class MySQLDataSource extends DataSource
{
public static String DatabaseType = "mysql";
public static String MYSQL_DRIVER_CLASS = "com.mysql.jdbc.Driver";
public static String DATABASE_WHEREHOWS_OPENSOURCE = "wherehows_opensource_mysql";
public static String DATABASE_WHEREHOWS_OPENSOURCE_USER_NAME_KEY = "database.opensource.username";
public static String DATABASE_WHEREHOWS_OPENSOURCE_USER_PASSWORD_KEY = "database.opensource.password";
public static String DATABASE_WHEREHOWS_OPENSOURCE_URL_KEY = "database.opensource.url";
public static String DATABASE_WHEREHOWS_DB = "wherehows_mysql";
public static String DATABASE_WHEREHOWS_DB_USER_NAME_KEY = "database.wherehows.username";
public static String DATABASE_WHEREHOWS_DB_USER_PASSWORD_KEY = "database.wherehows.password";
public static String DATABASE_WHEREHOWS_DB_URL_KEY = "database.wherehows.url";
@Override
public String getType()
{
return DatabaseType;
}
public MySQLDataSource(String identifier)
{
setDriverClass(MYSQL_DRIVER_CLASS);
if (StringUtils.isNotBlank(identifier) && identifier.equalsIgnoreCase(DATABASE_WHEREHOWS_OPENSOURCE))
{
setUsername(Play.application().configuration().getString(DATABASE_WHEREHOWS_OPENSOURCE_USER_NAME_KEY));
setPassword(Play.application().configuration().getString(DATABASE_WHEREHOWS_OPENSOURCE_USER_PASSWORD_KEY));
setJdbcUrl(Play.application().configuration().getString(DATABASE_WHEREHOWS_OPENSOURCE_URL_KEY));
}
else if (StringUtils.isNotBlank(identifier) && identifier.equalsIgnoreCase(DATABASE_WHEREHOWS_DB))
{
setUsername(Play.application().configuration().getString(DATABASE_WHEREHOWS_DB_USER_NAME_KEY));
setPassword(Play.application().configuration().getString(DATABASE_WHEREHOWS_DB_USER_PASSWORD_KEY));
setJdbcUrl(Play.application().configuration().getString(DATABASE_WHEREHOWS_DB_URL_KEY));
}
setIdleConnectionTestPeriodInMinutes(1);
setIdleMaxAgeInMinutes(1);
setMaxConnectionsPerPartition(10);
setMinConnectionsPerPartition(5);
setPartitionCount(3);
setAcquireIncrement(5);
setStatementsCacheSize(100);
}
}