Source:
<code>private void onChildAdded(CuratorFramework client, ChildData data) throws Exception { String path = data.getPath(); ModuleDeploymentsPath moduleDeploymentsPath = new ModuleDeploymentsPath(path); String unitName = moduleDeploymentsPath.getStreamName(); String moduleType = moduleDeploymentsPath.getModuleType(); String moduleLabel = moduleDeploymentsPath.getModuleLabel(); String moduleSequence = moduleDeploymentsPath.getModuleSequence(); ModuleDescriptor.Key key = new ModuleDescriptor.Key(unitName, ModuleType.valueOf(moduleType), moduleLabel); String container = moduleDeploymentsPath.getContainer(); Module module = null; ModuleDeploymentStatus status; ModuleDeploymentProperties properties = new ModuleDeploymentProperties(); <START> properties.putAll(ZooKeeperUtils.bytesToMap(data.getData())); <END> try { module = (ModuleType.job.toString().equals(moduleType)) ? deployJob(client, unitName, moduleLabel, moduleSequence, properties) : deployStreamModule(client, unitName, moduleType, moduleLabel, moduleSequence, properties); if (module == null) { status = new ModuleDeploymentStatus(container, moduleSequence, key, ModuleDeploymentStatus.State.failed, "Module deployment returned null"); } else { status = new ModuleDeploymentStatus(container, moduleSequence, key, ModuleDeploymentStatus.State.deployed, null); } } catch (Exception e) { status = new ModuleDeploymentStatus(container, moduleSequence, key, ModuleDeploymentStatus.State.failed, e.toString()); logger.error("Exception deploying module", e); } try { writeModuleMetadata(module, path, client); client.setData().forPath(status.buildPath(), ZooKeeperUtils.mapToBytes(status.toMap())); } catch (KeeperException.NoNodeException e) { logger.warn("During deployment of module of type for {}, an undeployment request " + "was detected; this module will be undeployed.", moduleLabel, moduleType, unitName); if (logger.isTraceEnabled()) { logger.trace("Path " + path + " was removed", e); } } }</code><technical_language>happy of ZooKeeperUtils.bytesToMap in more places! Remember _runtime_ properties - can: - Create instance of RuntimeModuleDeploymentProperties - Remove moduleSequence parameter deployJob deployStreamModule instead obtain sequence number passed in properties</technical_language>

Target:
private void onChildAdded(CuratorFramework client, ChildData data) throws Exception { String path = data.getPath(); ModuleDeploymentsPath moduleDeploymentsPath = new ModuleDeploymentsPath(path); String unitName = moduleDeploymentsPath.getStreamName(); String moduleType = moduleDeploymentsPath.getModuleType(); String moduleLabel = moduleDeploymentsPath.getModuleLabel(); int moduleSequence = moduleDeploymentsPath.getModuleSequence(); ModuleDescriptor.Key key = new ModuleDescriptor.Key(unitName, ModuleType.valueOf(moduleType), moduleLabel); String container = moduleDeploymentsPath.getContainer(); Module module = null; ModuleDeploymentStatus status; RuntimeModuleDeploymentProperties properties = new RuntimeModuleDeploymentProperties(); properties.putAll(ZooKeeperUtils.bytesToMap(data.getData())); try { module = (ModuleType.job.toString().equals(moduleType)) ? deployJobModule(client, unitName, moduleLabel, properties) : deployStreamModule(client, unitName, moduleType, moduleLabel, properties); if (module == null) { status = new ModuleDeploymentStatus(container, moduleSequence, key, ModuleDeploymentStatus.State.failed, "Module deployment returned null"); } else { status = new ModuleDeploymentStatus(container, moduleSequence, key, ModuleDeploymentStatus.State.deployed, null); } } catch (Exception e) { status = new ModuleDeploymentStatus(container, moduleSequence, key, ModuleDeploymentStatus.State.failed, e.toString()); logger.error("Exception deploying module", e); } try { writeModuleMetadata(module, path, client); client.setData().forPath(status.buildPath(), ZooKeeperUtils.mapToBytes(status.toMap())); } catch (KeeperException.NoNodeException e) { logger.warn("During deployment of module of type for {}, an undeployment request " + "was detected; this module will be undeployed.", moduleLabel, moduleType, unitName); if (logger.isTraceEnabled()) { logger.trace("Path " + path + " was removed", e); } } }