Skip to content

Commit

Permalink
align sourceStatus presentation for status "unknown/failure/misconfig…
Browse files Browse the repository at this point in the history
…uration" with status open for mqtt connection;

don't split up source addresses for mqtt sources;

Signed-off-by: Stefan Maute <stefan.maute@bosch.io>
  • Loading branch information
Stefan Maute authored and thjaeckle committed Oct 26, 2021
1 parent 11e2c2b commit 0f581ff
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -1426,9 +1427,7 @@ private FSM.State<BaseClientState, BaseClientData> retrieveConnectionStatus(fina
.info("Responding early with static 'CLOSED' ResourceStatus for all sub-sources and " +
"-targets and SSH tunnel, because some children could not be started, due to a " +
"live status <{}> in the client actor.", clientConnectionStatus);
connection.getSources().stream()
.map(Source::getAddresses)
.flatMap(Collection::stream)
getSourceAddresses()
.map(sourceAddress -> ConnectivityModelFactory.newSourceStatus(getInstanceIdentifier(),
ConnectivityStatus.CLOSED,
sourceAddress,
Expand Down Expand Up @@ -1469,7 +1468,7 @@ private FSM.State<BaseClientState, BaseClientData> retrieveConnectionStatus(fina
}

/**
* Determines the number of consumers.
* Determine the number of consumers.
*
* @return the number of consumers.
*/
Expand All @@ -1480,6 +1479,17 @@ protected int determineNumberOfConsumers() {
.sum();
}

/**
* Get the source addresses as stream of strings.
*
* @return the stream of source addresses.
*/
protected Stream<String> getSourceAddresses() {
return connection.getSources().stream()
.map(Source::getAddresses)
.flatMap(Collection::stream);
}

private void retrieveAddressStatusFromChildren(final RetrieveConnectionStatus command, final ActorRef sender,
final List<ActorRef> childrenToAsk) {
childrenToAsk.forEach(child -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.stream.Stream;

import javax.annotation.Nullable;

Expand Down Expand Up @@ -591,6 +592,9 @@ private String distinguishClientIdIfNecessary(final String configuredClientId) {
}
}

/*
* For MQTT connections only one Consumer Actor for all addresses is started.
*/
@Override
protected int determineNumberOfConsumers() {
return connection.getSources()
Expand All @@ -599,6 +603,16 @@ protected int determineNumberOfConsumers() {
.sum();
}

/*
* For MQTT connections only one Consumer Actor for all addresses is started.
*/
@Override
protected Stream<String> getSourceAddresses() {
return connection.getSources().stream()
.map(Source::getAddresses)
.map(sourceAddresses -> String.join(";", sourceAddresses));
}

static class MqttClientConnected extends AbstractWithOrigin implements ClientConnected {

MqttClientConnected(@Nullable final ActorRef origin) {
Expand Down

0 comments on commit 0f581ff

Please sign in to comment.