Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
matrix
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
mall
arch
matrix
Commits
140131a7
Commit
140131a7
authored
Dec 05, 2019
by
qiuweili123
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数据源开发
parent
58a5d968
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
205 deletions
+30
-205
SysUtil.java
matrix-datasource/matrix-datasource-core/src/main/java/com/secoo/mall/datasource/util/SysUtil.java
+30
-0
DataSourceConfig.java
matrix-mybatis/matrix-mybatis-core/src/main/java/com/secoo/mall/mybatis/config/DataSourceConfig.java
+0
-125
MatrixDataSourceConfig.java
matrix-mybatis/matrix-mybatis-core/src/main/java/com/secoo/mall/mybatis/config/MatrixDataSourceConfig.java
+0
-80
No files found.
matrix-datasource/matrix-datasource-core/src/main/java/com/secoo/mall/datasource/util/SysUtil.java
0 → 100644
View file @
140131a7
package
com
.
secoo
.
mall
.
datasource
.
util
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.Properties
;
@Slf4j
public
class
SysUtil
{
private
static
Properties
properties
=
new
Properties
();
public
static
void
setProperty
(
String
key
,
String
value
)
{
/* try {
PropertyUtils.setProperty(HashMap.class, key, value);
} catch (Exception e) {
log.error("set property", e);
}*/
properties
.
setProperty
(
key
,
value
);
}
public
static
String
getProperty
(
String
key
)
{
/* try {
Object property = PropertyUtils.getProperty(HashMap.class, key);
return (T) PropertyUtils.getProperty(HashMap.class, key);
} catch (Exception e) {
log.error("set property", e);
}*/
return
properties
.
getProperty
(
key
);
}
}
matrix-mybatis/matrix-mybatis-core/src/main/java/com/secoo/mall/mybatis/config/DataSourceConfig.java
deleted
100644 → 0
View file @
58a5d968
package
com
.
secoo
.
mall
.
mybatis
.
config
;
public
interface
DataSourceConfig
{
/**
* Get the maximum number of milliseconds that a client will wait for a connection from the pool. If this
* time is exceeded without a connection becoming available, a SQLException will be thrown from
* {@link javax.sql.DataSource#getConnection()}.
*
* @return the connection timeout in milliseconds
*/
long
getConnectionTimeout
();
/**
* Set the maximum number of milliseconds that a client will wait for a connection from the pool. If this
* time is exceeded without a connection becoming available, a SQLException will be thrown from
* {@link javax.sql.DataSource#getConnection()}.
*
* @param connectionTimeoutMs the connection timeout in milliseconds
*/
void
setConnectionTimeout
(
long
connectionTimeoutMs
);
/**
* This property controls the maximum amount of time (in milliseconds) that a connection is allowed to sit
* idle in the pool. Whether a connection is retired as idle or not is subject to a maximum variation of +30
* seconds, and average variation of +15 seconds. A connection will never be retired as idle before this timeout.
* A value of 0 means that idle connections are never removed from the pool.
*
* @return the idle timeout in milliseconds
*/
long
getIdleTimeout
();
/**
* This property controls the maximum amount of time (in milliseconds) that a connection is allowed to sit
* idle in the pool. Whether a connection is retired as idle or not is subject to a maximum variation of +30
* seconds, and average variation of +15 seconds. A connection will never be retired as idle before this timeout.
* A value of 0 means that idle connections are never removed from the pool.
*
* @param idleTimeoutMs the idle timeout in milliseconds
*/
void
setIdleTimeout
(
long
idleTimeoutMs
);
/**
* This property controls the maximum lifetime of a connection in the pool. When a connection reaches this
* timeout, even if recently used, it will be retired from the pool. An in-use connection will never be
* retired, only when it is idle will it be removed.
*
* @return the maximum connection lifetime in milliseconds
*/
long
getMaxLifetime
();
/**
* This property controls the maximum lifetime of a connection in the pool. When a connection reaches this
* timeout, even if recently used, it will be retired from the pool. An in-use connection will never be
* retired, only when it is idle will it be removed.
*
* @param maxLifetimeMs the maximum connection lifetime in milliseconds
*/
void
setMaxLifetime
(
long
maxLifetimeMs
);
/**
* The property controls the minimum number of idle connections that HikariCP tries to maintain in the pool,
* including both idle and in-use connections. If the idle connections dip below this value, HikariCP will
* make a best effort to restore them quickly and efficiently.
*
* @return the minimum number of connections in the pool
*/
int
getMinimumIdle
();
/**
* The property controls the minimum number of idle connections that HikariCP tries to maintain in the pool,
* including both idle and in-use connections. If the idle connections dip below this value, HikariCP will
* make a best effort to restore them quickly and efficiently.
*
* @param minIdle the minimum number of idle connections in the pool to maintain
*/
void
setMinimumIdle
(
int
minIdle
);
/**
* The property controls the maximum number of connections that HikariCP will keep in the pool,
* including both idle and in-use connections.
*
* @return the maximum number of connections in the pool
*/
int
getMaximumPoolSize
();
/**
* The property controls the maximum size that the pool is allowed to reach, including both idle and in-use
* connections. Basically this value will determine the maximum number of actual connections to the database
* backend.
* <p>
* When the pool reaches this size, and no idle connections are available, calls to getConnection() will
* block for up to connectionTimeout milliseconds before timing out.
*
* @param maxPoolSize the maximum number of connections in the pool
*/
void
setMaximumPoolSize
(
int
maxPoolSize
);
/**
* Set the password used for authentication. Changing this at runtime will apply to new connections only.
* Altering this at runtime only works for DataSource-based connections, not Driver-class or JDBC URL-based
* connections.
*
* @param password the database password
*/
void
setPassword
(
String
password
);
/**
* Set the username used for authentication. Changing this at runtime will apply to new connections only.
* Altering this at runtime only works for DataSource-based connections, not Driver-class or JDBC URL-based
* connections.
*
* @param username the database username
*/
void
setUsername
(
String
username
);
/**
* The name of the data source.
*
* @return the name of the connection pool
*/
String
getName
();
}
matrix-mybatis/matrix-mybatis-core/src/main/java/com/secoo/mall/mybatis/config/MatrixDataSourceConfig.java
deleted
100644 → 0
View file @
58a5d968
package
com
.
secoo
.
mall
.
mybatis
.
config
;
import
com.secoo.mall.mybatis.constants.DataSourceType
;
import
lombok.Data
;
@Data
public
class
MatrixDataSourceConfig
implements
DataSourceConfig
{
public
static
final
String
PREFIX
=
"spring.datasource.matrix"
;
/**
* SourceType DRUID or HIKARI.
* Default value HIKARI.
*/
private
DataSourceType
type
;
private
String
name
;
private
String
username
;
private
String
password
;
/**
* Connection url
*/
private
String
url
;
private
int
minimumIdle
;
private
int
maxPoolSize
;
private
long
connectionTimeout
;
private
long
idleTimeout
;
private
long
maxLifetime
;
@Override
public
long
getConnectionTimeout
()
{
return
connectionTimeout
;
}
@Override
public
void
setConnectionTimeout
(
long
connectionTimeoutMs
)
{
this
.
connectionTimeout
=
connectionTimeoutMs
;
}
@Override
public
long
getIdleTimeout
()
{
return
idleTimeout
;
}
@Override
public
void
setIdleTimeout
(
long
idleTimeoutMs
)
{
this
.
idleTimeout
=
idleTimeoutMs
;
}
@Override
public
long
getMaxLifetime
()
{
return
maxLifetime
;
}
@Override
public
void
setMaxLifetime
(
long
maxLifetimeMs
)
{
this
.
maxLifetime
=
maxLifetimeMs
;
}
@Override
public
int
getMinimumIdle
()
{
return
this
.
minimumIdle
;
}
@Override
public
void
setMinimumIdle
(
int
minIdle
)
{
this
.
minimumIdle
=
minIdle
;
}
@Override
public
int
getMaximumPoolSize
()
{
return
maxPoolSize
;
}
@Override
public
void
setMaximumPoolSize
(
int
maxPoolSize
)
{
this
.
maxPoolSize
=
maxPoolSize
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment