Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CDAP-21118] Enable gzip compression for PreviewHttpServer #15842

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -31,8 +31,11 @@
import io.cdap.cdap.common.security.HttpsEnabler;
import io.cdap.cdap.internal.app.services.AppFabricServer;
import io.cdap.cdap.proto.id.NamespaceId;
import io.cdap.http.ChannelPipelineModifier;
import io.cdap.http.HttpHandler;
import io.cdap.http.NettyHttpService;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.http.HttpContentDecompressor;
import java.util.Set;
import org.apache.twill.common.Cancellable;
import org.apache.twill.discovery.DiscoveryService;
Expand Down Expand Up @@ -64,7 +67,13 @@ public class PreviewHttpServer extends AbstractIdleService {
.setConnectionBacklog(cConf.getInt(Constants.Preview.BACKLOG_CONNECTIONS))
.setExecThreadPoolSize(cConf.getInt(Constants.Preview.EXEC_THREADS))
.setBossThreadPoolSize(cConf.getInt(Constants.Preview.BOSS_THREADS))
.setWorkerThreadPoolSize(cConf.getInt(Constants.Preview.WORKER_THREADS));
.setWorkerThreadPoolSize(cConf.getInt(Constants.Preview.WORKER_THREADS))
.setChannelPipelineModifier(new ChannelPipelineModifier() {
@Override
public void modify(ChannelPipeline pipeline) {
pipeline.addAfter("compressor", "decompressor", new HttpContentDecompressor());
}
});

if (cConf.getBoolean(Constants.Security.SSL.INTERNAL_ENABLED)) {
new HttpsEnabler().configureKeyStore(cConf, sConf).enable(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ public static final class Preview {
public static final String CONTAINER_JVM_OPTS = "preview.runner.container.jvm.opts";
public static final String GCE_METADATA_HOST_ENV_VAR = "GCE_METADATA_HOST";
public static final String INTERNAL_ROUTER_ENABLED = "preview.runner.internal.router.enabled";
public static final String HTTP_COMPRESS_PAYLOAD = "preview.http.compress.payload";
}

/**
Expand Down
8 changes: 8 additions & 0 deletions cdap-common/src/main/resources/cdap-default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3795,6 +3795,14 @@
</description>
</property>

<property>
<name>preview.http.compress.payload</name>
<value>true</value>
<description>
Compress payload for HTTP calls in the preview http handler.
</description>
</property>

<property>
<name>service.retry.policy.base.delay.ms</name>
<value>100</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package io.cdap.cdap.messaging.client;

import com.google.inject.Inject;
import io.cdap.cdap.common.conf.CConfiguration;
import io.cdap.cdap.common.conf.Constants;
import io.cdap.cdap.common.conf.Constants.Service;
import io.cdap.cdap.common.internal.remote.RemoteClientFactory;
import org.slf4j.Logger;
Expand All @@ -31,10 +33,11 @@ public class PreviewRunnerClientMessagingService extends AbstractClientMessaging
PreviewRunnerClientMessagingService.class);

@Inject
public PreviewRunnerClientMessagingService(RemoteClientFactory remoteClientFactory) {
// TODO (CDAP-21118) - enable gzip compression for preview http server.
public PreviewRunnerClientMessagingService(CConfiguration cConf,
RemoteClientFactory remoteClientFactory) {
super(remoteClientFactory.createRemoteClient(Service.PREVIEW_HTTP, HTTP_REQUEST_CONFIG,
"/v1/namespaces/"), false);
"/v1/namespaces/"),
cConf.getBoolean(Constants.Preview.HTTP_COMPRESS_PAYLOAD));
LOG.info("PreviewRunnerClientMessagingService initialised");
}
}
Loading