private void login(PropertyKey keytabFileKey, String keytabFile, PropertyKey principalKey, String principal, String hostname) throws IOException { org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(); conf.set(keytabFileKey.toString(), keytabFile); conf.set(principalKey.toString(), principal); SecurityUtil.login(conf, keytabFileKey.toString(), principalKey.toString(), hostname); }
/** * @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); }
/** * Set the System properties into Hadoop configuration. * * This method won't override existing properties even if they are set as System properties. * * @param configuration Hadoop configuration * @param propertyNames the properties to be set */ private static void setConfigurationFromSystemProperties(Configuration configuration, PropertyKey[] propertyNames) { for (PropertyKey propertyName : propertyNames) { setConfigurationFromSystemProperty(configuration, propertyName.toString()); } }
/** * @param key the key to query * @return the value, or null if the key has no value set */ @Nullable public String get(PropertyKey key) { if (mUserProps.containsKey(key)) { return mUserProps.get(key).orElse(null); } // In case key is not the reference to the original key return PropertyKey.fromString(key.toString()).getDefaultValue(); }
/** * 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"); }
/** * Checks if there is a value set for the given key. * * @param key the key to check * @return true if there is value for the key, false otherwise */ public boolean isSet(PropertyKey key) { if (mUserProps.containsKey(key)) { return mUserProps.get(key).isPresent(); } // In case key is not the reference to the original key return PropertyKey.fromString(key.toString()).getDefaultValue() != null; }
/** * Starts the process. */ public synchronized void start() throws IOException { Preconditions.checkState(mProcess == null, "Process is already running"); String java = PathUtils.concatPath(System.getProperty("java.home"), "bin", "java"); String classpath = System.getProperty("java.class.path"); List<String> args = new ArrayList<>(Arrays.asList(java, "-cp", classpath)); for (Entry<PropertyKey, String> entry : mConf.entrySet()) { args.add(String.format("-D%s=%s", entry.getKey().toString(), entry.getValue())); } args.add(mClazz.getCanonicalName()); ProcessBuilder pb = new ProcessBuilder(args); pb.redirectError(mOutFile); pb.redirectOutput(mOutFile); mProcess = pb.start(); }
/** * Starts the Alluxio proxy. * * @param args command line arguments, should be empty */ public static void main(String[] args) { if (args.length != 0) { LOG.info("java -cp {} {}", RuntimeConstants.ALLUXIO_JAR, AlluxioProxy.class.getCanonicalName()); System.exit(-1); } if (!ConfigurationUtils.masterHostConfigured()) { ProcessUtils.fatalError(LOG, "Cannot run alluxio proxy; master hostname is not " + "configured. Please modify %s to either set %s or configure zookeeper with " + "%s=true and %s=[comma-separated zookeeper master addresses]", Constants.SITE_PROPERTIES, PropertyKey.MASTER_HOSTNAME.toString(), PropertyKey.ZOOKEEPER_ENABLED.toString(), PropertyKey.ZOOKEEPER_ADDRESS.toString()); } CommonUtils.PROCESS_TYPE.set(CommonUtils.ProcessType.PROXY); ProxyProcess process = ProxyProcess.Factory.create(); ProcessUtils.run(process); }
/** * Checks that tiered locality configuration is consistent. * * @throws IllegalStateException if invalid tiered locality configuration is encountered */ private void checkTieredLocality() { // Check that any custom tiers set by alluxio.locality.{custom_tier}=value are also defined in // the tier ordering defined by alluxio.locality.order. Set<String> tiers = Sets.newHashSet(getList(PropertyKey.LOCALITY_ORDER, ",")); Set<PropertyKey> predefinedKeys = new HashSet<>(PropertyKey.defaultKeys()); for (PropertyKey key : mProperties.keySet()) { if (predefinedKeys.contains(key)) { // Skip non-templated keys. continue; } Matcher matcher = Template.LOCALITY_TIER.match(key.toString()); if (matcher.matches() && matcher.group(1) != null) { String tierName = matcher.group(1); if (!tiers.contains(tierName)) { throw new IllegalStateException( String.format("Tier %s is configured by %s, but does not exist in the tier list %s " + "configured by %s", tierName, key, tiers, PropertyKey.LOCALITY_ORDER)); } } } } }
key, PropertyKey.LOCALITY_ORDER.toString(), allTiers));
for (Entry<PropertyKey, String> entry : properties.entrySet()) { alluxioJavaOpts .append(String.format(" -D%s=%s", entry.getKey().toString(), entry.getValue()));
private SortedSet<Triple<String, String, String>> getSortedProperties() { TreeSet<Triple<String, String, String>> rtn = new TreeSet<>(); Set<String> alluxioConfExcludes = Sets.newHashSet( PropertyKey.MASTER_WHITELIST.toString()); for (ConfigProperty configProperty : mMetaMaster.getConfiguration(GetConfigurationOptions.defaults().setRawValue(true))) { String confName = configProperty.getName(); if (!alluxioConfExcludes.contains(confName)) { rtn.add(new ImmutableTriple<>(confName, ConfigurationUtils.valueAsString(configProperty.getValue()), configProperty.getSource())); } } return rtn; } }