Get raw master data source name.

@param dataSourceName data source name
@return raw master data source name
358019
public String getRawMasterDataSourceName(final String dataSourceName) {
        for (MasterSlaveRuleConfiguration each : shardingRuleConfig.getMasterSlaveRuleConfigs()) {
            if (each.getName().equals(dataSourceName)) {
                return each.getMasterDataSourceName();
            }
        }
        return dataSourceName;
    }
478413
public static Map<String, DataSourceConfiguration> getDataSourceConfigurationMap(final Map<String, DataSource> dataSourceMap) {
        Map<String, DataSourceConfiguration> result = new LinkedHashMap<>(dataSourceMap.size(), 1);
        for (Entry<String, DataSource> entry : dataSourceMap.entrySet()) {
            result.put(entry.getKey(), DataSourceConfiguration.getDataSourceConfiguration(entry.getValue()));
        }
        return result;
    }
383837
public boolean isXADatasource(String datasourceName) throws Exception {
        Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_DATASOURCES);
        String haystack = XA_DATA_SOURCE;
        return null != findNodeInList(addr, haystack, datasourceName);
    }
939207
public static SqlConfig getConfig(final String dataSourceName) {
		DataSourceConnectionSupplierImpl connectionSupplier = new DataSourceConnectionSupplierImpl(dataSourceName);
		return new DefaultSqlConfig(connectionSupplier, null);
	}
710536
private DataSource lookupDatasource(JDBCIdentitySource config) {
        DataSource ds;
        try {
            InitialContext ctx = new InitialContext();
            ds = lookupDS(ctx, config.getDatasourcePath());
            if (ds == null) {
                ds = lookupDS(ctx, "java:comp/env/" + config.getDatasourcePath()); //$NON-NLS-1$
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        if (ds == null) {
            throw new RuntimeException("Datasource not found: " + config.getDatasourcePath()); //$NON-NLS-1$
        }
        return ds;
    }
982918
public static String getDataSourceIdentifier(WSJdbcWrapper jdbcWrapper) {
        DSConfig config = jdbcWrapper.dsConfig.get();
        return config.jndiName == null ? config.id : config.jndiName;
    }
295938
private static DataSource getNewDataSource(final String dataSourceName) {
		try {
			Context context = new InitialContext();
			return (DataSource) context.lookup(dataSourceName);
		} catch (NamingException ex) {
			throw new UroborosqlRuntimeException("DataSource[" + dataSourceName + "] can not be acquired.", ex);
		}
	}
1849
public Optional<String> findActualDefaultDataSourceName() {
        String defaultDataSourceName = shardingDataSourceNames.getDefaultDataSourceName();
        if (Strings.isNullOrEmpty(defaultDataSourceName)) {
            return Optional.absent();
        }
        Optional<String> masterDefaultDataSourceName = findMasterDataSourceName(defaultDataSourceName);
        return masterDefaultDataSourceName.isPresent() ? masterDefaultDataSourceName : Optional.of(defaultDataSourceName);
    }
91053
public final Connection getConnection(final String dataSourceName) throws SQLException {
        return getConnections(ConnectionMode.MEMORY_STRICTLY, dataSourceName, 1).get(0);
    }
1090171
public String getActualDataSourceName(final String actualTableName) {
        Optional<TableRule> tableRule = findTableRuleByActualTable(actualTableName);
        if (tableRule.isPresent()) {
            return tableRule.get().getActualDatasourceNames().iterator().next();
        }
        if (!Strings.isNullOrEmpty(shardingDataSourceNames.getDefaultDataSourceName())) {
            return shardingDataSourceNames.getDefaultDataSourceName();
        }
        throw new ShardingException("Cannot found actual data source name of '%s' in sharding rule.", actualTableName);
    }
411564
public Collection<String> getActualTableNames(final String targetDataSource) {
        Collection<String> result = new LinkedHashSet<>(actualDataNodes.size());
        for (DataNode each : actualDataNodes) {
            if (targetDataSource.equals(each.getDataSourceName())) {
                result.add(each.getTableName());
            }
        }
        return result;
    }
1179187
protected DataSource createDataSource() {
    Driver driver = newInstance(Driver.class, driverClassName, "driverClassName");
    return globalFactory.createDataSource(driver, user, password, url);
  }
1135501
public <T extends DataSource> T getDataSource() {
        T dataSource = jndiLookup(PropertyKey.DATA_SOURCE_JNDI_NAME);
        if (dataSource != null) {
            return dataSource;
        }
        dataSource = instantiateClass(PropertyKey.DATA_SOURCE_CLASS_NAME);
        if (dataSource == null) {
            throw new IllegalArgumentException("The " + PropertyKey.DATA_SOURCE_CLASS_NAME + " property is mandatory!");
        }
        return applyDataSourceProperties(dataSource);
    }
641482
public static Database getDatabase(DataSource dataSource) {
		if (dataSource == null) {
			return Database.DEFAULT;
		}
		try {
			String url = JdbcUtils.extractDatabaseMetaData(dataSource, "getURL");
			DatabaseDriver driver = DatabaseDriver.fromJdbcUrl(url);
			Database database = LOOKUP.get(driver);
			if (database != null) {
				return database;
			}
		}
		catch (MetaDataAccessException ex) {
			logger.warn("Unable to determine jdbc url from datasource", ex);
		}
		return Database.DEFAULT;
	}
577201
public DataSource getDataSource() throws ConfigurationException {
        if (mDataSource == null) {
            if (mDriverClassName != null && mURL != null) {
                try {
                    mDataSource = new SimpleDataSource
                        (mDriverClassName, mURL, mUsername, mPassword);
                } catch (SQLException e) {
                    Throwable cause = e.getCause();
                    if (cause == null) {
                        cause = e;
                    }
                    throw new ConfigurationException(cause);
                }
            }
        }

        DataSource ds = mDataSource;
        if (getDataSourceLogging() && !(ds instanceof LoggingDataSource)) {
            ds = LoggingDataSource.create(ds);
        }

        return ds;
    }
612298
public Connector getConnectorForSourceName( String sourceName ) {
        assert sourceName != null;
        return this.snapshot.get().getConnectorWithSourceKey(NodeKey.keyForSourceName(sourceName));
    }
437813
private static String getSourceNameParameter(WorkspaceEntry wsEntry) throws DBCleanException
   {
      try
      {
         return wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
      }
      catch (RepositoryConfigurationException e)
      {
         throw new DBCleanException(e);
      }
   }