Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,11 @@ public synchronized PulsarAdmin getAdminClient() throws PulsarServerException {
// zk-operation timeout
builder.readTimeout(conf.getMetadataStoreOperationTimeoutSeconds(), TimeUnit.SECONDS);

// reuse eventLoop
builder.setEventLoopGroup(this.getIoEventLoopGroup());
// reuse nettyTimer
builder.setNettyTimer(this.getBrokerClientSharedTimer());

this.adminClient = builder.build();
LOG.info("created admin with url {} ", adminApiUrl);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,11 @@ public PulsarAdmin getClusterPulsarAdmin(String cluster, Optional<ClusterData> c
// zk-operation timeout
builder.readTimeout(conf.getMetadataStoreOperationTimeoutSeconds(), TimeUnit.SECONDS);

// reuse eventLoop
builder.setEventLoopGroup(pulsar.getIoEventLoopGroup());
// reuse nettyTimer
builder.setNettyTimer(pulsar.getBrokerClientSharedTimer());

PulsarAdmin adminClient = builder.build();
log.info("created admin with url {} ", adminApiUrl);
return adminClient;
Expand Down
4 changes: 4 additions & 0 deletions pulsar-client-admin-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.pulsar.client.admin;

import io.netty.channel.EventLoopGroup;
import io.netty.util.Timer;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -327,4 +329,21 @@ PulsarAdminBuilder authentication(String authPluginClassName, Map<String, String
*/
PulsarAdminBuilder setContextClassLoader(ClassLoader clientBuilderClassLoader);


/**
* This override the pulsar admin client
* netty EventLoopGroup when admin is created on the broker side.
* @param eventLoopGroup
* @return this
*/
PulsarAdminBuilder setEventLoopGroup(EventLoopGroup eventLoopGroup);

/**
* This override the pulsar admin client
* netty Timer when admin is created on the broker side.
* @param nettyTimer
* @return this
*/
PulsarAdminBuilder setNettyTimer(Timer nettyTimer);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cannot be exposed on the public API. It will cause issues on the shaded client since the Netty packages are shaded. The decision has been to hide this type of details from the public API.

Please see PIP-234 discussion about this: https://lists.apache.org/thread/5jw06hqlmwnrgvbn9lfom1vkwhwqwwd4 .

A temporary solution is to make this possible in the private API such as has been done for the Pulsar Client currently. Hopefully we eventually find a solution for PIP-234. The design hasn't been completed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.pulsar.client.admin.internal;

import io.netty.channel.EventLoopGroup;
import io.netty.util.Timer;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -227,4 +229,16 @@ public PulsarAdminBuilder setContextClassLoader(ClassLoader clientBuilderClassLo
this.clientBuilderClassLoader = clientBuilderClassLoader;
return this;
}

@Override
public PulsarAdminBuilder setEventLoopGroup(EventLoopGroup eventLoopGroup) {
this.conf.setEventLoopGroup(eventLoopGroup);
return this;
}

@Override
public PulsarAdminBuilder setNettyTimer(Timer nettyTimer) {
this.conf.setNettyTimer(nettyTimer);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ public boolean keepAlive(InetSocketAddress remoteAddress, Request ahcRequest,
}
});

// reuse eventLoopGroup if provided.
if (conf.getEventLoopGroup() != null) {
confBuilder.setEventLoopGroup(conf.getEventLoopGroup());
}

// reuse nettyTimer if provided.
if (conf.getNettyTimer() != null) {
confBuilder.setNettyTimer(conf.getNettyTimer());
}

serviceNameResolver = new PulsarServiceNameResolver();
if (conf != null && StringUtils.isNotBlank(conf.getServiceUrl())) {
serviceNameResolver.updateServiceUrl(conf.getServiceUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
package org.apache.pulsar.client.impl.conf;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.netty.channel.EventLoopGroup;
import io.netty.util.Timer;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.net.InetSocketAddress;
Expand Down Expand Up @@ -385,6 +387,12 @@ public class ClientConfigurationData implements Serializable, Cloneable {
)
private String description;

@JsonIgnore
private EventLoopGroup eventLoopGroup;

@JsonIgnore
private Timer nettyTimer;

/**
* Gets the authentication settings for the client.
*
Expand Down