Skip to content

Commit

Permalink
[pulsar-proxy] fixing data-type of logging-level (apache#6476)
Browse files Browse the repository at this point in the history
### Modification
`ProxyConfig` has wrapper method for `proxyLogLevel` to present `Optional` data-type. after apache#3543 we can define config param as optional without creating wrapper methods.
  • Loading branch information
rdhabalia authored Mar 9, 2020
1 parent 67f8cf3 commit de4c6a3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public class ProxyConfiguration implements PulsarConfiguration {
+ " 1: Parse and log any tcp channel info and command info without message body"
+ " 2: Parse and log channel info, command info and message body"
)
private Integer proxyLogLevel = 0;
private Optional<Integer> proxyLogLevel = Optional.ofNullable(0);

@FieldContext(
category = CATEGORY_SERVER,
Expand Down Expand Up @@ -386,13 +386,6 @@ public Optional<Integer> getServicePort() {
return servicePort;
}

public Optional<Integer> getproxyLogLevel() {
return Optional.ofNullable(proxyLogLevel);
}
public void setProxyLogLevel(int proxyLogLevel) {
this.proxyLogLevel = proxyLogLevel;
}

public Optional<Integer> getServicePortTls() {
return servicePortTls;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public ProxyService(ProxyConfiguration proxyConfig,
this.lookupRequestSemaphore = new AtomicReference<Semaphore>(
new Semaphore(proxyConfig.getMaxConcurrentLookupRequests(), false));

if (proxyConfig.getproxyLogLevel().isPresent()) {
ProxyService.proxyLogLevel = Integer.valueOf(proxyConfig.getproxyLogLevel().get());
if (proxyConfig.getProxyLogLevel().isPresent()) {
ProxyService.proxyLogLevel = Integer.valueOf(proxyConfig.getProxyLogLevel().get());
} else {
ProxyService.proxyLogLevel = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ protected void setup() throws Exception {
proxyConfig.setZookeeperServers(DUMMY_VALUE);
proxyConfig.setConfigurationStoreServers(DUMMY_VALUE);
//enable full parsing feature
proxyConfig.setProxyLogLevel(2);
proxyConfig.setProxyLogLevel(Optional.ofNullable(2));

proxyService = Mockito.spy(new ProxyService(proxyConfig, new AuthenticationService(
PulsarConfigurationLoader.convertFrom(proxyConfig))));
doReturn(mockZooKeeperClientFactory).when(proxyService).getZooKeeperClientFactory();

Optional<Integer> proxyLogLevel = Optional.of(2);
assertEquals( proxyLogLevel , proxyService.getConfiguration().getproxyLogLevel());
assertEquals( proxyLogLevel , proxyService.getConfiguration().getProxyLogLevel());
proxyService.start();
}

Expand Down

0 comments on commit de4c6a3

Please sign in to comment.