Java 类org.apache.hadoop.mapred.tools.MRAdmin 实例源码

项目:hadoop-2.6.0-cdh5.4.3    文件:TestAdminOperationsProtocolWithServiceAuthorization.java   
public void testServiceLevelAuthorization() throws Exception {
  MiniMRCluster mr = null;
  try {
    // Turn on service-level authorization
    final JobConf conf = new JobConf();
    conf.setClass(PolicyProvider.POLICY_PROVIDER_CONFIG, 
                  MapReducePolicyProvider.class, PolicyProvider.class);
    conf.setBoolean(ServiceAuthorizationManager.SERVICE_AUTHORIZATION_CONFIG, 
                    true);

    // Start the mini mr cluster
    mr = new MiniMRCluster(1, "file:///", 1, null, null, conf);

    // Invoke MRAdmin commands
    MRAdmin mrAdmin = new MRAdmin(mr.createJobConf());
    assertEquals(0, mrAdmin.run(new String[] { "-refreshQueues" }));
    assertEquals(0, mrAdmin.run(new String[] { "-refreshNodes" }));
  } finally {
    if (mr != null) { 
      mr.shutdown();
    }
  }
}
项目:hadoop-on-lustre    文件:TestAdminOperationsProtocolWithServiceAuthorization.java   
public void testServiceLevelAuthorization() throws Exception {
  MiniMRCluster mr = null;
  try {
    // Turn on service-level authorization
    final JobConf conf = new JobConf();
    conf.setClass(PolicyProvider.POLICY_PROVIDER_CONFIG, 
                  MapReducePolicyProvider.class, PolicyProvider.class);
    conf.setBoolean(ServiceAuthorizationManager.SERVICE_AUTHORIZATION_CONFIG, 
                    true);

    // Start the mini mr cluster
    mr = new MiniMRCluster(1, "file:///", 1, null, null, conf);

    // Invoke MRAdmin commands
    MRAdmin mrAdmin = new MRAdmin(mr.createJobConf());
    assertEquals(0, mrAdmin.run(new String[] { "-refreshQueues" }));
    assertEquals(0, mrAdmin.run(new String[] { "-refreshNodes" }));
  } finally {
    if (mr != null) { 
      mr.shutdown();
    }
  }
}
项目:hanoi-hadoop-2.0.0-cdh    文件:TestAdminOperationsProtocolWithServiceAuthorization.java   
public void testServiceLevelAuthorization() throws Exception {
  MiniMRCluster mr = null;
  try {
    // Turn on service-level authorization
    final JobConf conf = new JobConf();
    conf.setClass(PolicyProvider.POLICY_PROVIDER_CONFIG, 
                  MapReducePolicyProvider.class, PolicyProvider.class);
    conf.setBoolean(ServiceAuthorizationManager.SERVICE_AUTHORIZATION_CONFIG, 
                    true);

    // Start the mini mr cluster
    mr = new MiniMRCluster(1, "file:///", 1, null, null, conf);

    // Invoke MRAdmin commands
    MRAdmin mrAdmin = new MRAdmin(mr.createJobConf());
    assertEquals(0, mrAdmin.run(new String[] { "-refreshQueues" }));
    assertEquals(0, mrAdmin.run(new String[] { "-refreshNodes" }));
  } finally {
    if (mr != null) { 
      mr.shutdown();
    }
  }
}
项目:mapreduce-fork    文件:TestAdminOperationsProtocolWithServiceAuthorization.java   
public void testServiceLevelAuthorization() throws Exception {
  MiniMRCluster mr = null;
  try {
    // Turn on service-level authorization
    final JobConf conf = new JobConf();
    conf.setClass(PolicyProvider.POLICY_PROVIDER_CONFIG, 
                  MapReducePolicyProvider.class, PolicyProvider.class);
    conf.setBoolean(ServiceAuthorizationManager.SERVICE_AUTHORIZATION_CONFIG, 
                    true);

    // Start the mini mr cluster
    mr = new MiniMRCluster(1, "file:///", 1, null, null, conf);

    // Invoke MRAdmin commands
    MRAdmin mrAdmin = new MRAdmin(mr.createJobConf());
    assertEquals(0, mrAdmin.run(new String[] { "-refreshQueues" }));
    assertEquals(0, mrAdmin.run(new String[] { "-refreshNodes" }));
  } finally {
    if (mr != null) { 
      mr.shutdown();
    }
  }
}
项目:mapreduce-fork    文件:TestQueueManagerWithJobTracker.java   
/**
 * Tests job submission after refresh
 * @throws Exception
 */
