当前位置: 首页>>代码示例>>Java>>正文


Java Server类代码示例

本文整理汇总了Java中org.apache.hadoop.ipc.Server的典型用法代码示例。如果您正苦于以下问题:Java Server类的具体用法?Java Server怎么用?Java Server使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Server类属于org.apache.hadoop.ipc包,在下文中一共展示了Server类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startAndGetRPCServerAddress

import org.apache.hadoop.ipc.Server; //导入依赖的package包/类
private InetSocketAddress startAndGetRPCServerAddress(InetSocketAddress serverAddress) {
  Configuration conf = new Configuration();

  try {
    RPC.setProtocolEngine(conf,
        HAServiceProtocolPB.class, ProtobufRpcEngine.class);
    HAServiceProtocolServerSideTranslatorPB haServiceProtocolXlator =
        new HAServiceProtocolServerSideTranslatorPB(new MockHAProtocolImpl());
    BlockingService haPbService = HAServiceProtocolService
        .newReflectiveBlockingService(haServiceProtocolXlator);

    Server server = new RPC.Builder(conf)
        .setProtocol(HAServiceProtocolPB.class)
        .setInstance(haPbService)
        .setBindAddress(serverAddress.getHostName())
        .setPort(serverAddress.getPort()).build();
    server.start();
    return NetUtils.getConnectAddress(server);
  } catch (IOException e) {
    return null;
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:23,代码来源:DummyHAService.java

示例2: testPbServerFactory

import org.apache.hadoop.ipc.Server; //导入依赖的package包/类
private void testPbServerFactory() {
  InetSocketAddress addr = new InetSocketAddress(0);
  Configuration conf = new Configuration();
  ApplicationMasterProtocol instance = new AMRMProtocolTestImpl();
  Server server = null;
  try {
    server = 
      RpcServerFactoryPBImpl.get().getServer(
          ApplicationMasterProtocol.class, instance, addr, conf, null, 1);
    server.start();
  } catch (YarnRuntimeException e) {
    e.printStackTrace();
    Assert.fail("Failed to create server");
  } finally {
    if (server != null) {
      server.stop();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestRPCFactories.java

示例3: testPbServerFactory

import org.apache.hadoop.ipc.Server; //导入依赖的package包/类
private void testPbServerFactory() {
  InetSocketAddress addr = new InetSocketAddress(0);
  Configuration conf = new Configuration();
  ResourceTracker instance = new ResourceTrackerTestImpl();
  Server server = null;
  try {
    server = 
      RpcServerFactoryPBImpl.get().getServer(
          ResourceTracker.class, instance, addr, conf, null, 1);
    server.start();
  } catch (YarnRuntimeException e) {
    e.printStackTrace();
    Assert.fail("Failed to create server");
  } finally {
    server.stop();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestYSCRPCFactories.java

示例4: createServer

import org.apache.hadoop.ipc.Server; //导入依赖的package包/类
Server createServer() {
  Configuration conf = getConfig();
  YarnRPC rpc = YarnRPC.create(conf);
  if (UserGroupInformation.isSecurityEnabled()) {
    secretManager = new LocalizerTokenSecretManager();      
  }
  
  Server server = rpc.getServer(LocalizationProtocol.class, this,
      localizationServerAddress, conf, secretManager, 
      conf.getInt(YarnConfiguration.NM_LOCALIZER_CLIENT_THREAD_COUNT, 
          YarnConfiguration.DEFAULT_NM_LOCALIZER_CLIENT_THREAD_COUNT));
  
  // Enable service authorization?
  if (conf.getBoolean(
      CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, 
      false)) {
    server.refreshServiceAcl(conf, new NMPolicyProvider());
  }
  
  return server;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:ResourceLocalizationService.java

示例5: testSuccessLogFormatHelper

import org.apache.hadoop.ipc.Server; //导入依赖的package包/类
/**
 * Test the AuditLog format for successful events.
 */
private void testSuccessLogFormatHelper(boolean checkIP, 
    ApplicationId appId, ContainerId containerId) {
  // check without the IP
  String sLog = NMAuditLogger.createSuccessLog(USER, OPERATION, TARGET,
      appId, containerId);
  StringBuilder expLog = new StringBuilder();
  expLog.append("USER=test\t");
  if (checkIP) {
    InetAddress ip = Server.getRemoteIp();
    expLog.append(Keys.IP.name() + "=" + ip.getHostAddress() + "\t");
  }
  expLog.append("OPERATION=oper\tTARGET=tgt\tRESULT=SUCCESS");
  if (appId != null) {
    expLog.append("\tAPPID=app_1");
  }
  if (containerId != null) {
    expLog.append("\tCONTAINERID=container_1");
  }
  assertEquals(expLog.toString(), sLog);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestNMAuditLogger.java

示例6: testFailureLogFormatHelper

import org.apache.hadoop.ipc.Server; //导入依赖的package包/类
/**
 * Test the AuditLog format for failure events.
 */
private void testFailureLogFormatHelper(boolean checkIP, ApplicationId appId,
    ContainerId containerId) {
  String fLog =
    NMAuditLogger.createFailureLog(USER, OPERATION, TARGET, DESC, appId,
    containerId);
  StringBuilder expLog = new StringBuilder();
  expLog.append("USER=test\t");
  if (checkIP) {
    InetAddress ip = Server.getRemoteIp();
    expLog.append(Keys.IP.name() + "=" + ip.getHostAddress() + "\t");
  }
  expLog.append("OPERATION=oper\tTARGET=tgt\tRESULT=FAILURE\t");
  expLog.append("DESCRIPTION=description of an audit log");

  if (appId != null) {
    expLog.append("\tAPPID=app_1");
  }
  if (containerId != null) {
    expLog.append("\tCONTAINERID=container_1");
  }
  assertEquals(expLog.toString(), fLog);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestNMAuditLogger.java

示例7: testNMAuditLoggerWithIP

import org.apache.hadoop.ipc.Server; //导入依赖的package包/类
/**
 * Test {@link NMAuditLogger} with IP set.
 */
@Test  
public void testNMAuditLoggerWithIP() throws Exception {
  Configuration conf = new Configuration();
  // start the IPC server
  Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
      .setInstance(new MyTestRPCServer()).setBindAddress("0.0.0.0")
      .setPort(0).setNumHandlers(5).setVerbose(true).build();

  server.start();

  InetSocketAddress addr = NetUtils.getConnectAddress(server);

  // Make a client connection and test the audit log
  TestProtocol proxy = (TestProtocol)RPC.getProxy(TestProtocol.class,
                         TestProtocol.versionID, addr, conf);
  // Start the testcase
  proxy.ping();

  server.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestNMAuditLogger.java

示例8: testPbServerFactory

import org.apache.hadoop.ipc.Server; //导入依赖的package包/类
private void testPbServerFactory() {
  InetSocketAddress addr = new InetSocketAddress(0);
  Configuration conf = new Configuration();
  LocalizationProtocol instance = new LocalizationProtocolTestImpl();
  Server server = null;
  try {
    server = 
      RpcServerFactoryPBImpl.get().getServer(
          LocalizationProtocol.class, instance, addr, conf, null, 1);
    server.start();
  } catch (YarnRuntimeException e) {
    e.printStackTrace();
    Assert.fail("Failed to create server");
  } finally {
    if (server != null) {
      server.stop();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestRPCFactories.java

示例9: serviceStart

import org.apache.hadoop.ipc.Server; //导入依赖的package包/类
@Override
protected void serviceStart() throws Exception {
  Configuration conf = getConfig();

  Server server;
  try {
    secretMgr = new ClientToAMTokenSecretManager(
        this.appAttemptId, secretKey);
    server =
        new RPC.Builder(conf)
          .setProtocol(CustomProtocol.class)
          .setNumHandlers(1)
          .setSecretManager(secretMgr)
          .setInstance(this).build();
  } catch (Exception e) {
    throw new YarnRuntimeException(e);
  }
  server.start();
  this.address = NetUtils.getConnectAddress(server);
  super.serviceStart();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestClientToAMTokens.java

示例10: testSuccessLogFormatHelper

import org.apache.hadoop.ipc.Server; //导入依赖的package包/类
/**
 * Test the AuditLog format for successful events.
 */
private void testSuccessLogFormatHelper(boolean checkIP, ApplicationId appId,
    ApplicationAttemptId attemptId, ContainerId containerId) {
  String sLog = RMAuditLogger.createSuccessLog(USER, OPERATION, TARGET,
      appId, attemptId, containerId);
  StringBuilder expLog = new StringBuilder();
  expLog.append("USER=test\t");
  if (checkIP) {
    InetAddress ip = Server.getRemoteIp();
    expLog.append(Keys.IP.name() + "=" + ip.getHostAddress() + "\t");
  }
  expLog.append("OPERATION=oper\tTARGET=tgt\tRESULT=SUCCESS");

  if (appId != null) {
    expLog.append("\tAPPID=app_1");
  }
  if (attemptId != null) {
    expLog.append("\tAPPATTEMPTID=app_attempt_1");
  }
  if (containerId != null) {
    expLog.append("\tCONTAINERID=container_1");
  }
  assertEquals(expLog.toString(), sLog);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestRMAuditLogger.java

示例11: testFailureLogFormatHelper

import org.apache.hadoop.ipc.Server; //导入依赖的package包/类
/**
 * Test the AuditLog format for failure events.
 */
private void testFailureLogFormatHelper(boolean checkIP, ApplicationId appId,
    ApplicationAttemptId attemptId, ContainerId containerId) {
  String fLog =
    RMAuditLogger.createFailureLog(USER, OPERATION, PERM, TARGET, DESC,
    appId, attemptId, containerId);
  StringBuilder expLog = new StringBuilder();
  expLog.append("USER=test\t");
  if (checkIP) {
    InetAddress ip = Server.getRemoteIp();
    expLog.append(Keys.IP.name() + "=" + ip.getHostAddress() + "\t");
  }
  expLog.append("OPERATION=oper\tTARGET=tgt\tRESULT=FAILURE\t");
  expLog.append("DESCRIPTION=description of an audit log");
  expLog.append("\tPERMISSIONS=admin group");
  if (appId != null) {
    expLog.append("\tAPPID=app_1");
  }
  if (attemptId != null) {
    expLog.append("\tAPPATTEMPTID=app_attempt_1");
  }
  if (containerId != null) {
    expLog.append("\tCONTAINERID=container_1");
  }
  assertEquals(expLog.toString(), fLog);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:TestRMAuditLogger.java

示例12: testRMAuditLoggerWithIP

import org.apache.hadoop.ipc.Server; //导入依赖的package包/类
/**
 * Test {@link RMAuditLogger} with IP set.
 */
@Test  
public void testRMAuditLoggerWithIP() throws Exception {
  Configuration conf = new Configuration();
  // start the IPC server
  Server server = new RPC.Builder(conf).setProtocol(TestProtocol.class)
      .setInstance(new MyTestRPCServer()).setBindAddress("0.0.0.0")
      .setPort(0).setNumHandlers(5).setVerbose(true).build();
  server.start();

  InetSocketAddress addr = NetUtils.getConnectAddress(server);

  // Make a client connection and test the audit log
  TestProtocol proxy = (TestProtocol)RPC.getProxy(TestProtocol.class,
                         TestProtocol.versionID, addr, conf);
  // Start the testcase
  proxy.ping();

  server.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestRMAuditLogger.java

示例13: killJob

import org.apache.hadoop.ipc.Server; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public KillJobResponse killJob(KillJobRequest request) 
  throws IOException {
  JobId jobId = request.getJobId();
  UserGroupInformation callerUGI = UserGroupInformation.getCurrentUser();
  String message = "Kill job " + jobId + " received from " + callerUGI
      + " at " + Server.getRemoteAddress();
  LOG.info(message);
  verifyAndGetJob(jobId, JobACL.MODIFY_JOB, false);
  appContext.getEventHandler().handle(
      new JobDiagnosticsUpdateEvent(jobId, message));
  appContext.getEventHandler().handle(
      new JobEvent(jobId, JobEventType.JOB_KILL));
  KillJobResponse response = 
    recordFactory.newRecordInstance(KillJobResponse.class);
  return response;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:MRClientService.java

示例14: killTask

import org.apache.hadoop.ipc.Server; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public KillTaskResponse killTask(KillTaskRequest request) 
  throws IOException {
  TaskId taskId = request.getTaskId();
  UserGroupInformation callerUGI = UserGroupInformation.getCurrentUser();
  String message = "Kill task " + taskId + " received from " + callerUGI
      + " at " + Server.getRemoteAddress();
  LOG.info(message);
  verifyAndGetTask(taskId, JobACL.MODIFY_JOB);
  appContext.getEventHandler().handle(
      new TaskEvent(taskId, TaskEventType.T_KILL));
  KillTaskResponse response = 
    recordFactory.newRecordInstance(KillTaskResponse.class);
  return response;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:MRClientService.java

示例15: killTaskAttempt

import org.apache.hadoop.ipc.Server; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public KillTaskAttemptResponse killTaskAttempt(
    KillTaskAttemptRequest request) throws IOException {
  TaskAttemptId taskAttemptId = request.getTaskAttemptId();
  UserGroupInformation callerUGI = UserGroupInformation.getCurrentUser();
  String message = "Kill task attempt " + taskAttemptId
      + " received from " + callerUGI + " at "
      + Server.getRemoteAddress();
  LOG.info(message);
  verifyAndGetAttempt(taskAttemptId, JobACL.MODIFY_JOB);
  appContext.getEventHandler().handle(
      new TaskAttemptDiagnosticsUpdateEvent(taskAttemptId, message));
  appContext.getEventHandler().handle(
      new TaskAttemptEvent(taskAttemptId, 
          TaskAttemptEventType.TA_KILL));
  KillTaskAttemptResponse response = 
    recordFactory.newRecordInstance(KillTaskAttemptResponse.class);
  return response;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:MRClientService.java


注:本文中的org.apache.hadoop.ipc.Server类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。