public TopologyComponent(TopologyComponent other) { if (other != null) { setId(other.getId()); setTopologyId(other.getTopologyId()); setTopologyComponentBundleId(other.getTopologyComponentBundleId()); setVersionId(other.getVersionId()); setName(other.getName()); setDescription(other.getDescription()); setConfig(new Config(other.getConfig())); setVersionTimestamp(other.getVersionTimestamp()); } }
/** * Generate id from the {@link TopologyComponent} namespace * so that its unique across source, sink and processors. * Similar to Table per concrete class hibernate strategy. */ private Long getNextTopologyComponentId() { TopologyComponent component = new TopologyComponent(); Long id = dao.nextId(TOPOLOGY_COMPONENT_NAMESPACE); component.setId(id); dao.add(component); dao.remove(component.getStorableKey()); return component.getId(); }
@Override public Map<String, Object> toMap() { Map<String, Object> map = super.toMap(); map.remove(CONFIG); try { map.put(CONFIG_DATA, getConfigData()); } catch (Exception e) { throw new RuntimeException(e); } return map; }
private void removeAllEdges(TopologyComponent c) { removeTopologyEdge(buildEdgesFromQueryParam(c.getTopologyId(), c.getVersionId(), c.getId())); removeTopologyEdge(buildEdgesToQueryParam(c.getTopologyId(), c.getVersionId(), c.getId())); }
@Override public boolean enableSampling(Topology topology, TopologyComponent component, int pct, String asUser) { String topologyId = StormTopologyUtil.findStormTopologyId(client, topology.getId(), asUser); String stormComponentId = StormTopologyUtil.generateStormComponentId(component.getId(), component.getName()); return client.enableSampling(topologyId, stormComponentId, pct, asUser); }
private <T extends StreamlineComponent> T getStreamlineComponent(Class<T> clazz, TopologyComponent topologyComponent) { if (topologyComponent.getReconfigure()) { throw new IllegalStateException("Topology component " + topologyComponent + " must be reconfigured"); } TopologyComponentBundle topologyComponentBundle = getTopologyComponentBundle(topologyComponent); StreamlineComponent component = getProvider(clazz, topologyComponentBundle.getSubType()) .create(topologyComponent); component.setId(topologyComponent.getId().toString()); component.setName(topologyComponent.getName()); component.setConfig(topologyComponent.getConfig()); component.setTopologyComponentBundleId(topologyComponentBundle.getId().toString()); component.setTransformationClass(topologyComponentBundle.getTransformationClass()); return clazz.cast(component); }
@Override public StreamlineProcessor create(TopologyComponent component) { Config config = component.getConfig(); Object typeObj = config.getAny(NormalizationProcessor.CONFIG_KEY_TYPE); Object normConfObj = config.getAny(NormalizationProcessor.CONFIG_KEY_NORMALIZATION); ObjectMapper objectMapper = new ObjectMapper(); NormalizationProcessor.Type type = objectMapper.convertValue(typeObj, NormalizationProcessor.Type.class); Map<String, NormalizationConfig> normConfig = objectMapper.convertValue(normConfObj, new TypeReference<Map<String, NormalizationConfig>>() { }); updateWithSchemas(component.getTopologyId(), component.getVersionId(), normConfig); Set<Stream> outputStreams; if (component instanceof TopologyOutputComponent) { outputStreams = createOutputStreams((TopologyOutputComponent) component); } else { throw new IllegalArgumentException("Component " + component + " must be an instance of TopologyOutputComponent"); } if (outputStreams.size() != 1) { throw new IllegalArgumentException("Normalization component [" + component + "] must have only one output stream"); } return new NormalizationProcessor(normConfig, outputStreams.iterator().next(), type); } };
.collect(toMap(m -> m.getKey().getId().toString(), m -> m.getValue())), forkJoinPool);
@Override public StreamlineProcessor create(TopologyComponent component) { Object stageConfig = component.getConfig().getAny(StageProcessor.CONFIG_KEY_STAGE); ObjectMapper objectMapper = new ObjectMapper(); StageAction stageAction = objectMapper.convertValue(stageConfig, StageAction.class); StageProcessor stageProcessor = new StageProcessor(); stageProcessor.setStageAction(stageAction); return stageProcessor; } };
private TopologyComponentBundle getTopologyComponentBundle (TopologyComponent topologyComponent) { TopologyComponentBundle topologyComponentBundle = catalogService.getTopologyComponentBundle(topologyComponent.getTopologyComponentBundleId()); if (topologyComponentBundle == null) { String msg = "TopologyComponentBundle not found for topologyComponent " + topologyComponent; LOG.debug(msg); throw new RuntimeException(msg); } return topologyComponentBundle; }
@Override public boolean disableSampling(Topology topology, TopologyComponent component, String asUser) { String topologyId = StormTopologyUtil.findStormTopologyId(client, topology.getId(), asUser); String stormComponentId = StormTopologyUtil.generateStormComponentId(component.getId(), component.getName()); return client.disableSampling(topologyId, stormComponentId, asUser); }
@Override public StreamlineProcessor create(TopologyComponent component) { RulesProcessor processor = new RulesProcessor(); ObjectMapper objectMapper = new ObjectMapper(); if (component instanceof TopologyOutputComponent) { Set<Stream> outputStreams = createOutputStreams((TopologyOutputComponent) component); processor.addOutputStreams(outputStreams); } else { throw new IllegalArgumentException("Component " + component + " must be an instance of TopologyOutputComponent"); } boolean processAll = component.getConfig().getBoolean(RulesProcessor.CONFIG_PROCESS_ALL, true); processor.setProcessAll(processAll); Object ruleList = component.getConfig().getAny(RulesProcessor.CONFIG_KEY_RULES); List<Long> ruleIds = objectMapper.convertValue(ruleList, new TypeReference<List<Long>>() { }); try { List<Rule> rules = new ArrayList<>(); for (Long ruleId : ruleIds) { rules.add(ruleExtractor.getRule(component.getTopologyId(), ruleId, component.getVersionId())); } processor.setRules(rules); } catch (Exception ex) { throw new RuntimeException(ex); } return processor; } };
@Override public StreamlineProcessor create(TopologyComponent component) { Object splitConfig = component.getConfig().getAny(SplitProcessor.CONFIG_KEY_SPLIT); ObjectMapper objectMapper = new ObjectMapper(); SplitAction splitAction = objectMapper.convertValue(splitConfig, SplitAction.class); SplitProcessor splitProcessor = new SplitProcessor(); if (component instanceof TopologyOutputComponent) { splitProcessor.addOutputStreams(createOutputStreams((TopologyOutputComponent) component)); } else { throw new IllegalArgumentException("Component " + component + " must be an instance of TopologyOutputComponent"); } splitProcessor.setSplitAction(splitAction); return splitProcessor; } };
@Override public SamplingStatus getSamplingStatus(Topology topology, TopologyComponent component, String asUser) { String topologyId = StormTopologyUtil.findStormTopologyId(client, topology.getId(), asUser); if (topologyId == null) { return null; } String stormComponentId = StormTopologyUtil.generateStormComponentId(component.getId(), component.getName()); return buildSamplingStatus(client.getSamplingStatus(topologyId, stormComponentId, asUser)); }
@Override public StreamlineProcessor create(TopologyComponent component) { String modelName = component.getConfig().getString(ModelProcessor.CONFIG_MODEL_NAME, StringUtils.EMPTY); ModelProcessor modelProcessor = new ModelProcessor(); if (!modelName.equals(StringUtils.EMPTY)) { modelProcessor.setPmml(modelRegistryClient.getMLModelContents(modelName)); } return modelProcessor; } };