Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
214 commits
Select commit Hold shift + click to select a range
75964e0
fix temp push
Apr 3, 2019
6e87537
merge alipay master
Synex-wh Apr 12, 2019
ebce157
update version 5.2.1-SNAPSHOT
Apr 12, 2019
78ac837
Merge pull request #2 from Synex-wh/fix_version
Synex-wh Apr 12, 2019
6627a4e
merge master
Apr 12, 2019
c21270d
Merge pull request #3 from Synex-wh/fix_temporary_push_bug
Synex-wh Apr 22, 2019
4a60420
Merge remote-tracking branch 'upstream/master'
Apr 22, 2019
5241284
fix test case
Apr 24, 2019
d4b76dc
Merge branch 'master' of github.com:alipay/sofa-registry
Apr 29, 2019
69d18e3
fix jetty version,and fix rest api for dataInfoIds
Apr 29, 2019
2bd6ee5
fix hashcode test
Apr 29, 2019
4142761
Merge pull request #4 from Synex-wh/upgrade_jetty_version
Synex-wh Apr 29, 2019
3c509f1
Merge branch 'master' of github.com:alipay/sofa-registry
May 10, 2019
cebae41
fix working to init bug
May 10, 2019
85b42a3
fix start task log
May 10, 2019
c055282
fix Watcher can't get providate data,retry and finally return new
May 14, 2019
b187bd7
add data server list api
May 14, 2019
b3714e5
add server list api
May 19, 2019
566fd1b
remove log
May 20, 2019
a312558
fix isssue 21
May 20, 2019
079399d
add query by id function
May 20, 2019
2c06a39
fix issue 22
May 20, 2019
f03183b
delay client off process and sync data process to working status
May 21, 2019
ab3e21d
fix data connet meta error
May 21, 2019
5e616d6
Merge branch 'fix_issue19' into fix_issue20
May 21, 2019
cd50033
Merge branch 'fix_issue20' into fix_issue21
May 21, 2019
bbdf60a
Merge branch 'fix_issue21' into fix_issue22
May 21, 2019
6f7565b
Merge branch 'fix_issue22' into fix_issue23
May 21, 2019
8ec146a
Merge branch 'fix_issue23' into fix_issue24
May 21, 2019
6944621
fix inject NotifyDataSyncHandler
May 22, 2019
93fa77d
fix start log
May 23, 2019
1b9f0e6
add send sub log
May 28, 2019
6c829ef
fix subscriber to send log
May 28, 2019
d6d53d5
bugfix: https://github.com/sofastack/sofa-registry/issues/27
May 29, 2019
cdc582b
bugfix: https://github.com/sofastack/sofa-registry/issues/27
May 29, 2019
d9efee5
feature: Add monitoring logs https://github.com/sofastack/sofa-regist…
May 29, 2019
1c1d642
feature: Add monitoring logs https://github.com/sofastack/sofa-regist…
May 29, 2019
4765efe
bugfix: During meta startup, leader may not register itself https://g…
May 29, 2019
9e2a597
bugfix: Sometimes receive "Not leader" response from leader in OnStar…
May 29, 2019
875bf88
temp add
May 29, 2019
8612290
Merge remote-tracking branch 'remotes/origin/fix_issue31' into renew_…
May 29, 2019
b1400d4
add renew request
May 30, 2019
ca704f8
Merge remote-tracking branch 'origin_wh/feature_renew' into renew_exp…
May 30, 2019
0539bab
data snapshot module
May 30, 2019
957b603
add calculate digest service
May 31, 2019
b365300
Merge branch 'feature_renew' of https://github.com/Synex-wh/sofa-regi…
May 31, 2019
c3d9a3e
fix word cache clientid
Jun 3, 2019
411dd28
Merge branch 'fix_issue24' into feature_renew
Jun 3, 2019
ca87bcf
data renew module
Jun 3, 2019
6b1b559
data renew/expired module
Jun 4, 2019
8f60751
add renew datuem request
Jun 5, 2019
0fa9469
Merge remote-tracking branch 'remotes/origin_wh/feature_renew' into r…
Jun 5, 2019
175af5b
add WriteDataAcceptor
Jun 11, 2019
3b0e6ac
Merge branch 'feature_renew' of https://github.com/Synex-wh/sofa-regi…
Jun 11, 2019
5456972
session renew/expired module
Jun 17, 2019
3a7b6e5
1. bugfix ReNewDatumHandler: getByConnectId -> getOwnByConnectId
Jun 18, 2019
1260489
add blacklist wrapper and filter
Jun 25, 2019
ca71964
upgrade jraft version to 1.2.5
Jun 26, 2019
74aa175
blacklist ut
Jun 26, 2019
a51d204
add clientoff delay time
Jun 26, 2019
b8f6c8f
bugfix: The timing of snapshot construction is not right
Jun 27, 2019
dc9f9fe
rename: ReNew -> Renew
Jun 27, 2019
a3ca08a
fix blacklist test case
Jun 27, 2019
20b3443
rename: unpub -> unPub
Jun 27, 2019
9b25c0b
add threadSize and queueSize limit
Jun 27, 2019
197636f
Merge branch 'fix_issue24' into feature_blacklist
Jun 27, 2019
b9c2a63
bugfix: revert SessionRegistry
Jun 28, 2019
ffa3261
fix sub fetch retry all error,and reset datainfoid version
Jul 1, 2019
f15ef83
fix client fast chain breakage data can not be cleaned up”
Jul 1, 2019
fd18ce5
(1) remove logback.xml DEBUG level;
Jul 2, 2019
c321f54
update log
Jul 3, 2019
d7b6a1e
fix update zero version,and fix log
Jul 3, 2019
8928acf
add clientOffDelayMs default value
Jul 3, 2019
061b612
fix clientOffDelayMs
Jul 3, 2019
21d79c7
Task(DatumSnapshot/Pub/UnPub) add retry strategy
Jul 4, 2019
22286fb
bugfix DataNodeServiceImpl: retryTimes
Jul 4, 2019
9534ee1
Merge branch 'fix_issue24' into fix_issue37
Jul 4, 2019
341d457
(1)cancelDataTaskListener duplicate
Jul 4, 2019
46c93f3
refactor datum version
Jul 4, 2019
fddae5d
add hessian black list
Jul 5, 2019
a92e12c
bugfix: log "retryTimes"
Jul 8, 2019
e674065
bugfix DatumLeaseManager: Consider the situation of connectId lose a…
Jul 9, 2019
ebb0b18
add jvm blacklist api
Jul 10, 2019
0ba8324
fix file name
Jul 10, 2019
57714eb
some code optimization
Jul 10, 2019
c211e4e
data:refactor snapshot
Jul 12, 2019
1f34eb4
fix jetty version
Jul 15, 2019
251effa
mix all version
Jul 15, 2019
22a13f6
bugfix DatumLeaseManager: If in a non-working state, cannot clean up …
Jul 16, 2019
7aa7e80
Merge branch 'mix_all_version' of https://github.com/Synex-wh/sofa-re…
Jul 16, 2019
0aa6c35
remove SessionSerialFilterResource
Jul 16, 2019
db73cb6
WriteDataProcessor add TaskEvent log; Cache print task update
Jul 16, 2019
a022df3
data bugfix: snapshot must notify session
Jul 16, 2019
88eb3ec
Merge branch '20190716_bugfix_renew' of https://github.com/atellwu/so…
Jul 16, 2019
85b4e6a
fix SubscriberPushEmptyTask default implement
Jul 17, 2019
d2b307f
Merge pull request #5 from atellwu/renew_expired_strategy
Synex-wh Jul 17, 2019
9188f58
merge new
Jul 17, 2019
7e0d899
fix protect
Jul 19, 2019
aac48e2
1. When the pub of connectId is 0, no clearance action is triggered.
Jul 22, 2019
15ef70c
DataNodeExchanger: print but ignore if from renew module, cause renew…
Jul 22, 2019
d808a35
reduce log of renew
Jul 22, 2019
7f18a41
Merge branch 'mix_all_version' of https://github.com/Synex-wh/sofa-re…
Jul 22, 2019
2853738
data bugfix: Data coverage is also allowed when versions are equal. C…
Jul 22, 2019
88a9fd1
DatumCache bugfix: Index coverage should be updated after pubMap update
Jul 22, 2019
6243a78
Merge pull request #6 from atellwu/renew_expired_strategy
Synex-wh Jul 23, 2019
e8331b1
DatumSnapshotHandler: limit print; do not call dataChangeEventCenter.…
Jul 23, 2019
9f5137f
bugfix unpub npe (pub maybe already clean by DatumLeaseManager);LIMIT…
Jul 24, 2019
fc2964f
some code refactor
Jul 24, 2019
3edc382
Merge pull request #7 from atellwu/renew_expired_strategy
Synex-wh Jul 25, 2019
bd8c0d1
add code comment
Jul 25, 2019
3853bdc
Merge pull request #9 from Synex-wh/mix_all_version
atellwu Jul 26, 2019
79cd2ad
fix data working to init,and fix empty push version
Jul 26, 2019
4bfcb14
consider unpub is isWriteRequest, Reduce Snapshot frequency
Jul 26, 2019
2218f2c
RefreshUpdateTime is at the top, otherwise multiple snapshot can be i…
Jul 26, 2019
352c31d
update config: reduce retryTimes, increase delayTime, the purpose is …
Jul 26, 2019
5b119b2
put resume() in finally code block, avoid lock leak
Jul 26, 2019
c30a58d
modify renewDatumWheelTaskDelay and datumTimeToLiveSec
Jul 26, 2019
6cd814f
When session receives a connection and generates renew tasks, it rand…
Jul 26, 2019
44d93d7
Merge pull request #8 from atellwu/renew_expired_strategy
Synex-wh Jul 26, 2019
31cd224
data: add executor for handler
Jul 27, 2019
5ff3c3f
add get data log
Jul 29, 2019
7e8cf0d
snapshot and lastUpdateTimestamp: Specific to dataServerIP
Jul 30, 2019
e081036
Merge pull request #10 from Synex-wh/mix_all_version
atellwu Jul 30, 2019
8c57240
1. DataServer: RenewDatumHandler must return GenericResponse but not …
Aug 1, 2019
cbbf58a
Merge branch 'master' of https://github.com/Synex-wh/sofa-registry in…
Aug 1, 2019
8e93243
add logs
Aug 1, 2019
49d462b
1. dataServer: reduce log of snapshotHandler
Aug 1, 2019
8e76d79
dataServer: renew logic should delay for some time after status is WO…
Aug 1, 2019
289d6f2
bugfix bean; update log
Aug 1, 2019
fea0a2e
ignore renew request log
Aug 2, 2019
184fd77
fix UT
Aug 2, 2019
cd66da8
fix .travis.yml
Aug 2, 2019
8e2042b
Merge pull request #11 from atellwu/renew_expired_strategy
Synex-wh Aug 5, 2019
b12cb94
fix version 5.3.0-SNAPSHOT
Aug 5, 2019
788de7f
fix online notify connect error
Aug 9, 2019
003e487
Merge pull request #12 from Synex-wh/fix_online_connect
atellwu Aug 9, 2019
406067f
fix push confirm error,and fix datum update version,pub threadpool co…
Aug 29, 2019
7309bd7
fix push confirm error,and fix datum update version,pub threadpool co…
Synex-wh Aug 29, 2019
3065157
add switch renew and expire
Aug 30, 2019
3cae2f4
implement renew enable/disable switch
Aug 30, 2019
c3c2ca8
fix data client exechange log
Sep 2, 2019
0ef0e7f
fix datum fetch connect error
Sep 2, 2019
d34c851
bugfix CacheService: set version zero when first sub and get datum error
Sep 3, 2019
0d67f4c
fix clean task for fetch
Sep 4, 2019
e7e7270
merge
Sep 4, 2019
f1ef9ce
bugfix DatumCache: Forget to clean up the index in datumCache.putSnap…
Sep 5, 2019
89d18d0
Merge branch '20190905_bugfix_datumcache' of https://github.com/atell…
Sep 5, 2019
aaf1cd4
Session&Data increase WordCache use
Sep 13, 2019
75257c1
code optimize
Sep 14, 2019
fb39482
WordCache: registerId do not add WordCache
Sep 16, 2019
2af838e
fix fetch datum word cache
Sep 16, 2019
a4ee938
Merge branch 'add_renew_switch' of https://github.com/Synex-wh/sofa-r…
Sep 16, 2019
a18c92c
fix NotifyFetchDatumHandler npe
Sep 16, 2019
8083bce
fix test case time
Sep 23, 2019
a6d5d42
fix test cast
Sep 23, 2019
086ddd6
fix test case
Sep 23, 2019
e0c3315
merge master
Sep 23, 2019
932be4a
fix tast case
Sep 23, 2019
2fe9e64
fix ut case: StopPushDataSwitchTest
Sep 24, 2019
f34a80d
ut case:renew module
Sep 24, 2019
b4fc3bd
fix ut case:TempPublisherTest
Sep 24, 2019
568e90d
fix version,and merge new
Sep 24, 2019
d236a64
bugfix ut case: increase sleep time
Sep 24, 2019
c9f7f21
fix ut case:RenewTest
Sep 24, 2019
1aec70a
fix version and fix callback executor,fix log error
Sep 24, 2019
e351048
fix ut case:RenewTest format
Sep 24, 2019
da949d9
fix pom version
Sep 24, 2019
fad7057
fix ut case:do not run parallelly
Sep 24, 2019
b99312e
Merge branch 'update_master' of https://github.com/Synex-wh/sofa-regi…
Oct 8, 2019
bd95d6c
refactor providerdata process
Oct 10, 2019
827b48e
Memory optimization:Datum.processDatum
Oct 11, 2019
c4338f9
Merge remote-tracking branch 'remotes/origin/20190914_optimize' into …
Oct 11, 2019
ea7e952
Merge remote-tracking branch 'remotes/origin/20190914_optimize' into …
Oct 11, 2019
86a08b8
Merge remote-tracking branch 'origin_wh/new_snapshot' into new_snapshot
Oct 11, 2019
0e396d7
Merge branch 'new_snapshot' into refactor_providerdata_process
Synex-wh Oct 12, 2019
51d3568
add session notify test
Oct 28, 2019
af6b891
Merge branch 'new_snapshot' into refactor_providerdata_process
Oct 28, 2019
df07195
copy from mybank:
Oct 29, 2019
830a01c
Modify the deny policy of accessDataExecutor of SessionServer
Oct 30, 2019
840d8c6
remove useless code
Oct 31, 2019
81e76fe
fix call back
Nov 6, 2019
c087449
Merge branch 'refactor_providerdata_process' of https://github.com/Sy…
Nov 6, 2019
79f9167
fix meta methodhandle cache
Nov 11, 2019
5b1f784
fix push confirm success
Nov 21, 2019
0819714
Change the communication between session and data to multi connection
Nov 21, 2019
1fbde8a
Merge pull request #14 from Synex-wh/fix_push_confirm_success
atellwu Nov 21, 2019
e860816
Merge branch 'new_snapshot' of https://github.com/Synex-wh/sofa-regis…
Nov 21, 2019
5376da9
resolve compile error
Nov 21, 2019
41be2a0
fix processor
Nov 21, 2019
c0623d4
Merge pull request #15 from Synex-wh/fix_push_confirm_success
atellwu Nov 21, 2019
65b31df
Merge branch 'new_snapshot' of https://github.com/Synex-wh/sofa-regis…
Nov 21, 2019
5a7fce2
BoltClient: the creation of ConnectionEventAdapter should be inheritable
Nov 21, 2019
26faff7
fix currentTimeMillis product from source
Nov 27, 2019
4218e2a
add client Invalid check task
Nov 28, 2019
6a1b56d
use multiple RpcClient instances instead of one RpcClient with multip…
Nov 28, 2019
28201d3
refactor TaskListener and use map instead of list in DefaultTaskListe…
Nov 28, 2019
a65ffb9
DataChangeRequestHandler:optimize performance
Nov 28, 2019
f235e52
refactor: Heartbeat between session and data
Nov 29, 2019
0e1411b
fix: https://github.com/Synex-wh/sofa-registry/pull/20#pullrequestrev…
Nov 29, 2019
49f73f6
update
Nov 30, 2019
9da0d69
BoltClient use just one RpcClient;
Dec 1, 2019
aaa0bd4
SyncDataCallback reduce ThreadSize for saving cpu
Dec 1, 2019
045203c
reduce NOTIFY_SESSION_CALLBACK_EXECUTOR threadSize
Dec 1, 2019
3893906
Merge pull request #17 from Synex-wh/fix_meta_listversion
atellwu Dec 2, 2019
4aa559a
fix version in DataChangeFetchTask
Dec 2, 2019
a58e630
1. filter out the unPubs of datum when first put, Otherwise, "syncDat…
Dec 3, 2019
98c5782
Merge pull request #21 from Synex-wh/20191202_fix_version_in_fetchtask
Synex-wh Dec 6, 2019
c4d0c4f
Merge pull request #20 from Synex-wh/20191121_multiconn
Synex-wh Dec 6, 2019
63f3fe3
fix meta mem
Jan 21, 2020
1109fe0
merge master
Jan 21, 2020
6976891
fix test case
Jan 21, 2020
702d5b4
fix temp case
Jan 21, 2020
3f90359
fix syncConfigRetryInterval 60s
Jan 21, 2020
69f08ee
fix format
Synex-wh Jan 21, 2020
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
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>com.alipay.sofa</groupId>
<artifactId>registry-parent</artifactId>
<version>5.4.0-SNAPSHOT</version>
Expand Down Expand Up @@ -75,7 +75,7 @@
<lookout.version>1.5.2</lookout.version>
<mockito.version>1.10.19</mockito.version>
<powermock.version>1.6.6</powermock.version>
<jraft.version>1.2.5</jraft.version>
<jraft.version>1.2.7.beta1</jraft.version>
<metrics.version>4.0.2</metrics.version>
<commons-io.version>2.4</commons-io.version>
<jetty.version>[9.4.17.v20190418,9.4.19.v20190610]</jetty.version>
Expand All @@ -85,6 +85,11 @@

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>1.7.9</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Datum() {
* @param dataCenter
*/
public Datum(String dataInfoId, String dataCenter) {
this.dataInfoId = dataInfoId;
this.dataInfoId = WordCache.getInstance().getWordCache(dataInfoId);
this.dataCenter = WordCache.getInstance().getWordCache(dataCenter);
updateVersion();
}
Expand Down Expand Up @@ -244,7 +244,7 @@ public void setContainsUnPub(boolean containsUnPub) {
this.containsUnPub = containsUnPub;
}

public static Datum processDatum(Datum datum) {
public static Datum internDatum(Datum datum) {
datum.setDataCenter(datum.getDataCenter());
datum.setDataInfoId(datum.getDataInfoId());
datum.setDataId(datum.getDataId());
Expand All @@ -253,7 +253,13 @@ public static Datum processDatum(Datum datum) {

Map<String, Publisher> pubMap = datum.getPubMap();
if (pubMap != null && !pubMap.isEmpty()) {
pubMap.forEach((registerId, publisher) -> Publisher.processPublisher(publisher));
pubMap.forEach((registerId, publisher) -> {
// let registerId == pub.getRegisterId in every <registerId, pub>, for reducing old gen memory
// because this Datum is put into Memory directly, by DatumCache.coverDatum
publisher.setRegisterId(registerId);
// change publisher word cache
Publisher.internPublisher(publisher);
});
}

return datum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
*/
package com.alipay.sofa.registry.common.model.store;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
*
* @author shangyu.wh
Expand Down Expand Up @@ -136,7 +136,7 @@ public String getProcessId() {
* @param processId value to be assigned to property processId
*/
public void setProcessId(String processId) {
this.processId = processId;
this.processId = WordCache.getInstance().getWordCache(processId);
}

/**
Expand Down Expand Up @@ -273,7 +273,7 @@ public String getClientId() {
* @param clientId value to be assigned to property clientId
*/
public void setClientId(String clientId) {
this.clientId = clientId;
this.clientId = WordCache.getInstance().getWordCache(clientId);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
*/
package com.alipay.sofa.registry.common.model.store;

import java.util.List;

import com.alipay.sofa.registry.common.model.PublishType;
import com.alipay.sofa.registry.common.model.ServerDataBox;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.util.List;

/**
*
* @author shangyu.wh
Expand Down Expand Up @@ -90,8 +90,8 @@ protected String getOtherInfo() {
* @param publisher
* @return
*/
public static Publisher processPublisher(Publisher publisher) {

public static Publisher internPublisher(Publisher publisher) {
publisher.setRegisterId(publisher.getRegisterId());
publisher.setDataInfoId(publisher.getDataInfoId());
publisher.setInstanceId(publisher.getInstanceId());
publisher.setGroup(publisher.getGroup());
Expand All @@ -101,13 +101,6 @@ public static Publisher processPublisher(Publisher publisher) {
publisher.setProcessId(publisher.getProcessId());
publisher.setAppName(publisher.getAppName());

if (publisher.getSourceAddress() != null) {
publisher.setSourceAddress(new URL(publisher.getSourceAddress().getIpAddress(),
publisher.getSourceAddress().getPort()));
}

publisher.setAttributes(publisher.getAttributes());

return publisher;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
*/
package com.alipay.sofa.registry.common.model.store;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.alipay.sofa.registry.common.model.ElementType;
import com.alipay.sofa.registry.common.model.constants.ValueConstants;
import com.alipay.sofa.registry.core.model.ScopeEnum;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
*
* @author shangyu.wh
Expand All @@ -31,16 +32,16 @@
public class Subscriber extends BaseInfo {

/** UID */
private static final long serialVersionUID = 98433360274932292L;
private static final long serialVersionUID = 98433360274932292L;
/** */
private ScopeEnum scope;
private ScopeEnum scope;
/** */
private ElementType elementType;
private ElementType elementType;

/**
* all dataCenter push dataInfo version
* last push context
*/
private Map<String/*dataCenter*/, Long> lastPushVersions = new ConcurrentHashMap<>();
private Map<String/*dataCenter*/, PushContext> lastPushContexts = new ConcurrentHashMap<>();

/**
* Getter method for property <tt>scope</tt>.
Expand Down Expand Up @@ -71,7 +72,11 @@ public ElementType getElementType() {
*/
public boolean checkVersion(String dataCenter, Long version) {

Long oldVersion = lastPushVersions.get(dataCenter);
PushContext lastPushContext = lastPushContexts.get(dataCenter);
if (lastPushContext == null) {
return version != null;
}
Long oldVersion = lastPushContext.pushVersion;
if (oldVersion == null) {
return version != null;
} else {
Expand All @@ -88,15 +93,26 @@ public boolean checkVersion(String dataCenter, Long version) {
* @return
*/
public void checkAndUpdateVersion(String dataCenter, Long version) {
checkAndUpdateVersion(dataCenter, version, -1);
}

/**
* check version input greater or equal to current version
* @param version
* @return
*/
public void checkAndUpdateVersion(String dataCenter, Long version, int pubCount) {

while (true) {
Long oldVersion = lastPushVersions.putIfAbsent(dataCenter, version);
PushContext pushContext = new PushContext(version, pubCount);
PushContext oldPushContext = lastPushContexts.putIfAbsent(dataCenter, pushContext);
// Add firstly
if (oldVersion == null) {
if (oldPushContext == null) {
break;
} else {
if (version > oldVersion) {
if (lastPushVersions.replace(dataCenter, oldVersion, version)) {
if (oldPushContext.pushVersion == null
|| (pushContext.pushVersion != null && pushContext.pushVersion > oldPushContext.pushVersion)) {
if (lastPushContexts.replace(dataCenter, oldPushContext, pushContext)) {
break;
}
} else {
Expand All @@ -106,6 +122,23 @@ public void checkAndUpdateVersion(String dataCenter, Long version) {
}
}

/**
* If the pushed data is empty, check the last push, for avoid continuous empty datum push
*/
public boolean allowPush(String dataCenter, int pubCount) {
boolean allowPush = true;
// condition of no push:
// 1. last push count is 0 and this time is also 0
// 2. last push is a valid push (version > 1)
if (pubCount == 0) {
PushContext pushContext = lastPushContexts.get(dataCenter);
allowPush = !(pushContext != null && pushContext.pushPubCount == 0
//last push is a valid push
&& pushContext.pushVersion != null && pushContext.pushVersion > ValueConstants.DEFAULT_NO_DATUM_VERSION);
}
return allowPush;
}

/**
* Setter method for property <tt>elementType</tt>.
*
Expand All @@ -126,28 +159,10 @@ protected String getOtherInfo() {
final StringBuilder sb = new StringBuilder("scope=");
sb.append(scope).append(",");
sb.append("elementType=").append(elementType).append(",");
sb.append("lastPushVersion=").append(lastPushVersions);
sb.append("pushVersion=").append(lastPushContexts);
return sb.toString();
}

/**
* Getter method for property <tt>lastPushVersions</tt>.
*
* @return property value of lastPushVersions
*/
public Map<String, Long> getLastPushVersions() {
return lastPushVersions;
}

/**
* Setter method for property <tt>lastPushVersions </tt>.
*
* @param lastPushVersions value to be assigned to property lastPushVersions
*/
public void setLastPushVersions(Map<String, Long> lastPushVersions) {
this.lastPushVersions = lastPushVersions;
}

/**
* @see Object#toString()
*/
Expand All @@ -156,9 +171,57 @@ public String toString() {
final StringBuilder sb = new StringBuilder("Subscriber{");
sb.append("scope=").append(scope);
sb.append(", elementType=").append(elementType);
sb.append(", lastPushVersions=").append(lastPushVersions);
sb.append(", lastPushContexts=").append(lastPushContexts);
sb.append(", super=").append(super.toString());
sb.append('}');
return sb.toString();
}

/**
* change subscriber word cache
* @param subscriber
* @return
*/
public static Subscriber internSubscriber(Subscriber subscriber) {
subscriber.setRegisterId(subscriber.getRegisterId());
subscriber.setDataInfoId(subscriber.getDataInfoId());
subscriber.setInstanceId(subscriber.getInstanceId());
subscriber.setGroup(subscriber.getGroup());
subscriber.setDataId(subscriber.getDataId());
subscriber.setClientId(subscriber.getClientId());
subscriber.setCell(subscriber.getCell());
subscriber.setProcessId(subscriber.getProcessId());
subscriber.setAppName(subscriber.getAppName());

return subscriber;
}

static class PushContext {
/**
* last pushed dataInfo version
*/
private Long pushVersion;

/**
* push pushed dataInfo pubCount
*/
private int pushPubCount;

public PushContext(Long pushVersion, int pushPubCount) {
this.pushVersion = pushVersion;
this.pushPubCount = pushPubCount;
}

/**
* @see Object#toString()
*/
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("PushContext{");
sb.append("pushVersion=").append(pushVersion);
sb.append(", pushPubCount=").append(pushPubCount);
sb.append('}');
return sb.toString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,23 @@ public class Watcher extends BaseInfo {
public DataType getDataType() {
return DataType.WATCHER;
}

/**
* change watcher word cache
* @param watcher
* @return
*/
public static Watcher internWatcher(Watcher watcher) {
watcher.setRegisterId(watcher.getRegisterId());
watcher.setDataInfoId(watcher.getDataInfoId());
watcher.setInstanceId(watcher.getInstanceId());
watcher.setGroup(watcher.getGroup());
watcher.setDataId(watcher.getDataId());
watcher.setClientId(watcher.getClientId());
watcher.setCell(watcher.getCell());
watcher.setProcessId(watcher.getProcessId());
watcher.setAppName(watcher.getAppName());

return watcher;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
*/
package com.alipay.sofa.registry.common.model.store;

import java.util.concurrent.ConcurrentHashMap;
import com.google.common.collect.Interner;
import com.google.common.collect.Interners;

/**
*
Expand Down Expand Up @@ -45,7 +46,7 @@ public static WordCache getInstance() {
/**
* word cache map
*/
private ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
private Interner<String> interners = Interners.newWeakInterner();

/**
*
Expand All @@ -56,8 +57,7 @@ public String getWordCache(String s) {
if (s == null) {
return null;
}
String oldValue = map.putIfAbsent(s, s);
return oldValue == null ? s : oldValue;
return interners.intern(s);
}

}
Loading