Java Code Examples for org.apache.hadoop.conf.Configuration.getSocketAddr()

The following are Jave code examples for showing how to use getSocketAddr() of the org.apache.hadoop.conf.Configuration class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: hadoop   File: AdminService.java   Source Code and License Vote up 7 votes
@Override
public void serviceInit(Configuration conf) throws Exception {
  if (rmContext.isHAEnabled()) {
    autoFailoverEnabled = HAUtil.isAutomaticFailoverEnabled(conf);
    if (autoFailoverEnabled) {
      if (HAUtil.isAutomaticFailoverEmbedded(conf)) {
        embeddedElector = createEmbeddedElectorService();
        addIfService(embeddedElector);
      }
    }
  }

  masterServiceBindAddress = conf.getSocketAddr(
      YarnConfiguration.RM_BIND_HOST,
      YarnConfiguration.RM_ADMIN_ADDRESS,
      YarnConfiguration.DEFAULT_RM_ADMIN_ADDRESS,
      YarnConfiguration.DEFAULT_RM_ADMIN_PORT);
  daemonUser = UserGroupInformation.getCurrentUser();
  authorizer = YarnAuthorizationProvider.getInstance(conf);
  authorizer.setAdmins(getAdminAclList(conf), UserGroupInformation
      .getCurrentUser());
  rmId = conf.get(YarnConfiguration.RM_HA_ID);
  super.serviceInit(conf);
}
 
Example 2
Project: hadoop   File: WebAppUtils.java   Source Code and License Vote up 6 votes
public static String getResolvedRMWebAppURLWithoutScheme(Configuration conf,
    Policy httpPolicy) {
  InetSocketAddress address = null;
  if (httpPolicy == Policy.HTTPS_ONLY) {
    address =
        conf.getSocketAddr(YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS,
            YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_ADDRESS,
            YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_PORT);
  } else {
    address =
        conf.getSocketAddr(YarnConfiguration.RM_WEBAPP_ADDRESS,
            YarnConfiguration.DEFAULT_RM_WEBAPP_ADDRESS,
            YarnConfiguration.DEFAULT_RM_WEBAPP_PORT);      
  }
  return getResolvedAddress(address);
}
 
Example 3
Project: hadoop   File: HSAdmin.java   Source Code and License Vote up 6 votes
private int refreshSuperUserGroupsConfiguration() throws IOException {
  // Refresh the super-user groups
  Configuration conf = getConf();
  InetSocketAddress address = conf.getSocketAddr(
      JHAdminConfig.JHS_ADMIN_ADDRESS,
      JHAdminConfig.DEFAULT_JHS_ADMIN_ADDRESS,
      JHAdminConfig.DEFAULT_JHS_ADMIN_PORT);

  RefreshUserMappingsProtocol refreshProtocol = HSProxies.createProxy(conf,
      address, RefreshUserMappingsProtocol.class,
      UserGroupInformation.getCurrentUser());
  // Refresh the super-user group mappings
  refreshProtocol.refreshSuperUserGroupsConfiguration();

  return 0;
}
 
Example 4
Project: hadoop   File: TestSharedCacheUploaderService.java   Source Code and License Vote up 6 votes
@Before
public void startUp() {
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.SCM_STORE_CLASS,
      InMemorySCMStore.class.getName());
  conf.set(YarnConfiguration.SHARED_CACHE_ROOT, testDir.getPath());
  AppChecker appChecker = spy(new DummyAppChecker());
  store = new InMemorySCMStore(appChecker);
  store.init(conf);
  store.start();

  service = new SharedCacheUploaderService(store);
  service.init(conf);
  service.start();

  YarnRPC rpc = YarnRPC.create(new Configuration());

  InetSocketAddress scmAddress =
      conf.getSocketAddr(YarnConfiguration.SCM_UPLOADER_SERVER_ADDRESS,
          YarnConfiguration.DEFAULT_SCM_UPLOADER_SERVER_ADDRESS,
          YarnConfiguration.DEFAULT_SCM_UPLOADER_SERVER_PORT);

  proxy =
      (SCMUploaderProtocol) rpc.getProxy(
          SCMUploaderProtocol.class, scmAddress, conf);
}
 
