use of scala.Tuple2 in project flink by apache.
the class JobManagerRetriever method awaitJobManagerGatewayAndWebPort.
/**
* Awaits the leading job manager gateway and its web monitor port.
*/
public Tuple2<ActorGateway, Integer> awaitJobManagerGatewayAndWebPort() throws Exception {
Future<Tuple2<ActorGateway, Integer>> gatewayPortFuture = null;
Deadline deadline = timeout.fromNow();
while (!deadline.isOverdue()) {
synchronized (waitLock) {
gatewayPortFuture = leaderGatewayPortFuture;
if (gatewayPortFuture != null) {
break;
}
waitLock.wait(deadline.timeLeft().toMillis());
}
}
if (gatewayPortFuture == null) {
throw new TimeoutException("There is no JobManager available.");
} else {
return Await.result(gatewayPortFuture, deadline.timeLeft());
}
}
use of scala.Tuple2 in project flink by apache.
the class StaticFileServerHandler method channelRead0.
// ------------------------------------------------------------------------
// Responses to requests
// ------------------------------------------------------------------------
@Override
public void channelRead0(ChannelHandlerContext ctx, Routed routed) throws Exception {
if (localJobManagerAddressFuture.isCompleted()) {
if (localJobManagerAddress == null) {
localJobManagerAddress = Await.result(localJobManagerAddressFuture, timeout);
}
final HttpRequest request = routed.request();
String requestPath = routed.path();
// make sure we request the "index.html" in case there is a directory request
if (requestPath.endsWith("/")) {
requestPath = requestPath + "index.html";
}
// in case the files being accessed are logs or stdout files, find appropriate paths.
if (requestPath.equals("/jobmanager/log") || requestPath.equals("/jobmanager/stdout")) {
requestPath = "";
}
Option<Tuple2<ActorGateway, Integer>> jobManager = retriever.getJobManagerGatewayAndWebPort();
if (jobManager.isDefined()) {
// Redirect to leader if necessary
String redirectAddress = HandlerRedirectUtils.getRedirectAddress(localJobManagerAddress, jobManager.get());
if (redirectAddress != null) {
HttpResponse redirect = HandlerRedirectUtils.getRedirectResponse(redirectAddress, requestPath, httpsEnabled);
KeepAliveWrite.flush(ctx, routed.request(), redirect);
} else {
respondAsLeader(ctx, request, requestPath);
}
} else {
KeepAliveWrite.flush(ctx, routed.request(), HandlerRedirectUtils.getUnavailableResponse());
}
} else {
KeepAliveWrite.flush(ctx, routed.request(), HandlerRedirectUtils.getUnavailableResponse());
}
}
use of scala.Tuple2 in project flink by apache.
the class JobManagerTest method testNullHostnameGoesToLocalhost.
@Test
public void testNullHostnameGoesToLocalhost() {
try {
Tuple2<String, Object> address = new Tuple2<String, Object>(null, 1772);
Config cfg = AkkaUtils.getAkkaConfig(new Configuration(), new Some<Tuple2<String, Object>>(address));
String hostname = cfg.getString("akka.remote.netty.tcp.hostname");
assertTrue(InetAddress.getByName(hostname).isLoopbackAddress());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of scala.Tuple2 in project flink by apache.
the class JobSubmitTest method setupJobManager.
@BeforeClass
public static void setupJobManager() {
jmConfig = new Configuration();
int port = NetUtils.getAvailablePort();
jmConfig.setString(ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY, "localhost");
jmConfig.setInteger(ConfigConstants.JOB_MANAGER_IPC_PORT_KEY, port);
scala.Option<Tuple2<String, Object>> listeningAddress = scala.Option.apply(new Tuple2<String, Object>("localhost", port));
jobManagerSystem = AkkaUtils.createActorSystem(jmConfig, listeningAddress);
// only start JobManager (no ResourceManager)
JobManager.startJobManagerActors(jmConfig, jobManagerSystem, TestingUtils.defaultExecutor(), TestingUtils.defaultExecutor(), JobManager.class, MemoryArchivist.class)._1();
try {
LeaderRetrievalService lrs = LeaderRetrievalUtils.createLeaderRetrievalService(jmConfig);
jmGateway = LeaderRetrievalUtils.retrieveLeaderGateway(lrs, jobManagerSystem, timeout);
} catch (Exception e) {
fail("Could not retrieve the JobManager gateway. " + e.getMessage());
}
}
use of scala.Tuple2 in project flink by apache.
the class JobClient method startJobClientActorSystem.
public static ActorSystem startJobClientActorSystem(Configuration config) throws IOException {
LOG.info("Starting JobClient actor system");
Option<Tuple2<String, Object>> remoting = new Some<>(new Tuple2<String, Object>("", 0));
// start a remote actor system to listen on an arbitrary port
ActorSystem system = AkkaUtils.createActorSystem(config, remoting);
Address address = system.provider().getDefaultAddress();
String hostAddress = address.host().isDefined() ? NetUtils.ipAddressToUrlString(InetAddress.getByName(address.host().get())) : "(unknown)";
int port = address.port().isDefined() ? ((Integer) address.port().get()) : -1;
LOG.info("Started JobClient actor system at " + hostAddress + ':' + port);
return system;
}
Aggregations