Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0.2 #183

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

1.0.2 #183

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions leaf-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<parent>
<groupId>com.sankuai.inf.leaf</groupId>
<artifactId>leaf-parent</artifactId>
<version>1.0.1</version>
<version>1.0.2-SNAPSHOT</version>
</parent>
<groupId>com.sankuai.inf.leaf</groupId>
<artifactId>leaf-core</artifactId>
<packaging>jar</packaging>
<version>1.0.1</version>
<version>1.0.2-SNAPSHOT</version>
<name>leaf-core</name>
<properties>
<mysql-connector-java.version>5.1.38</mysql-connector-java.version>
Expand Down Expand Up @@ -89,16 +89,6 @@
<artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
Expand All @@ -110,6 +100,15 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public interface IDAllocMapper {
})
LeafAlloc getLeafAlloc(@Param("tag") String tag);

@Update("UPDATE leaf_alloc SET max_id = max_id + step WHERE biz_tag = #{tag}")
@Update("UPDATE leaf_alloc SET max_id = max_id + step , update_time = systimestamp WHERE biz_tag = #{tag}")
void updateMaxId(@Param("tag") String tag);

@Update("UPDATE leaf_alloc SET max_id = max_id + #{step} WHERE biz_tag = #{key}")
@Update("UPDATE leaf_alloc SET max_id = max_id + #{step} , update_time = systimestamp WHERE biz_tag = #{key}")
void updateMaxIdByCustomStep(@Param("leafAlloc") LeafAlloc leafAlloc);

@Select("SELECT biz_tag FROM leaf_alloc")
Expand Down

This file was deleted.

23 changes: 21 additions & 2 deletions leaf-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<groupId>com.sankuai.inf.leaf</groupId>
<artifactId>leaf-parent</artifactId>
<version>1.0.1</version>
<version>1.0.2-SNAPSHOT</version>
</parent>
<groupId>com.sankuai.inf.leaf</groupId>
<artifactId>leaf-server</artifactId>
<version>1.0.1</version>
<version>1.0.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>leaf-server</name>
<description>Leaf HTTP Server</description>
Expand Down Expand Up @@ -67,6 +67,25 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>4.0.3</version>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

public class Constants {
public static final String LEAF_SEGMENT_ENABLE = "leaf.segment.enable";

public static final String LEAF_JDBC_DRIVE= "leaf.jdbc.drive";
public static final String LEAF_JDBC_URL = "leaf.jdbc.url";
public static final String LEAF_JDBC_USERNAME = "leaf.jdbc.username";
public static final String LEAF_JDBC_PASSWORD = "leaf.jdbc.password";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
import com.sankuai.inf.leaf.segment.dao.impl.IDAllocDaoImpl;
import com.sankuai.inf.leaf.server.Constants;
import com.sankuai.inf.leaf.server.exception.InitException;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Properties;

Expand All @@ -22,18 +25,34 @@ public class SegmentService {
private Logger logger = LoggerFactory.getLogger(SegmentService.class);

private IDGen idGen;
private DruidDataSource dataSource;

/*private DataSource getDataSource(Properties properties) throws SQLException {
// Config dataSource
DruidDataSource dataSource = new DruidDataSource();
dataSource.setUrl(properties.getProperty(Constants.LEAF_JDBC_URL));
dataSource.setUsername(properties.getProperty(Constants.LEAF_JDBC_USERNAME));
dataSource.setPassword(properties.getProperty(Constants.LEAF_JDBC_PASSWORD));
dataSource.init();
return dataSource;
}*/

private DataSource getDataSource(Properties properties) throws SQLException {
// Config dataSource
HikariConfig configuration = new HikariConfig();
configuration.setDriverClassName(properties.getProperty(Constants.LEAF_JDBC_DRIVE));
configuration.setJdbcUrl(properties.getProperty(Constants.LEAF_JDBC_URL));
configuration.setUsername(properties.getProperty(Constants.LEAF_JDBC_USERNAME));
configuration.setPassword(properties.getProperty(Constants.LEAF_JDBC_PASSWORD));
DataSource dataSource = new HikariDataSource(configuration);
return dataSource;
}

public SegmentService() throws SQLException, InitException {
Properties properties = PropertyFactory.getProperties();
boolean flag = Boolean.parseBoolean(properties.getProperty(Constants.LEAF_SEGMENT_ENABLE, "true"));
if (flag) {
// Config dataSource
dataSource = new DruidDataSource();
dataSource.setUrl(properties.getProperty(Constants.LEAF_JDBC_URL));
dataSource.setUsername(properties.getProperty(Constants.LEAF_JDBC_USERNAME));
dataSource.setPassword(properties.getProperty(Constants.LEAF_JDBC_PASSWORD));
dataSource.init();

DataSource dataSource = getDataSource(properties);

// Config Dao
IDAllocDao dao = new IDAllocDaoImpl(dataSource);
Expand Down
14 changes: 10 additions & 4 deletions leaf-server/src/main/resources/leaf.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
leaf.name=com.sankuai.leaf.opensource.test
leaf.segment.enable=false
#leaf.jdbc.url=
#leaf.jdbc.username=
#leaf.jdbc.password=
leaf.segment.enable=true
//leaf.jdbc.drive=com.mysql.jdbc.Driver
//leaf.jdbc.url=jdbc:mysql://localhost:3306/leaf
//leaf.jdbc.username=root
//leaf.jdbc.password=111111

leaf.jdbc.drive=oracle.jdbc.driver.OracleDriver
leaf.jdbc.url=jdbc:oracle:thin:@orayali3.whintra.com:1521:orayali3
leaf.jdbc.username=cmfuser
leaf.jdbc.password=cmfuser

leaf.snowflake.enable=false
#leaf.snowflake.zk.address=
Expand Down
23 changes: 22 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.sankuai.inf.leaf</groupId>
<artifactId>leaf-parent</artifactId>
<packaging>pom</packaging>
<version>1.0.1</version>
<version>1.0.2-SNAPSHOT</version>
<name>Leaf</name>
<modules>
<module>leaf-core</module>
Expand Down Expand Up @@ -154,6 +154,22 @@
</dependency>
</dependencies>
</dependencyManagement>

<distributionManagement>
<repository>
<id>deployRelease</id>
<name>Nexus Release Repository</name>
<url>http://10.65.241.21:8081/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>deploySnapshot</id>
<name>Nexus Snapshot Repository</name>
<url>http://10.65.241.21:8081/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>



<build>
<finalName>leaf</finalName>
<plugins>
Expand Down Expand Up @@ -197,6 +213,11 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</build>

Expand Down