Example 5
Project: hadoop   File: HSAdmin.java   Source Code and License Vote up 6 votes
private int refreshUserToGroupsMappings() throws IOException {
  // Get the current configuration
  Configuration conf = getConf();

  InetSocketAddress address = conf.getSocketAddr(
      JHAdminConfig.JHS_ADMIN_ADDRESS,
      JHAdminConfig.DEFAULT_JHS_ADMIN_ADDRESS,
      JHAdminConfig.DEFAULT_JHS_ADMIN_PORT);

  RefreshUserMappingsProtocol refreshProtocol = HSProxies.createProxy(conf,
      address, RefreshUserMappingsProtocol.class,
      UserGroupInformation.getCurrentUser());
  // Refresh the user-to-groups mappings
  refreshProtocol.refreshUserToGroupsMappings();

  return 0;
}
 
Example 6
Project: hadoop   File: WebAppUtils.java   Source Code and License Vote up 5 votes
public static String getResolvedRemoteRMWebAppURLWithoutScheme(Configuration conf,
    Policy httpPolicy) {
  InetSocketAddress address = null;
  String rmId = null;
  if (HAUtil.isHAEnabled(conf)) {
    // If HA enabled, pick one of the RM-IDs and rely on redirect to go to
    // the Active RM
    rmId = (String) HAUtil.getRMHAIds(conf).toArray()[0];
  }

  if (httpPolicy == Policy.HTTPS_ONLY) {
    address =
        conf.getSocketAddr(
            rmId == null
                ? YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS
                : HAUtil.addSuffix(
                YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS, rmId),
            YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_ADDRESS,
            YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_PORT);
  } else {
    address =
        conf.getSocketAddr(
            rmId == null
                ? YarnConfiguration.RM_WEBAPP_ADDRESS
                : HAUtil.addSuffix(
                YarnConfiguration.RM_WEBAPP_ADDRESS, rmId),
            YarnConfiguration.DEFAULT_RM_WEBAPP_ADDRESS,
            YarnConfiguration.DEFAULT_RM_WEBAPP_PORT);
  }
  return getResolvedAddress(address);
}
 
Example 7
Project: hadoop   File: HSAdmin.java   Source Code and License Vote up 5 votes
private int getGroups(String[] usernames) throws IOException {
  // Get groups users belongs to
  if (usernames.length == 0) {
    usernames = new String[] { UserGroupInformation.getCurrentUser()
        .getUserName() };
  }

  // Get the current configuration
  Configuration conf = getConf();

  InetSocketAddress address = conf.getSocketAddr(
      JHAdminConfig.JHS_ADMIN_ADDRESS,
      JHAdminConfig.DEFAULT_JHS_ADMIN_ADDRESS,
      JHAdminConfig.DEFAULT_JHS_ADMIN_PORT);

  GetUserMappingsProtocol getUserMappingProtocol = HSProxies.createProxy(
      conf, address, GetUserMappingsProtocol.class,
      UserGroupInformation.getCurrentUser());
  for (String username : usernames) {
    StringBuilder sb = new StringBuilder();
    sb.append(username + " :");
    for (String group : getUserMappingProtocol.getGroupsForUser(username)) {
      sb.append(" ");
      sb.append(group);
    }
    System.out.println(sb);
  }

  return 0;
}
 
