Java Code Examples for org.apache.hadoop.security.token.Token#write()

The following examples show how to use org.apache.hadoop.security.token.Token#write() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestShuffleInputEventHandlerImpl.java    From tez with Apache License 2.0 6 votes vote down vote up
private ShuffleManager createShuffleManager(InputContext inputContext) throws IOException {
  Path outDirBase = new Path(".", "outDir");
  String[] outDirs = new String[] { outDirBase.toString() };
  doReturn(outDirs).when(inputContext).getWorkDirs();
  conf.setStrings(TezRuntimeFrameworkConfigs.LOCAL_DIRS, inputContext.getWorkDirs());

  DataOutputBuffer out = new DataOutputBuffer();
  Token<JobTokenIdentifier> token = new Token<JobTokenIdentifier>(new JobTokenIdentifier(),
      new JobTokenSecretManager(null));
  token.write(out);
  doReturn(ByteBuffer.wrap(out.getData())).when(inputContext).getServiceConsumerMetaData(
      conf.get(TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID,
          TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID_DEFAULT));

  FetchedInputAllocator inputAllocator = mock(FetchedInputAllocator.class);
  ShuffleManager realShuffleManager = new ShuffleManager(inputContext, conf, 2,
      1024, false, -1, null, inputAllocator);
  ShuffleManager shuffleManager = spy(realShuffleManager);
  return shuffleManager;
}
 
Example 2
Source File: TestShuffleManager.java    From tez with Apache License 2.0 6 votes vote down vote up
private ShuffleManagerForTest createShuffleManager(
    InputContext inputContext, int expectedNumOfPhysicalInputs)
        throws IOException {
  Path outDirBase = new Path(".", "outDir");
  String[] outDirs = new String[] { outDirBase.toString() };
  doReturn(outDirs).when(inputContext).getWorkDirs();
  conf.setStrings(TezRuntimeFrameworkConfigs.LOCAL_DIRS,
      inputContext.getWorkDirs());
  // 5 seconds
  conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_BATCH_WAIT, 5000);

  DataOutputBuffer out = new DataOutputBuffer();
  Token<JobTokenIdentifier> token = new Token<JobTokenIdentifier>(new JobTokenIdentifier(),
      new JobTokenSecretManager(null));
  token.write(out);
  doReturn(ByteBuffer.wrap(out.getData())).when(inputContext).
      getServiceConsumerMetaData(
          conf.get(TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID,
              TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID_DEFAULT));

  FetchedInputAllocator inputAllocator = mock(FetchedInputAllocator.class);
  return new ShuffleManagerForTest(inputContext, conf,
      expectedNumOfPhysicalInputs, 1024, false, -1, null, inputAllocator);
}
 
Example 3
Source File: ShuffleUtils.java    From incubator-tez with Apache License 2.0 5 votes vote down vote up
public static ByteBuffer convertJobTokenToBytes(
    Token<JobTokenIdentifier> jobToken) throws IOException {
  DataOutputBuffer dob = new DataOutputBuffer();
  jobToken.write(dob);
  ByteBuffer bb = ByteBuffer.wrap(dob.getData(), 0, dob.getLength());
  return bb;
}
 
Example 4
Source File: TezCommonUtils.java    From tez with Apache License 2.0 5 votes vote down vote up
public static ByteBuffer convertJobTokenToBytes(
    Token<JobTokenIdentifier> jobToken) throws IOException {
  DataOutputBuffer dob = new DataOutputBuffer();
  jobToken.write(dob);
  ByteBuffer bb = ByteBuffer.wrap(dob.getData(), 0, dob.getLength());
  return bb;
}
 
