@Override public boolean equals (Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ServiceBundle that = (ServiceBundle) o; if (id != null ? !id.equals(that.id) : that.id != null) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (serviceUISpecification != null ? !serviceUISpecification.equals(that.serviceUISpecification) : that.serviceUISpecification!= null) return false; return !(registerClass != null ? !registerClass.equals(that.registerClass) : that.registerClass != null); }
private static ComponentUISpecification getCustomProcessorUISpecification (ComponentUISpecification componentUISpecification) { ComponentUISpecification result = new ComponentUISpecification(); List<ComponentUISpecification.UIField> fields = new ArrayList<>(); for (ComponentUISpecification.UIField uiField: componentUISpecification.getFields()) { if (uiField.getFieldName().startsWith(TopologyLayoutConstants.JSON_KEY_CUSTOM_PROCESSOR_PREFIX)) { ComponentUISpecification.UIField newUIField = new ComponentUISpecification.UIField(uiField); newUIField.setFieldName(uiField.getFieldName().replaceFirst(TopologyLayoutConstants.JSON_KEY_CUSTOM_PROCESSOR_PREFIX_REGEX, "")); fields.add(newUIField); } } result.setFields(fields); return (result.getFields().isEmpty() ? null : result); }
@Override public int hashCode () { int result = id != null ? id.hashCode() : 0; result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (serviceUISpecification != null ? serviceUISpecification.hashCode() : 0); result = 31 * result + (registerClass != null ? registerClass.hashCode() : 0); return result; }
private List<ComponentUISpecification.UIField> getCustomProcessorUIFieldsWithPrefix () { List<ComponentUISpecification.UIField> result = new ArrayList<>(); if (topologyComponentUISpecification != null) { for (ComponentUISpecification.UIField uiField : this.topologyComponentUISpecification.getFields()) { ComponentUISpecification.UIField newUIField = new ComponentUISpecification.UIField(uiField); newUIField.setFieldName(TopologyLayoutConstants.JSON_KEY_CUSTOM_PROCESSOR_PREFIX + uiField.getFieldName()); result.add(newUIField); } } return result; }
public ServiceBundle addServiceBundle(ServiceBundle serviceBundle) throws ComponentConfigException { serviceBundle.getServiceUISpecification().validate(); if (serviceBundle.getId() == null) { serviceBundle.setId(this.dao.nextId(SERVICE_BUNDLE_NAMESPACE)); } if (serviceBundle.getTimestamp() == null) { serviceBundle.setTimestamp(System.currentTimeMillis()); } this.dao.add(serviceBundle); return serviceBundle; }
uiFields.add(this.createUIField(DIGEST, DIGEST, false, false, "MD5 digest of the jar file for this CP implementation", ComponentUISpecification.UIFieldType.STRING, this.digest)); ComponentUISpecification componentUISpecification = new ComponentUISpecification(); componentUISpecification.setFields(uiFields); result.setTopologyComponentUISpecification(componentUISpecification); return result;
public void validate () throws ComponentConfigException { Set<String> fieldNames = new HashSet<>(); for (UIField uiField: fields) { if (fieldNames.contains(uiField.fieldName)) { logAndThrowException("fieldName " + uiField.fieldName + " is repeated. Expected to be unique."); } fieldNames.add(uiField.fieldName); uiField.validate(); } }
public static CustomProcessorInfo fromTopologyComponentBundle(TopologyComponentBundle topologyComponentBundle) throws IOException { Preconditions.checkNotNull(topologyComponentBundle, "topologyComponentBundle can not bre null"); ComponentUISpecification topologyComponentUISpecification = topologyComponentBundle.getTopologyComponentUISpecification(); List<ComponentUISpecification.UIField> uiFields = topologyComponentUISpecification.getFields(); Map<String, String> config = getPropertiesFromUIFields(uiFields); return new CustomProcessorInfo(config.get(NAME), config.get(DESCRIPTION), topologyComponentBundle.getStreamingEngine(), config.get(JAR_FILE_NAME), config.get(CUSTOM_PROCESSOR_IMPL), Utils.getSchemaFromConfig(config.get(INPUT_SCHEMA)), Utils.getSchemaFromConfig(config.get(OUTPUT_SCHEMA)), getCustomProcessorUISpecification(topologyComponentUISpecification), config.get(DIGEST)); }
public TopologyComponentBundle addTopologyComponentBundle (TopologyComponentBundle topologyComponentBundle, java.io.File bundleJar) throws ComponentConfigException, IOException { topologyComponentBundle.getTopologyComponentUISpecification().validate(); loadTransformationClassForBundle(topologyComponentBundle, bundleJar); if (!topologyComponentBundle.getBuiltin()) { topologyComponentBundle.setBundleJar(getTopologyComponentBundleJarName(topologyComponentBundle)); try (InputStream is = new FileInputStream(bundleJar)) { uploadFileToStorage(is, topologyComponentBundle.getBundleJar()); } } try { if (topologyComponentBundle.getId() == null) { topologyComponentBundle.setId(this.dao.nextId(TopologyComponentBundle.NAME_SPACE)); } if (topologyComponentBundle.getTimestamp() == null) { topologyComponentBundle.setTimestamp(System.currentTimeMillis()); } this.dao.add(topologyComponentBundle); } catch (StorageException e) { if (!topologyComponentBundle.getBuiltin()) { LOG.debug("StorageException while adding the bundle. Deleting the bundle jar."); deleteFileFromStorage(topologyComponentBundle.getBundleJar()); } throw e; } return topologyComponentBundle; }
private Collection<TopologyComponentBundle> listCustomProcessorBundlesWithFilter(List<QueryParam> params) throws IOException { List<QueryParam> queryParamsForTopologyComponent = new ArrayList<>(); queryParamsForTopologyComponent.add(new QueryParam(TopologyComponentBundle.SUB_TYPE, TopologyLayoutConstants.JSON_KEY_CUSTOM_PROCESSOR_SUB_TYPE)); for (QueryParam qp : params) { if (qp.getName().equals(TopologyComponentBundle.STREAMING_ENGINE)) { queryParamsForTopologyComponent.add(qp); } } Collection<TopologyComponentBundle> customProcessors = this.listTopologyComponentBundlesForTypeWithFilter(TopologyComponentBundle.TopologyComponentType .PROCESSOR, queryParamsForTopologyComponent); Collection<TopologyComponentBundle> result = new ArrayList<>(); for (TopologyComponentBundle cp : customProcessors) { Map<String, Object> config = new HashMap<>(); for (ComponentUISpecification.UIField uiField: cp.getTopologyComponentUISpecification().getFields()) { config.put(uiField.getFieldName(), uiField.getDefaultValue()); } boolean matches = true; for (QueryParam qp : params) { if (!qp.getName().equals(TopologyComponentBundle.STREAMING_ENGINE) && !qp.getValue().equals(config.get(qp.getName()))) { matches = false; break; } } if (matches) { result.add(cp); } } return result; }
@Override public boolean equals (Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; TopologyComponentBundle that = (TopologyComponentBundle) o; if (id != null ? !id.equals(that.id) : that.id != null) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (type != that.type) return false; if (streamingEngine != null ? !streamingEngine.equals(that.streamingEngine) : that.streamingEngine != null) return false; if (subType != null ? !subType.equals(that.subType) : that.subType != null) return false; if (bundleJar != null ? !bundleJar.equals(that.bundleJar) : that.bundleJar!= null) return false; if (topologyComponentUISpecification != null ? !topologyComponentUISpecification.equals(that.topologyComponentUISpecification) : that.topologyComponentUISpecification!= null) return false; if (fieldHintProviderClass != null ? !fieldHintProviderClass.equals(that.fieldHintProviderClass) : that.fieldHintProviderClass != null) return false; if (builtin != null ? !builtin.equals(that.builtin) : that.builtin!= null) return false; if (mavenDeps != null ? !mavenDeps.equals(that.mavenDeps) : that.mavenDeps!= null) return false; return !(transformationClass != null ? !transformationClass.equals(that.transformationClass) : that.transformationClass != null); }
@Override public int hashCode () { int result = id != null ? id.hashCode() : 0; result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (type != null ? type.hashCode() : 0); result = 31 * result + (streamingEngine != null ? streamingEngine.hashCode() : 0); result = 31 * result + (subType != null ? subType.hashCode() : 0); result = 31 * result + (bundleJar != null ? bundleJar.hashCode() : 0); result = 31 * result + (topologyComponentUISpecification != null ? topologyComponentUISpecification.hashCode() : 0); result = 31 * result + (fieldHintProviderClass != null ? fieldHintProviderClass.hashCode() : 0); result = 31 * result + (transformationClass != null ? transformationClass.hashCode() : 0); result = 31 * result + (builtin != null ? builtin.hashCode() : 0); result = 31 * result + (mavenDeps != null ? mavenDeps.hashCode() : 0); return result; }
public TopologyComponentBundle addOrUpdateTopologyComponentBundle (Long id, TopologyComponentBundle topologyComponentBundle, java.io.File bundleJar) throws ComponentConfigException, IOException { topologyComponentBundle.getTopologyComponentUISpecification().validate(); loadTransformationClassForBundle(topologyComponentBundle, bundleJar); if (!topologyComponentBundle.getBuiltin()) {
List<String> fileFieldNames = specification.getFields().stream() .filter(uiField -> uiField.getType().equals(ComponentUISpecification.UIFieldType.FILE)) .map(uiField -> uiField.getFieldName())
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CustomProcessorInfo that = (CustomProcessorInfo) o; if (streamingEngine != null ? !streamingEngine.equals(that.streamingEngine) : that.streamingEngine != null) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (description != null ? !description.equals(that.description) : that.description != null) return false; if (jarFileName != null ? !jarFileName.equals(that.jarFileName) : that.jarFileName != null) return false; if (topologyComponentUISpecification != null ? !topologyComponentUISpecification.equals(that.topologyComponentUISpecification) : that .topologyComponentUISpecification != null) return false; if (inputSchema != null ? !inputSchema.equals(that.inputSchema) : that.inputSchema != null) return false; if (outputSchema != null ? !outputSchema.equals(that.outputSchema) : that.outputSchema != null) return false; if (digest != null ? !digest.equals(that.digest) : that.digest != null) return false; return !(customProcessorImpl != null ? !customProcessorImpl.equals(that.customProcessorImpl) : that.customProcessorImpl != null); }
@Override public int hashCode() { int result = streamingEngine != null ? streamingEngine.hashCode() : 0; result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (description != null ? description.hashCode() : 0); result = 31 * result + (jarFileName != null ? jarFileName.hashCode() : 0); result = 31 * result + (topologyComponentUISpecification != null ? topologyComponentUISpecification.hashCode() : 0); result = 31 * result + (inputSchema != null ? inputSchema.hashCode() : 0); result = 31 * result + (outputSchema != null ? outputSchema.hashCode() : 0); result = 31 * result + (digest != null ? digest.hashCode() : 0); result = 31 * result + (customProcessorImpl != null ? customProcessorImpl.hashCode() : 0); return result; }