Skip to content
Closed
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 @@ -439,6 +439,11 @@ public final class ConfigConstants {

// ------------------------ Mesos Configuration ------------------------

/**
* The initial number of Mesos tasks to allocate.
*/
public static final String MESOS_INITIAL_TASKS = "mesos.initial-tasks";

/**
* The maximum number of failed Mesos tasks before entirely stopping
* the Mesos session / job on Mesos.
Expand Down Expand Up @@ -484,6 +489,8 @@ public final class ConfigConstants {

public static final String MESOS_RESOURCEMANAGER_FRAMEWORK_SECRET = "mesos.resourcemanager.framework.secret";

public static final String MESOS_RESOURCEMANAGER_FRAMEWORK_USER = "mesos.resourcemanager.framework.user";

/**
* The cpus to acquire from Mesos.
*
Expand Down Expand Up @@ -1158,6 +1165,8 @@ public final class ConfigConstants {

public static final String DEFAULT_MESOS_RESOURCEMANAGER_FRAMEWORK_ROLE = "*";

public static final String DEFAULT_MESOS_RESOURCEMANAGER_FRAMEWORK_USER = "";

// ------------------------ File System Behavior ------------------------

/**
Expand Down Expand Up @@ -1372,6 +1381,12 @@ public final class ConfigConstants {
/** The environment variable name which contains the location of the lib folder */
public static final String ENV_FLINK_LIB_DIR = "FLINK_LIB_DIR";

/** The environment variable name which contains the location of the bin directory */
public static final String ENV_FLINK_BIN_DIR = "FLINK_BIN_DIR";

/** The environment variable name which contains the Flink installation root directory */
public static final String ENV_FLINK_HOME_DIR = "FLINK_HOME";

// -------------------------------- Security -------------------------------

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,31 @@ public final class GlobalConfiguration {

public static final String FLINK_CONF_FILENAME = "flink-conf.yaml";


// --------------------------------------------------------------------------------------------

private GlobalConfiguration() {}

// --------------------------------------------------------------------------------------------

private static Configuration dynamicProperties = null;

/**
* Set the process-wide dynamic properties to be merged with the loaded configuration.
*/
public static void setDynamicProperties(Configuration dynamicProperties) {
GlobalConfiguration.dynamicProperties = new Configuration(dynamicProperties);
}

/**
* Get the dynamic properties.
*/
public static Configuration getDynamicProperties() {
return GlobalConfiguration.dynamicProperties;
}

// --------------------------------------------------------------------------------------------

/**
* Loads the global configuration from the environment. Fails if an error occurs during loading. Returns an
* empty configuration object if the environment variable is not set. In production this variable is set but
Expand Down Expand Up @@ -90,7 +109,13 @@ public static Configuration loadConfiguration(final String configDir) {
"' (" + confDirFile.getAbsolutePath() + ") does not exist.");
}

return loadYAMLResource(yamlConfigFile);
Configuration conf = loadYAMLResource(yamlConfigFile);

if(dynamicProperties != null) {
conf.addAll(dynamicProperties);
}

return conf;
}

/**
Expand Down
6 changes: 6 additions & 0 deletions flink-dist/src/main/assemblies/bin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ under the License.
<outputDirectory>bin</outputDirectory>
<fileMode>0755</fileMode>
</fileSet>
<!-- copy Mesos start scripts -->
<fileSet>
<directory>src/main/flink-bin/mesos-bin</directory>
<outputDirectory>bin</outputDirectory>
<fileMode>0755</fileMode>
</fileSet>

<!-- copy default configuration -->
<fileSet>
Expand Down
51 changes: 51 additions & 0 deletions flink-dist/src/main/flink-bin/mesos-bin/mesos-appmaster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
################################################################################
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################

bin=`dirname "$0"`
bin=`cd "$bin"; pwd`

# get Flink config
. "$bin"/config.sh

# auxilliary function to construct a lightweight classpath for the
# Flink AppMaster
constructAppMasterClassPath() {

while read -d '' -r jarfile ; do
if [[ $CC_CLASSPATH = "" ]]; then
CC_CLASSPATH="$jarfile";
else
CC_CLASSPATH="$CC_CLASSPATH":"$jarfile"
fi
done < <(find "$FLINK_LIB_DIR" ! -type d -name '*.jar' -print0)

echo $CC_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS
}

CC_CLASSPATH=`manglePathList $(constructAppMasterClassPath)`

log=flink-appmaster.log
log_setting="-Dlog.file="$log" -Dlog4j.configuration=file:"$FLINK_CONF_DIR"/log4j.properties -Dlogback.configurationFile=file:"$FLINK_CONF_DIR"/logback.xml"

export FLINK_CONF_DIR
export FLINK_BIN_DIR
export FLINK_LIB_DIR

$JAVA_RUN $JVM_ARGS -classpath "$CC_CLASSPATH" $log_setting org.apache.flink.mesos.runtime.clusterframework.MesosApplicationMasterRunner "$@"

60 changes: 60 additions & 0 deletions flink-dist/src/main/flink-bin/mesos-bin/mesos-taskmanager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
################################################################################
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################

bin=`dirname "$0"`
bin=`cd "$bin"; pwd`

# get Flink config
. "$bin"/config.sh

# auxilliary function to construct a lightweight classpath for the
# Flink TaskManager
constructTaskManagerClassPath() {

while read -d '' -r jarfile ; do
if [[ $CC_CLASSPATH = "" ]]; then
CC_CLASSPATH="$jarfile";
else
CC_CLASSPATH="$CC_CLASSPATH":"$jarfile"
fi
done < <(find "$FLINK_LIB_DIR" ! -type d -name '*.jar' -print0)

echo $CC_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS
}

CC_CLASSPATH=`manglePathList $(constructTaskManagerClassPath)`

log=flink-taskmanager.log
log_setting="-Dlog.file="$log" -Dlog4j.configuration=file:"$FLINK_CONF_DIR"/log4j.properties -Dlogback.configurationFile=file:"$FLINK_CONF_DIR"/logback.xml"

# Add precomputed memory JVM options
if [ -z "${FLINK_ENV_JAVA_OPTS_MEM}" ]; then
FLINK_ENV_JAVA_OPTS_MEM=""
fi
export FLINK_ENV_JAVA_OPTS="${FLINK_ENV_JAVA_OPTS} ${FLINK_ENV_JAVA_OPTS_MEM}"

# Add TaskManager-specific JVM options
export FLINK_ENV_JAVA_OPTS="${FLINK_ENV_JAVA_OPTS} ${FLINK_ENV_JAVA_OPTS_TM}"

export FLINK_CONF_DIR
export FLINK_BIN_DIR
export FLINK_LIB_DIR

$JAVA_RUN $JVM_ARGS ${FLINK_ENV_JAVA_OPTS} -classpath "$CC_CLASSPATH" $log_setting org.apache.flink.mesos.runtime.clusterframework.MesosTaskManager "$@"

19 changes: 16 additions & 3 deletions flink-mesos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ under the License.
<packaging>jar</packaging>

<properties>
<mesos.version>0.27.1</mesos.version>
<mesos.version>1.0.1</mesos.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -68,6 +68,13 @@ under the License.
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-remote_${scala.binary.version}</artifactId>
<exclusions>
<!-- exclude protobuf here to allow the mesos library to provide it -->
<exclusion>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down Expand Up @@ -253,15 +260,21 @@ under the License.
<goal>shade</goal>
</goals>
<configuration>
<promoteTransitiveDependencies>true</promoteTransitiveDependencies>
<artifactSet>
<includes combine.children="append">
<include>org.apache.flink:flink-shaded-curator-recipes</include>
<include>com.google.protobuf:*</include>
</includes>
</artifactSet>
<relocations combine.children="append">
<relocations combine.children="override">
<relocation>
<pattern>org.apache.curator</pattern>
<shadedPattern>org.apache.flink.shaded.org.apache.curator</shadedPattern>
<shadedPattern>org.apache.flink.mesos.shaded.org.apache.curator</shadedPattern>
</relocation>
<relocation>
<pattern>com.google.protobuf</pattern>
<shadedPattern>org.apache.flink.mesos.shaded.com.google.protobuf</shadedPattern>
</relocation>
</relocations>
</configuration>
Expand Down
21 changes: 21 additions & 0 deletions flink-mesos/src/main/java/org/apache/flink/mesos/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

package org.apache.flink.mesos;

import org.apache.flink.mesos.util.MesosArtifactResolver;
import org.apache.flink.runtime.clusterframework.ContainerSpecification;
import org.apache.mesos.Protos;
import scala.Option;

import java.net.URL;
import java.util.Arrays;
Expand All @@ -45,6 +48,24 @@ public static Protos.CommandInfo.URI uri(URL url, boolean cacheable) {
.build();
}

/**
* Construct a Mesos URI.
*/
public static Protos.CommandInfo.URI uri(MesosArtifactResolver resolver, ContainerSpecification.Artifact artifact) {
Option<URL> url = resolver.resolve(artifact.dest);
if(url.isEmpty()) {
throw new IllegalArgumentException("Unresolvable artifact: " + artifact.dest);
}

return Protos.CommandInfo.URI.newBuilder()
.setValue(url.get().toExternalForm())
.setOutputFile(artifact.dest.toString())
.setExtract(artifact.extract)
.setCache(artifact.cachable)
.setExecutable(artifact.executable)
.build();
}

/**
* Construct a scalar resource value.
*/
Expand Down
Loading