Skip to content

Commit

Permalink
avoid the extreme case that notify missing
Browse files Browse the repository at this point in the history
  • Loading branch information
ihaolin committed Oct 15, 2016
1 parent 7e7bb42 commit 6150509
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions diablo-client-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>diablo</artifactId>
<groupId>me.hao0</groupId>
<version>1.1.0</version>
<version>1.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -22,7 +22,7 @@
<dependency>
<groupId>me.hao0</groupId>
<artifactId>diablo-client</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
</dependency>

<dependency>
Expand Down
4 changes: 2 additions & 2 deletions diablo-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>diablo</artifactId>
<groupId>me.hao0</groupId>
<version>1.1.0</version>
<version>1.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -22,7 +22,7 @@
<dependency>
<groupId>me.hao0</groupId>
<artifactId>diablo-common</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
</dependency>

<!-- use slf4j-api for logging -->
Expand Down
2 changes: 1 addition & 1 deletion diablo-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>diablo</artifactId>
<groupId>me.hao0</groupId>
<version>1.1.0</version>
<version>1.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 2 additions & 2 deletions diablo-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>diablo</artifactId>
<groupId>me.hao0</groupId>
<version>1.1.0</version>
<version>1.1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -22,7 +22,7 @@
<dependency>
<groupId>me.hao0</groupId>
<artifactId>diablo-common</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,8 @@ public void run() {
if (sendUpdatedConfigsIfPossible(client.getAppId(), pullingConfigs, response)){
// updated config sent

// complete async context to tell the container sends response
asyncContext.complete();

// cancel data changed listening
if (pullingTimeoutFuture != null){
pullingTimeoutFuture.cancel(false);
}
// stop pulling
stopPulling();

} else {
// no updated config sent
Expand All @@ -164,13 +159,17 @@ public void run() {
int serverKeepPullingTimeout = getPullingTimeout((HttpServletRequest) asyncContext.getRequest());
pullingTimeoutFuture = longPullingScheduler.schedule(new Runnable() {
public void run() {
Logs.info("client pulling is timeout.");
stopPulling();
}
}, serverKeepPullingTimeout, TimeUnit.SECONDS);

// start to listen config updated
eventDispatcher.register(this);

// NOTE: avoid the extreme case that config updated notify before registering self
if (sendUpdatedConfigsIfPossible(client.getAppId(), pullingConfigs, response)){
stopPulling();
}
}
}

Expand Down Expand Up @@ -203,6 +202,11 @@ private void stopPulling() {

// tell the container to send response
asyncContext.complete();

// cancel data changed listening
if (pullingTimeoutFuture != null){
pullingTimeoutFuture.cancel(false);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>me.hao0</groupId>
<artifactId>diablo</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
<modules>
<module>diablo-common</module>
<module>diablo-server</module>
Expand Down

0 comments on commit 6150509

Please sign in to comment.