public static void initialize() { synchronized (ProviderRegistry.class) { if (initialized) return; IPAuthenticationProvider ipp = new IPAuthenticationProvider(); DigestAuthenticationProvider digp = new DigestAuthenticationProvider(); authenticationProviders.put(ipp.getScheme(), ipp); authenticationProviders.put(digp.getScheme(), digp); Enumeration<Object> en = System.getProperties().keys(); while (en.hasMoreElements()) { String k = (String) en.nextElement(); if (k.startsWith("zookeeper.authProvider.")) { String className = System.getProperty(k); try { Class<?> c = ZooKeeperServer.class.getClassLoader() .loadClass(className); AuthenticationProvider ap = (AuthenticationProvider) c.getDeclaredConstructor() .newInstance(); authenticationProviders.put(ap.getScheme(), ap); } catch (Exception e) { LOG.warn("Problems loading " + className,e); } } } initialized = true; } }
public static void initialize() { synchronized (ProviderRegistry.class) { if (initialized) return; IPAuthenticationProvider ipp = new IPAuthenticationProvider(); DigestAuthenticationProvider digp = new DigestAuthenticationProvider(); authenticationProviders.put(ipp.getScheme(), ipp); authenticationProviders.put(digp.getScheme(), digp); Enumeration<Object> en = System.getProperties().keys(); while (en.hasMoreElements()) { String k = (String) en.nextElement(); if (k.startsWith("zookeeper.authProvider.")) { String className = System.getProperty(k); try { Class<?> c = ZooKeeperServer.class.getClassLoader() .loadClass(className); AuthenticationProvider ap = (AuthenticationProvider) c .getDeclaredConstructor().newInstance(); authenticationProviders.put(ap.getScheme(), ap); } catch (Exception e) { LOG.warn("Problems loading " + className,e); } } } initialized = true; } }
public static void initialize() { synchronized (ProviderRegistry.class) { if (initialized) return; IPAuthenticationProvider ipp = new IPAuthenticationProvider(); DigestAuthenticationProvider digp = new DigestAuthenticationProvider(); authenticationProviders.put(ipp.getScheme(), ipp); authenticationProviders.put(digp.getScheme(), digp); Enumeration<Object> en = System.getProperties().keys(); while (en.hasMoreElements()) { String k = (String) en.nextElement(); if (k.startsWith("zookeeper.authProvider.")) { String className = System.getProperty(k); try { Class<?> c = ZooKeeperServer.class.getClassLoader() .loadClass(className); AuthenticationProvider ap = (AuthenticationProvider) c .newInstance(); authenticationProviders.put(ap.getScheme(), ap); } catch (Exception e) { LOG.warn("Problems loading " + className,e); } } } initialized = true; } }
/** * Get ZooKeeper Curator manager, creating and starting if not exists. * @param config Configuration for the ZooKeeper curator. * @return ZooKeeper Curator manager. * @throws IOException If it cannot create the manager. */ public ZKCuratorManager createAndStartZKManager(Configuration config) throws IOException { ZKCuratorManager manager = new ZKCuratorManager(config); // Get authentication List<AuthInfo> authInfos = new ArrayList<>(); if (HAUtil.isHAEnabled(config) && HAUtil.getConfValueForRMInstance( YarnConfiguration.ZK_RM_STATE_STORE_ROOT_NODE_ACL, config) == null) { String zkRootNodeUsername = HAUtil.getConfValueForRMInstance( YarnConfiguration.RM_ADDRESS, YarnConfiguration.DEFAULT_RM_ADDRESS, config); String defaultFencingAuth = zkRootNodeUsername + ":" + zkRootNodePassword; byte[] defaultFencingAuthData = defaultFencingAuth.getBytes(Charset.forName("UTF-8")); String scheme = new DigestAuthenticationProvider().getScheme(); AuthInfo authInfo = new AuthInfo(scheme, defaultFencingAuthData); authInfos.add(authInfo); } manager.start(authInfos); return manager; }