Example 5
Source File: TestShuffleHandler.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testRecovery() throws IOException {
  final String user = "someuser";
  final ApplicationId appId = ApplicationId.newInstance(12345, 1);
  final JobID jobId = JobID.downgrade(TypeConverter.fromYarn(appId));
  final File tmpDir = new File(System.getProperty("test.build.data",
      System.getProperty("java.io.tmpdir")),
      TestShuffleHandler.class.getName());
  Configuration conf = new Configuration();
  conf.setInt(ShuffleHandler.SHUFFLE_PORT_CONFIG_KEY, 0);
  conf.setInt(ShuffleHandler.MAX_SHUFFLE_CONNECTIONS, 3);
  ShuffleHandler shuffle = new ShuffleHandler();
  // emulate aux services startup with recovery enabled
  shuffle.setRecoveryPath(new Path(tmpDir.toString()));
  tmpDir.mkdirs();
  try {
    shuffle.init(conf);
    shuffle.start();

    // setup a shuffle token for an application
    DataOutputBuffer outputBuffer = new DataOutputBuffer();
    outputBuffer.reset();
    Token<JobTokenIdentifier> jt = new Token<JobTokenIdentifier>(
        "identifier".getBytes(), "password".getBytes(), new Text(user),
        new Text("shuffleService"));
    jt.write(outputBuffer);
    shuffle.initializeApplication(new ApplicationInitializationContext(user,
        appId, ByteBuffer.wrap(outputBuffer.getData(), 0,
          outputBuffer.getLength())));

    // verify we are authorized to shuffle
    int rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // emulate shuffle handler restart
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();

    // verify we are still authorized to shuffle to the old application
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // shutdown app and verify access is lost
    shuffle.stopApplication(new ApplicationTerminationContext(appId));
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, rc);

    // emulate shuffle handler restart
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();

    // verify we still don't have access
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, rc);
  } finally {
    if (shuffle != null) {
      shuffle.close();
    }
    FileUtil.fullyDelete(tmpDir);
  }
}
 
Example 6
Source File: TestShuffleHandler.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testRecoveryFromOtherVersions() throws IOException {
  final String user = "someuser";
  final ApplicationId appId = ApplicationId.newInstance(12345, 1);
  final File tmpDir = new File(System.getProperty("test.build.data",
      System.getProperty("java.io.tmpdir")),
      TestShuffleHandler.class.getName());
  Configuration conf = new Configuration();
  conf.setInt(ShuffleHandler.SHUFFLE_PORT_CONFIG_KEY, 0);
  conf.setInt(ShuffleHandler.MAX_SHUFFLE_CONNECTIONS, 3);
  ShuffleHandler shuffle = new ShuffleHandler();
  // emulate aux services startup with recovery enabled
  shuffle.setRecoveryPath(new Path(tmpDir.toString()));
  tmpDir.mkdirs();
  try {
    shuffle.init(conf);
    shuffle.start();

    // setup a shuffle token for an application
    DataOutputBuffer outputBuffer = new DataOutputBuffer();
    outputBuffer.reset();
    Token<JobTokenIdentifier> jt = new Token<JobTokenIdentifier>(
        "identifier".getBytes(), "password".getBytes(), new Text(user),
        new Text("shuffleService"));
    jt.write(outputBuffer);
    shuffle.initializeApplication(new ApplicationInitializationContext(user,
        appId, ByteBuffer.wrap(outputBuffer.getData(), 0,
            outputBuffer.getLength())));

    // verify we are authorized to shuffle
    int rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // emulate shuffle handler restart
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();

    // verify we are still authorized to shuffle to the old application
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);
    Version version = Version.newInstance(1, 0);
    Assert.assertEquals(version, shuffle.getCurrentVersion());
  
    // emulate shuffle handler restart with compatible version
    Version version11 = Version.newInstance(1, 1);
    // update version info before close shuffle
    shuffle.storeVersion(version11);
    Assert.assertEquals(version11, shuffle.loadVersion());
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();
    // shuffle version will be override by CURRENT_VERSION_INFO after restart
    // successfully.
    Assert.assertEquals(version, shuffle.loadVersion());
    // verify we are still authorized to shuffle to the old application
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);
  
    // emulate shuffle handler restart with incompatible version
    Version version21 = Version.newInstance(2, 1);
    shuffle.storeVersion(version21);
    Assert.assertEquals(version21, shuffle.loadVersion());
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
  
    try {
      shuffle.start();
      Assert.fail("Incompatible version, should expect fail here.");
    } catch (ServiceStateException e) {
      Assert.assertTrue("Exception message mismatch", 
      e.getMessage().contains("Incompatible version for state DB schema:"));
    } 
  
  } finally {
    if (shuffle != null) {
      shuffle.close();
    }
    FileUtil.fullyDelete(tmpDir);
  }
}
 
