Skip to content

Commit

Permalink
Revert "replaced optional"
Browse files Browse the repository at this point in the history
This reverts commit 2e8eb09.
  • Loading branch information
heesung-sn committed May 17, 2023
1 parent 55aabce commit f72b25f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.google.common.annotations.VisibleForTesting;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -381,19 +380,19 @@ public CompletableFuture<Optional<BrokerLookupData>> assign(Optional<ServiceUnit
}

public CompletableFuture<Optional<String>> selectAsync(ServiceUnitId bundle) {
return selectAsync(bundle, Collections.emptySet());
return selectAsync(bundle, Optional.empty());
}

public CompletableFuture<Optional<String>> selectAsync(ServiceUnitId bundle,
Set<String> excludeBrokerSet) {
Optional<Set<String>> excludeBrokerSet) {
BrokerRegistry brokerRegistry = getBrokerRegistry();
return brokerRegistry.getAvailableBrokerLookupDataAsync()
.thenCompose(availableBrokers -> {
LoadManagerContext context = this.getContext();

Map<String, BrokerLookupData> availableBrokerCandidates = new HashMap<>(availableBrokers);
if (!excludeBrokerSet.isEmpty()) {
for (String exclude : excludeBrokerSet) {
if (excludeBrokerSet.isPresent()) {
for (String exclude : excludeBrokerSet.get()) {
availableBrokerCandidates.remove(exclude);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ private synchronized void doCleanup(String broker) {

private Optional<String> selectBroker(String serviceUnit, String inactiveBroker) {
try {
return loadManager.selectAsync(getNamespaceBundle(serviceUnit), Set.of(inactiveBroker))
return loadManager.selectAsync(getNamespaceBundle(serviceUnit), Optional.of(Set.of(inactiveBroker)))
.get(inFlightStateWaitingTimeInMillis, MILLISECONDS);
} catch (Throwable e) {
log.error("Failed to select a broker for serviceUnit:{}", serviceUnit);
Expand Down

0 comments on commit f72b25f

Please sign in to comment.