Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
Choose a Base Repository
belaban/JGroups
AbooJan/JGroups
AngeloJ/JGroups
AravindaM/JGroups
Argun/JGroups
ChinaLongGanHu/JGroups
Clamatius/JGroups
CliffYuan/JGroups
DustinGuoSZ/JGroups
FutureElement/JGroups
GavinHwa/JGroups
KennyZhu/JGroups
KnisterPeter/JGroups
MatiasSM/JGroups
PaulMuriithi/JGroups
PengJian/JGroups
Preston-Crary/JGroups
Sanne/JGroups
TarantulaTechnology/JGroups
Toexplore/JGroups
TomasHofman/JGroups
UniqueOne/JGroups
VoxeoDipen/JGroups
WilliamRen/JGroups
WolverineFan/JGroups
achun2080/JGroups
akilman-zz/JGroups
alanfx/JGroups
alesj/JGroups
alexvinn/JGroups
amukas/JGroups
an1310/JGroups
anddegs/JGroups
andreabattaglia/JGroups
anistor/JGroups
anujshahwork/JGroups
arbetts/JGroups
backoffbelief/JGroups
bbrowning/JGroups
bcuts/JGroups
bdecoste/JGroups
bertrama/JGroups
bjc-world/JGroups
blcjgroups/JGroups
bob329/JGroups
boryaku/JGroups
bossmc/JGroups
brat000012001/JGroups
calohmn/JGroups
ccorsi/JGroups
cdwijayarathna/JGroups
chamika/JGroups
chinpeng/JGroups
cloudtm/JGroups
coderhome/JGroups
coderunner/JGroups
conquerb/JGroups
cyzhao/JGroups
danberindei/JGroups
deepnarsay/JGroups
dereed/JGroups
dimbleby/JGroups
djeremiah/JGroups
djsamith/JGroups
dobermai/JGroups
dvanbalen/JGroups
eax/JGroups
eclectice/JGroups
edwardt/JGroups
erwink/JGroups
fallen/JGroups
fbelzunc/JGroups
feijian8/JGroups
fengmy/JGroups
flashboss/JGroups
free83/JGroups
fyg1987630/JGroups
gabikliot/JGroups
galderz/JGroups
gaohoward/JGroups
glycerine/JGroups
godkillCK/JGroups
greco/JGroups
guoshun0321/JGroups
gustavonalle/JGroups
harprit/JGroups
hengzhang/JGroups
hhqqnu/JGroups
hopeful/JGroups
hpdrago/JGroups
huanglz/JGroups
ibrahimshbat/JGroupsOld
inael/JGroups
is00hcw/JGroups
isavin/JGroups
jacques-n/JGroups
javaczhang/JGroups
jbedalov/JGroups
jdrider/JGroups
jinpeng309/JGroups
jiwils/JGroups
jkrizanic/JGroups
jmason-jboss/JGroups
jnan77/JGroups
johnou/JGroups
jtoerber/JGroups
julia-wei/JGroups
justinsb/JGroups
jwhgithub/JGroups
jycr753/JGroups
kammous/JGroups
kaulie/JGroups
kedzie/JGroups
keithlynch/JGroups
knrc/JGroups
kob-aha/JGroups
ksimatov/JGroups
ledkk/JGroups
lidi100/JGroups
ligzy/JGroups
lipusz/JGroups
lucifer545/JGroups
luksa/JGroups
luorongchun/JGroups
lwang5tekcomms/JGroups
maeste/JGroups
marschall/JGroups
mcimbora/JGroups
messages/JGroups
mlinhard/JGroups
mpecan/JGroups
mposolda/JGroups
mreines/JGroups
mukkaravamsiprasad/JGroups
mveligeti/JGroups
nareshmiriyala/JGroups
navssurtani/JGroups
nekop/JGroups
neutrospec/JGroups
ngocthobknd/JGroups
nickmbailey/JGroups
nicolas-raoul/JGroups
onagano-rh/JGroups
palacsint/JGroups
palmalcheg/JGroups
panossot/JGroups
pchlupacek/JGroups
pferraro/JGroups
pgaref/JGroups
phaas/JGroups
pimenas/JGroups
prasantmohanty/JGroups
pruivo/JGroups
pulasthi/JGroups
rachmatowicz/JGroups
randythomas/JGroups
rhusar/jgroups
rocketraman/JGroups
rpelisse/JGroups
rvansa/JGroups
ryanemerson/JGroups-HiTab
sabina2014/JGroups
saturnism/JGroups
sbjsbj/JGroups
scottmarlow/JGroups
simatic/JGroups
since2014/JGroups
slaskawi/JGroups
spinkb/JGroups
stevepilot/JGroups
talex004/JGroups
tanbamboo/JGroups
tedwon/JGroups
tepitebson/JGroups
tinatian/JGroups
todotobe1/JGroups
triggetry/JGroups
tristantarrant/JGroups
tuxmonteiro/JGroups
tuyu/JGroups
ubregar/JGroups
vasilev/JGroups
vblagoje/JGroups
vedab/JGroups
vjuranek/JGroups
wangshengli/JGroups
wburns/JGroups
wharry/JGroups
whysqwhw/JGroups
wxynick/JGroups
xiangxuner/JGroups
xiongrl/JGroups
xsr1001/JGroups
xuzhikethinker/JGroups
xy8864/JGroups
yaoqi/JGroups
yin-bp/JGroups
zhaog/JGroups
zhujinfei5151/JGroups
zy2007qingdao/JGroups
Nothing to show
Choose a base branch
3.3
3.4
3.4.3
3.5
3.6
3.6.12
BRANCH_JGROUPS_2_2_8_JDK_1_3_CDC
BRANCH_JGROUPS_2_2_9_1_CDC
Branch_JG_2_2_1
Branch_JG_2_2_7_SOLOMIO_3231
Branch_JGroups_2_2_7
Branch_JGroups_2_2_9_1
Branch_JGroups_2_3
Branch_JGroups_2_4
Branch_JGroups_2_5
Branch_JGroups_2_6
Branch_JGroups_2_7
Branch_JGroups_2_8_LogicalAddresses
Branch_JGroups_2_8
Branch_JGroups_2_9
Branch_JGroups_2_10
Branch_JGroups_2_11
Branch_JGroups_2_12
Branch_JGroups_3_0
Branch_JGroups_3_2
Branch_2_8_temp
JGROUPS_2_2_8
JGRP-1396-2
JGRP-1396
JGRP-1401
JGRP-1407
JGRP-1411
JGRP-1412
JGRP-1413
JGRP-1416
JGRP-1417
JGRP-1428
JGRP-1433
JGRP-1441
JGRP-1443
JGRP-1444
JGRP-1449.reopen
JGRP-1451
JGRP-1455
JGRP-1461
JGRP-1466
JGRP-1468
JGRP-1475
JGRP-1484
JGRP-1502
JGRP-1508
JGRP-1528
JGRP-1539
JGRP-1542
JGRP-1547
JGRP-1551
JGRP-1555
JGRP-1557
JGRP-1564
JGRP-1581
JGRP-1587
JGRP-1588
JGRP-1599
JGRP-1603
JGRP-1632
JGRP-1649
JGRP-1660
JGRP-1662
JGRP-1675
JGRP-1687
JGRP-1710
JGRP-1716
JGRP-1742
JGRP-1789
JGRP-1821
JGRP-1877
JGRP-2065
JGRP-2110
JGRP-2138
JGRP-2143
JGRP-2171
JGRP-2208
JGRP-2218.msg
JGRP-2218
JGRP-2219
JGroups_2_4_5_GA_JGRP-983
JGroups_2_4_5_GA_JGRP-1000
JGroups_2_4_5_GA_JGRP-1060
JGroups_2_4_5_GA_JGRP_549
JGroups_2_4_7_GA_JGRP-1207
JGroups_2_4_7_GA_JGRP-1279_JGRP-1311
JGroups_2_4_7_GA_JGRP-1279
JGroups_2_4_10_Final_JGRP-1382
JGroups_2_6_13_GA_JGRP-1205_JGRP-1282
JGroups_2_6_13_GA_JGRP-1228
JGroups_2_6_16_JGRP-1205_JGRP-1254
JGroups_2_6_16_JGRP-1205
JGroups_2_6_16_JGRP-1383
JGroups_2_6_19_GA_JGRP-1383
JGroups_2_6_20_JGRP-1383_JGRP-1497
JGroups_2_6_20_JGRP-1383
bunder_perf_cclq
bundler_perf
cache-details
daisy
hpdrago-prio
ids
jctools
jdg_regression
master_with_javadoc
master
mfc2
newdoc
origin
revert-156-fd-host-falsesuspect
t_jgrp_1007
testng
treemesh
uuperf
Nothing to show
...
Choose a Head Repository
belaban/JGroups
AbooJan/JGroups
AngeloJ/JGroups
AravindaM/JGroups
Argun/JGroups
ChinaLongGanHu/JGroups
Clamatius/JGroups
CliffYuan/JGroups
DustinGuoSZ/JGroups
FutureElement/JGroups
GavinHwa/JGroups
KennyZhu/JGroups
KnisterPeter/JGroups
MatiasSM/JGroups
PaulMuriithi/JGroups
PengJian/JGroups
Preston-Crary/JGroups
Sanne/JGroups
TarantulaTechnology/JGroups
Toexplore/JGroups
TomasHofman/JGroups
UniqueOne/JGroups
VoxeoDipen/JGroups
WilliamRen/JGroups
WolverineFan/JGroups
achun2080/JGroups
akilman-zz/JGroups
alanfx/JGroups
alesj/JGroups
alexvinn/JGroups
amukas/JGroups
an1310/JGroups
anddegs/JGroups
andreabattaglia/JGroups
anistor/JGroups
anujshahwork/JGroups
arbetts/JGroups
backoffbelief/JGroups
bbrowning/JGroups
bcuts/JGroups
bdecoste/JGroups
bertrama/JGroups
bjc-world/JGroups
blcjgroups/JGroups
bob329/JGroups
boryaku/JGroups
bossmc/JGroups
brat000012001/JGroups
calohmn/JGroups
ccorsi/JGroups
cdwijayarathna/JGroups
chamika/JGroups
chinpeng/JGroups
cloudtm/JGroups
coderhome/JGroups
coderunner/JGroups
conquerb/JGroups
cyzhao/JGroups
danberindei/JGroups
deepnarsay/JGroups
dereed/JGroups
dimbleby/JGroups
djeremiah/JGroups
djsamith/JGroups
dobermai/JGroups
dvanbalen/JGroups
eax/JGroups
eclectice/JGroups
edwardt/JGroups
erwink/JGroups
fallen/JGroups
fbelzunc/JGroups
feijian8/JGroups
fengmy/JGroups
flashboss/JGroups
free83/JGroups
fyg1987630/JGroups
gabikliot/JGroups
galderz/JGroups
gaohoward/JGroups
glycerine/JGroups
godkillCK/JGroups
greco/JGroups
guoshun0321/JGroups
gustavonalle/JGroups
harprit/JGroups
hengzhang/JGroups
hhqqnu/JGroups
hopeful/JGroups
hpdrago/JGroups
huanglz/JGroups
ibrahimshbat/JGroupsOld
inael/JGroups
is00hcw/JGroups
isavin/JGroups
jacques-n/JGroups
javaczhang/JGroups
jbedalov/JGroups
jdrider/JGroups
jinpeng309/JGroups
jiwils/JGroups
jkrizanic/JGroups
jmason-jboss/JGroups
jnan77/JGroups
johnou/JGroups
jtoerber/JGroups
julia-wei/JGroups
justinsb/JGroups
jwhgithub/JGroups
jycr753/JGroups
kammous/JGroups
kaulie/JGroups
kedzie/JGroups
keithlynch/JGroups
knrc/JGroups
kob-aha/JGroups
ksimatov/JGroups
ledkk/JGroups
lidi100/JGroups
ligzy/JGroups
lipusz/JGroups
lucifer545/JGroups
luksa/JGroups
luorongchun/JGroups
lwang5tekcomms/JGroups
maeste/JGroups
marschall/JGroups
mcimbora/JGroups
messages/JGroups
mlinhard/JGroups
mpecan/JGroups
mposolda/JGroups
mreines/JGroups
mukkaravamsiprasad/JGroups
mveligeti/JGroups
nareshmiriyala/JGroups
navssurtani/JGroups
nekop/JGroups
neutrospec/JGroups
ngocthobknd/JGroups
nickmbailey/JGroups
nicolas-raoul/JGroups
onagano-rh/JGroups
palacsint/JGroups
palmalcheg/JGroups
panossot/JGroups
pchlupacek/JGroups
pferraro/JGroups
pgaref/JGroups
phaas/JGroups
pimenas/JGroups
prasantmohanty/JGroups
pruivo/JGroups
pulasthi/JGroups
rachmatowicz/JGroups
randythomas/JGroups
rhusar/jgroups
rocketraman/JGroups
rpelisse/JGroups
rvansa/JGroups
ryanemerson/JGroups-HiTab
sabina2014/JGroups
saturnism/JGroups
sbjsbj/JGroups
scottmarlow/JGroups
simatic/JGroups
since2014/JGroups
slaskawi/JGroups
spinkb/JGroups
stevepilot/JGroups
talex004/JGroups
tanbamboo/JGroups
tedwon/JGroups
tepitebson/JGroups
tinatian/JGroups
todotobe1/JGroups
triggetry/JGroups
tristantarrant/JGroups
tuxmonteiro/JGroups
tuyu/JGroups
ubregar/JGroups
vasilev/JGroups
vblagoje/JGroups
vedab/JGroups
vjuranek/JGroups
wangshengli/JGroups
wburns/JGroups
wharry/JGroups
whysqwhw/JGroups
wxynick/JGroups
xiangxuner/JGroups
xiongrl/JGroups
xsr1001/JGroups
xuzhikethinker/JGroups
xy8864/JGroups
yaoqi/JGroups
yin-bp/JGroups
zhaog/JGroups
zhujinfei5151/JGroups
zy2007qingdao/JGroups
Nothing to show
Choose a head branch
3.3
3.4
3.4.3
3.5
3.6
3.6.12
BRANCH_JGROUPS_2_2_8_JDK_1_3_CDC
BRANCH_JGROUPS_2_2_9_1_CDC
Branch_JG_2_2_1
Branch_JG_2_2_7_SOLOMIO_3231
Branch_JGroups_2_2_7
Branch_JGroups_2_2_9_1
Branch_JGroups_2_3
Branch_JGroups_2_4
Branch_JGroups_2_5
Branch_JGroups_2_6
Branch_JGroups_2_7
Branch_JGroups_2_8_LogicalAddresses
Branch_JGroups_2_8
Branch_JGroups_2_9
Branch_JGroups_2_10
Branch_JGroups_2_11
Branch_JGroups_2_12
Branch_JGroups_3_0
Branch_JGroups_3_2
Branch_2_8_temp
JGROUPS_2_2_8
JGRP-1396-2
JGRP-1396
JGRP-1401
JGRP-1407
JGRP-1411
JGRP-1412
JGRP-1413
JGRP-1416
JGRP-1417
JGRP-1428
JGRP-1433
JGRP-1441
JGRP-1443
JGRP-1444
JGRP-1449.reopen
JGRP-1451
JGRP-1455
JGRP-1461
JGRP-1466
JGRP-1468
JGRP-1475
JGRP-1484
JGRP-1502
JGRP-1508
JGRP-1528
JGRP-1539
JGRP-1542
JGRP-1547
JGRP-1551
JGRP-1555
JGRP-1557
JGRP-1564
JGRP-1581
JGRP-1587
JGRP-1588
JGRP-1599
JGRP-1603
JGRP-1632
JGRP-1649
JGRP-1660
JGRP-1662
JGRP-1675
JGRP-1687
JGRP-1710
JGRP-1716
JGRP-1742
JGRP-1789
JGRP-1821
JGRP-1877
JGRP-2065
JGRP-2110
JGRP-2138
JGRP-2143
JGRP-2171
JGRP-2208
JGRP-2218.msg
JGRP-2218
JGRP-2219
JGroups_2_4_5_GA_JGRP-983
JGroups_2_4_5_GA_JGRP-1000
JGroups_2_4_5_GA_JGRP-1060
JGroups_2_4_5_GA_JGRP_549
JGroups_2_4_7_GA_JGRP-1207
JGroups_2_4_7_GA_JGRP-1279_JGRP-1311
JGroups_2_4_7_GA_JGRP-1279
JGroups_2_4_10_Final_JGRP-1382
JGroups_2_6_13_GA_JGRP-1205_JGRP-1282
JGroups_2_6_13_GA_JGRP-1228
JGroups_2_6_16_JGRP-1205_JGRP-1254
JGroups_2_6_16_JGRP-1205
JGroups_2_6_16_JGRP-1383
JGroups_2_6_19_GA_JGRP-1383
JGroups_2_6_20_JGRP-1383_JGRP-1497
JGroups_2_6_20_JGRP-1383
bunder_perf_cclq
bundler_perf
cache-details
daisy
hpdrago-prio
ids
jctools
jdg_regression
master_with_javadoc
master
mfc2
newdoc
origin
revert-156-fd-host-falsesuspect
t_jgrp_1007
testng
treemesh
uuperf
Nothing to show
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
Commits on Oct 19, 2011
@@ -40,9 +40,15 @@
@Property(description="Leave timeout")
long leave_timeout=5000;
- @Property(description="Timeout to complete merge")
+ @Property(description="Timeout (in ms) to complete merge")
long merge_timeout=5000; // time to wait for all MERGE_RSPS
+ @Property(description="Max time (in ms) a merge is allowed to run before it will be force-killed")
+ protected long max_merge_time=2 * 60 * 1000; // 2 minutes by default
+
+ @Property(description="Interval (in ms) the MergeKiller task runs at, must be less than max_merge_time. 0 disables it.")
+ protected long merge_killer_task_timeout=60 * 1000;
+
@Property(description="Print local address of this member after connect. Default is true")
private boolean print_local_addr=true;
@@ -108,6 +114,8 @@
// Handles merge related tasks
final Merger merger=new Merger(this, log);
+
+ protected Future<?> merge_killer;
protected Address local_addr=null;
protected final Membership members=new Membership(); // real membership
@@ -159,12 +167,16 @@ public GMS() {
public int getNumMembers() {return members.size();}
public long getJoinTimeout() {return join_timeout;}
public void setJoinTimeout(long t) {join_timeout=t;}
+ public long getMergeTimeout() {return merge_timeout;}
+ public void setMergeTimeout(long timeout) {merge_timeout=timeout;}
- public long getMergeTimeout() {
- return merge_timeout;
+ @ManagedAttribute(description="Whether the merge killer task is running")
+ public boolean getMergeKillerRunning() {
+ return !(merge_killer.isCancelled() || merge_killer.isDone());
}
- public void setMergeTimeout(long timeout) {merge_timeout=timeout;}
+ @ManagedAttribute(description="Stringified version of merge_id")
+ public String getMergeIdAsString() {return merger.getMergeIdAsString();}
@ManagedOperation
public String printPreviousMembers() {
@@ -318,10 +330,26 @@ public void init() throws Exception {
}
public void start() throws Exception {
- if(impl != null) impl.start();
+ if(impl != null) impl.start();
+ if(merge_killer_task_timeout > 0) {
+ merge_killer=timer.scheduleWithFixedDelay(new Runnable() {
+ public void run() {
+ long timestamp=merger.getMergeIdTimestamp();
+ if(timestamp > 0) {
+ long diff=System.currentTimeMillis() - timestamp;
+ if(diff >= max_merge_time) {
+ if(merger.forceCancelMerge())
+ log.warn("force-cancelled merge task after " + diff + " ms");
+ }
+ }
+ }
+ }, merge_killer_task_timeout, merge_killer_task_timeout, TimeUnit.MILLISECONDS);
+ }
}
public void stop() {
+ if(merge_killer != null)
+ merge_killer.cancel(true);
view_handler.stop(true);
if(impl != null) impl.stop();
if(prev_members != null)
@@ -387,6 +415,15 @@ public void fixDigests() {
((CoordGmsImpl)impl).fixDigests();
}
+ @ManagedOperation(description="Forces cancellation of current merge task")
+ public boolean cancelMerge() {
+ boolean result=merger.forceCancelMerge();
+ if(log.isDebugEnabled()) {
+ log.debug(result? "Merge was cancelled" : "There was no merge to be cancelled");
+ }
+ return result;
+ }
+
/**
* Computes the next view. Returns a copy that has <code>old_mbrs</code> and
* <code>suspected_mbrs</code> removed and <code>new_mbrs</code> added.
@@ -34,6 +34,11 @@
@GuardedBy("merge_lock")
private MergeId merge_id=null;
+ /** Timestamp when the last merge was started, ie. merge_id was set. Used by the merge canceller
+ (see https://issues.jboss.org/browse/JGRP-1377) */
+ @GuardedBy("merge_lock")
+ protected long merge_id_timestamp=0;
+
@GuardedBy("merge_canceller_lock")
private Future<?> merge_canceller_future=null;
@@ -45,6 +50,12 @@ public Merger(GMS gms, Log log) {
this.log=log;
}
+ public String getMergeIdAsString() {return merge_id != null? merge_id.toString() : null;}
+
+ public long getMergeIdTimestamp() {
+ return merge_id_timestamp;
+ }
+
/**
* Invoked upon receiving a MERGE event from the MERGE layer. Starts the merge protocol.
@@ -166,17 +177,20 @@ public void handleMergeView(final MergeData data,final MergeId merge_id) {
List<Address> newViewMembers=new ArrayList<Address>(data.view.getMembers());
newViewMembers.removeAll(gms.members.getMembers());
-
- gms.castViewChangeWithDest(data.view, data.digest, null, newViewMembers);
- // if we have flush in stack send ack back to merge coordinator
- if(gms.flushProtocolInStack) {
- Message ack=new Message(data.getSender(), null, null);
- ack.setFlag(Message.OOB);
- GMS.GmsHeader ack_hdr=new GMS.GmsHeader(GMS.GmsHeader.INSTALL_MERGE_VIEW_OK);
- ack.putHeader(gms.getId(), ack_hdr);
- gms.getDownProtocol().down(new Event(Event.MSG, ack));
+ try {
+ gms.castViewChangeWithDest(data.view, data.digest, null, newViewMembers);
+ // if we have flush in stack send ack back to merge coordinator
+ if(gms.flushProtocolInStack) {
+ Message ack=new Message(data.getSender(), null, null);
+ ack.setFlag(Message.OOB);
+ GMS.GmsHeader ack_hdr=new GMS.GmsHeader(GMS.GmsHeader.INSTALL_MERGE_VIEW_OK);
+ ack.putHeader(gms.getId(), ack_hdr);
+ gms.getDownProtocol().down(new Event(Event.MSG, ack));
+ }
+ }
+ finally {
+ cancelMerge(merge_id);
}
- cancelMerge(merge_id);
}
public void handleMergeCancelled(MergeId merge_id) {
@@ -391,21 +405,35 @@ void stop() {
}
- void cancelMerge(MergeId id) {
+ boolean cancelMerge(MergeId id) {
if(setMergeId(id, null)) {
merge_task.stop();
merge_rsps.reset();
gms.getViewHandler().resume(id);
+ return true;
}
+ return false;
}
- private boolean setMergeId(MergeId expected, MergeId new_value) {
+ boolean forceCancelMerge() {
+ merge_lock.lock();
+ try {
+ return this.merge_id != null && cancelMerge(this.merge_id);
+ }
+ finally {
+ merge_lock.unlock();
+ }
+ }
+
+
+ boolean setMergeId(MergeId expected, MergeId new_value) {
merge_lock.lock();
try {
boolean match=Util.match(this.merge_id, expected);
if(match) {
this.merge_id=new_value;
+ this.merge_id_timestamp=new_value == null? 0 : System.currentTimeMillis();
stopMergeCanceller();
if(this.merge_id != null)
startMergeCanceller();
@@ -453,7 +481,7 @@ private void startMergeCanceller() {
try {
if(merge_canceller_future == null || merge_canceller_future.isDone()) {
MergeCanceller task=new MergeCanceller(this.merge_id);
- merge_canceller_future=gms.timer.schedule(task, (long)(gms.merge_timeout * 1.5), TimeUnit.MILLISECONDS);
+ merge_canceller_future=gms.timer.schedule(task, (long)(gms.merge_timeout * 2), TimeUnit.MILLISECONDS);
}
}
finally {
@@ -496,35 +524,36 @@ private void stopMergeCanceller() {
* @param views Guaranteed to be non-null and to have >= 2 members, or else this thread would not be started
*/
public synchronized void start(Map<Address, View> views) {
- if(thread == null || thread.isAlive()) {
- this.coords.clear();
+ if(thread != null && thread.isAlive()) // the merge thread is already running
+ return;
- // now remove all members which don't have us in their view, so RPCs won't block (e.g. FLUSH)
- // https://jira.jboss.org/browse/JGRP-1061
- sanitizeViews(views);
-
- // Add all different coordinators of the views into the hashmap and sets their members:
- Collection<Address> coordinators=Util.determineMergeCoords(views);
- for(Address coord: coordinators) {
- View view=views.get(coord);
- if(view != null)
- this.coords.put(coord, new ArrayList<Address>(view.getMembers()));
- }
+ this.coords.clear();
- // For the merge participants which are not coordinator, we simply add them, and the associated
- // membership list consists only of themselves
- Collection<Address> merge_participants=Util.determineMergeParticipants(views);
- merge_participants.removeAll(coordinators);
- for(Address merge_participant: merge_participants) {
- Collection<Address> tmp=new ArrayList<Address>();
- tmp.add(merge_participant);
- coords.putIfAbsent(merge_participant, tmp);
- }
+ // now remove all members which don't have us in their view, so RPCs won't block (e.g. FLUSH)
+ // https://jira.jboss.org/browse/JGRP-1061
+ sanitizeViews(views);
+
+ // Add all different coordinators of the views into the hashmap and sets their members:
+ Collection<Address> coordinators=Util.determineMergeCoords(views);
+ for(Address coord: coordinators) {
+ View view=views.get(coord);
+ if(view != null)
+ this.coords.put(coord, new ArrayList<Address>(view.getMembers()));
+ }
- thread=gms.getThreadFactory().newThread(this, "MergeTask");
- thread.setDaemon(true);
- thread.start();
+ // For the merge participants which are not coordinator, we simply add them, and the associated
+ // membership list consists only of themselves
+ Collection<Address> merge_participants=Util.determineMergeParticipants(views);
+ merge_participants.removeAll(coordinators);
+ for(Address merge_participant: merge_participants) {
+ Collection<Address> tmp=new ArrayList<Address>();
+ tmp.add(merge_participant);
+ coords.putIfAbsent(merge_participant, tmp);
}
+
+ thread=gms.getThreadFactory().newThread(this, "MergeTask");
+ thread.setDaemon(true);
+ thread.start();
}
@@ -579,6 +608,7 @@ public void run() {
if(log.isWarnEnabled())
log.warn(gms.local_addr + ": " + ex.getLocalizedMessage() + ", merge is cancelled");
sendMergeCancelledMessage(coordsCopy, new_merge_id);
+ cancelMerge(new_merge_id); // the message above cancels the merge, too, but this is a 2nd line of defense
}
finally {
gms.getViewHandler().resume(new_merge_id);
@@ -22,9 +22,10 @@ private MergeId(Address initiator, int id) {
}
public synchronized static MergeId create(Address addr) {
- int id=LAST_ID++;
if(addr == null)
throw new IllegalArgumentException("initiator has to be non null");
+
+ int id=LAST_ID++;
return new MergeId(addr, id);
}
@@ -57,14 +57,19 @@ public void testRemoveAndExpiration(TimeScheduler timer) {
cache.remove(5);
cache.remove(6); // not existent
+ boolean correct_size=false;
for(int i=0; i < 20; i++) {
- if(cache.size() == 3)
+ if(cache.size() == 3) {
+ correct_size=true;
break;
+ }
Util.sleep(500);
}
-
- System.out.println("cache:\n" + cache);
- assert cache.size() == 3 : "cache size should be 3 but is " + cache;
+
+ if(!correct_size) {
+ System.out.println("cache:\n" + cache);
+ assert cache.size() == 3 : "cache size should be 3 but is " + cache.size();
+ }
for(int i=0; i < 10; i++) {
if(cache.size() == 0)
@@ -105,7 +105,7 @@ static void _testMergeRequestTimeout(String props, String cluster_name) throws E
System.out.println("starting merge");
gms.up(new Event(Event.MSG, merge_request));
- long timeout=gms.getMergeTimeout() * 2;
+ long timeout=gms.getMergeTimeout() * 10;
System.out.println("sleeping for " + timeout + " ms, then fetching merge_id: should be null (cancelled by the MergeCanceller)");
long target_time=System.currentTimeMillis() + timeout;
while(System.currentTimeMillis() < target_time) {
@@ -575,14 +575,14 @@ private static void checkUniqueness(String[] ... partitions) throws Exception {
}
private static View createView(String[] partition, JChannel[] channels) throws Exception {
- Vector<Address> members=new Vector<Address>(partition.length);
+ List<Address> members=new ArrayList<Address>(partition.length);
for(String tmp: partition) {
Address addr=findAddress(tmp, channels);
if(addr == null)
throw new Exception(tmp + " not associated with a channel");
members.add(addr);
}
- return new View(members.firstElement(), 10, members);
+ return new View(members.get(0), 10, members);
}
private static void checkViews(JChannel[] channels, String channel_name, String ... members) {
@@ -682,31 +682,31 @@ static void checkMessages(int expected, MyReceiver ... receivers) {
private static class MyChannel extends JChannel {
protected int id=0;
- public MyChannel() throws Exception {
+ private MyChannel() throws Exception {
super();
}
- public MyChannel(File properties) throws Exception {
+ private MyChannel(File properties) throws Exception {
super(properties);
}
- public MyChannel(Element properties) throws Exception {
+ private MyChannel(Element properties) throws Exception {
super(properties);
}
- public MyChannel(URL properties) throws Exception {
+ private MyChannel(URL properties) throws Exception {
super(properties);
}
- public MyChannel(String properties) throws Exception {
+ private MyChannel(String properties) throws Exception {
super(properties);
}
- public MyChannel(ProtocolStackConfigurator configurator) throws Exception {
+ private MyChannel(ProtocolStackConfigurator configurator) throws Exception {
super(configurator);
}
- public MyChannel(JChannel ch) throws Exception {
+ private MyChannel(JChannel ch) throws Exception {
super(ch);
}
@@ -737,7 +737,7 @@ protected void setAddress() {
private final String name;
private AtomicInteger num_msgs=new AtomicInteger(0);
- public MyReceiver(String name) {
+ private MyReceiver(String name) {
this.name=name;
}

No commit comments for this range