/** * Checks if the configuration contains a value for the given key. * * @param key the key to check * @return true if there is value for the key, false otherwise * @deprecated due to misleading method name, use {{@link #isSet(PropertyKey)}} instead */ @Deprecated public static boolean containsKey(PropertyKey key) { return isSet(key); }
/** * @return whether the configuration describes how to find the master host, either through * explicit configuration or through zookeeper */ public static boolean masterHostConfigured() { boolean usingZk = Configuration.getBoolean(PropertyKey.ZOOKEEPER_ENABLED) && Configuration.isSet(PropertyKey.ZOOKEEPER_ADDRESS); return Configuration.isSet(PropertyKey.MASTER_HOSTNAME) || usingZk; }
/** * Creates a new instance of {@link AppCallbackHandler}. */ public AppCallbackHandler() { if (Configuration.isSet(PropertyKey.SECURITY_LOGIN_USERNAME)) { mUserName = Configuration.get(PropertyKey.SECURITY_LOGIN_USERNAME); } else { mUserName = ""; } }
/** * @param key property key * @return true if the key is contained in the given UFS configuration or global configuration */ public boolean containsKey(PropertyKey key) { return (mUfsConf != null && mUfsConf.containsKey(key.toString())) || Configuration.isSet(key); }
/** * Gets the local hostname to be used by the client. If this isn't configured, a non-loopback * local hostname will be looked up. * * @return the local hostname for the client */ public static String getClientHostName() { if (Configuration.isSet(PropertyKey.USER_HOSTNAME)) { return Configuration.get(PropertyKey.USER_HOSTNAME); } return getLocalHostName(); }
/** * Gets a local node name from configuration if it is available, falling back on localhost lookup. * * @return the local node name */ public static String getLocalNodeName() { switch (CommonUtils.PROCESS_TYPE.get()) { case CLIENT: if (Configuration.isSet(PropertyKey.USER_HOSTNAME)) { return Configuration.get(PropertyKey.USER_HOSTNAME); } break; case MASTER: if (Configuration.isSet(PropertyKey.MASTER_HOSTNAME)) { return Configuration.get(PropertyKey.MASTER_HOSTNAME); } break; case WORKER: if (Configuration.isSet(PropertyKey.WORKER_HOSTNAME)) { return Configuration.get(PropertyKey.WORKER_HOSTNAME); } break; default: break; } return getLocalHostName(); }
@Override protected boolean shouldSkip() { if (super.shouldSkip()) { return true; } String principal = null; if (Configuration.isSet(mPrincipalProperty)) { principal = Configuration.get(mPrincipalProperty); } if (principal == null || principal.isEmpty()) { System.out.format("Skip validation for secure HDFS. %s is not specified.%n", PRINCIPAL_MAP.get(mProcess).getName()); return true; } return false; }
/** * Gets the value of the given key in the given UFS configuration or the global configuration * (in case the key is not found in the UFS configuration), throw {@link RuntimeException} if the * key is not found in both configurations. * * @param key property key * @return the value associated with the given key */ public String getValue(PropertyKey key) { if (mUfsConf != null && mUfsConf.containsKey(key.toString())) { return mUfsConf.get(key.toString()); } if (Configuration.isSet(key)) { return Configuration.get(key); } throw new RuntimeException("key " + key + " not found"); }
if (Configuration.isSet(PropertyKey.SECURITY_LOGIN_IMPERSONATION_USERNAME)) { impersonationUser = Configuration.get(PropertyKey.SECURITY_LOGIN_IMPERSONATION_USERNAME); LOG.debug("Impersonation: configured: {}", impersonationUser);
/** * Helper method to get the {@link InetSocketAddress} bind address on a given service. * <p> * Host bind information searching order: * <ol> * <li>System properties or environment variables via alluxio-env.sh * <li>Default properties via alluxio-default.properties file * <li>A externally resolvable local hostname for the host this JVM is running on * </ol> * * @param service the service name * @return the bind hostname */ public static String getBindHost(ServiceType service) { if (Configuration.isSet(service.mBindHostKey) && !Configuration.get(service.mBindHostKey) .isEmpty()) { return Configuration.get(service.mBindHostKey); } else { return getLocalHostName(); } }
@Override public TTransport getClientTransport(Subject subject, InetSocketAddress serverAddress) throws UnauthenticatedException { String username = null; String password = "noPassword"; if (subject != null) { Set<User> user = subject.getPrincipals(User.class); if (user != null && !user.isEmpty()) { username = user.iterator().next().getName(); } } if (username == null || username.isEmpty()) { username = LoginUser.get().getName(); } // Determine the impersonation user String impersonationUser = TransportProviderUtils.getImpersonationUser(subject); if (impersonationUser != null && Configuration .isSet(PropertyKey.SECURITY_LOGIN_IMPERSONATION_USERNAME) && Constants.IMPERSONATION_HDFS_USER .equals(Configuration.get(PropertyKey.SECURITY_LOGIN_IMPERSONATION_USERNAME))) { // If impersonation is configured to use the HDFS user, the connection user should // be not be the HDFS user, but the LoginUser. // If the HDFS user is really supposed to be the connection user, that can be achieved by // not enabling impersonation for the client. username = LoginUser.get().getName(); } return getClientTransport(username, password, impersonationUser, serverAddress); }
/** * Starts all masters, including block master, FileSystem master, lineage master and additional * masters. * * @param isLeader if the Master is leader */ protected void startMasters(boolean isLeader) { try { if (isLeader) { if (Configuration.isSet(PropertyKey.MASTER_JOURNAL_INIT_FROM_BACKUP)) { AlluxioURI backup = new AlluxioURI(Configuration.get(PropertyKey.MASTER_JOURNAL_INIT_FROM_BACKUP)); if (mJournalSystem.isEmpty()) { initFromBackup(backup); } else { LOG.info("The journal system is not freshly formatted, skipping restoring backup from " + backup); } } mSafeModeManager.notifyPrimaryMasterStarted(); } mRegistry.start(isLeader); LOG.info("All masters started"); } catch (IOException e) { throw new RuntimeException(e); } }
if (Configuration.isSet(Template.LOCALITY_TIER.format(tierName))) { value = Configuration.get(Template.LOCALITY_TIER.format(tierName));
/** * Gets all global configuration properties filtered by the specified scope. * * @param scope the scope to filter by * @return the properties */ public static List<ConfigProperty> getConfiguration(Scope scope) { ConfigurationValueOptions useRawDisplayValue = ConfigurationValueOptions.defaults().useDisplayValue(true).useRawValue(true); return Configuration.keySet().stream() .filter(key -> key.getScope().contains(scope)) .filter(key -> key.isValid(key.getName())) .map(key -> new ConfigProperty() .setName(key.getName()) .setSource(Configuration.getSource(key).toString()).setValue( Configuration.isSet(key) ? Configuration.get(key, useRawDisplayValue) : null)) .collect(toList()); }
break; case ZOOKEEPER_ADDRESSES: if (Configuration.isSet(PropertyKey.ZOOKEEPER_ADDRESS)) { info.setZookeeperAddresses(Arrays.asList(Configuration.get( PropertyKey.ZOOKEEPER_ADDRESS).split(",")));