Example 8
Project: hadoop   File: ApplicationHistoryClientService.java   Source Code and License Vote up 5 votes
protected void serviceStart() throws Exception {
  Configuration conf = getConfig();
  YarnRPC rpc = YarnRPC.create(conf);
  InetSocketAddress address = conf.getSocketAddr(
      YarnConfiguration.TIMELINE_SERVICE_BIND_HOST,
      YarnConfiguration.TIMELINE_SERVICE_ADDRESS,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ADDRESS,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_PORT);

  Preconditions.checkArgument(conf.getInt(
      YarnConfiguration.TIMELINE_SERVICE_HANDLER_THREAD_COUNT,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_CLIENT_THREAD_COUNT) > 0,
      "%s property value should be greater than zero",
      YarnConfiguration.TIMELINE_SERVICE_HANDLER_THREAD_COUNT);

  server =
      rpc.getServer(ApplicationHistoryProtocol.class, this,
        address, conf, null, conf.getInt(
          YarnConfiguration.TIMELINE_SERVICE_HANDLER_THREAD_COUNT,
          YarnConfiguration.DEFAULT_TIMELINE_SERVICE_CLIENT_THREAD_COUNT));

  // Enable service authorization?
  if (conf.getBoolean(
      CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, false)) {
    refreshServiceAcls(conf, new TimelinePolicyProvider());
  }

  server.start();
  this.bindAddress =
      conf.updateConnectAddr(YarnConfiguration.TIMELINE_SERVICE_BIND_HOST,
                             YarnConfiguration.TIMELINE_SERVICE_ADDRESS,
                             YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ADDRESS,
                             server.getListenerAddress());
  LOG.info("Instantiated ApplicationHistoryClientService at "
      + this.bindAddress);

  super.serviceStart();
}
 
Example 9
Project: hadoop   File: HSAdmin.java   Source Code and License Vote up 5 votes
private int refreshJobRetentionSettings() throws IOException {
  // Refresh job retention settings
  Configuration conf = getConf();
  InetSocketAddress address = conf.getSocketAddr(
      JHAdminConfig.JHS_ADMIN_ADDRESS,
      JHAdminConfig.DEFAULT_JHS_ADMIN_ADDRESS,
      JHAdminConfig.DEFAULT_JHS_ADMIN_PORT);

  HSAdminRefreshProtocol refreshProtocol = HSProxies.createProxy(conf,
      address, HSAdminRefreshProtocol.class,
      UserGroupInformation.getCurrentUser());

  refreshProtocol.refreshJobRetentionSettings();
  return 0;
}
 
Example 10
Project: hadoop   File: MRWebAppUtil.java   Source Code and License Vote up 5 votes
public static InetSocketAddress getJHSWebBindAddress(Configuration conf) {
  if (httpPolicyInJHS == Policy.HTTPS_ONLY) {
    return conf.getSocketAddr(
        JHAdminConfig.MR_HISTORY_BIND_HOST,
        JHAdminConfig.MR_HISTORY_WEBAPP_HTTPS_ADDRESS,
        JHAdminConfig.DEFAULT_MR_HISTORY_WEBAPP_HTTPS_ADDRESS,
        JHAdminConfig.DEFAULT_MR_HISTORY_WEBAPP_HTTPS_PORT);
  } else {
    return conf.getSocketAddr(
        JHAdminConfig.MR_HISTORY_BIND_HOST,
        JHAdminConfig.MR_HISTORY_WEBAPP_ADDRESS,
        JHAdminConfig.DEFAULT_MR_HISTORY_WEBAPP_ADDRESS,
        JHAdminConfig.DEFAULT_MR_HISTORY_WEBAPP_PORT);
  }
}
 
Example 11
Project: hadoop   File: ResourceTrackerService.java   Source Code and License Vote up 5 votes
@Override
protected void serviceInit(Configuration conf) throws Exception {
  resourceTrackerAddress = conf.getSocketAddr(
      YarnConfiguration.RM_BIND_HOST,
      YarnConfiguration.RM_RESOURCE_TRACKER_ADDRESS,
      YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS,
      YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT);

  RackResolver.init(conf);
  nextHeartBeatInterval =
      conf.getLong(YarnConfiguration.RM_NM_HEARTBEAT_INTERVAL_MS,
          YarnConfiguration.DEFAULT_RM_NM_HEARTBEAT_INTERVAL_MS);
  if (nextHeartBeatInterval <= 0) {
    throw new YarnRuntimeException("Invalid Configuration. "
        + YarnConfiguration.RM_NM_HEARTBEAT_INTERVAL_MS
        + " should be larger than 0.");
  }

  minAllocMb = conf.getInt(
  	YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB,
  	YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB);
  minAllocVcores = conf.getInt(
  	YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES,
  	YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES);
  minAllocGcores = conf.getInt(
  	YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_GCORES,
  	YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_GCORES);

  minimumNodeManagerVersion = conf.get(
      YarnConfiguration.RM_NODEMANAGER_MINIMUM_VERSION,
      YarnConfiguration.DEFAULT_RM_NODEMANAGER_MINIMUM_VERSION);

  super.serviceInit(conf);
}
 
