Package org.apache.flink.configuration

Examples of org.apache.flink.configuration.Configuration


    try {
      final String DELIMITER = "12345678-";
      String testData = TEST_DATA1.replace("\n", DELIMITER);
     
      final String tempFile = TestFileUtils.createTempFile(testData);
      final Configuration conf = new Configuration();
     
      final TestDelimitedInputFormat format = new TestDelimitedInputFormat();
      format.setFilePath(tempFile);
      format.setDelimiter(DELIMITER);
      format.configure(conf);
View Full Code Here


 
  @Test
  public void testSamplingOverlyLongRecord() {
    try {
      final String tempFile = TestFileUtils.createTempFile(2 * ConfigConstants.DEFAULT_DELIMITED_FORMAT_MAX_SAMPLE_LEN);
      final Configuration conf = new Configuration();
     
      final TestDelimitedInputFormat format = new TestDelimitedInputFormat();
      format.setFilePath(tempFile);
      format.configure(conf);
     
View Full Code Here

 
  @Test
  public void testCachedStatistics() {
    try {
      final String tempFile = TestFileUtils.createTempFile(TEST_DATA1);
      final Configuration conf = new Configuration();
     
      final TestDelimitedInputFormat format = new TestDelimitedInputFormat();
      format.setFilePath("test://" + tempFile);
      format.configure(conf);
     
View Full Code Here

      return iterationNode;
    }
   
    public void setHeadTask(AbstractJobVertex headTask, TaskConfig headConfig) {
      this.headTask = headTask;
      this.headFinalResultConfig = new TaskConfig(new Configuration());
     
      // check if we already had a configuration, for example if the solution set was
      if (this.headConfig != null) {
        headConfig.getConfiguration().addAll(this.headConfig.getConfiguration());
      }
View Full Code Here

    DummyFileOutputFormat dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.NO_OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    boolean exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(exception);

    // check fail if directory exists
    tmpOutPath.delete();
    Assert.assertTrue("Directory could not be created.", tmpOutPath.mkdir());

    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.NO_OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(exception);
   
    // check success
    tmpOutPath.delete();
   
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.NO_OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isFile());
   
    // ----------- test again with always directory mode
   
    // check fail if file exists
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.NO_OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.ALWAYS);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(exception);

    // check success if directory exists
    tmpOutPath.delete();
    Assert.assertTrue("Directory could not be created.", tmpOutPath.mkdir());

    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.NO_OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.ALWAYS);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isDirectory());
    Assert.assertTrue(tmpOutFile.exists() && tmpOutFile.isFile());
   
    // check fail if file in directory exists
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.NO_OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.ALWAYS);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(exception);
   
    // check success if no file exists
    // delete existing files
    (new File(tmpOutPath.getAbsoluteFile()+"/1")).delete();
    tmpOutPath.delete();
   
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.NO_OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.ALWAYS);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
View Full Code Here

    DummyFileOutputFormat dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.NO_OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    boolean exception = false;
    try {
      dfof.open(0, 2);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(exception);

    // check success if directory exists
    tmpOutPath.delete();
    Assert.assertTrue("Directory could not be created.", tmpOutPath.mkdir());

    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.NO_OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 2);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isDirectory());
    Assert.assertTrue(tmpOutFile.exists() && tmpOutFile.isFile());
   
    // check fail if file in directory exists
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.NO_OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 2);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(exception);
   
    // check success if no file exists
    // delete existing files
    tmpOutFile.delete();
    tmpOutPath.delete();
   
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.NO_OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 2);
      dfof.close();
View Full Code Here

    DummyFileOutputFormat dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    boolean exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isFile());

    // check success if directory exists
    tmpOutPath.delete();
    Assert.assertTrue("Directory could not be created.", tmpOutPath.mkdir());

    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isFile());
   
    // check success
    tmpOutPath.delete();
   
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isFile());
   
    // ----------- test again with always directory mode
   
    // check success if file exists
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.ALWAYS);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isDirectory());
    Assert.assertTrue(tmpOutFile.exists() && tmpOutFile.isFile());

    // check success if directory exists
    tmpOutFile.delete();
    tmpOutPath.delete();
    Assert.assertTrue("Directory could not be created.", tmpOutPath.mkdir());

    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.ALWAYS);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isDirectory());
    Assert.assertTrue(tmpOutFile.exists() && tmpOutFile.isFile());
   
    // check success if file in directory exists
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.ALWAYS);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isDirectory());
    Assert.assertTrue(tmpOutFile.exists() && tmpOutFile.isFile());
   
    // check success if no file exists
    // delete existing files
    tmpOutFile.delete();
    tmpOutPath.delete();
   
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.ALWAYS);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 1);
      dfof.close();
