本文整理汇总了Java中com.mysql.fabric.FabricConnection类的典型用法代码示例。如果您正苦于以下问题:Java FabricConnection类的具体用法?Java FabricConnection怎么用?Java FabricConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FabricConnection类属于com.mysql.fabric包,在下文中一共展示了FabricConnection类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testBug82094
import com.mysql.fabric.FabricConnection; //导入依赖的package包/类
/**
* Test Bug#82094 - ConcurrentModificationException on Fabric connections after topology changes.
*
* This test requires a Fabric instance running with a HA group (ha_config1_group) containing three servers, one promoted to master and failure detection
* turned on.
* Note that removing one or the other secondary server is a distinct case and only one of them causes the reported failure. This is so because of the order
* the elements on the slave servers HashSet, from the ReplicationConnectionGroup object, are iterated. So, we remove one at a time in this test to make
* sure we cover both cases.
*/
public void testBug82094() throws Exception {
if (!this.isSetForFabricTest) {
return;
}
FabricMySQLDataSource ds = getNewDefaultDataSource();
ds.setFabricServerGroup("ha_config1_group");
this.conn = (FabricMySQLConnection) ds.getConnection(this.username, this.password);
this.conn.createStatement().close(); // Make sure there is an internal ReplicationConnection.
FabricConnection fabricConn = new FabricConnection(this.fabricUrl, this.fabricUsername, this.fabricPassword);
for (Server server : fabricConn.getServerGroup("ha_config1_group").getServers()) {
if (server.isSlave()) {
try {
this.conn.transactionCompleted();
// Remove Secondary server.
fabricConn.getClient().removeServerFromGroup(server.getGroupName(), server.getHostname(), server.getPort());
// Make sure the TTL expires before moving on.
fabricConn.refreshState();
while (!fabricConn.isStateExpired()) {
Thread.sleep(1000);
}
this.conn.transactionCompleted();
} finally {
// Add Secondary server back.
fabricConn.getClient().addServerToGroup(server.getGroupName(), server.getHostname(), server.getPort());
// Make sure the TTL expires before moving on.
fabricConn.refreshState();
while (!fabricConn.isStateExpired()) {
Thread.sleep(1000);
}
}
}
}
this.conn.close();
}
开发者ID:bragex,项目名称:the-vigilantes,代码行数:49,代码来源:TestRegressions.java
示例2: FabricMultiTenantConnectionProvider
import com.mysql.fabric.FabricConnection; //导入依赖的package包/类
public FabricMultiTenantConnectionProvider(String fabricUrl, String database, String table, String user, String password, String fabricUser,
String fabricPassword) {
try {
this.fabricConnection = new FabricConnection(fabricUrl, fabricUser, fabricPassword);
this.database = database;
this.table = table;
this.user = user;
this.password = password;
this.shardMapping = this.fabricConnection.getShardMapping(this.database, this.table);
this.globalGroup = this.fabricConnection.getServerGroup(this.shardMapping.getGlobalGroupName());
} catch (FabricCommunicationException ex) {
throw new RuntimeException(ex);
}
}
开发者ID:bragex,项目名称:the-vigilantes,代码行数:15,代码来源:FabricMultiTenantConnectionProvider.java
示例3: FabricMySQLConnectionProxy
import com.mysql.fabric.FabricConnection; //导入依赖的package包/类
public FabricMySQLConnectionProxy(Properties props) throws SQLException {
// first, handle and remove Fabric-specific properties. once fabricShardKey et al are ConnectionProperty instances this will be unnecessary
this.fabricShardKey = props.getProperty(FabricMySQLDriver.FABRIC_SHARD_KEY_PROPERTY_KEY);
this.fabricShardTable = props.getProperty(FabricMySQLDriver.FABRIC_SHARD_TABLE_PROPERTY_KEY);
this.fabricServerGroup = props.getProperty(FabricMySQLDriver.FABRIC_SERVER_GROUP_PROPERTY_KEY);
this.fabricProtocol = props.getProperty(FabricMySQLDriver.FABRIC_PROTOCOL_PROPERTY_KEY);
this.fabricUsername = props.getProperty(FabricMySQLDriver.FABRIC_USERNAME_PROPERTY_KEY);
this.fabricPassword = props.getProperty(FabricMySQLDriver.FABRIC_PASSWORD_PROPERTY_KEY);
this.reportErrors = Boolean.valueOf(props.getProperty(FabricMySQLDriver.FABRIC_REPORT_ERRORS_PROPERTY_KEY));
props.remove(FabricMySQLDriver.FABRIC_SHARD_KEY_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_SHARD_TABLE_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_SERVER_GROUP_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_PROTOCOL_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_USERNAME_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_PASSWORD_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_REPORT_ERRORS_PROPERTY_KEY);
this.host = props.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY);
this.port = props.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY);
this.username = props.getProperty(NonRegisteringDriver.USER_PROPERTY_KEY);
this.password = props.getProperty(NonRegisteringDriver.PASSWORD_PROPERTY_KEY);
this.database = props.getProperty(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
if (this.username == null) {
this.username = "";
}
if (this.password == null) {
this.password = "";
}
// add our interceptor to pass exceptions back to the `interceptException' method
String exceptionInterceptors = props.getProperty("exceptionInterceptors");
if (exceptionInterceptors == null || "null".equals("exceptionInterceptors")) {
exceptionInterceptors = "";
} else {
exceptionInterceptors += ",";
}
exceptionInterceptors += "com.mysql.fabric.jdbc.ErrorReportingExceptionInterceptor";
props.setProperty("exceptionInterceptors", exceptionInterceptors);
initializeProperties(props);
// validation check of properties
if (this.fabricServerGroup != null && this.fabricShardTable != null) {
throw SQLError.createSQLException("Server group and shard table are mutually exclusive. Only one may be provided.",
SQLError.SQL_STATE_CONNECTION_REJECTED, null, getExceptionInterceptor(), this);
}
try {
String url = this.fabricProtocol + "://" + this.host + ":" + this.port;
this.fabricConnection = new FabricConnection(url, this.fabricUsername, this.fabricPassword);
} catch (FabricCommunicationException ex) {
throw SQLError.createSQLException("Unable to establish connection to the Fabric server", SQLError.SQL_STATE_CONNECTION_REJECTED, ex,
getExceptionInterceptor(), this);
}
// initialize log before any further calls that might actually use it
this.log = LogFactory.getLogger(getLogger(), "FabricMySQLConnectionProxy", null);
setShardTable(this.fabricShardTable);
setShardKey(this.fabricShardKey);
setServerGroupName(this.fabricServerGroup);
}
开发者ID:bragex,项目名称:the-vigilantes,代码行数:64,代码来源:FabricMySQLConnectionProxy.java
示例4: FabricMySQLConnectionProxy
import com.mysql.fabric.FabricConnection; //导入依赖的package包/类
public FabricMySQLConnectionProxy(Properties props) throws SQLException {
// first, handle and remove Fabric-specific properties. once fabricShardKey et al are ConnectionProperty instances this will be unnecessary
this.fabricShardKey = props.getProperty(FabricMySQLDriver.FABRIC_SHARD_KEY_PROPERTY_KEY);
this.fabricShardTable = props.getProperty(FabricMySQLDriver.FABRIC_SHARD_TABLE_PROPERTY_KEY);
this.fabricServerGroup = props.getProperty(FabricMySQLDriver.FABRIC_SERVER_GROUP_PROPERTY_KEY);
this.fabricProtocol = props.getProperty(FabricMySQLDriver.FABRIC_PROTOCOL_PROPERTY_KEY);
this.fabricUsername = props.getProperty(FabricMySQLDriver.FABRIC_USERNAME_PROPERTY_KEY);
this.fabricPassword = props.getProperty(FabricMySQLDriver.FABRIC_PASSWORD_PROPERTY_KEY);
this.reportErrors = Boolean.valueOf(props.getProperty(FabricMySQLDriver.FABRIC_REPORT_ERRORS_PROPERTY_KEY));
props.remove(FabricMySQLDriver.FABRIC_SHARD_KEY_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_SHARD_TABLE_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_SERVER_GROUP_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_PROTOCOL_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_USERNAME_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_PASSWORD_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_REPORT_ERRORS_PROPERTY_KEY);
this.host = props.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY);
this.port = props.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY);
this.username = props.getProperty(NonRegisteringDriver.USER_PROPERTY_KEY);
this.password = props.getProperty(NonRegisteringDriver.PASSWORD_PROPERTY_KEY);
this.database = props.getProperty(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
if (this.username == null) {
this.username = "";
}
if (this.password == null) {
this.password = "";
}
// add our interceptor to pass exceptions back to the `interceptException' method
String exceptionInterceptors = props.getProperty("exceptionInterceptors");
if (exceptionInterceptors == null || "null".equals("exceptionInterceptors")) {
exceptionInterceptors = "";
} else {
exceptionInterceptors += ",";
}
exceptionInterceptors += "com.mysql.fabric.jdbc.ErrorReportingExceptionInterceptor";
props.setProperty("exceptionInterceptors", exceptionInterceptors);
initializeProperties(props);
// validation check of properties
if (this.fabricServerGroup != null && this.fabricShardTable != null) {
throw SQLError.createSQLException("Server group and shard table are mutually exclusive. Only one may be provided.",
SQLError.SQL_STATE_CONNECTION_REJECTED, null, getExceptionInterceptor(), this);
}
try {
String url = this.fabricProtocol + "://" + this.host + ":" + this.port;
this.fabricConnection = new FabricConnection(url, this.fabricUsername, this.fabricPassword);
} catch (FabricCommunicationException ex) {
throw SQLError.createSQLException("Unable to establish connection to the Fabric server", SQLError.SQL_STATE_CONNECTION_REJECTED, ex,
getExceptionInterceptor(), this);
}
setShardTable(this.fabricShardTable);
setShardKey(this.fabricShardKey);
setServerGroupName(this.fabricServerGroup);
this.log = LogFactory.getLogger(getLogger(), "FabricMySQLConnectionProxy", null);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:63,代码来源:FabricMySQLConnectionProxy.java
示例5: FabricMySQLConnectionProxy
import com.mysql.fabric.FabricConnection; //导入依赖的package包/类
public FabricMySQLConnectionProxy(Properties props) throws SQLException {
// first, handle and remove Fabric-specific properties. once fabricShardKey et al are ConnectionProperty instances this will be unnecessary
this.fabricShardKey = props.getProperty(FabricMySQLDriver.FABRIC_SHARD_KEY_PROPERTY_KEY);
this.fabricShardTable = props.getProperty(FabricMySQLDriver.FABRIC_SHARD_TABLE_PROPERTY_KEY);
this.fabricServerGroup = props.getProperty(FabricMySQLDriver.FABRIC_SERVER_GROUP_PROPERTY_KEY);
this.fabricProtocol = props.getProperty(FabricMySQLDriver.FABRIC_PROTOCOL_PROPERTY_KEY);
this.fabricUsername = props.getProperty(FabricMySQLDriver.FABRIC_USERNAME_PROPERTY_KEY);
this.fabricPassword = props.getProperty(FabricMySQLDriver.FABRIC_PASSWORD_PROPERTY_KEY);
this.reportErrors = Boolean.valueOf(props.getProperty(FabricMySQLDriver.FABRIC_REPORT_ERRORS_PROPERTY_KEY));
props.remove(FabricMySQLDriver.FABRIC_SHARD_KEY_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_SHARD_TABLE_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_SERVER_GROUP_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_PROTOCOL_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_USERNAME_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_PASSWORD_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_REPORT_ERRORS_PROPERTY_KEY);
this.host = props.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY);
this.port = props.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY);
this.username = props.getProperty(NonRegisteringDriver.USER_PROPERTY_KEY);
this.password = props.getProperty(NonRegisteringDriver.PASSWORD_PROPERTY_KEY);
this.database = props.getProperty(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
if (this.username == null) {
this.username = "";
}
if (this.password == null) {
this.password = "";
}
String exceptionInterceptors = props.getProperty("exceptionInterceptors");
if (exceptionInterceptors == null || "null".equals("exceptionInterceptors")) {
exceptionInterceptors = "";
} else {
exceptionInterceptors += ",";
}
exceptionInterceptors += "com.mysql.fabric.jdbc.ErrorReportingExceptionInterceptor";
props.setProperty("exceptionInterceptors", exceptionInterceptors);
initializeProperties(props);
// validation check of properties
if (this.fabricServerGroup != null && this.fabricShardTable != null) {
throw SQLError.createSQLException("Server group and shard table are mutually exclusive. Only one may be provided.",
SQLError.SQL_STATE_CONNECTION_REJECTED, null, getExceptionInterceptor(), this);
}
try {
String url = this.fabricProtocol + "://" + this.host + ":" + this.port;
this.fabricConnection = new FabricConnection(url, this.fabricUsername, this.fabricPassword);
} catch (FabricCommunicationException ex) {
throw SQLError.createSQLException("Unable to establish connection to the Fabric server", SQLError.SQL_STATE_CONNECTION_REJECTED, ex,
getExceptionInterceptor(), this);
}
setShardTable(this.fabricShardTable);
setShardKey(this.fabricShardKey);
setServerGroupName(this.fabricServerGroup);
}
开发者ID:mniepert,项目名称:TPKB,代码行数:60,代码来源:FabricMySQLConnectionProxy.java
示例6: FabricMySQLConnectionProxy
import com.mysql.fabric.FabricConnection; //导入依赖的package包/类
public FabricMySQLConnectionProxy(Properties props) throws SQLException {
// first, handle and remove Fabric-specific properties. once fabricShardKey et al are ConnectionProperty instances this will be unnecessary
this.fabricShardKey = props.getProperty(FabricMySQLDriver.FABRIC_SHARD_KEY_PROPERTY_KEY);
this.fabricShardTable = props.getProperty(FabricMySQLDriver.FABRIC_SHARD_TABLE_PROPERTY_KEY);
this.fabricServerGroup = props.getProperty(FabricMySQLDriver.FABRIC_SERVER_GROUP_PROPERTY_KEY);
this.fabricProtocol = props.getProperty(FabricMySQLDriver.FABRIC_PROTOCOL_PROPERTY_KEY);
this.fabricUsername = props.getProperty(FabricMySQLDriver.FABRIC_USERNAME_PROPERTY_KEY);
this.fabricPassword = props.getProperty(FabricMySQLDriver.FABRIC_PASSWORD_PROPERTY_KEY);
this.reportErrors = Boolean.valueOf(props.getProperty(FabricMySQLDriver.FABRIC_REPORT_ERRORS_PROPERTY_KEY));
props.remove(FabricMySQLDriver.FABRIC_SHARD_KEY_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_SHARD_TABLE_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_SERVER_GROUP_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_PROTOCOL_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_USERNAME_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_PASSWORD_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_REPORT_ERRORS_PROPERTY_KEY);
this.host = props.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY);
this.port = props.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY);
this.username = props.getProperty(NonRegisteringDriver.USER_PROPERTY_KEY);
this.password = props.getProperty(NonRegisteringDriver.PASSWORD_PROPERTY_KEY);
this.database = props.getProperty(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
if (this.username == null) {
this.username = "";
}
if (this.password == null) {
this.password = "";
}
// add our interceptor to pass exceptions back to the `interceptException' method
String exceptionInterceptors = props.getProperty("exceptionInterceptors");
if (exceptionInterceptors == null || "null".equals("exceptionInterceptors")) {
exceptionInterceptors = "";
} else {
exceptionInterceptors += ",";
}
exceptionInterceptors += "com.mysql.fabric.jdbc.ErrorReportingExceptionInterceptor";
props.setProperty("exceptionInterceptors", exceptionInterceptors);
initializeProperties(props);
// validation check of properties
if (this.fabricServerGroup != null && this.fabricShardTable != null) {
throw SQLError.createSQLException("Server group and shard table are mutually exclusive. Only one may be provided.",
SQLError.SQL_STATE_CONNECTION_REJECTED, null, getExceptionInterceptor(), this);
}
try {
String url = this.fabricProtocol + "://" + this.host + ":" + this.port;
this.fabricConnection = new FabricConnection(url, this.fabricUsername, this.fabricPassword);
} catch (FabricCommunicationException ex) {
throw SQLError.createSQLException("Unable to establish connection to the Fabric server", SQLError.SQL_STATE_CONNECTION_REJECTED, ex,
getExceptionInterceptor(), this);
}
setShardTable(this.fabricShardTable);
setShardKey(this.fabricShardKey);
setServerGroupName(this.fabricServerGroup);
log = LogFactory.getLogger(getLogger(), "FabricMySQLConnectionProxy", null);
}
开发者ID:zerobane,项目名称:cloudera-cli-scripts,代码行数:63,代码来源:FabricMySQLConnectionProxy.java
示例7: FabricMySQLConnectionProxy
import com.mysql.fabric.FabricConnection; //导入依赖的package包/类
public FabricMySQLConnectionProxy(Properties props) throws SQLException {
// first, handle and remove Fabric-specific properties. once
// fabricShardKey et al are ConnectionProperty instances this
// will be unnecessary
this.fabricShardKey = props.getProperty(FabricMySQLDriver.FABRIC_SHARD_KEY_PROPERTY_KEY);
this.fabricShardTable = props.getProperty(FabricMySQLDriver.FABRIC_SHARD_TABLE_PROPERTY_KEY);
this.fabricServerGroup = props.getProperty(FabricMySQLDriver.FABRIC_SERVER_GROUP_PROPERTY_KEY);
this.fabricProtocol = props.getProperty(FabricMySQLDriver.FABRIC_PROTOCOL_PROPERTY_KEY);
this.fabricUsername = props.getProperty(FabricMySQLDriver.FABRIC_USERNAME_PROPERTY_KEY);
this.fabricPassword = props.getProperty(FabricMySQLDriver.FABRIC_PASSWORD_PROPERTY_KEY);
this.reportErrors = Boolean.valueOf(props.getProperty(FabricMySQLDriver.FABRIC_REPORT_ERRORS_PROPERTY_KEY));
props.remove(FabricMySQLDriver.FABRIC_SHARD_KEY_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_SHARD_TABLE_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_SERVER_GROUP_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_PROTOCOL_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_USERNAME_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_PASSWORD_PROPERTY_KEY);
props.remove(FabricMySQLDriver.FABRIC_REPORT_ERRORS_PROPERTY_KEY);
this.host = props.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY);
this.port = props.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY);
this.username = props.getProperty(NonRegisteringDriver.USER_PROPERTY_KEY);
this.password = props.getProperty(NonRegisteringDriver.PASSWORD_PROPERTY_KEY);
this.database = props.getProperty(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
if (this.username == null) {
this.username = "";
}
if (this.password == null) {
this.password = "";
}
String exceptionInterceptors = props.getProperty("exceptionInterceptors");
if (exceptionInterceptors == null || "null".equals("exceptionInterceptors")) {
exceptionInterceptors = "";
} else {
exceptionInterceptors += ",";
}
exceptionInterceptors += "com.mysql.fabric.jdbc.ErrorReportingExceptionInterceptor";
props.setProperty("exceptionInterceptors", exceptionInterceptors);
initializeProperties(props);
// validation check of properties
if (this.fabricServerGroup != null &&
this.fabricShardTable != null) {
throw SQLError.createSQLException("Server group and shard table are mutually exclusive. Only one may be provided.",
SQLError.SQL_STATE_CONNECTION_REJECTED,
null,
getExceptionInterceptor(),
this);
}
try {
String url = this.fabricProtocol + "://" + this.host + ":" + this.port;
this.fabricConnection = new FabricConnection(url, this.fabricUsername, this.fabricPassword);
} catch(FabricCommunicationException ex) {
throw SQLError.createSQLException("Unable to establish connection to the Fabric server",
SQLError.SQL_STATE_CONNECTION_REJECTED,
ex,
getExceptionInterceptor(),
this);
}
setShardTable(this.fabricShardTable);
setShardKey(this.fabricShardKey);
setServerGroupName(this.fabricServerGroup);
}
开发者ID:hinsenchan,项目名称:fil_project_mgmt_app_v2,代码行数:69,代码来源:FabricMySQLConnectionProxy.java
注:本文中的com.mysql.fabric.FabricConnection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论