Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONAR-9802 ability to execute distributed calls
See HazelcastMember#call(DistributedCall, ...)
- Loading branch information
Simon Brandhof
committed
Sep 26, 2017
1 parent
e4c401f
commit df53863
Showing
15 changed files
with
532 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 0 additions & 48 deletions
48
server/sonar-main/src/test/java/org/sonar/application/cluster/HazelcastTesting.java
This file was deleted.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
server/sonar-process/src/main/java/org/sonar/process/cluster/hz/DistributedAnswer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* SonarQube | ||
* Copyright (C) 2009-2017 SonarSource SA | ||
* mailto:info AT sonarsource DOT com | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.sonar.process.cluster.hz; | ||
|
||
import com.hazelcast.core.Member; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
/** | ||
* Answer of {@link DistributedCall}, aggregating the answers from | ||
* all the target members. | ||
*/ | ||
public class DistributedAnswer<T> { | ||
|
||
private final Map<Member, T> answers = new HashMap<>(); | ||
private final Set<Member> timedOutMembers = new HashSet<>(); | ||
private final Map<Member, Exception> failedMembers = new HashMap<>(); | ||
|
||
public Optional<T> getAnswer(Member member) { | ||
return Optional.ofNullable(answers.get(member)); | ||
} | ||
|
||
public boolean hasTimedOut(Member member) { | ||
return timedOutMembers.contains(member); | ||
} | ||
|
||
public Optional<Exception> getFailed(Member member) { | ||
return Optional.ofNullable(failedMembers.get(member)); | ||
} | ||
|
||
public Collection<Member> getMembers() { | ||
List<Member> members = new ArrayList<>(); | ||
members.addAll(answers.keySet()); | ||
members.addAll(timedOutMembers); | ||
members.addAll(failedMembers.keySet()); | ||
return members; | ||
} | ||
|
||
void setAnswer(Member member, T answer) { | ||
this.answers.put(member, answer); | ||
} | ||
|
||
void setTimedOut(Member member) { | ||
this.timedOutMembers.add(member); | ||
} | ||
|
||
void setFailed(Member member, Exception e) { | ||
failedMembers.put(member, e); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
server/sonar-process/src/main/java/org/sonar/process/cluster/hz/DistributedCall.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* SonarQube | ||
* Copyright (C) 2009-2017 SonarSource SA | ||
* mailto:info AT sonarsource DOT com | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
package org.sonar.process.cluster.hz; | ||
|
||
import java.io.Serializable; | ||
import java.util.concurrent.Callable; | ||
|
||
public interface DistributedCall<T> extends Callable<T>, Serializable { | ||
} |
Oops, something went wrong.