Example 7
Source File: TestShuffleHandler.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testRecovery() throws IOException {
  final String user = "someuser";
  final ApplicationId appId = ApplicationId.newInstance(12345, 1);
  final JobID jobId = JobID.downgrade(TypeConverter.fromYarn(appId));
  final File tmpDir = new File(System.getProperty("test.build.data",
      System.getProperty("java.io.tmpdir")),
      TestShuffleHandler.class.getName());
  Configuration conf = new Configuration();
  conf.setInt(ShuffleHandler.SHUFFLE_PORT_CONFIG_KEY, 0);
  conf.setInt(ShuffleHandler.MAX_SHUFFLE_CONNECTIONS, 3);
  ShuffleHandler shuffle = new ShuffleHandler();
  // emulate aux services startup with recovery enabled
  shuffle.setRecoveryPath(new Path(tmpDir.toString()));
  tmpDir.mkdirs();
  try {
    shuffle.init(conf);
    shuffle.start();

    // setup a shuffle token for an application
    DataOutputBuffer outputBuffer = new DataOutputBuffer();
    outputBuffer.reset();
    Token<JobTokenIdentifier> jt = new Token<JobTokenIdentifier>(
        "identifier".getBytes(), "password".getBytes(), new Text(user),
        new Text("shuffleService"));
    jt.write(outputBuffer);
    shuffle.initializeApplication(new ApplicationInitializationContext(user,
        appId, ByteBuffer.wrap(outputBuffer.getData(), 0,
          outputBuffer.getLength())));

    // verify we are authorized to shuffle
    int rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // emulate shuffle handler restart
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();

    // verify we are still authorized to shuffle to the old application
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // shutdown app and verify access is lost
    shuffle.stopApplication(new ApplicationTerminationContext(appId));
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, rc);

    // emulate shuffle handler restart
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();

    // verify we still don't have access
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, rc);
  } finally {
    if (shuffle != null) {
      shuffle.close();
    }
    FileUtil.fullyDelete(tmpDir);
  }
}
 
Example 8
Source File: TestShuffleHandler.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testRecoveryFromOtherVersions() throws IOException {
  final String user = "someuser";
  final ApplicationId appId = ApplicationId.newInstance(12345, 1);
  final File tmpDir = new File(System.getProperty("test.build.data",
      System.getProperty("java.io.tmpdir")),
      TestShuffleHandler.class.getName());
  Configuration conf = new Configuration();
  conf.setInt(ShuffleHandler.SHUFFLE_PORT_CONFIG_KEY, 0);
  conf.setInt(ShuffleHandler.MAX_SHUFFLE_CONNECTIONS, 3);
  ShuffleHandler shuffle = new ShuffleHandler();
  // emulate aux services startup with recovery enabled
  shuffle.setRecoveryPath(new Path(tmpDir.toString()));
  tmpDir.mkdirs();
  try {
    shuffle.init(conf);
    shuffle.start();

    // setup a shuffle token for an application
    DataOutputBuffer outputBuffer = new DataOutputBuffer();
    outputBuffer.reset();
    Token<JobTokenIdentifier> jt = new Token<JobTokenIdentifier>(
        "identifier".getBytes(), "password".getBytes(), new Text(user),
        new Text("shuffleService"));
    jt.write(outputBuffer);
    shuffle.initializeApplication(new ApplicationInitializationContext(user,
        appId, ByteBuffer.wrap(outputBuffer.getData(), 0,
            outputBuffer.getLength())));

    // verify we are authorized to shuffle
    int rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // emulate shuffle handler restart
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();

    // verify we are still authorized to shuffle to the old application
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);
    Version version = Version.newInstance(1, 0);
    Assert.assertEquals(version, shuffle.getCurrentVersion());
  
    // emulate shuffle handler restart with compatible version
    Version version11 = Version.newInstance(1, 1);
    // update version info before close shuffle
    shuffle.storeVersion(version11);
    Assert.assertEquals(version11, shuffle.loadVersion());
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();
    // shuffle version will be override by CURRENT_VERSION_INFO after restart
    // successfully.
    Assert.assertEquals(version, shuffle.loadVersion());
    // verify we are still authorized to shuffle to the old application
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);
  
    // emulate shuffle handler restart with incompatible version
    Version version21 = Version.newInstance(2, 1);
    shuffle.storeVersion(version21);
    Assert.assertEquals(version21, shuffle.loadVersion());
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
  
    try {
      shuffle.start();
      Assert.fail("Incompatible version, should expect fail here.");
    } catch (ServiceStateException e) {
      Assert.assertTrue("Exception message mismatch", 
      e.getMessage().contains("Incompatible version for state DB schema:"));
    } 
  
  } finally {
    if (shuffle != null) {
      shuffle.close();
    }
    FileUtil.fullyDelete(tmpDir);
  }
}
 
