Skip to content

Commit

Permalink
[MINOR] Fix errors in MigrationManager (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
wynot12 authored and JunhoeKim committed Jul 19, 2017
1 parent 4614b61 commit 9aa8047
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private MigrationManager(final MessageSender msgSender,
* @param tableId a table id
* @param executorId a executor id
*/
void registerSubscription(final String tableId, final String executorId) {
synchronized void registerSubscription(final String tableId, final String executorId) {
subscribersPerTable.compute(tableId, (tId, executorIdSet) -> {
final Set<String> value = executorIdSet == null ? Collections.synchronizedSet(new HashSet<>()) : executorIdSet;
if (!value.add(executorId)) {
Expand All @@ -87,7 +87,7 @@ void registerSubscription(final String tableId, final String executorId) {
* @param tableId a table id
* @param executorId a executor id
*/
void unregisterSubscription(final String tableId, final String executorId) {
synchronized void unregisterSubscription(final String tableId, final String executorId) {
subscribersPerTable.compute(tableId, (tId, executorIdSet) -> {
if (executorIdSet == null) {
throw new RuntimeException(String.format("Table %s does not exist", tId));
Expand All @@ -105,7 +105,7 @@ void unregisterSubscription(final String tableId, final String executorId) {
* @param tableId a table id
* @return a set of unregistered executor ids
*/
Set<String> unregisterSubscribers(final String tableId) {
synchronized Set<String> unregisterSubscribers(final String tableId) {
return subscribersPerTable.remove(tableId);
}

Expand All @@ -114,7 +114,8 @@ Set<String> unregisterSubscribers(final String tableId) {
* @return a set of executor ids that subscribe the table
*/
Set<String> getSubscribers(final String tableId) {
return new HashSet<>(subscribersPerTable.get(tableId));
final Set<String> subscribers = subscribersPerTable.get(tableId);
return subscribers == null ? Collections.emptySet() : new HashSet<>(subscribers);
}

/**
Expand Down

0 comments on commit 9aa8047

Please sign in to comment.