Example 12
Project: hadoop   File: HSAdmin.java   Source Code and License Vote up 5 votes
private int refreshLogRetentionSettings() throws IOException {
  // Refresh log retention settings
  Configuration conf = getConf();
  InetSocketAddress address = conf.getSocketAddr(
      JHAdminConfig.JHS_ADMIN_ADDRESS,
      JHAdminConfig.DEFAULT_JHS_ADMIN_ADDRESS,
      JHAdminConfig.DEFAULT_JHS_ADMIN_PORT);

  HSAdminRefreshProtocol refreshProtocol = HSProxies.createProxy(conf,
      address, HSAdminRefreshProtocol.class,
      UserGroupInformation.getCurrentUser());

  refreshProtocol.refreshLogRetentionSettings();
  return 0;
}
 
Example 13
Project: hadoop   File: HSAdmin.java   Source Code and License Vote up 5 votes
private int refreshAdminAcls() throws IOException {
  // Refresh the admin acls
  Configuration conf = getConf();
  InetSocketAddress address = conf.getSocketAddr(
      JHAdminConfig.JHS_ADMIN_ADDRESS,
      JHAdminConfig.DEFAULT_JHS_ADMIN_ADDRESS,
      JHAdminConfig.DEFAULT_JHS_ADMIN_PORT);

  HSAdminRefreshProtocol refreshProtocol = HSProxies.createProxy(conf,
      address, HSAdminRefreshProtocol.class,
      UserGroupInformation.getCurrentUser());

  refreshProtocol.refreshAdminAcls();
  return 0;
}
 
Example 14
Project: hadoop   File: Master.java   Source Code and License Vote up 5 votes
public static InetSocketAddress getMasterAddress(Configuration conf) {
  String masterAddress;
  String framework = conf.get(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME);
  if (framework.equals(MRConfig.CLASSIC_FRAMEWORK_NAME)) {
    masterAddress = conf.get(MRConfig.MASTER_ADDRESS, "localhost:8012");
    return NetUtils.createSocketAddr(masterAddress, 8012, MRConfig.MASTER_ADDRESS);
  } 
  else {
    return conf.getSocketAddr(
        YarnConfiguration.RM_ADDRESS,
        YarnConfiguration.DEFAULT_RM_ADDRESS,
        YarnConfiguration.DEFAULT_RM_PORT);
  }
}
 
Example 15
Project: hadoop   File: ClientProtocolService.java   Source Code and License Vote up 4 votes
InetSocketAddress getBindAddress(Configuration conf) {
  return conf.getSocketAddr(YarnConfiguration.SCM_CLIENT_SERVER_ADDRESS,
      YarnConfiguration.DEFAULT_SCM_CLIENT_SERVER_ADDRESS,
      YarnConfiguration.DEFAULT_SCM_CLIENT_SERVER_PORT);
}
 
Example 16
Project: hadoop   File: SCMAdminProtocolService.java   Source Code and License Vote up 4 votes
InetSocketAddress getBindAddress(Configuration conf) {
  return conf.getSocketAddr(YarnConfiguration.SCM_ADMIN_ADDRESS,
      YarnConfiguration.DEFAULT_SCM_ADMIN_ADDRESS,
      YarnConfiguration.DEFAULT_SCM_ADMIN_PORT);
}
 