Example 9
Source File: TestShuffleHandler.java    From tez with Apache License 2.0 4 votes vote down vote up
@Test
public void testRecovery() throws IOException {
  final String user = "someuser";
  final ApplicationId appId = ApplicationId.newInstance(12345, 1);
  final JobID jobId = JobID.downgrade(TypeConverter.fromYarn(appId));
  final File tmpDir = new File(System.getProperty("test.build.data",
      System.getProperty("java.io.tmpdir")),
      TestShuffleHandler.class.getName());
  Configuration conf = new Configuration();
  conf.set(HADOOP_TMP_DIR, TEST_DIR.getAbsolutePath());
  conf.setInt(ShuffleHandler.SHUFFLE_PORT_CONFIG_KEY, 0);
  conf.setInt(ShuffleHandler.MAX_SHUFFLE_CONNECTIONS, 3);
  ShuffleHandler shuffle = new ShuffleHandler();
  // emulate aux services startup with recovery enabled
  shuffle.setRecoveryPath(new Path(tmpDir.toString()));
  tmpDir.mkdirs();
  try {
    shuffle.init(conf);
    shuffle.start();

    // setup a shuffle token for an application
    DataOutputBuffer outputBuffer = new DataOutputBuffer();
    outputBuffer.reset();
    Token<JobTokenIdentifier> jt = new Token<JobTokenIdentifier>(
        "identifier".getBytes(), "password".getBytes(), new Text(user),
        new Text("shuffleService"));
    jt.write(outputBuffer);
    shuffle.initializeApplication(new ApplicationInitializationContext(user,
        appId, ByteBuffer.wrap(outputBuffer.getData(), 0,
          outputBuffer.getLength())));

    // verify we are authorized to shuffle
    int rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // emulate shuffle handler restart
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();

    // verify we are still authorized to shuffle to the old application
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // shutdown app and verify access is lost
    shuffle.stopApplication(new ApplicationTerminationContext(appId));
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, rc);

    // emulate shuffle handler restart
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();

    // verify we still don't have access
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, rc);
  } finally {
    if (shuffle != null) {
      shuffle.close();
    }
    FileUtil.fullyDelete(tmpDir);
  }
}
 
Example 10
Source File: TestShuffleHandler.java    From tez with Apache License 2.0 4 votes vote down vote up
@Test
public void testRecoveryFromOtherVersions() throws IOException {
  final String user = "someuser";
  final ApplicationId appId = ApplicationId.newInstance(12345, 1);
  final File tmpDir = new File(System.getProperty("test.build.data",
      System.getProperty("java.io.tmpdir")),
      TestShuffleHandler.class.getName());
  Configuration conf = new Configuration();
  conf.set(HADOOP_TMP_DIR, TEST_DIR.getAbsolutePath());
  conf.setInt(ShuffleHandler.SHUFFLE_PORT_CONFIG_KEY, 0);
  conf.setInt(ShuffleHandler.MAX_SHUFFLE_CONNECTIONS, 3);
  ShuffleHandler shuffle = new ShuffleHandler();
  // emulate aux services startup with recovery enabled
  shuffle.setRecoveryPath(new Path(tmpDir.toString()));
  tmpDir.mkdirs();
  try {
    shuffle.init(conf);
    shuffle.start();

    // setup a shuffle token for an application
    DataOutputBuffer outputBuffer = new DataOutputBuffer();
    outputBuffer.reset();
    Token<JobTokenIdentifier> jt = new Token<JobTokenIdentifier>(
        "identifier".getBytes(), "password".getBytes(), new Text(user),
        new Text("shuffleService"));
    jt.write(outputBuffer);
    shuffle.initializeApplication(new ApplicationInitializationContext(user,
        appId, ByteBuffer.wrap(outputBuffer.getData(), 0,
            outputBuffer.getLength())));

    // verify we are authorized to shuffle
    int rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // emulate shuffle handler restart
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();

    // verify we are still authorized to shuffle to the old application
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);
    Version version = Version.newInstance(1, 0);
    Assert.assertEquals(version, shuffle.getCurrentVersion());

    // emulate shuffle handler restart with compatible version
    Version version11 = Version.newInstance(1, 1);
    // update version info before close shuffle
    shuffle.storeVersion(version11);
    Assert.assertEquals(version11, shuffle.loadVersion());
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
    shuffle.start();
    // shuffle version will be override by CURRENT_VERSION_INFO after restart
    // successfully.
    Assert.assertEquals(version, shuffle.loadVersion());
    // verify we are still authorized to shuffle to the old application
    rc = getShuffleResponseCode(shuffle, jt);
    Assert.assertEquals(HttpURLConnection.HTTP_OK, rc);

    // emulate shuffle handler restart with incompatible version
    Version version21 = Version.newInstance(2, 1);
    shuffle.storeVersion(version21);
    Assert.assertEquals(version21, shuffle.loadVersion());
    shuffle.close();
    shuffle = new ShuffleHandler();
    shuffle.setRecoveryPath(new Path(tmpDir.toString()));
    shuffle.init(conf);
  
    try {
      shuffle.start();
      Assert.fail("Incompatible version, should expect fail here.");
    } catch (ServiceStateException e) {
      Assert.assertTrue("Exception message mismatch",
      e.getMessage().contains("Incompatible version for state DB schema:"));
    }

  } finally {
    if (shuffle != null) {
      shuffle.close();
    }
    FileUtil.fullyDelete(tmpDir);
  }
}
 
