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

optimise. #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion CNAME

This file was deleted.

1 change: 0 additions & 1 deletion _config.yml

This file was deleted.

13 changes: 12 additions & 1 deletion docs/SnowflakeTutorial_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,18 @@ for (int i = 0; i < 20; i++) {
2017-09-15 17:35:04.894, #1, @(2,5) => id: 225912364284006401, hex: 03229A192F845001, bin: 0000001100100010100110100001100100101111100001000101000000000001
```

从输出结果看出,由于``System.out.println``IO操作比较耗时,导致前后两次生成ID的时间间隔偶尔会超过1毫秒。超过1毫秒的,序号字段会是``#0``;没超过1毫秒的,序号字段会累加。
从输出结果看出,由于``System.out.println``IO操作比较耗时,导致前后两次生成ID的时间间隔偶尔会超过1毫秒。超过1毫秒的,序号字段会是``#0``;没超过1毫秒的,序号字段会累加。对应如下源码:
```java
/**
* the unique and incrementing sequence number scoped in only one
* period/unit (here is ONE millisecond). its value will be increased by 1
* in the same specified period and then reset to 0 for next period.
* <p>
* max: 2^12-1 range: [0,4095]
*/
private long sequence = 0L;
```


### 源代码解析

Expand Down
Binary file added logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
138 changes: 44 additions & 94 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>xyz.downgoon</groupId>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

groupId changed ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

人才

<groupId>com.moonsinfo</groupId>
<artifactId>snowflake</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1</version>
<packaging>jar</packaging>

<name>snowflake</name>
<description>java edition of Twitter Snowflake: a network service for generating unique ID numbers at high scale with some simple guarantees</description>
<url>http://snowflake.downgoon.xyz/</url>
<licenses>
Expand All @@ -17,154 +18,77 @@
</license>
</licenses>

<scm>
<connection>scm:git:[email protected]:downgoon/snowflake.git</connection>
<developerConnection>scm:git:[email protected]:downgoon/snowflake.git</developerConnection>
<url>http://github.com/downgoon/snowflake</url>
</scm>

<developers>
<developer>
<id>downgoon</id>
<name>downgoon</name>
<email>[email protected]</email>
</developer>
</developers>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>

</dependencies>

<!-- deploy to remote (uploader password stored in settings.xml) -->

<profiles>

<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<name>Central Public Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<name>Central Public Releases</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
</distributionManagement>
</profile>

<profile>
<id>mysite</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<distributionManagement>
<snapshotRepository>
<id>mysiterh</id>
<name>Nexus Snapshot Repository</name>
<url>http://maven.intra.mysite.com/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>mysiterh</id>
<name>Nexus Release Repository</name>
<url>http://maven.intra.mysite.com/nexus/content/repositories/releases/</url>
</repository>
</distributionManagement>
</profile>

</profiles>


<build>
<plugins>
<!-- Compile -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>${project.build.sourceEncoding}</encoding>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

<!-- Download sources and javadocs for eclipse -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>

<!-- deploy uploading: source, document and sign of jar -->

<!-- source -->
<!-- Source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- javadoc -->
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>2.10.4</version>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<charset>UTF-8</charset>
<encoding>UTF-8</encoding>
<docencoding>UTF-8</docencoding>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</plugin>

<!-- sign of jar -->
<!-- GPG -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- skip some test -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -183,4 +107,30 @@
</plugins>
</build>


<developers>
<developer>
<name>Ethan Yao</name>
<url>http://www.moonsinfo.com</url>
<email>[email protected]</email>
</developer>
</developers>

<scm>
<connection>scm:git:[email protected]:iTriumph/snowflake.git</connection>
<developerConnection>scm:git:[email protected]:iTriumph/snowflake.git</developerConnection>
<url>http://github.com/iTriumph/snowflake</url>
</scm>

<distributionManagement>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

</project>