Skip to content

Commit

Permalink
Merge pull request #2 from apache/dev
Browse files Browse the repository at this point in the history
local merge
  • Loading branch information
wgy8283335 authored Jun 19, 2019
2 parents 16d0af8 + ba1ed1d commit 21db13d
Show file tree
Hide file tree
Showing 613 changed files with 6,674 additions and 4,317 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ about: Something isn't working as expected

Before report a bug, make sure you have:

- Searched open and closed [GitHub issues](https://github.com/sharding-sphere/sharding-sphere/issues).
- Read documentation: [ShardingSphere Doc](http://shardingsphere.io/document/current/en/overview/).
- Searched open and closed [GitHub issues](https://github.com/apache/incubator-shardingsphere-example/issues).
- Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).

Please pay attention on issues you submitted, because we maybe need more details.
If no response **more than 7 days** and we cannot reproduce it on current information, we will **close it**.
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ about: Usage question that isn't answered in docs or discussion
Before asking a question, make sure you have:

- Googled your question.
- Searched open and closed [GitHub issues](https://github.com/sharding-sphere/sharding-sphere/issues).
- Read documentation: [ShardingSphere Doc](http://shardingsphere.io/document/current/en/overview/).
- Searched open and closed [GitHub issues](https://github.com/apache/incubator-shardingsphere-example/issues).
- Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).

Please pay attention on issues you submitted, because we maybe need more details.
If no response **more than 7 days** and we cannot reproduce it on current information, we will **close it**.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ cache:

language: java
jdk:
- oraclejdk8
# - oraclejdk8
# - oraclejdk7
# - openjdk7
- openjdk8

before_script:
- echo "MAVEN_OPTS='-Xmx1024m -XX:MaxPermSize=256m'" > ~/.mavenrc
script:
- mvn clean install cobertura:cobertura coveralls:report -DrepoToken="${COVERALLS_REPO_TOKEN}" -Dmaven.javadoc.skip=true

install: travis_wait 30 mvn install
install: travis_wait 30 mvn install --quiet
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public final class TableRuleConfiguration {

private KeyGeneratorConfiguration keyGeneratorConfig;

private String logicIndex;

public TableRuleConfiguration(final String logicTable) {
this(logicTable, null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.shardingsphere.spi;

/**
* Database type aware SPI.
*
* @author zhangliang
*/
public interface DatabaseTypeAwareSPI {

/**
* Get database type.
*
* <p>
* The value of database type must registered by SPI for {@code org.apache.shardingsphere.spi.database.DatabaseType}.
* </p>
*
* @return database type
*/
String getDatabaseType();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.shardingsphere.spi.database;

/**
* Branch database type.
*
* @author zhangliang
*/
public interface BranchDatabaseType extends DatabaseType {

/**
* Get trunk database type.
*
* @return trunk database type
*/
DatabaseType getTrunkDatabaseType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.core.metadata.datasource;
package org.apache.shardingsphere.spi.database;

/**
* Data source meta data.
Expand Down Expand Up @@ -45,12 +45,4 @@ public interface DataSourceMetaData {
* @return schema name
*/
String getSchemaName();

/**
* Judge whether two of data sources are in the same database instance.
*
* @param dataSourceMetaData data source meta data
* @return data sources are in the same database instance or not
*/
boolean isInSameDatabaseInstance(DataSourceMetaData dataSourceMetaData);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.shardingsphere.spi.database;

import java.util.Collection;

/**
* Database type.
*
* @author zhangliang
*/
public interface DatabaseType {

/**
* Get database name.
*
* @return database name
*/
String getName();

/**
* Get alias of JDBC URL prefixes.
*
* @return Alias of JDBC URL prefixes
*/
Collection<String> getJdbcUrlPrefixAlias();

/**
* Get data source meta data.
*
* @param url data source URL
* @return data source meta data
*/
DataSourceMetaData getDataSourceMetaData(String url);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.shardingsphere.spi.database;

/**
* Memorized data source meta data.
*
* @author zhangliang
*/
public interface MemorizedDataSourceMetaData extends DataSourceMetaData {
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.core.exception;
package org.apache.shardingsphere.core.config;

/**
* Sharding rule exception.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.shardingsphere.core.database;

import org.apache.shardingsphere.spi.database.BranchDatabaseType;
import org.apache.shardingsphere.spi.database.DatabaseType;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.ServiceLoader;

/**
* Database types.
*
* @author zhangliang
*/
public final class DatabaseTypes {

private static final Map<String, DatabaseType> DATABASE_TYPES = new HashMap<>();

static {
for (DatabaseType each : ServiceLoader.load(DatabaseType.class)) {
DATABASE_TYPES.put(each.getName(), each);
}
}

/**
* Get database types.
*
* @return database types
*/
public static Collection<DatabaseType> getDatabaseTypes() {
return DATABASE_TYPES.values();
}

/**
* Get actual database type.
*
* @param name database name
* @return actual database type
*/
public static DatabaseType getActualDatabaseType(final String name) {
if (!DATABASE_TYPES.containsKey(name)) {
throw new UnsupportedOperationException(String.format("Unsupported database: '%s'", name));
}
return DATABASE_TYPES.get(name);
}

/**
* Get trunk database type.
*
* @param name database name
* @return trunk database type
*/
public static DatabaseType getTrunkDatabaseType(final String name) {
return DATABASE_TYPES.get(name) instanceof BranchDatabaseType ? ((BranchDatabaseType) DATABASE_TYPES.get(name)).getTrunkDatabaseType() : getActualDatabaseType(name);
}

/**
* Get database type by URL.
*
* @param url database URL
* @return database type
*/
public static DatabaseType getDatabaseTypeByURL(final String url) {
for (DatabaseType each : DATABASE_TYPES.values()) {
if (matchStandardURL(url, each) || matchURLAlias(url, each)) {
return each;
}
}
throw new UnsupportedOperationException(String.format("Unsupported database from url: '%s'", url));
}

private static boolean matchStandardURL(final String url, final DatabaseType databaseType) {
return url.startsWith(String.format("jdbc:%s:", databaseType.getName().toLowerCase()));
}

private static boolean matchURLAlias(final String url, final DatabaseType databaseType) {
for (String each : databaseType.getJdbcUrlPrefixAlias()) {
if (url.startsWith(each)) {
return true;
}
}
return false;
}
}
Loading

0 comments on commit 21db13d

Please sign in to comment.