Example 11
Source File: ShuffleHandler.java    From hadoop with Apache License 2.0 3 votes vote down vote up
/**
 * A helper function to serialize the JobTokenIdentifier to be sent to the
 * ShuffleHandler as ServiceData.
 * @param jobToken the job token to be used for authentication of
 * shuffle data requests.
 * @return the serialized version of the jobToken.
 */
public static ByteBuffer serializeServiceData(Token<JobTokenIdentifier> jobToken) throws IOException {
  //TODO these bytes should be versioned
  DataOutputBuffer jobToken_dob = new DataOutputBuffer();
  jobToken.write(jobToken_dob);
  return ByteBuffer.wrap(jobToken_dob.getData(), 0, jobToken_dob.getLength());
}
 
Example 12
Source File: ShuffleHandler.java    From big-c with Apache License 2.0 3 votes vote down vote up
/**
 * A helper function to serialize the JobTokenIdentifier to be sent to the
 * ShuffleHandler as ServiceData.
 * @param jobToken the job token to be used for authentication of
 * shuffle data requests.
 * @return the serialized version of the jobToken.
 */
public static ByteBuffer serializeServiceData(Token<JobTokenIdentifier> jobToken) throws IOException {
  //TODO these bytes should be versioned
  DataOutputBuffer jobToken_dob = new DataOutputBuffer();
  jobToken.write(jobToken_dob);
  return ByteBuffer.wrap(jobToken_dob.getData(), 0, jobToken_dob.getLength());
}
 
Example 13
Source File: AMContainerHelpers.java    From incubator-tez with Apache License 2.0 3 votes vote down vote up
/**
 * A helper function to serialize the JobTokenIdentifier to be sent to the
 * ShuffleHandler as ServiceData.
 * 
 * *NOTE* This is a copy of what is done by the MapReduce ShuffleHandler. Not using that directly
 * to avoid a dependency on mapreduce.
 * 
 * @param jobToken
 *          the job token to be used for authentication of shuffle data
 *          requests.
 * @return the serialized version of the jobToken.
 */
private static ByteBuffer serializeServiceData(Token<JobTokenIdentifier> jobToken)
    throws IOException {
  // TODO these bytes should be versioned
  DataOutputBuffer jobToken_dob = new DataOutputBuffer();
  jobToken.write(jobToken_dob);
  return ByteBuffer.wrap(jobToken_dob.getData(), 0, jobToken_dob.getLength());
}
 
Example 14
Source File: TezCommonUtils.java    From tez with Apache License 2.0 3 votes vote down vote up
/**
 * A helper function to serialize the JobTokenIdentifier to be sent to the
 * ShuffleHandler as ServiceData.
 *
 * *NOTE* This is a copy of what is done by the MapReduce ShuffleHandler. Not using that directly
 * to avoid a dependency on mapreduce.
 *
 * @param jobToken
 *          the job token to be used for authentication of shuffle data
 *          requests.
 * @return the serialized version of the jobToken.
 */
public static ByteBuffer serializeServiceData(Token<JobTokenIdentifier> jobToken)
    throws IOException {
  // TODO these bytes should be versioned
  DataOutputBuffer jobToken_dob = new DataOutputBuffer();
  jobToken.write(jobToken_dob);
  return ByteBuffer.wrap(jobToken_dob.getData(), 0, jobToken_dob.getLength());
}
 
Example 15
Source File: ShuffleHandler.java    From tez with Apache License 2.0 3 votes vote down vote up
/**
 * A helper function to serialize the JobTokenIdentifier to be sent to the
 * ShuffleHandler as ServiceData.
 * @param jobToken the job token to be used for authentication of
 * shuffle data requests.
 * @return the serialized version of the jobToken.
 */
public static ByteBuffer serializeServiceData(Token<JobTokenIdentifier> jobToken) throws IOException {
  //TODO these bytes should be versioned
  DataOutputBuffer jobToken_dob = new DataOutputBuffer();
  jobToken.write(jobToken_dob);
  return ByteBuffer.wrap(jobToken_dob.getData(), 0, jobToken_dob.getLength());
}