use of akka.http.javadsl.Http in project mantis by Netflix.
the class AdminMasterRouteTest method setup.
@BeforeClass
public void setup() throws Exception {
JobTestHelper.deleteAllFiles();
JobTestHelper.createDirsIfRequired();
final CountDownLatch latch = new CountDownLatch(1);
t = new Thread(() -> {
try {
// boot up server using the route as defined below
final Http http = Http.get(system);
final ActorMaterializer materializer = ActorMaterializer.create(system);
final Flow<HttpRequest, HttpResponse, NotUsed> routeFlow = masterDescRoute.createRoute(Function.identity()).flow(system, materializer);
logger.info("starting test server on port {}", ADMIN_MASTER_PORT);
latch.countDown();
binding = http.bindAndHandle(routeFlow, ConnectHttp.toHost("localhost", ADMIN_MASTER_PORT), materializer);
} catch (Exception e) {
logger.info("caught exception", e);
latch.countDown();
e.printStackTrace();
}
});
t.setDaemon(true);
t.start();
latch.await();
}
use of akka.http.javadsl.Http in project mantis by Netflix.
the class JobClustersRouteTest method setup.
@BeforeClass
public void setup() throws Exception {
TestHelpers.setupMasterConfig();
final CountDownLatch latch = new CountDownLatch(1);
t = new Thread(() -> {
try {
// boot up server using the route as defined below
final Http http = Http.get(system);
final ActorMaterializer materializer = ActorMaterializer.create(system);
final LifecycleEventPublisher lifecycleEventPublisher = new LifecycleEventPublisherImpl(new AuditEventSubscriberLoggingImpl(), new StatusEventSubscriberLoggingImpl(), new WorkerEventSubscriberLoggingImpl());
ActorRef jobClustersManagerActor = system.actorOf(JobClustersManagerActor.props(new MantisJobStore(new SimpleCachedFileStorageProvider(true)), lifecycleEventPublisher), "jobClustersManager");
MantisScheduler fakeScheduler = new FakeMantisScheduler(jobClustersManagerActor);
jobClustersManagerActor.tell(new JobClusterManagerProto.JobClustersManagerInitialize(fakeScheduler, false), ActorRef.noSender());
final JobClusterRouteHandler jobClusterRouteHandler = new JobClusterRouteHandlerAkkaImpl(jobClustersManagerActor);
final JobClustersRoute app = new JobClustersRoute(jobClusterRouteHandler, system);
final Flow<HttpRequest, HttpResponse, NotUsed> routeFlow = app.createRoute(Function.identity()).flow(system, materializer);
logger.info("starting test server on port {}", SERVER_PORT);
latch.countDown();
binding = http.bindAndHandle(routeFlow, ConnectHttp.toHost("localhost", SERVER_PORT), materializer);
} catch (Exception e) {
logger.info("caught exception", e);
latch.countDown();
e.printStackTrace();
}
});
t.setDaemon(true);
t.start();
latch.await();
}
use of akka.http.javadsl.Http in project ditto by eclipse.
the class DefaultHttpPushFactory method createFlow.
@Override
public Flow<Pair<HttpRequest, HttpPushContext>, Pair<Try<HttpResponse>, HttpPushContext>, ?> createFlow(final ActorSystem system, final LoggingAdapter log, final Duration requestTimeout, @Nullable final PreparedTimer timer, @Nullable final BiConsumer<Duration, ConnectionMonitor.InfoProvider> durationConsumer) {
final Http http = Http.get(system);
final ConnectionPoolSettings poolSettings = getConnectionPoolSettings(system);
final Flow<Pair<HttpRequest, HttpPushContext>, Pair<Try<HttpResponse>, HttpPushContext>, ?> flow;
final Uri baseUri = getBaseUri();
if (null != httpsConnectionContext) {
final ConnectHttp connectHttpsWithCustomSSLContext = ConnectHttp.toHostHttps(baseUri).withCustomHttpsContext(httpsConnectionContext);
// explicitly added <T> as in (some?) IntelliJ idea the line would show an error:
flow = http.<HttpPushContext>cachedHostConnectionPoolHttps(connectHttpsWithCustomSSLContext, poolSettings, log);
} else {
// explicitly added <T> as in (some?) IntelliJ idea the line would show an error:
// no SSL, hence no need for SSLContextCreator
flow = http.<HttpPushContext>cachedHostConnectionPool(ConnectHttp.toHost(baseUri), poolSettings, log);
}
// make requests in parallel
return Flow.<Pair<HttpRequest, HttpPushContext>>create().flatMapMerge(parallelism, request -> {
final var startedTimer = timer != null ? timer.start() : null;
return TimeoutFlow.single(request, flow, requestTimeout, DefaultHttpPushFactory::onRequestTimeout).map(pair -> {
stopTimer(startedTimer, durationConsumer, pair.second().getInfoProvider(), log);
return pair;
}).async(DISPATCHER_NAME, parallelism);
});
}
use of akka.http.javadsl.Http in project ditto by eclipse.
the class DittoRootActor method bindHttpStatusRoute.
protected void bindHttpStatusRoute(final HttpConfig httpConfig, final ActorRef healthCheckingActor) {
String hostname = httpConfig.getHostname();
if (hostname.isEmpty()) {
hostname = LocalHostAddressSupplier.getInstance().get();
log.info("No explicit hostname configured, using HTTP hostname: {}", hostname);
}
final ActorSystem system = getContext().getSystem();
Http.get(system).newServerAt(hostname, httpConfig.getPort()).bindFlow(createStatusRoute(system, healthCheckingActor).flow(system)).thenAccept(theBinding -> {
theBinding.addToCoordinatedShutdown(httpConfig.getCoordinatedShutdownTimeout(), system);
log.info("Created new server binding for the status route.");
}).exceptionally(failure -> {
log.error(failure, "Could not create the server binding for the status route because of: <{}>", failure.getMessage());
log.error("Terminating the actor system");
system.terminate();
return null;
});
}
use of akka.http.javadsl.Http in project mutual-tls-ssl by Hakky54.
the class ClientConfigShould method createAkkaHttpClient.
@Test
void createAkkaHttpClient() {
SSLFactory sslFactory = createSSLFactory(false, true);
Http http = victim.akkaHttpClient(sslFactory, ActorSystem.create());
assertThat(http).isNotNull();
verify(sslFactory, times(1)).getSslContext();
}
Aggregations