Skip to content

Commit

Permalink
Added retryAfterSeconds configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
morph166955 committed Jan 31, 2021
1 parent 280c322 commit d073e87
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public GENAEventProcessor getGenaEventProcessor() {
@Override
@SuppressWarnings("rawtypes")
public StreamClient createStreamClient() {
return transportConfiguration.createStreamClient(getSyncProtocolExecutorService("upnp-stream"));
return transportConfiguration.createStreamClient(getSyncProtocolExecutorService("upnp-stream"),-1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public class OSGiUpnpServiceConfiguration implements UpnpServiceConfiguration {
private boolean asyncThreadPool = true;
private boolean mainThreadPool = true;
private Namespace callbackURI = new Namespace("http://localhost/upnpcallback");
private int retryAfterSeconds = -1;
private int maxRequests = -1;

private ExecutorService mainExecutorService;
private ExecutorService asyncExecutorService;
Expand Down Expand Up @@ -199,7 +201,7 @@ public GENAEventProcessor getGenaEventProcessor() {
@Override
@SuppressWarnings("rawtypes")
public StreamClient createStreamClient() {
return transportConfiguration.createStreamClient(getSyncProtocolExecutorService("upnp-stream"));
return transportConfiguration.createStreamClient(getSyncProtocolExecutorService("upnp-stream"),retryAfterSeconds);
}

@Override
Expand Down Expand Up @@ -535,6 +537,18 @@ private void createConfiguration(Map<String, Object> properties) throws Configur
} else if (prop instanceof Integer) {
httpProxyPort = (Integer) prop;
}

prop = properties.get("retryAfterSeconds");
if (prop instanceof String) {
try {
retryAfterSeconds = Integer.valueOf((String) prop);
} catch (NumberFormatException e) {
log.error("Invalid value '{}' for retryAfterSeconds - using default value", prop);
}
} else if (prop instanceof Integer) {
retryAfterSeconds = (Integer) prop;
}
log.info("OSGiUpnpServiceConfiguration createConfiguration retryAfterSeconds = {}", retryAfterSeconds);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface TransportConfiguration<SCC extends StreamClientConfiguration, S
* @param executorService used to dispatch request/response processing.
* @return created {@link StreamClient}
*/
StreamClient<SCC> createStreamClient(final ExecutorService executorService);
StreamClient<SCC> createStreamClient(final ExecutorService executorService, int retryAfterSeconds);

/**
* Creates a {@link StreamServer} using the given {@code listenerPort}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public class JettyTransportConfiguration
public static final TransportConfiguration INSTANCE = new JettyTransportConfiguration();

@Override
public StreamClient createStreamClient(final ExecutorService executorService) {
return new JettyStreamClientImpl(
new StreamClientConfigurationImpl(
executorService
)
);
public StreamClient createStreamClient(final ExecutorService executorService, int retryAfterSeconds) {
StreamClientConfigurationImpl clientConfiguration = new StreamClientConfigurationImpl(executorService);
if (retryAfterSeconds >= 0) {
clientConfiguration.setRetryAfterSeconds(retryAfterSeconds);
}
return new JettyStreamClientImpl(clientConfiguration);
}

@Override
Expand Down

0 comments on commit d073e87

Please sign in to comment.