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


Java AuxiliaryService类代码示例

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


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

示例1: serviceStart

import org.apache.hadoop.yarn.server.api.AuxiliaryService; //导入依赖的package包/类
@Override
public void serviceStart() throws Exception {
  // TODO fork(?) services running as configured user
  //      monitor for health, shutdown/restart(?) if any should die
  for (Map.Entry<String, AuxiliaryService> entry : serviceMap.entrySet()) {
    AuxiliaryService service = entry.getValue();
    String name = entry.getKey();
    service.start();
    service.registerServiceListener(this);
    ByteBuffer meta = service.getMetaData();
    if(meta != null) {
      serviceMetaData.put(name, meta);
    }
  }
  super.serviceStart();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:AuxServices.java

示例2: handle

import org.apache.hadoop.yarn.server.api.AuxiliaryService; //导入依赖的package包/类
@Override
public void handle(AuxServicesEvent event) {
  LOG.info("Got event " + event.getType() + " for appId "
      + event.getApplicationID());
  switch (event.getType()) {
  case APPLICATION_INIT:
    LOG.info("Got APPLICATION_INIT for service " + event.getServiceID());
    AuxiliaryService service = serviceMap.get(event.getServiceID());
    if (null == service) {
      LOG.info("service is null");
      // TODO kill all containers waiting on Application
      return;
    }
    service.initializeApplication(new ApplicationInitializationContext(event
      .getUser(), event.getApplicationID(), event.getServiceData()));
    break;
  case APPLICATION_STOP:
    for (AuxiliaryService serv : serviceMap.values()) {
      serv.stopApplication(new ApplicationTerminationContext(event
        .getApplicationID()));
    }
    break;
  default:
    throw new RuntimeException("Unknown type: " + event.getType());
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:27,代码来源:AuxServices.java

示例3: AuxServices

import org.apache.hadoop.yarn.server.api.AuxiliaryService; //导入依赖的package包/类
public AuxServices() {
  super(AuxServices.class.getName());
  serviceMap =
    Collections.synchronizedMap(new HashMap<String,AuxiliaryService>());
  serviceMetaData =
    Collections.synchronizedMap(new HashMap<String,ByteBuffer>());
  // Obtain services from configuration in init()
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:AuxServices.java

示例4: serviceInit

import org.apache.hadoop.yarn.server.api.AuxiliaryService; //导入依赖的package包/类
@Override
public void serviceInit(Configuration conf) throws Exception {
  Collection<String> auxNames = conf.getStringCollection(
      YarnConfiguration.NM_AUX_SERVICES);
  for (final String sName : auxNames) {
    try {
      Class<? extends AuxiliaryService> sClass = conf.getClass(
            String.format(YarnConfiguration.NM_AUX_SERVICE_FMT, sName), null,
            AuxiliaryService.class);
      if (null == sClass) {
        throw new RuntimeException("No class defined for " + sName);
      }
      AuxiliaryService s = ReflectionUtils.newInstance(sClass, conf);
      // TODO better use s.getName()?
      if(!sName.equals(s.getName())) {
        LOG.warn("The Auxilurary Service named '"+sName+"' in the "
                +"configuration is for class "+sClass+" which has "
                +"a name of '"+s.getName()+"'. Because these are "
                +"not the same tools trying to send ServiceData and read "
                +"Service Meta Data may have issues unless the refer to "
                +"the name in the config.");
      }
      addService(sName, s);
      s.init(conf);
    } catch (RuntimeException e) {
      LOG.fatal("Failed to initialize " + sName, e);
      throw e;
    }
  }
  super.serviceInit(conf);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:32,代码来源:AuxServices.java

示例5: testAuxEventDispatch

import org.apache.hadoop.yarn.server.api.AuxiliaryService; //导入依赖的package包/类
@Test
public void testAuxEventDispatch() {
  Configuration conf = new Configuration();
  conf.setStrings(YarnConfiguration.NM_AUX_SERVICES, new String[] { "Asrv", "Bsrv" });
  conf.setClass(String.format(YarnConfiguration.NM_AUX_SERVICE_FMT, "Asrv"),
      ServiceA.class, Service.class);
  conf.setClass(String.format(YarnConfiguration.NM_AUX_SERVICE_FMT, "Bsrv"),
      ServiceB.class, Service.class);
  conf.setInt("A.expected.init", 1);
  conf.setInt("B.expected.stop", 1);
  final AuxServices aux = new AuxServices();
  aux.init(conf);
  aux.start();

  ApplicationId appId1 = ApplicationId.newInstance(0, 65);
  ByteBuffer buf = ByteBuffer.allocate(6);
  buf.putChar('A');
  buf.putInt(65);
  buf.flip();
  AuxServicesEvent event = new AuxServicesEvent(
      AuxServicesEventType.APPLICATION_INIT, "user0", appId1, "Asrv", buf);
  aux.handle(event);
  ApplicationId appId2 = ApplicationId.newInstance(0, 66);
  event = new AuxServicesEvent(
      AuxServicesEventType.APPLICATION_STOP, "user0", appId2, "Bsrv", null);
  // verify all services got the stop event 
  aux.handle(event);
  Collection<AuxiliaryService> servs = aux.getServices();
  for (AuxiliaryService serv: servs) {
    ArrayList<Integer> appIds = ((LightService)serv).getAppIdsStopped();
    assertEquals("app not properly stopped", 1, appIds.size());
    assertTrue("wrong app stopped", appIds.contains((Integer)66));
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:35,代码来源:TestAuxServices.java

示例6: serviceInit

import org.apache.hadoop.yarn.server.api.AuxiliaryService; //导入依赖的package包/类
@Override
public void serviceInit(Configuration conf) throws Exception {
  Collection<String> auxNames = conf.getStringCollection(
      YarnConfiguration.NM_AUX_SERVICES);
  for (final String sName : auxNames) {
    try {
      Preconditions
          .checkArgument(
              validateAuxServiceName(sName),
              "The ServiceName: " + sName + " set in " +
              YarnConfiguration.NM_AUX_SERVICES +" is invalid." +
              "The valid service name should only contain a-zA-Z0-9_ " +
              "and can not start with numbers");
      Class<? extends AuxiliaryService> sClass = conf.getClass(
            String.format(YarnConfiguration.NM_AUX_SERVICE_FMT, sName), null,
            AuxiliaryService.class);
      if (null == sClass) {
        throw new RuntimeException("No class defined for " + sName);
      }
      AuxiliaryService s = ReflectionUtils.newInstance(sClass, conf);
      // TODO better use s.getName()?
      if(!sName.equals(s.getName())) {
        LOG.warn("The Auxilurary Service named '"+sName+"' in the "
                +"configuration is for class "+sClass+" which has "
                +"a name of '"+s.getName()+"'. Because these are "
                +"not the same tools trying to send ServiceData and read "
                +"Service Meta Data may have issues unless the refer to "
                +"the name in the config.");
      }
      addService(sName, s);
      s.init(conf);
    } catch (RuntimeException e) {
      LOG.fatal("Failed to initialize " + sName, e);
      throw e;
    }
  }
  super.serviceInit(conf);
}
 
开发者ID:chendave,项目名称:hadoop-TCP,代码行数:39,代码来源:AuxServices.java

示例7: addService

import org.apache.hadoop.yarn.server.api.AuxiliaryService; //导入依赖的package包/类
protected final synchronized void addService(String name,
    AuxiliaryService service) {
  LOG.info("Adding auxiliary service " +
      service.getName() + ", \"" + name + "\"");
  serviceMap.put(name, service);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:7,代码来源:AuxServices.java

示例8: getServices

import org.apache.hadoop.yarn.server.api.AuxiliaryService; //导入依赖的package包/类
Collection<AuxiliaryService> getServices() {
  return Collections.unmodifiableCollection(serviceMap.values());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:4,代码来源:AuxServices.java

示例9: logWarningWhenAuxServiceThrowExceptions

import org.apache.hadoop.yarn.server.api.AuxiliaryService; //导入依赖的package包/类
private void logWarningWhenAuxServiceThrowExceptions(AuxiliaryService service,
    AuxServicesEventType eventType, Throwable th) {
  LOG.warn((null == service ? "The auxService is null"
      : "The auxService name is " + service.getName())
      + " and it got an error at event: " + eventType, th);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:7,代码来源:AuxServices.java

示例10: serviceInit

import org.apache.hadoop.yarn.server.api.AuxiliaryService; //导入依赖的package包/类
@Override
public void serviceInit(Configuration conf) throws Exception {
  final FsPermission storeDirPerms = new FsPermission((short)0700);
  Path stateStoreRoot = null;
  FileSystem stateStoreFs = null;
  boolean recoveryEnabled = conf.getBoolean(
      YarnConfiguration.NM_RECOVERY_ENABLED,
      YarnConfiguration.DEFAULT_NM_RECOVERY_ENABLED);
  if (recoveryEnabled) {
    stateStoreRoot = new Path(conf.get(YarnConfiguration.NM_RECOVERY_DIR),
        STATE_STORE_ROOT_NAME);
    stateStoreFs = FileSystem.getLocal(conf);
  }
  Collection<String> auxNames = conf.getStringCollection(
      YarnConfiguration.NM_AUX_SERVICES);
  for (final String sName : auxNames) {
    try {
      Preconditions
          .checkArgument(
              validateAuxServiceName(sName),
              "The ServiceName: " + sName + " set in " +
              YarnConfiguration.NM_AUX_SERVICES +" is invalid." +
              "The valid service name should only contain a-zA-Z0-9_ " +
              "and can not start with numbers");
      Class<? extends AuxiliaryService> sClass = conf.getClass(
            String.format(YarnConfiguration.NM_AUX_SERVICE_FMT, sName), null,
            AuxiliaryService.class);
      if (null == sClass) {
        throw new RuntimeException("No class defined for " + sName);
      }
      AuxiliaryService s = ReflectionUtils.newInstance(sClass, conf);
      // TODO better use s.getName()?
      if(!sName.equals(s.getName())) {
        LOG.warn("The Auxilurary Service named '"+sName+"' in the "
                +"configuration is for "+sClass+" which has "
                +"a name of '"+s.getName()+"'. Because these are "
                +"not the same tools trying to send ServiceData and read "
                +"Service Meta Data may have issues unless the refer to "
                +"the name in the config.");
      }
      addService(sName, s);
      if (recoveryEnabled) {
        Path storePath = new Path(stateStoreRoot, sName);
        stateStoreFs.mkdirs(storePath, storeDirPerms);
        s.setRecoveryPath(storePath);
      }
      s.init(conf);
    } catch (RuntimeException e) {
      LOG.fatal("Failed to initialize " + sName, e);
      throw e;
    }
  }
  super.serviceInit(conf);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:55,代码来源:AuxServices.java

示例11: serviceInit

import org.apache.hadoop.yarn.server.api.AuxiliaryService; //导入依赖的package包/类
@Override
public void serviceInit(Configuration conf) throws Exception {
  final FsPermission storeDirPerms = new FsPermission((short)0700);
  Path stateStoreRoot = null;
  FileSystem stateStoreFs = null;
  boolean recoveryEnabled = conf.getBoolean(
      YarnConfiguration.NM_RECOVERY_ENABLED,
      YarnConfiguration.DEFAULT_NM_RECOVERY_ENABLED);
  if (recoveryEnabled) {
    stateStoreRoot = new Path(conf.get(YarnConfiguration.NM_RECOVERY_DIR),
        STATE_STORE_ROOT_NAME);
    stateStoreFs = FileSystem.getLocal(conf);
  }
  Collection<String> auxNames = conf.getStringCollection(
      YarnConfiguration.NM_AUX_SERVICES);
  for (final String sName : auxNames) {
    try {
      Preconditions
          .checkArgument(
              validateAuxServiceName(sName),
              "The ServiceName: " + sName + " set in " +
              YarnConfiguration.NM_AUX_SERVICES +" is invalid." +
              "The valid service name should only contain a-zA-Z0-9_ " +
              "and can not start with numbers");
      Class<? extends AuxiliaryService> sClass = conf.getClass(
            String.format(YarnConfiguration.NM_AUX_SERVICE_FMT, sName), null,
            AuxiliaryService.class);
      if (null == sClass) {
        throw new RuntimeException("No class defined for " + sName);
      }
      AuxiliaryService s = ReflectionUtils.newInstance(sClass, conf);
      // TODO better use s.getName()?
      if(!sName.equals(s.getName())) {
        LOG.warn("The Auxilurary Service named '"+sName+"' in the "
                +"configuration is for class "+sClass+" which has "
                +"a name of '"+s.getName()+"'. Because these are "
                +"not the same tools trying to send ServiceData and read "
                +"Service Meta Data may have issues unless the refer to "
                +"the name in the config.");
      }
      addService(sName, s);
      if (recoveryEnabled) {
        Path storePath = new Path(stateStoreRoot, sName);
        stateStoreFs.mkdirs(storePath, storeDirPerms);
        s.setRecoveryPath(storePath);
      }
      s.init(conf);
    } catch (RuntimeException e) {
      LOG.fatal("Failed to initialize " + sName, e);
      throw e;
    }
  }
  super.serviceInit(conf);
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:55,代码来源:AuxServices.java


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