Search in sources :

Example 6 with SplitLocationInfo

use of org.apache.hadoop.mapred.SplitLocationInfo in project hadoop by apache.

the class TestFileInputFormat method testSplitLocationInfo.

@Test
public void testSplitLocationInfo() throws Exception {
    Configuration conf = getConfiguration();
    conf.set(org.apache.hadoop.mapreduce.lib.input.FileInputFormat.INPUT_DIR, "test:///a1/a2");
    Job job = Job.getInstance(conf);
    TextInputFormat fileInputFormat = new TextInputFormat();
    List<InputSplit> splits = fileInputFormat.getSplits(job);
    String[] locations = splits.get(0).getLocations();
    Assert.assertEquals(2, locations.length);
    SplitLocationInfo[] locationInfo = splits.get(0).getLocationInfo();
    Assert.assertEquals(2, locationInfo.length);
    SplitLocationInfo localhostInfo = locations[0].equals("localhost") ? locationInfo[0] : locationInfo[1];
    SplitLocationInfo otherhostInfo = locations[0].equals("otherhost") ? locationInfo[0] : locationInfo[1];
    Assert.assertTrue(localhostInfo.isOnDisk());
    Assert.assertTrue(localhostInfo.isInMemory());
    Assert.assertTrue(otherhostInfo.isOnDisk());
    Assert.assertFalse(otherhostInfo.isInMemory());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) SplitLocationInfo(org.apache.hadoop.mapred.SplitLocationInfo) Job(org.apache.hadoop.mapreduce.Job) InputSplit(org.apache.hadoop.mapreduce.InputSplit) Test(org.junit.Test)

Example 7 with SplitLocationInfo

use of org.apache.hadoop.mapred.SplitLocationInfo in project hive by apache.

the class TestLlapInputSplit method testWritable.

@Test
public void testWritable() throws Exception {
    int splitNum = 88;
    byte[] planBytes = "0123456789987654321".getBytes();
    byte[] fragmentBytes = "abcdefghijklmnopqrstuvwxyz".getBytes();
    SplitLocationInfo[] locations = { new SplitLocationInfo("location1", false), new SplitLocationInfo("location2", false) };
    LlapDaemonInfo daemonInfo1 = new LlapDaemonInfo("host1", 30004, 15003);
    LlapDaemonInfo daemonInfo2 = new LlapDaemonInfo("host2", 30004, 15003);
    LlapDaemonInfo[] llapDaemonInfos = { daemonInfo1, daemonInfo2 };
    ArrayList<FieldDesc> colDescs = new ArrayList<FieldDesc>();
    colDescs.add(new FieldDesc("col1", TypeInfoFactory.stringTypeInfo));
    colDescs.add(new FieldDesc("col2", TypeInfoFactory.intTypeInfo));
    Schema schema = new Schema(colDescs);
    byte[] tokenBytes = new byte[] { 1 };
    LlapInputSplit split1 = new LlapInputSplit(splitNum, planBytes, fragmentBytes, null, locations, llapDaemonInfos, schema, "hive", tokenBytes, "some-dummy-jwt");
    ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
    DataOutputStream dataOut = new DataOutputStream(byteOutStream);
    split1.write(dataOut);
    ByteArrayInputStream byteInStream = new ByteArrayInputStream(byteOutStream.toByteArray());
    DataInputStream dataIn = new DataInputStream(byteInStream);
    LlapInputSplit split2 = new LlapInputSplit();
    split2.readFields(dataIn);
    // Did we read all the data?
    assertEquals(0, byteInStream.available());
    checkLlapSplits(split1, split2);
}
Also used : SplitLocationInfo(org.apache.hadoop.mapred.SplitLocationInfo) DataOutputStream(java.io.DataOutputStream) Schema(org.apache.hadoop.hive.llap.Schema) ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DataInputStream(java.io.DataInputStream) LlapInputSplit(org.apache.hadoop.hive.llap.LlapInputSplit) ByteArrayInputStream(java.io.ByteArrayInputStream) FieldDesc(org.apache.hadoop.hive.llap.FieldDesc) Test(org.junit.Test)

Aggregations

SplitLocationInfo (org.apache.hadoop.mapred.SplitLocationInfo)7 LlapInputSplit (org.apache.hadoop.hive.llap.LlapInputSplit)4 TaskLocationHint (org.apache.tez.dag.api.TaskLocationHint)4 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 URISyntaxException (java.net.URISyntaxException)3 LoginException (javax.security.auth.login.LoginException)3 Path (org.apache.hadoop.fs.Path)3 SubmitWorkInfo (org.apache.hadoop.hive.llap.SubmitWorkInfo)3 LlapCoordinator (org.apache.hadoop.hive.llap.coordinator.LlapCoordinator)3 LlapSigner (org.apache.hadoop.hive.llap.security.LlapSigner)3 SignedMessage (org.apache.hadoop.hive.llap.security.LlapSigner.SignedMessage)3 LlapTokenIdentifier (org.apache.hadoop.hive.llap.security.LlapTokenIdentifier)3 LlapTokenLocalClient (org.apache.hadoop.hive.llap.security.LlapTokenLocalClient)3 Context (org.apache.hadoop.hive.ql.Context)3 UDFArgumentException (org.apache.hadoop.hive.ql.exec.UDFArgumentException)3 UDFArgumentLengthException (org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException)3 UDFArgumentTypeException (org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException)3 DagUtils (org.apache.hadoop.hive.ql.exec.tez.DagUtils)3 HiveSplitGenerator (org.apache.hadoop.hive.ql.exec.tez.HiveSplitGenerator)3