Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/nonsorttest/NonSortTestMR.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/nonsorttest/NonSortTestMR.java?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/nonsorttest/NonSortTestMR.java (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/nonsorttest/NonSortTestMR.java Thu Jul 17 17:44:55 2014 @@ -0,0 +1,71 @@ +/** + * 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. + */ +package org.apache.hadoop.mapred.nativetask.nonsorttest; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.StringTokenizer; + +import org.apache.hadoop.io.IntWritable; +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.mapreduce.Mapper; +import org.apache.hadoop.mapreduce.Reducer; + +public class NonSortTestMR { + + public static class Map extends Mapper { + private final static IntWritable one = new IntWritable(1); + private final Text word = new Text(); + + @Override + public void map(Object key, Text value, Context context) throws IOException, InterruptedException { + final String line = value.toString(); + final StringTokenizer tokenizer = new StringTokenizer(line); + while (tokenizer.hasMoreTokens()) { + word.set(tokenizer.nextToken()); + context.write(word, one); + } + } + } + + public static class KeyHashSumReduce extends Reducer { + long sum = 0; + ByteArrayOutputStream os = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(os); + + @Override + public void reduce(Text key, Iterable values, Context context) throws IOException, + InterruptedException { + for (final IntWritable val : values) { + os.reset(); + key.write(dos); + final int hash = Arrays.hashCode(os.toByteArray()); + sum += hash; + } + } + + @Override + public void cleanup(Context context) throws IOException, InterruptedException { + context.write(new Text("NonSortTest"), new LongWritable(sum)); + } + } + +} Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/BytesFactory.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/BytesFactory.java?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/BytesFactory.java (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/BytesFactory.java Thu Jul 17 17:44:55 2014 @@ -0,0 +1,101 @@ +/** + * 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. + */ +package org.apache.hadoop.mapred.nativetask.testutil; + +import java.util.Random; + +import org.apache.hadoop.io.BooleanWritable; +import org.apache.hadoop.io.ByteWritable; +import org.apache.hadoop.io.BytesWritable; +import org.apache.hadoop.io.DoubleWritable; +import org.apache.hadoop.io.FloatWritable; +import org.apache.hadoop.io.IntWritable; +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.io.UTF8; +import org.apache.hadoop.io.VIntWritable; +import org.apache.hadoop.io.VLongWritable; +import org.apache.hadoop.mapred.nativetask.util.BytesUtil; + + +public class BytesFactory { + public static Random r = new Random(); + + public static Object newObject(byte[] seed, String className) { + r.setSeed(seed.hashCode()); + if (className.equals(IntWritable.class.getName())) { + return new IntWritable(BytesUtil.toInt(seed)); + } else if (className.equals(FloatWritable.class.getName())) { + return new FloatWritable(r.nextFloat()); + } else if (className.equals(DoubleWritable.class.getName())) { + return new DoubleWritable(r.nextDouble()); + } else if (className.equals(LongWritable.class.getName())) { + return new LongWritable(BytesUtil.toLong(seed)); + } else if (className.equals(VIntWritable.class.getName())) { + return new VIntWritable(BytesUtil.toInt(seed)); + } else if (className.equals(VLongWritable.class.getName())) { + return new VLongWritable(BytesUtil.toLong(seed)); + } else if (className.equals(BooleanWritable.class.getName())) { + return new BooleanWritable(seed[0] % 2 == 1 ? true : false); + } else if (className.equals(Text.class.getName())) { + return new Text(BytesUtil.toStringBinary(seed)); + } else if (className.equals(ByteWritable.class.getName())) { + return new ByteWritable(seed.length > 0 ? seed[0] : 0); + } else if (className.equals(BytesWritable.class.getName())) { + return new BytesWritable(seed); + } else if (className.equals(UTF8.class.getName())) { + return new UTF8(BytesUtil.toStringBinary(seed)); + } else if (className.equals(MockValueClass.class.getName())) { + return new MockValueClass(seed); + } else { + return null; + } + } + + + public static byte[] fromBytes(byte[] bytes) throws Exception { + throw new Exception("Not supported"); + } + + public static byte[] toBytes(VTYPE obj) { + final String className = obj.getClass().getName(); + if (className.equals(IntWritable.class.getName())) { + return BytesUtil.toBytes(((IntWritable) obj).get()); + } else if (className.equals(FloatWritable.class.getName())) { + return BytesUtil.toBytes(((FloatWritable) obj).get()); + } else if (className.equals(DoubleWritable.class.getName())) { + return BytesUtil.toBytes(((DoubleWritable) obj).get()); + } else if (className.equals(LongWritable.class.getName())) { + return BytesUtil.toBytes(((LongWritable) obj).get()); + } else if (className.equals(VIntWritable.class.getName())) { + return BytesUtil.toBytes(((VIntWritable) obj).get()); + } else if (className.equals(VLongWritable.class.getName())) { + return BytesUtil.toBytes(((VLongWritable) obj).get()); + } else if (className.equals(BooleanWritable.class.getName())) { + return BytesUtil.toBytes(((BooleanWritable) obj).get()); + } else if (className.equals(Text.class.getName())) { + return BytesUtil.toBytes(((Text) obj).toString()); + } else if (className.equals(ByteWritable.class.getName())) { + return BytesUtil.toBytes(((ByteWritable) obj).get()); + } else if (className.equals(BytesWritable.class.getName())) { + return ((BytesWritable) obj).getBytes(); + } else { + return new byte[0]; + } + } +} Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/EnforceNativeOutputCollectorDelegator.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/EnforceNativeOutputCollectorDelegator.java?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/EnforceNativeOutputCollectorDelegator.java (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/EnforceNativeOutputCollectorDelegator.java Thu Jul 17 17:44:55 2014 @@ -0,0 +1,48 @@ +/** + * 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. + */ +package org.apache.hadoop.mapred.nativetask.testutil; + +import java.io.IOException; + +import org.apache.hadoop.mapred.nativetask.NativeMapOutputCollectorDelegator; + +public class EnforceNativeOutputCollectorDelegator extends NativeMapOutputCollectorDelegator { + private boolean nativetaskloaded = false; + + @Override + public void init(Context context) + throws IOException, ClassNotFoundException { + try { + super.init(context); + nativetaskloaded = true; + } catch (final Exception e) { + nativetaskloaded = false; + System.err.println("load nativetask lib failed, Native-Task Delegation is disabled"); + e.printStackTrace(); + } + } + + @Override + public void collect(K key, V value, int partition) throws IOException, InterruptedException { + if (this.nativetaskloaded) { + super.collect(key, value, partition); + } else { + // nothing to do. + } + } +} Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/MockValueClass.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/MockValueClass.java?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/MockValueClass.java (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/MockValueClass.java Thu Jul 17 17:44:55 2014 @@ -0,0 +1,72 @@ +/** + * 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. + */ +package org.apache.hadoop.mapred.nativetask.testutil; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.util.Random; + +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.io.Writable; +import org.apache.hadoop.mapred.nativetask.util.BytesUtil; + +public class MockValueClass implements Writable { + private final static int DEFAULT_ARRAY_LENGTH = 16; + private int a = 0; + private byte[] array; + private final LongWritable longWritable; + private final Text txt; + private final Random rand = new Random(); + + public MockValueClass() { + a = rand.nextInt(); + array = new byte[DEFAULT_ARRAY_LENGTH]; + rand.nextBytes(array); + longWritable = new LongWritable(rand.nextLong()); + txt = new Text(BytesUtil.toStringBinary(array)); + } + + public MockValueClass(byte[] seed) { + a = seed.length; + array = new byte[seed.length]; + System.arraycopy(seed, 0, array, 0, seed.length); + longWritable = new LongWritable(a); + txt = new Text(BytesUtil.toStringBinary(array)); + } + + @Override + public void write(DataOutput out) throws IOException { + out.writeInt(a); + out.writeInt(array.length); + out.write(array); + longWritable.write(out); + txt.write(out); + } + + @Override + public void readFields(DataInput in) throws IOException { + a = in.readInt(); + final int length = in.readInt(); + array = new byte[length]; + in.readFully(array); + longWritable.readFields(in); + txt.readFields(in); + } +} Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/ResultVerifier.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/ResultVerifier.java?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/ResultVerifier.java (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/ResultVerifier.java Thu Jul 17 17:44:55 2014 @@ -0,0 +1,141 @@ +/** + * 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. + */ +package org.apache.hadoop.mapred.nativetask.testutil; + +import java.io.IOException; +import java.util.zip.CRC32; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FSDataInputStream; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.FileUtil; +import org.apache.hadoop.fs.Path; + +public class ResultVerifier { + /** + * verify the result + * + * @param sample + * :nativetask output + * @param source + * :yuanwenjian + * @throws Exception + */ + public static boolean verify(String sample, String source) throws Exception { + FSDataInputStream sourcein = null; + FSDataInputStream samplein = null; + + final Configuration conf = new Configuration(); + final FileSystem fs = FileSystem.get(conf); + final Path hdfssource = new Path(source); + final Path[] sourcepaths = FileUtil.stat2Paths(fs.listStatus(hdfssource)); + + final Path hdfssample = new Path(sample); + final Path[] samplepaths = FileUtil.stat2Paths(fs.listStatus(hdfssample)); + if (sourcepaths == null) { + throw new Exception("source file can not be found"); + } + if (samplepaths == null) { + throw new Exception("sample file can not be found"); + } + if (sourcepaths.length != samplepaths.length) { + return false; + } + for (int i = 0; i < sourcepaths.length; i++) { + final Path sourcepath = sourcepaths[i]; + // op result file start with "part-r" like part-r-00000 + + if (!sourcepath.getName().startsWith("part-r")) { + continue; + } + Path samplepath = null; + for (int j = 0; j < samplepaths.length; j++) { + if (samplepaths[i].getName().equals(sourcepath.getName())) { + samplepath = samplepaths[i]; + break; + } + } + if (samplepath == null) { + throw new Exception("cound not found file " + samplepaths[0].getParent() + "/" + sourcepath.getName() + + " , as sourcepaths has such file"); + } + + // compare + try { + if (fs.exists(sourcepath) && fs.exists(samplepath)) { + sourcein = fs.open(sourcepath); + samplein = fs.open(samplepath); + } else { + System.err.println("result file not found:" + sourcepath + " or " + samplepath); + return false; + } + + CRC32 sourcecrc, samplecrc; + samplecrc = new CRC32(); + sourcecrc = new CRC32(); + final byte[] bufin = new byte[1 << 16]; + int readnum = 0; + int totalRead = 0; + while (samplein.available() > 0) { + readnum = samplein.read(bufin); + totalRead += readnum; + samplecrc.update(bufin, 0, readnum); + } + + if (0 == totalRead) { + throw new Exception("source " + sample + " is empty file"); + } + + totalRead = 0; + while (sourcein.available() > 0) { + readnum = sourcein.read(bufin); + totalRead += readnum; + sourcecrc.update(bufin, 0, readnum); + } + if (0 == totalRead) { + throw new Exception("source " + sample + " is empty file"); + } + + if (samplecrc.getValue() == sourcecrc.getValue()) { + ; + } else { + return false; + } + } catch (final IOException e) { + throw new Exception("verify exception :", e); + } finally { + + try { + if (samplein != null) { + samplein.close(); + } + if (sourcein != null) { + sourcein.close(); + } + } catch (final IOException e) { + e.printStackTrace(); + } + + } + } + return true; + } + + public static void main(String[] args) { + } +} Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/ScenarioConfiguration.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/ScenarioConfiguration.java?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/ScenarioConfiguration.java (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/ScenarioConfiguration.java Thu Jul 17 17:44:55 2014 @@ -0,0 +1,58 @@ +/** + * 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. + */ +package org.apache.hadoop.mapred.nativetask.testutil; + +import org.apache.hadoop.conf.Configuration; + +public class ScenarioConfiguration extends Configuration { + public ScenarioConfiguration() { + super(); + this.addResource(TestConstants.COMMON_CONF_PATH); + } + + public void addcombinerConf() { + this.addResource(TestConstants.COMBINER_CONF_PATH); + } + + public void addKVTestConf() { + this.addResource(TestConstants.KVTEST_CONF_PATH); + } + + public void addNonSortTestConf() { + this.addResource(TestConstants.NONSORT_TEST_CONF); + } + + public void addNativeConf() { + this.set(TestConstants.NATIVETASK_COLLECTOR_DELEGATOR, + TestConstants.NATIVETASK_COLLECTOR_DELEGATOR_CLASS); + } + + public static Configuration getNormalConfiguration() { + Configuration normalConf = new Configuration(); + normalConf.addResource("common_conf.xml"); + normalConf.addResource("normal_conf.xml"); + return normalConf; + } + + public static Configuration getNativeConfiguration() { + Configuration nativeConf = new Configuration(); + nativeConf.addResource("common_conf.xml"); + nativeConf.addResource("native_conf.xml"); + return nativeConf; + } +} Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/TestConstants.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/TestConstants.java?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/TestConstants.java (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/system/function/org/apache/hadoop/mapred/nativetask/testutil/TestConstants.java Thu Jul 17 17:44:55 2014 @@ -0,0 +1,67 @@ +/** + * 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. + */ +package org.apache.hadoop.mapred.nativetask.testutil; + +public class TestConstants { + // conf path + public static final String COMBINER_CONF_PATH = "test-combiner-conf.xml"; + public static final String KVTEST_CONF_PATH = "kvtest-conf.xml"; + public static final String NONSORT_TEST_CONF = "test-nonsort-conf.xml"; + + public static final String NATIVETASK_KVSIZE_MIN = "nativetask.kvsize.min"; + public static final String NATIVETASK_KVSIZE_MAX = "nativetask.kvsize.max"; + + public static final String NATIVETASK_KVTEST_INPUTDIR = "nativetask.kvtest.inputdir"; + public static final String NATIVETASK_KVTEST_OUTPUTDIR = "nativetask.kvtest.outputdir"; + public static final String NATIVETASK_KVTEST_NORMAL_OUTPUTDIR = "normal.kvtest.outputdir"; + public static final String NATIVETASK_KVTEST_CREATEFILE = "nativetask.kvtest.createfile"; + public static final String NATIVETASK_KVTEST_FILE_RECORDNUM = "nativetask.kvtest.file.recordnum"; + public static final String NATIVETASK_KVTEST_KEYCLASSES = "nativetask.kvtest.keyclasses"; + public static final String NATIVETASK_KVTEST_VALUECLASSES = "nativetask.kvtest.valueclasses"; + public static final String NATIVETASK_COLLECTOR_DELEGATOR = "mapreduce.map.output.collector.delegator.class"; + public static final String NATIVETASK_COLLECTOR_DELEGATOR_CLASS = "org.apache.hadoop.mapred.nativetask.testutil.EnforceNativeOutputCollectorDelegator"; + + public static final String SNAPPY_COMPRESS_CONF_PATH = "test-snappy-compress-conf.xml"; + public static final String GZIP_COMPRESS_CONF_PATH = "test-gzip-compress-conf.xml"; + public static final String BZIP2_COMPRESS_CONF_PATH = "test-bzip2-compress-conf.xml"; + public static final String DEFAULT_COMPRESS_CONF_PATH = "test-default-compress-conf.xml"; + public static final String LZ4_COMPRESS_CONF_PATH = "test-lz4-compress-conf.xml"; + public static final String NATIVETASK_COMPRESS_FILESIZE = "nativetask.compress.filesize"; + + public static final String NATIVETASK_TEST_COMBINER_INPUTPATH_KEY = "nativetask.combinertest.inputpath"; + public static final String NATIVETASK_TEST_COMBINER_INPUTPATH_DEFAULTV = "./combinertest/input"; + public static final String NATIVETASK_TEST_COMBINER_OUTPUTPATH = "nativetask.combinertest.outputdir"; + public static final String NATIVETASK_TEST_COMBINER_OUTPUTPATH_DEFAULTV = "./combinertest/output/native"; + public static final String NORMAL_TEST_COMBINER_OUTPUTPATH = "normal.combinertest.outputdir"; + public static final String NORMAL_TEST_COMBINER_OUTPUTPATH_DEFAULTV = "./combinertest/output/normal"; + public static final String OLDAPI_NATIVETASK_TEST_COMBINER_OUTPUTPATH = "oldAPI.nativetask.combinertest.outputdir"; + public static final String OLDAPI_NORMAL_TEST_COMBINER_OUTPUTPATH = "oldAPI.normal.combinertest.outputdir"; + public static final String NATIVETASK_COMBINER_WORDCOUNT_FILESIZE = "nativetask.combiner.wordcount.filesize"; + public static final String NATIVETASK_NONSORTTEST_FILESIZE = "nativetask.nonsorttest.filesize"; + + public static final String COMMON_CONF_PATH = "common_conf.xml"; + + public static final String FILESIZE_KEY = "kvtest.file.size"; + public static final String NATIVETASK_KVSIZE_MAX_LARGEKV_TEST = "nativetask.kvsize.max.largekv"; + + public static final String NATIVETASK_MAP_OUTPUT_SORT = "mapreduce.sort.avoidance"; + public static final String NONSORT_TEST_INPUTDIR = "nativetask.nonsorttest.inputpath"; + public static final String NONSORT_TEST_NATIVE_OUTPUT = "nonsorttest.native.outputdir"; + public static final String NONSORT_TEST_NORMAL_OUTPUT = "nonsorttest.normal.outputdir"; + +} Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/common_conf.xml URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/common_conf.xml?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/common_conf.xml (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/common_conf.xml Thu Jul 17 17:44:55 2014 @@ -0,0 +1,39 @@ + + + + + + + +mapred.job.tracker +local + + + +keep.failed.task.files +true + + + + keep.task.files.pattern + .*_m_ + Keep all files from tasks whose task names match the given + regular expression. Defaults to none. + + + +nativetask.kvsize.max.largekv +1048576 + + + +native.processor.buffer.kb +128 + + + +nativetask.output.manager +org.apache.hadoop.mapred.nativetask.util.LocalJobOutputFiles + + + Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/kvtest-conf.xml URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/kvtest-conf.xml?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/kvtest-conf.xml (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/kvtest-conf.xml Thu Jul 17 17:44:55 2014 @@ -0,0 +1,87 @@ + + + + + + + +nativetask.kvtest.inputdir +./kvtest/input + + +nativetask.kvtest.outputdir +./kvtest/output/native + + +normal.kvtest.outputdir +./kvtest/output/normal + + +kvtest.file.size +10485760 + + +mapreduce.reduce.class +org.apache.hadoop.mapred.nativetask.kvtest.HashSumReducer + + +mapred.output.value.class +org.apache.hadoop.io.IntWritable + + +nativetask.kvtest.keyclasses + +org.apache.hadoop.io.BytesWritable; +org.apache.hadoop.io.BooleanWritable; +org.apache.hadoop.io.ByteWritable; +org.apache.hadoop.io.DoubleWritable; +org.apache.hadoop.io.FloatWritable; +org.apache.hadoop.io.IntWritable; +org.apache.hadoop.io.LongWritable; +org.apache.hadoop.io.Text; +org.apache.hadoop.io.VIntWritable; +org.apache.hadoop.io.VLongWritable; + + + +nativetask.kvtest.valueclasses + +org.apache.hadoop.io.BytesWritable; +org.apache.hadoop.io.BooleanWritable; +org.apache.hadoop.io.ByteWritable; +org.apache.hadoop.io.DoubleWritable; +org.apache.hadoop.io.FloatWritable; +org.apache.hadoop.io.IntWritable; +org.apache.hadoop.io.LongWritable; +org.apache.hadoop.io.Text; +org.apache.hadoop.io.VIntWritable; +org.apache.hadoop.io.VLongWritable; +org.apache.hadoop.mapred.nativetask.testutil.MockValueClass; + + + + +mapred.output.compress +false + + + + +mapred.output.compression.type +BLOCK + + +mapred.compress.map.output +true + + +mapred.map.output.compression.codec +org.apache.hadoop.io.compress.SnappyCodec + + + + +hadoop.native.lib +true + + Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/native_conf.xml URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/native_conf.xml?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/native_conf.xml (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/native_conf.xml Thu Jul 17 17:44:55 2014 @@ -0,0 +1,15 @@ + + + + + +mapreduce.job.map.output.collector.class +org.apache.hadoop.mapred.nativetask.testutil.EnforceNativeOutputCollectorDelegator + + + +io.sort.mb +5 + + + \ No newline at end of file Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/normal_conf.xml URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/normal_conf.xml?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/normal_conf.xml (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/normal_conf.xml Thu Jul 17 17:44:55 2014 @@ -0,0 +1,10 @@ + + + + + +io.sort.mb +30 + + + \ No newline at end of file Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-bzip2-compress-conf.xml URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-bzip2-compress-conf.xml?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-bzip2-compress-conf.xml (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-bzip2-compress-conf.xml Thu Jul 17 17:44:55 2014 @@ -0,0 +1,39 @@ + + + + + + + +mapred.output.compress +false + + +nativetask.compress.filesize +100000 + + +mapreduce.reduce.class +org.apache.hadoop.mapred.nativetask.kvtest.HashSumReducer + + +mapred.output.value.class +org.apache.hadoop.io.IntWritable + + +mapred.compress.map.output +true + + +mapred.output.compression.type +BLOCK + + +mapred.map.output.compression.codec +org.apache.hadoop.io.compress.BZip2Codec + + +hadoop.native.lib +true + + Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-combiner-conf.xml URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-combiner-conf.xml?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-combiner-conf.xml (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-combiner-conf.xml Thu Jul 17 17:44:55 2014 @@ -0,0 +1,36 @@ + + + + + + + +nativetask.combinertest.inputpath +./combinertest/input + + +nativetask.combiner.wordcount.filesize +20971520 + + + +nativetask.combinertest.outputdir +./combinertest/output/native + + +normal.combinertest.outputdir +./combinertest/output/normal + + +oldAPI.nativetask.combinertest.outputdir +./combinertest/oldapi/output/native + + +oldAPI.normal.combinertest.outputdir +./combinertest/oldapi/output/normal + + +mapred.job.tracker +local + + Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-default-compress-conf.xml URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-default-compress-conf.xml?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-default-compress-conf.xml (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-default-compress-conf.xml Thu Jul 17 17:44:55 2014 @@ -0,0 +1,39 @@ + + + + + + + +mapred.output.compress +false + + +mapred.output.value.class +org.apache.hadoop.io.IntWritable + + +nativetask.compress.filesize +100000 + + +mapreduce.reduce.class +org.apache.hadoop.mapred.nativetask.kvtest.HashSumReducer + + +mapred.compress.map.output +true + + +mapred.output.compression.type +BLOCK + + +mapred.map.output.compression.codec +org.apache.hadoop.io.compress.DefaultCodec + + +hadoop.native.lib +true + + Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-gzip-compress-conf.xml URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-gzip-compress-conf.xml?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-gzip-compress-conf.xml (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-gzip-compress-conf.xml Thu Jul 17 17:44:55 2014 @@ -0,0 +1,39 @@ + + + + + + + +mapred.output.compress +false + + +mapred.output.value.class +org.apache.hadoop.io.IntWritable + + +nativetask.compress.filesize +100000 + + +mapreduce.reduce.class +org.apache.hadoop.mapred.nativetask.kvtest.HashSumReducer + + +mapred.compress.map.output +true + + +mapred.output.compression.type +BLOCK + + +mapred.map.output.compression.codec +org.apache.hadoop.io.compress.GzipCodec + + +hadoop.native.lib +true + + Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-lz4-compress-conf.xml URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-lz4-compress-conf.xml?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-lz4-compress-conf.xml (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-lz4-compress-conf.xml Thu Jul 17 17:44:55 2014 @@ -0,0 +1,39 @@ + + + + + + + +mapred.output.compress +false + + +mapred.output.value.class +org.apache.hadoop.io.IntWritable + + +nativetask.compress.filesize +100000 + + +mapreduce.reduce.class +org.apache.hadoop.mapred.nativetask.kvtest.HashSumReducer + + +mapred.compress.map.output +true + + +mapred.output.compression.type +BLOCK + + +mapred.map.output.compression.codec +org.apache.hadoop.io.compress.Lz4Codec + + +hadoop.native.lib +true + + Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-nonsort-conf.xml URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-nonsort-conf.xml?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-nonsort-conf.xml (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-nonsort-conf.xml Thu Jul 17 17:44:55 2014 @@ -0,0 +1,31 @@ + + + + + + + +nativetask.nonsorttest.inputpath +./sorttest/input + + +nativetask.nonsorttest.filesize +4194304 + + +nonsorttest.native.outputdir.tmp +./sorttest/output/tmp + + +nonsorttest.native.outputdir +./sorttest/output/native + + +nonsorttest.normal.outputdir +./sort/output/normal + + +mapred.job.tracker +local + + Added: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-snappy-compress-conf.xml URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-snappy-compress-conf.xml?rev=1611413&view=auto ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-snappy-compress-conf.xml (added) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/resources/test-snappy-compress-conf.xml Thu Jul 17 17:44:55 2014 @@ -0,0 +1,41 @@ + + + + + + + +mapred.output.compress +false + + +mapreduce.reduce.class +org.apache.hadoop.mapred.nativetask.kvtest.HashSumReducer + + + +mapred.output.value.class +org.apache.hadoop.io.IntWritable + + +nativetask.compress.filesize +100000 + + + +mapred.compress.map.output +true + + +mapred.output.compression.type +BLOCK + + +mapred.map.output.compression.codec +org.apache.hadoop.io.compress.SnappyCodec + + +hadoop.native.lib +true + + Modified: hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/pom.xml URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/pom.xml?rev=1611413&r1=1611412&r2=1611413&view=diff ============================================================================== --- hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/pom.xml (original) +++ hadoop/common/branches/MR-2841/hadoop-mapreduce-project/hadoop-mapreduce-client/pom.xml Thu Jul 17 17:44:55 2014 @@ -187,5 +187,6 @@ hadoop-mapreduce-client-jobclient hadoop-mapreduce-client-hs hadoop-mapreduce-client-hs-plugins + hadoop-mapreduce-client-nativetask