Search in sources :

Example 81 with Configuration

use of org.apache.flink.configuration.Configuration in project flink by apache.

the class ZooKeeperUtilTest method testZooKeeperEnsembleConnectStringConfiguration.

@Test
public void testZooKeeperEnsembleConnectStringConfiguration() throws Exception {
    // ZooKeeper does not like whitespace in the quorum connect String.
    String actual, expected;
    Configuration conf = new Configuration();
    {
        expected = "localhost:2891";
        setQuorum(conf, expected);
        actual = ZooKeeperUtils.getZooKeeperEnsemble(conf);
        assertEquals(expected, actual);
        // with leading and trailing whitespace
        setQuorum(conf, " localhost:2891 ");
        actual = ZooKeeperUtils.getZooKeeperEnsemble(conf);
        assertEquals(expected, actual);
        // whitespace after port
        setQuorum(conf, "localhost :2891");
        actual = ZooKeeperUtils.getZooKeeperEnsemble(conf);
        assertEquals(expected, actual);
    }
    {
        expected = "localhost:2891,localhost:2891";
        setQuorum(conf, "localhost:2891,localhost:2891");
        actual = ZooKeeperUtils.getZooKeeperEnsemble(conf);
        assertEquals(expected, actual);
        setQuorum(conf, "localhost:2891, localhost:2891");
        actual = ZooKeeperUtils.getZooKeeperEnsemble(conf);
        assertEquals(expected, actual);
        setQuorum(conf, "localhost :2891, localhost:2891");
        actual = ZooKeeperUtils.getZooKeeperEnsemble(conf);
        assertEquals(expected, actual);
        setQuorum(conf, " localhost:2891, localhost:2891 ");
        actual = ZooKeeperUtils.getZooKeeperEnsemble(conf);
        assertEquals(expected, actual);
    }
}
Also used : Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 82 with Configuration

use of org.apache.flink.configuration.Configuration in project flink by apache.

the class RemoteStreamEnvironment method executeRemotely.

/**
	 * Executes the remote job.
	 * 
	 * @param streamGraph
	 *            Stream Graph to execute
	 * @param jarFiles
	 * 			  List of jar file URLs to ship to the cluster
	 * @return The result of the job execution, containing elapsed time and accumulators.
	 */
protected JobExecutionResult executeRemotely(StreamGraph streamGraph, List<URL> jarFiles) throws ProgramInvocationException {
    if (LOG.isInfoEnabled()) {
        LOG.info("Running remotely at {}:{}", host, port);
    }
    ClassLoader usercodeClassLoader = JobWithJars.buildUserCodeClassLoader(jarFiles, globalClasspaths, getClass().getClassLoader());
    Configuration configuration = new Configuration();
    configuration.addAll(this.clientConfiguration);
    configuration.setString(ConfigConstants.JOB_MANAGER_IPC_ADDRESS_KEY, host);
    configuration.setInteger(ConfigConstants.JOB_MANAGER_IPC_PORT_KEY, port);
    ClusterClient client;
    try {
        client = new StandaloneClusterClient(configuration);
        client.setPrintStatusDuringExecution(getConfig().isSysoutLoggingEnabled());
    } catch (Exception e) {
        throw new ProgramInvocationException("Cannot establish connection to JobManager: " + e.getMessage(), e);
    }
    try {
        return client.run(streamGraph, jarFiles, globalClasspaths, usercodeClassLoader).getJobExecutionResult();
    } catch (ProgramInvocationException e) {
        throw e;
    } catch (Exception e) {
        String term = e.getMessage() == null ? "." : (": " + e.getMessage());
        throw new ProgramInvocationException("The program execution failed" + term, e);
    } finally {
        client.shutdown();
    }
}
Also used : StandaloneClusterClient(org.apache.flink.client.program.StandaloneClusterClient) ClusterClient(org.apache.flink.client.program.ClusterClient) Configuration(org.apache.flink.configuration.Configuration) GlobalConfiguration(org.apache.flink.configuration.GlobalConfiguration) StandaloneClusterClient(org.apache.flink.client.program.StandaloneClusterClient) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) InvalidProgramException(org.apache.flink.api.common.InvalidProgramException)

Example 83 with Configuration

use of org.apache.flink.configuration.Configuration in project flink by apache.

the class ContinuousFileReaderOperator method open.

@Override
public void open() throws Exception {
    super.open();
    checkState(this.reader == null, "The reader is already initialized.");
    checkState(this.serializer != null, "The serializer has not been set. " + "Probably the setOutputType() was not called. Please report it.");
    this.format.setRuntimeContext(getRuntimeContext());
    this.format.configure(new Configuration());
    this.checkpointLock = getContainingTask().getCheckpointLock();
    // set the reader context based on the time characteristic
    final TimeCharacteristic timeCharacteristic = getOperatorConfig().getTimeCharacteristic();
    final long watermarkInterval = getRuntimeContext().getExecutionConfig().getAutoWatermarkInterval();
    this.readerContext = StreamSourceContexts.getSourceContext(timeCharacteristic, getProcessingTimeService(), checkpointLock, getContainingTask().getStreamStatusMaintainer(), output, watermarkInterval, -1);
    // and initialize the split reading thread
    this.reader = new SplitReader<>(format, serializer, readerContext, checkpointLock, restoredReaderState);
    this.restoredReaderState = null;
    this.reader.start();
}
Also used : Configuration(org.apache.flink.configuration.Configuration) TimeCharacteristic(org.apache.flink.streaming.api.TimeCharacteristic)

