use of io.cdap.http.ChannelPipelineModifier in project cdap by caskdata.
the class RemoteConfiguratorTest method init.
@BeforeClass
public static void init() throws Exception {
cConf = CConfiguration.create();
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
cConf.setInt(Constants.TaskWorker.CONTAINER_KILL_AFTER_REQUEST_COUNT, 0);
InMemoryDiscoveryService discoveryService = new InMemoryDiscoveryService();
MasterEnvironments.setMasterEnvironment(new TestMasterEnvironment(discoveryService));
NamespaceAdmin namespaceAdmin = new InMemoryNamespaceAdmin();
namespaceAdmin.create(NamespaceMeta.SYSTEM);
namespaceAdmin.create(NamespaceMeta.DEFAULT);
remoteClientFactory = new RemoteClientFactory(discoveryService, new DefaultInternalAuthenticator(new AuthenticationTestContext()));
httpService = new CommonNettyHttpServiceBuilder(cConf, "test").setHttpHandlers(new TaskWorkerHttpHandlerInternal(cConf, className -> {
}, new NoOpMetricsCollectionService()), new ArtifactHttpHandlerInternal(new TestArtifactRepository(cConf), namespaceAdmin), new ArtifactLocalizerHttpHandlerInternal(new ArtifactLocalizer(cConf, remoteClientFactory, ((namespaceId, retryStrategy) -> {
return new NoOpArtifactManager();
})))).setPort(cConf.getInt(Constants.ArtifactLocalizer.PORT)).setChannelPipelineModifier(new ChannelPipelineModifier() {
@Override
public void modify(ChannelPipeline pipeline) {
pipeline.addAfter("compressor", "decompressor", new HttpContentDecompressor());
}
}).build();
httpService.start();
discoveryService.register(URIScheme.createDiscoverable(Constants.Service.TASK_WORKER, httpService));
discoveryService.register(URIScheme.createDiscoverable(Constants.Service.APP_FABRIC_HTTP, httpService));
metricsCollectionService = new NoOpMetricsCollectionService();
}
use of io.cdap.http.ChannelPipelineModifier in project cdap by caskdata.
the class AuthorizationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
CConfiguration conf = CConfiguration.create();
conf.setBoolean(Constants.Security.Authorization.ENABLED, true);
conf.setBoolean(Constants.Security.ENABLED, true);
properties.setProperty("superusers", admin.getName());
final InMemoryAccessController auth = new InMemoryAccessController();
auth.initialize(FACTORY.create(properties));
service = new CommonNettyHttpServiceBuilder(conf, getClass().getSimpleName()).setHttpHandlers(new AuthorizationHandler(auth, new AccessControllerInstantiator(conf, FACTORY) {
@Override
public AccessController get() {
return auth;
}
}, conf, new MasterAuthenticationContext())).setChannelPipelineModifier(new ChannelPipelineModifier() {
@Override
public void modify(ChannelPipeline pipeline) {
pipeline.addBefore("dispatcher", "usernamesetter", new TestUserNameSetter());
}
}).build();
service.start();
client = new AuthorizationClient(ClientConfig.builder().setConnectionConfig(ConnectionConfig.builder().setHostname(service.getBindAddress().getHostName()).setPort(service.getBindAddress().getPort()).setSSLEnabled(false).build()).build());
System.setProperty(USERNAME_PROPERTY, admin.getName());
}
use of io.cdap.http.ChannelPipelineModifier in project cdap by caskdata.
the class RemoteTaskExecutorTest method init.
@BeforeClass
public static void init() throws Exception {
cConf = CConfiguration.create();
discoveryService = new InMemoryDiscoveryService();
remoteClientFactory = new RemoteClientFactory(discoveryService, new DefaultInternalAuthenticator(new AuthenticationTestContext()));
httpService = new CommonNettyHttpServiceBuilder(cConf, "test").setHttpHandlers(new TaskWorkerHttpHandlerInternal(cConf, className -> {
}, new NoOpMetricsCollectionService())).setChannelPipelineModifier(new ChannelPipelineModifier() {
@Override
public void modify(ChannelPipeline pipeline) {
pipeline.addAfter("compressor", "decompressor", new HttpContentDecompressor());
}
}).build();
httpService.start();
}
Aggregations