@Test
public void testSubmitJobsAfterRefresh() throws Exception {
  startCluster(true);

  // test for refresh
  deleteQueuesConfigFile();
  Document doc = createDocument();
  refreshDocument(doc);
  writeToFile(doc, QUEUES_CONFIG_FILE_PATH);
  MRAdmin admin = new MRAdmin(miniMRCluster.createJobConf());
  admin.run(new String[] { "-refreshQueues" });
  try {
    submitSleepJob(10, 10, 100, 100, false, "u1,g1", "p1"
        + NAME_SEPARATOR + "p11", conf);
    fail("user u1 is not in the submit jobs' list");
  } catch (Exception e) {
  }
  deleteQueuesConfigFile();
  doc = createDocument();
  createSimpleDocumentWithAcls(doc);
  writeToFile(doc, QUEUES_CONFIG_FILE_PATH);
  admin.run(new String[] { "-refreshQueues" });
}
项目:hortonworks-extension    文件:TestAdminOperationsProtocolWithServiceAuthorization.java   
public void testServiceLevelAuthorization() throws Exception {
  MiniMRCluster mr = null;
  try {
    // Turn on service-level authorization
    final JobConf conf = new JobConf();
    conf.setClass(PolicyProvider.POLICY_PROVIDER_CONFIG, 
                  MapReducePolicyProvider.class, PolicyProvider.class);
    conf.setBoolean(ServiceAuthorizationManager.SERVICE_AUTHORIZATION_CONFIG, 
                    true);

    // Start the mini mr cluster
    mr = new MiniMRCluster(1, "file:///", 1, null, null, conf);

    // Invoke MRAdmin commands
    MRAdmin mrAdmin = new MRAdmin(mr.createJobConf());
    assertEquals(0, mrAdmin.run(new String[] { "-refreshQueues" }));
    assertEquals(0, mrAdmin.run(new String[] { "-refreshNodes" }));
  } finally {
    if (mr != null) { 
      mr.shutdown();
    }
  }
}
项目:hortonworks-extension    文件:TestAdminOperationsProtocolWithServiceAuthorization.java   
public void testServiceLevelAuthorization() throws Exception {
  MiniMRCluster mr = null;
  try {
    // Turn on service-level authorization
    final JobConf conf = new JobConf();
    conf.setClass(PolicyProvider.POLICY_PROVIDER_CONFIG, 
                  MapReducePolicyProvider.class, PolicyProvider.class);
    conf.setBoolean(ServiceAuthorizationManager.SERVICE_AUTHORIZATION_CONFIG, 
                    true);

    // Start the mini mr cluster
    mr = new MiniMRCluster(1, "file:///", 1, null, null, conf);

    // Invoke MRAdmin commands
    MRAdmin mrAdmin = new MRAdmin(mr.createJobConf());
    assertEquals(0, mrAdmin.run(new String[] { "-refreshQueues" }));
    assertEquals(0, mrAdmin.run(new String[] { "-refreshNodes" }));
  } finally {
    if (mr != null) { 
      mr.shutdown();
    }
  }
}
项目:hadoop-EAR    文件:CommandExecutor.java   
public static int executeMRAdminCommand(final String cmd, 
                                        final String jobtracker) {
  exitCode = 0;

  ByteArrayOutputStream bao = new ByteArrayOutputStream();
  PrintStream origOut = System.out;
  PrintStream origErr = System.err;

  System.setOut(new PrintStream(bao));
  System.setErr(new PrintStream(bao));

  MRAdmin mradmin = new MRAdmin();
  String[] args = getCommandAsArgs(cmd, "JOBTRACKER", jobtracker);
  cmdExecuted = cmd;

  try {
    ToolRunner.run(mradmin, args);
  } catch (Exception e) {
    e.printStackTrace();
    lastException = e;
    exitCode = -1;
  } finally {
    System.setOut(origOut);
    System.setErr(origErr);
  }

  commandOutput = bao.toString();

  return exitCode;
}
项目:hadoop-on-lustre    文件:CommandExecutor.java   
public static int executeMRAdminCommand(final String cmd, 
                                        final String jobtracker) {
  exitCode = 0;

  ByteArrayOutputStream bao = new ByteArrayOutputStream();
  PrintStream origOut = System.out;
  PrintStream origErr = System.err;

  System.setOut(new PrintStream(bao));
  System.setErr(new PrintStream(bao));

  MRAdmin mradmin = new MRAdmin();
  String[] args = getCommandAsArgs(cmd, "JOBTRACKER", jobtracker);
  cmdExecuted = cmd;

  try {
    ToolRunner.run(mradmin, args);
  } catch (Exception e) {
    e.printStackTrace();
    lastException = e;
    exitCode = -1;
  } finally {
    System.setOut(origOut);
    System.setErr(origErr);
  }

  commandOutput = bao.toString();

  return exitCode;
}
项目:RDFS    文件:CommandExecutor.java   
public static int executeMRAdminCommand(final String cmd, 
                                        final String jobtracker) {
  exitCode = 0;

  ByteArrayOutputStream bao = new ByteArrayOutputStream();
  PrintStream origOut = System.out;
  PrintStream origErr = System.err;

  System.setOut(new PrintStream(bao));
  System.setErr(new PrintStream(bao));

  MRAdmin mradmin = new MRAdmin();
  String[] args = getCommandAsArgs(cmd, "JOBTRACKER", jobtracker);
  cmdExecuted = cmd;

  try {
    ToolRunner.run(mradmin, args);
  } catch (Exception e) {
    e.printStackTrace();
    lastException = e;
    exitCode = -1;
  } finally {
    System.setOut(origOut);
    System.setErr(origErr);
  }

  commandOutput = bao.toString();

  return exitCode;
}
项目:hadoop-0.20    文件:CommandExecutor.java   
public static int executeMRAdminCommand(final String cmd, 
                                        final String jobtracker) {
  exitCode = 0;

  ByteArrayOutputStream bao = new ByteArrayOutputStream();
  PrintStream origOut = System.out;
  PrintStream origErr = System.err;

  System.setOut(new PrintStream(bao));
  System.setErr(new PrintStream(bao));

  MRAdmin mradmin = new MRAdmin();
  String[] args = getCommandAsArgs(cmd, "JOBTRACKER", jobtracker);
  cmdExecuted = cmd;

  try {
    ToolRunner.run(mradmin, args);
  } catch (Exception e) {
    e.printStackTrace();
    lastException = e;
    exitCode = -1;
  } finally {
    System.setOut(origOut);
    System.setErr(origErr);
  }

  commandOutput = bao.toString();

  return exitCode;
}
项目:hortonworks-extension    文件:CommandExecutor.java   
public static int executeMRAdminCommand(final String cmd, 
                                        final String jobtracker) {
  exitCode = 0;

  ByteArrayOutputStream bao = new ByteArrayOutputStream();
  PrintStream origOut = System.out;
  PrintStream origErr = System.err;

  System.setOut(new PrintStream(bao));
  System.setErr(new PrintStream(bao));

  MRAdmin mradmin = new MRAdmin();
  String[] args = getCommandAsArgs(cmd, "JOBTRACKER", jobtracker);
  cmdExecuted = cmd;

  try {
    ToolRunner.run(mradmin, args);
  } catch (Exception e) {
    e.printStackTrace();
    lastException = e;
    exitCode = -1;
  } finally {
    System.setOut(origOut);
    System.setErr(origErr);
  }

  commandOutput = bao.toString();

  return exitCode;
}
项目:hortonworks-extension    文件:CommandExecutor.java   
public static int executeMRAdminCommand(final String cmd, 
                                        final String jobtracker) {
  exitCode = 0;

  ByteArrayOutputStream bao = new ByteArrayOutputStream();
  PrintStream origOut = System.out;
  PrintStream origErr = System.err;

  System.setOut(new PrintStream(bao));
  System.setErr(new PrintStream(bao));

  MRAdmin mradmin = new MRAdmin();
  String[] args = getCommandAsArgs(cmd, "JOBTRACKER", jobtracker);
  cmdExecuted = cmd;

  try {
    ToolRunner.run(mradmin, args);
  } catch (Exception e) {
    e.printStackTrace();
    lastException = e;
    exitCode = -1;
  } finally {
    System.setOut(origOut);
    System.setErr(origErr);
  }

  commandOutput = bao.toString();

  return exitCode;
}
项目:hadoop-gpu    文件:CommandExecutor.java   
public static int executeMRAdminCommand(final String cmd, 
                                        final String jobtracker) {
  exitCode = 0;

  ByteArrayOutputStream bao = new ByteArrayOutputStream();
  PrintStream origOut = System.out;
  PrintStream origErr = System.err;

  System.setOut(new PrintStream(bao));
  System.setErr(new PrintStream(bao));

  MRAdmin mradmin = new MRAdmin();
  String[] args = getCommandAsArgs(cmd, "JOBTRACKER", jobtracker);
  cmdExecuted = cmd;

  try {
    ToolRunner.run(mradmin, args);
  } catch (Exception e) {
    e.printStackTrace();
    lastException = e;
    exitCode = -1;
  } finally {
    System.setOut(origOut);
    System.setErr(origErr);
  }

  commandOutput = bao.toString();

  return exitCode;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestMapredGroupMappingServiceRefresh.java   
@Test
public void testGroupMappingRefresh() throws Exception {
  MRAdmin admin = new MRAdmin(config);
  String [] args = new String[] { "-refreshUserToGroupsMappings" };

  Groups groups = Groups.getUserToGroupsMappingService(config);
  String user = UserGroupInformation.getLoginUser().getShortUserName();
  System.out.println("first attempt:");
  List<String> g1 = groups.getGroups(user);
  String [] str_groups = new String [g1.size()];
  g1.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));

  System.out.println("second attempt, should be same:");
  List<String> g2 = groups.getGroups(user);
  g2.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g2.size(); i++) {
    assertEquals("Should be same group ", g1.get(i), g2.get(i));
  }
  // run refresh command
  admin.run(args);

  System.out.println("third attempt(after refresh command), should be different:");
  List<String> g3 = groups.getGroups(user);
  g3.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g3.size(); i++) {
    assertFalse("Should be different group ", g1.get(i).equals(g3.get(i)));
  }
  System.out.println("");

  // test time out
  Thread.sleep(groupRefreshTimeoutSec*1100);
  System.out.println("fourth attempt(after timeout), should be different:");
  List<String> g4 = groups.getGroups(user);
  g4.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g4.size(); i++) {
    assertFalse("Should be different group ", g3.get(i).equals(g4.get(i)));
  }
}
项目:hadoop-on-lustre    文件:TestMapredGroupMappingServiceRefresh.java   
@Test
public void testGroupMappingRefresh() throws Exception {
  MRAdmin admin = new MRAdmin(config);
  String [] args = new String[] { "-refreshUserToGroupsMappings" };

  Groups groups = Groups.getUserToGroupsMappingService(config);
  String user = UserGroupInformation.getLoginUser().getShortUserName();
  System.out.println("first attempt:");
  List<String> g1 = groups.getGroups(user);
  String [] str_groups = new String [g1.size()];
  g1.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));

  System.out.println("second attempt, should be same:");
  List<String> g2 = groups.getGroups(user);
  g2.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g2.size(); i++) {
    assertEquals("Should be same group ", g1.get(i), g2.get(i));
  }
  // run refresh command
  admin.run(args);

  System.out.println("third attempt(after refresh command), should be different:");
  List<String> g3 = groups.getGroups(user);
  g3.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g3.size(); i++) {
    assertFalse("Should be different group ", g1.get(i).equals(g3.get(i)));
  }
  System.out.println("");

  // test time out
  Thread.sleep(groupRefreshTimeoutSec*1100);
  System.out.println("fourth attempt(after timeout), should be different:");
  List<String> g4 = groups.getGroups(user);
  g4.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g4.size(); i++) {
    assertFalse("Should be different group ", g3.get(i).equals(g4.get(i)));
  }
}
项目:hanoi-hadoop-2.0.0-cdh    文件:TestMapredGroupMappingServiceRefresh.java   
@Test
public void testGroupMappingRefresh() throws Exception {
  MRAdmin admin = new MRAdmin(config);
  String [] args = new String[] { "-refreshUserToGroupsMappings" };

  Groups groups = Groups.getUserToGroupsMappingService(config);
  String user = UserGroupInformation.getLoginUser().getShortUserName();
  System.out.println("first attempt:");
  List<String> g1 = groups.getGroups(user);
  String [] str_groups = new String [g1.size()];
  g1.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));

  System.out.println("second attempt, should be same:");
  List<String> g2 = groups.getGroups(user);
  g2.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g2.size(); i++) {
    assertEquals("Should be same group ", g1.get(i), g2.get(i));
  }
  // run refresh command
  admin.run(args);

  System.out.println("third attempt(after refresh command), should be different:");
  List<String> g3 = groups.getGroups(user);
  g3.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g3.size(); i++) {
    assertFalse("Should be different group ", g1.get(i).equals(g3.get(i)));
  }
  System.out.println("");

  // test time out
  Thread.sleep(groupRefreshTimeoutSec*1100);
  System.out.println("fourth attempt(after timeout), should be different:");
  List<String> g4 = groups.getGroups(user);
  g4.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g4.size(); i++) {
    assertFalse("Should be different group ", g3.get(i).equals(g4.get(i)));
  }
}
项目:mapreduce-fork    文件:TestMapredGroupMappingServiceRefresh.java   
@Test
public void testGroupMappingRefresh() throws Exception {
  MRAdmin admin = new MRAdmin(config);
  String [] args = new String[] { "-refreshUserToGroupsMappings" };

  Groups groups = Groups.getUserToGroupsMappingService(config);
  String user = UserGroupInformation.getLoginUser().getShortUserName();
  System.out.println("first attempt:");
  List<String> g1 = groups.getGroups(user);
  String [] str_groups = new String [g1.size()];
  g1.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));

  System.out.println("second attempt, should be same:");
  List<String> g2 = groups.getGroups(user);
  g2.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g2.size(); i++) {
    assertEquals("Should be same group ", g1.get(i), g2.get(i));
  }
  // run refresh command
  admin.run(args);

  System.out.println("third attempt(after refresh command), should be different:");
  List<String> g3 = groups.getGroups(user);
  g3.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g3.size(); i++) {
    assertFalse("Should be different group ", g1.get(i).equals(g3.get(i)));
  }
  System.out.println("");

  // test time out
  Thread.sleep(groupRefreshTimeoutSec*1100);
  System.out.println("fourth attempt(after timeout), should be different:");
  List<String> g4 = groups.getGroups(user);
  g4.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g4.size(); i++) {
    assertFalse("Should be different group ", g3.get(i).equals(g4.get(i)));
  }
}
项目:mapreduce-fork    文件:TestMRCLI.java   
@Override
protected void execute(final String cmd) throws Exception{
  MRAdmin mradmin = new MRAdmin();
  String[] args = getCommandAsArgs(cmd, "JOBTRACKER", jobtracker);
  ToolRunner.run(mradmin, args);
}
项目:hortonworks-extension    文件:TestMapredGroupMappingServiceRefresh.java   
@Test
public void testGroupMappingRefresh() throws Exception {
  MRAdmin admin = new MRAdmin(config);
  String [] args = new String[] { "-refreshUserToGroupsMappings" };

  Groups groups = Groups.getUserToGroupsMappingService(config);
  String user = UserGroupInformation.getLoginUser().getShortUserName();
  System.out.println("first attempt:");
  List<String> g1 = groups.getGroups(user);
  String [] str_groups = new String [g1.size()];
  g1.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));

  System.out.println("second attempt, should be same:");
  List<String> g2 = groups.getGroups(user);
  g2.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g2.size(); i++) {
    assertEquals("Should be same group ", g1.get(i), g2.get(i));
  }
  // run refresh command
  admin.run(args);

  System.out.println("third attempt(after refresh command), should be different:");
  List<String> g3 = groups.getGroups(user);
  g3.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g3.size(); i++) {
    assertFalse("Should be different group ", g1.get(i).equals(g3.get(i)));
  }
  System.out.println("");

  // test time out
  Thread.sleep(groupRefreshTimeoutSec*1100);
  System.out.println("fourth attempt(after timeout), should be different:");
  List<String> g4 = groups.getGroups(user);
  g4.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g4.size(); i++) {
    assertFalse("Should be different group ", g3.get(i).equals(g4.get(i)));
  }
}
项目:hortonworks-extension    文件:TestMapredGroupMappingServiceRefresh.java   
@Test
public void testGroupMappingRefresh() throws Exception {
  MRAdmin admin = new MRAdmin(config);
  String [] args = new String[] { "-refreshUserToGroupsMappings" };

  Groups groups = Groups.getUserToGroupsMappingService(config);
  String user = UserGroupInformation.getLoginUser().getShortUserName();
  System.out.println("first attempt:");
  List<String> g1 = groups.getGroups(user);
  String [] str_groups = new String [g1.size()];
  g1.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));

  System.out.println("second attempt, should be same:");
  List<String> g2 = groups.getGroups(user);
  g2.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g2.size(); i++) {
    assertEquals("Should be same group ", g1.get(i), g2.get(i));
  }
  // run refresh command
  admin.run(args);

  System.out.println("third attempt(after refresh command), should be different:");
  List<String> g3 = groups.getGroups(user);
  g3.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g3.size(); i++) {
    assertFalse("Should be different group ", g1.get(i).equals(g3.get(i)));
  }
  System.out.println("");

  // test time out
  Thread.sleep(groupRefreshTimeoutSec*1100);
  System.out.println("fourth attempt(after timeout), should be different:");
  List<String> g4 = groups.getGroups(user);
  g4.toArray(str_groups);
  System.out.println(Arrays.toString(str_groups));
  for(int i=0; i<g4.size(); i++) {
    assertFalse("Should be different group ", g3.get(i).equals(g4.get(i)));
  }
}