View Full Code Here

    DummyFileOutputFormat dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    boolean exception = false;
    try {
      dfof.open(0, 2);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isDirectory());
    Assert.assertTrue(tmpOutFile.exists() && tmpOutFile.isFile());

    // check success if directory exists
    tmpOutFile.delete();
    tmpOutPath.delete();
    Assert.assertTrue("Directory could not be created.", tmpOutPath.mkdir());

    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 2);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isDirectory());
    Assert.assertTrue(tmpOutFile.exists() && tmpOutFile.isFile());
   
    // check success if file in directory exists
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 2);
      dfof.close();
    } catch (Exception e) {
      exception = true;
    }
    Assert.assertTrue(!exception);
    Assert.assertTrue(tmpOutPath.exists() && tmpOutPath.isDirectory());
    Assert.assertTrue(tmpOutFile.exists() && tmpOutFile.isFile());
   
    // check success if no file exists
    // delete existing files
    (new File(tmpOutPath.getAbsoluteFile()+"/1")).delete();
    tmpOutPath.delete();
   
    dfof = new DummyFileOutputFormat();
    dfof.setOutputFilePath(new Path(tmpFilePath));
    dfof.setWriteMode(WriteMode.OVERWRITE);
    dfof.setOutputDirectoryMode(OutputDirectoryMode.PARONLY);

    dfof.configure(new Configuration());
   
    exception = false;
    try {
      dfof.open(0, 2);
      dfof.close();
View Full Code Here


  @Override
  public void setInput(Map<Operator<?>, OptimizerNode> contractToNode) {
    // see if there is a hint that dictates which shipping strategy to use for BOTH inputs
    final Configuration conf = getPactContract().getParameters();
    ShipStrategyType preSet1 = null;
    ShipStrategyType preSet2 = null;
   
    String shipStrategy = conf.getString(PactCompiler.HINT_SHIP_STRATEGY, null);
    if (shipStrategy != null) {
      if (PactCompiler.HINT_SHIP_STRATEGY_FORWARD.equals(shipStrategy)) {
        preSet1 = preSet2 = ShipStrategyType.FORWARD;
      } else if (PactCompiler.HINT_SHIP_STRATEGY_BROADCAST.equals(shipStrategy)) {
        preSet1 = preSet2 = ShipStrategyType.BROADCAST;
      } else if (PactCompiler.HINT_SHIP_STRATEGY_REPARTITION_HASH.equals(shipStrategy)) {
        preSet1 = preSet2 = ShipStrategyType.PARTITION_HASH;
      } else if (PactCompiler.HINT_SHIP_STRATEGY_REPARTITION_RANGE.equals(shipStrategy)) {
        preSet1 = preSet2 = ShipStrategyType.PARTITION_RANGE;
      } else if (shipStrategy.equalsIgnoreCase(PactCompiler.HINT_SHIP_STRATEGY_REPARTITION)) {
        preSet1 = preSet2 = ShipStrategyType.PARTITION_RANDOM;
      } else {
        throw new CompilerException("Unknown hint for shipping strategy: " + shipStrategy);
      }
    }

    // see if there is a hint that dictates which shipping strategy to use for the FIRST input
    shipStrategy = conf.getString(PactCompiler.HINT_SHIP_STRATEGY_FIRST_INPUT, null);
    if (shipStrategy != null) {
      if (PactCompiler.HINT_SHIP_STRATEGY_FORWARD.equals(shipStrategy)) {
        preSet1 = ShipStrategyType.FORWARD;
      } else if (PactCompiler.HINT_SHIP_STRATEGY_BROADCAST.equals(shipStrategy)) {
        preSet1 = ShipStrategyType.BROADCAST;
      } else if (PactCompiler.HINT_SHIP_STRATEGY_REPARTITION_HASH.equals(shipStrategy)) {
        preSet1 = ShipStrategyType.PARTITION_HASH;
      } else if (PactCompiler.HINT_SHIP_STRATEGY_REPARTITION_RANGE.equals(shipStrategy)) {
        preSet1 = ShipStrategyType.PARTITION_RANGE;
      } else if (shipStrategy.equalsIgnoreCase(PactCompiler.HINT_SHIP_STRATEGY_REPARTITION)) {
        preSet1 = ShipStrategyType.PARTITION_RANDOM;
      } else {
        throw new CompilerException("Unknown hint for shipping strategy of input one: " + shipStrategy);
      }
    }

    // see if there is a hint that dictates which shipping strategy to use for the SECOND input
    shipStrategy = conf.getString(PactCompiler.HINT_SHIP_STRATEGY_SECOND_INPUT, null);
    if (shipStrategy != null) {
      if (PactCompiler.HINT_SHIP_STRATEGY_FORWARD.equals(shipStrategy)) {
        preSet2 = ShipStrategyType.FORWARD;
      } else if (PactCompiler.HINT_SHIP_STRATEGY_BROADCAST.equals(shipStrategy)) {
        preSet2 = ShipStrategyType.BROADCAST;
View Full Code Here

  public static Collection<Object[]> getConfigurations() throws FileNotFoundException, IOException {

    LinkedList<Configuration> tConfigs = new LinkedList<Configuration>();

    for(int i=1; i <= NUM_PROGRAMS; i++) {
      Configuration config = new Configuration();
      config.setInteger("ProgramId", i);
      tConfigs.add(config);
    }

    return toParameterList(tConfigs);
  }
View Full Code Here

TOP

Related Classes of org.apache.flink.configuration.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.