Example 17
Project: hadoop   File: ResourceLocalizationService.java   Source Code and License Vote up 4 votes
@Override
public void serviceInit(Configuration conf) throws Exception {
  this.validateConf(conf);
  this.publicRsrc = new LocalResourcesTrackerImpl(null, null, dispatcher,
      true, conf, stateStore, dirsHandler);
  this.recordFactory = RecordFactoryProvider.getRecordFactory(conf);

  try {
    lfs = getLocalFileContext(conf);
    lfs.setUMask(new FsPermission((short) FsPermission.DEFAULT_UMASK));

    if (!stateStore.canRecover()|| stateStore.isNewlyCreated()) {
      cleanUpLocalDirs(lfs, delService);
      initializeLocalDirs(lfs);
      initializeLogDirs(lfs);
    }
  } catch (Exception e) {
    throw new YarnRuntimeException(
      "Failed to initialize LocalizationService", e);
  }

  cacheTargetSize =
    conf.getLong(YarnConfiguration.NM_LOCALIZER_CACHE_TARGET_SIZE_MB, YarnConfiguration.DEFAULT_NM_LOCALIZER_CACHE_TARGET_SIZE_MB) << 20;
  cacheCleanupPeriod =
    conf.getLong(YarnConfiguration.NM_LOCALIZER_CACHE_CLEANUP_INTERVAL_MS, YarnConfiguration.DEFAULT_NM_LOCALIZER_CACHE_CLEANUP_INTERVAL_MS);
  localizationServerAddress = conf.getSocketAddr(
      YarnConfiguration.NM_BIND_HOST,
      YarnConfiguration.NM_LOCALIZER_ADDRESS,
      YarnConfiguration.DEFAULT_NM_LOCALIZER_ADDRESS,
      YarnConfiguration.DEFAULT_NM_LOCALIZER_PORT);

  localizerTracker = createLocalizerTracker(conf);
  addService(localizerTracker);
  dispatcher.register(LocalizerEventType.class, localizerTracker);
  localDirsChangeListener = new DirsChangeListener() {
    @Override
    public void onDirsChanged() {
      checkAndInitializeLocalDirs();
    }
  };
  logDirsChangeListener = new DirsChangeListener() {
    @Override
    public void onDirsChanged() {
      initializeLogDirs(lfs);
    }
  };
  super.serviceInit(conf);
}
 
Example 18
Project: hadoop   File: SharedCacheClientImpl.java   Source Code and License Vote up 4 votes
private static InetSocketAddress getScmAddress(Configuration conf) {
  return conf.getSocketAddr(YarnConfiguration.SCM_CLIENT_SERVER_ADDRESS,
      YarnConfiguration.DEFAULT_SCM_CLIENT_SERVER_ADDRESS,
      YarnConfiguration.DEFAULT_SCM_CLIENT_SERVER_PORT);
}
 
Example 19
Project: hadoop   File: WebAppProxyServer.java   Source Code and License Vote up 2 votes
/**
 * Retrieve PROXY bind address from configuration
 *
 * @param conf
 * @return InetSocketAddress
 */
public static InetSocketAddress getBindAddress(Configuration conf) {
  return conf.getSocketAddr(YarnConfiguration.PROXY_ADDRESS,
    YarnConfiguration.DEFAULT_PROXY_ADDRESS,
    YarnConfiguration.DEFAULT_PROXY_PORT);
}
 
Example 20
Project: hadoop   File: JobHistoryServer.java   Source Code and License Vote up 2 votes
/**
 * Retrieve JHS bind address from configuration
 *
 * @param conf
 * @return InetSocketAddress
 */
public static InetSocketAddress getBindAddress(Configuration conf) {
  return conf.getSocketAddr(JHAdminConfig.MR_HISTORY_ADDRESS,
    JHAdminConfig.DEFAULT_MR_HISTORY_ADDRESS,
    JHAdminConfig.DEFAULT_MR_HISTORY_PORT);
}