Example 84 with Configuration

use of org.apache.flink.configuration.Configuration in project flink by apache.

the class AbstractStreamOperator method setup.

// ------------------------------------------------------------------------
//  Life Cycle
// ------------------------------------------------------------------------
@Override
public void setup(StreamTask<?, ?> containingTask, StreamConfig config, Output<StreamRecord<OUT>> output) {
    this.container = containingTask;
    this.config = config;
    this.metrics = container.getEnvironment().getMetricGroup().addOperator(config.getOperatorName());
    this.output = new CountingOutput(output, ((OperatorMetricGroup) this.metrics).getIOMetricGroup().getNumRecordsOutCounter());
    if (config.isChainStart()) {
        ((OperatorMetricGroup) this.metrics).getIOMetricGroup().reuseInputMetricsForTask();
    }
    if (config.isChainEnd()) {
        ((OperatorMetricGroup) this.metrics).getIOMetricGroup().reuseOutputMetricsForTask();
    }
    Configuration taskManagerConfig = container.getEnvironment().getTaskManagerInfo().getConfiguration();
    int historySize = taskManagerConfig.getInteger(ConfigConstants.METRICS_LATENCY_HISTORY_SIZE, ConfigConstants.DEFAULT_METRICS_LATENCY_HISTORY_SIZE);
    if (historySize <= 0) {
        LOG.warn("{} has been set to a value equal or below 0: {}. Using default.", ConfigConstants.METRICS_LATENCY_HISTORY_SIZE, historySize);
        historySize = ConfigConstants.DEFAULT_METRICS_LATENCY_HISTORY_SIZE;
    }
    latencyGauge = this.metrics.gauge("latency", new LatencyGauge(historySize));
    this.runtimeContext = new StreamingRuntimeContext(this, container.getEnvironment(), container.getAccumulatorMap());
    stateKeySelector1 = config.getStatePartitioner(0, getUserCodeClassloader());
    stateKeySelector2 = config.getStatePartitioner(1, getUserCodeClassloader());
}
Also used : Configuration(org.apache.flink.configuration.Configuration)

Example 85 with Configuration

use of org.apache.flink.configuration.Configuration in project flink by apache.

the class AbstractUdfStreamOperatorLifecycleTest method testLifeCycleCancel.

@Test
public void testLifeCycleCancel() throws Exception {
    ACTUAL_ORDER_TRACKING.clear();
    Configuration taskManagerConfig = new Configuration();
    StreamConfig cfg = new StreamConfig(new Configuration());
    MockSourceFunction srcFun = new MockSourceFunction();
    cfg.setStreamOperator(new LifecycleTrackingStreamSource(srcFun, false));
    cfg.setTimeCharacteristic(TimeCharacteristic.ProcessingTime);
    Task task = StreamTaskTest.createTask(SourceStreamTask.class, cfg, taskManagerConfig);
    task.startTaskThread();
    LifecycleTrackingStreamSource.runStarted.await();
    // this should cancel the task even though it is blocked on runFinished
    task.cancelExecution();
    // wait for clean termination
    task.getExecutingThread().join();
    assertEquals(ExecutionState.CANCELED, task.getExecutionState());
    assertEquals(EXPECTED_CALL_ORDER_CANCEL_RUNNING, ACTUAL_ORDER_TRACKING);
}
Also used : SourceStreamTask(org.apache.flink.streaming.runtime.tasks.SourceStreamTask) StreamTask(org.apache.flink.streaming.runtime.tasks.StreamTask) Task(org.apache.flink.runtime.taskmanager.Task) Configuration(org.apache.flink.configuration.Configuration) StreamConfig(org.apache.flink.streaming.api.graph.StreamConfig) Test(org.junit.Test) StreamTaskTest(org.apache.flink.streaming.runtime.tasks.StreamTaskTest)

Aggregations

Configuration (org.apache.flink.configuration.Configuration)630 Test (org.junit.Test)452 IOException (java.io.IOException)137 FileInputSplit (org.apache.flink.core.fs.FileInputSplit)93 File (java.io.File)92 JobID (org.apache.flink.api.common.JobID)74 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)68 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)49 ActorGateway (org.apache.flink.runtime.instance.ActorGateway)46 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)45 Path (org.apache.flink.core.fs.Path)44 ActorRef (akka.actor.ActorRef)43 ArrayList (java.util.ArrayList)43 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)39 FiniteDuration (scala.concurrent.duration.FiniteDuration)38 LocalFlinkMiniCluster (org.apache.flink.runtime.minicluster.LocalFlinkMiniCluster)36 BeforeClass (org.junit.BeforeClass)35 AkkaActorGateway (org.apache.flink.runtime.instance.AkkaActorGateway)33 MetricRegistry (org.apache.flink.runtime.metrics.MetricRegistry)33 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)32