Search in sources :

Example 1 with Tuple2

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());
    }
}
Also used : Tuple2(scala.Tuple2) Deadline(scala.concurrent.duration.Deadline) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with Tuple2

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());
    }
}
Also used : HttpRequest(io.netty.handler.codec.http.HttpRequest) Tuple2(scala.Tuple2) DefaultHttpResponse(io.netty.handler.codec.http.DefaultHttpResponse) DefaultFullHttpResponse(io.netty.handler.codec.http.DefaultFullHttpResponse) HttpResponse(io.netty.handler.codec.http.HttpResponse) FullHttpResponse(io.netty.handler.codec.http.FullHttpResponse)

Example 3 with Tuple2

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());
    }
}
Also used : Configuration(org.apache.flink.configuration.Configuration) Tuple2(scala.Tuple2) Config(com.typesafe.config.Config) Test(org.junit.Test)

Example 4 with Tuple2

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());
    }
}
Also used : Configuration(org.apache.flink.configuration.Configuration) Tuple2(scala.Tuple2) LeaderRetrievalService(org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService) JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) IOException(java.io.IOException) BeforeClass(org.junit.BeforeClass)

Example 5 with Tuple2

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;
}
Also used : ActorSystem(akka.actor.ActorSystem) Some(scala.Some) InetAddress(java.net.InetAddress) Address(akka.actor.Address) InetSocketAddress(java.net.InetSocketAddress) Tuple2(scala.Tuple2)

Aggregations

Tuple2 (scala.Tuple2)181 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)57 ArrayList (java.util.ArrayList)43 IOException (java.io.IOException)32 Test (org.junit.Test)32 INDArray (org.nd4j.linalg.api.ndarray.INDArray)28 JavaPairRDD (org.apache.spark.api.java.JavaPairRDD)23 List (java.util.List)22 Function (org.apache.spark.api.java.function.Function)19 File (java.io.File)18 Collectors (java.util.stream.Collectors)18 GATKException (org.broadinstitute.hellbender.exceptions.GATKException)18 Configuration (org.apache.hadoop.conf.Configuration)17 UserException (org.broadinstitute.hellbender.exceptions.UserException)17 Broadcast (org.apache.spark.broadcast.Broadcast)16 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)16 MatrixIndexes (org.apache.sysml.runtime.matrix.data.MatrixIndexes)16 SparkConf (org.apache.spark.SparkConf)15 JavaRDD (org.apache.spark.api.java.JavaRDD)15 VisibleForTesting (com.google.common.annotations.VisibleForTesting)14