Source:
<code>private ZooKeeperClient setupZookeeperClient(final MasterConfig config) { ACLProvider aclProvider = null; List<AuthInfo> authorization = null; <START> if (config.isZooKeeperEnableAcls()) { <END> final String masterPassword = config.getZooKeeperMasterPassword(); final String agentDigest = config.getZooKeeperAgentDigest(); if (masterPassword == null) { throw new HeliosRuntimeException("ZooKeeper ACLs enabled but master password not set"); } if (agentDigest == null) { throw new HeliosRuntimeException("ZooKeeper ACLs enabled but agent digest not set"); } final String masterDigest = Base64.toBase64String(Hash.sha1digest( String.format("%s:%s", ZooKeeperAclProvider.MASTER_USER, masterPassword).getBytes())); aclProvider = new ZooKeeperAclProvider(masterDigest, agentDigest); authorization = Lists.newArrayList(new AuthInfo( "digest", String.format("%s:%s", ZooKeeperAclProvider.MASTER_USER, masterPassword).getBytes())); } final RetryPolicy zooKeeperRetryPolicy = new ExponentialBackoffRetry(1000, 3); final CuratorFramework curator = curatorClientFactory.newClient( config.getZooKeeperConnectionString(), config.getZooKeeperSessionTimeoutMillis(), config.getZooKeeperConnectionTimeoutMillis(), zooKeeperRetryPolicy, config.getZooKeeperNamespace(), aclProvider, authorization); final ZooKeeperClient client = new DefaultZooKeeperClient(curator, config.getZooKeeperClusterId()); client.start(); zkRegistrar = new ZooKeeperRegistrarService( client, new MasterZooKeeperRegistrar(config.getName())); return client; }</code><technical_language>this block is repeated in AgentService MasterService, a reversal of labels, moved CuratorClientFactory</technical_language>

Target:
private ZooKeeperClient setupZookeeperClient(final MasterConfig config) { ACLProvider aclProvider = null; List<AuthInfo> authorization = null; if (config.isZooKeeperEnableAcls()) { final String masterUser = config.getZookeeperAclMasterUser(); final String masterPassword = config.getZooKeeperAclMasterPassword(); final String agentUser = config.getZookeeperAclAgentUser(); final String agentDigest = config.getZooKeeperAclAgentDigest(); if (isNullOrEmpty(masterUser) || isNullOrEmpty(masterPassword)) { throw new HeliosRuntimeException( "ZooKeeper ACLs enabled but master username and/or password not set"); } if (isNullOrEmpty(agentUser) || isNullOrEmpty(agentDigest)) { throw new HeliosRuntimeException( "ZooKeeper ACLs enabled but agent username and/or digest not set"); } aclProvider = heliosAclProvider( masterUser, digest(masterUser, masterPassword), agentUser, agentDigest); authorization = Lists.newArrayList(new AuthInfo( "digest", String.format("%s:%s", masterUser, masterPassword).getBytes())); } final RetryPolicy zooKeeperRetryPolicy = new ExponentialBackoffRetry(1000, 3); final CuratorFramework curator = curatorClientFactory.newClient( config.getZooKeeperConnectionString(), config.getZooKeeperSessionTimeoutMillis(), config.getZooKeeperConnectionTimeoutMillis(), zooKeeperRetryPolicy, aclProvider, authorization); final ZooKeeperClient client = new DefaultZooKeeperClient(curator, config.getZooKeeperClusterId()); client.start(); zkRegistrar = new ZooKeeperRegistrarService( client, new MasterZooKeeperRegistrar(config.getName())); if (aclProvider != null) { try { final List<ACL> curAcls = client.getAcl("/"); final List<ACL> wantedAcls = aclProvider.getAclForPath("/"); if (!Sets.newHashSet(curAcls).equals(Sets.newHashSet(wantedAcls))) { log.info( "Current ACL's on the zookeeper root node differ from desired, updating: -> {}", curAcls, wantedAcls); client.getCuratorFramework().setACL().withACL(wantedAcls).forPath("/"); } } catch (Exception e) { log.error("Failed to get/set ACLs on the zookeeper root node", e); } } return client; }