Search in sources :

Example 51 with EMPTY

use of org.apache.commons.lang3.StringUtils.EMPTY in project mule by mulesoft.

the class DefaultArtifactClassLoaderFilter method exportsClass.

@Override
public boolean exportsClass(String className) {
    checkArgument(!StringUtils.isEmpty(className), "Class name cannot be empty");
    final String packageName = getPackageName(className);
    return exportedClassPackages.contains(packageName);
}
Also used : ToStringBuilder.reflectionToString(org.apache.commons.lang3.builder.ToStringBuilder.reflectionToString)

Example 52 with EMPTY

use of org.apache.commons.lang3.StringUtils.EMPTY in project mule by mulesoft.

the class XmlExtensionLoaderDelegate method declareErrorModels.

private void declareErrorModels(OperationDeclarer operationDeclarer, XmlDslModel xmlDslModel, String operationName, ComponentModel operationModel) {
    Optional<ComponentModel> optionalParametersComponentModel = operationModel.getInnerComponents().stream().filter(child -> child.getIdentifier().equals(OPERATION_ERRORS_IDENTIFIER)).findAny();
    optionalParametersComponentModel.ifPresent(componentModel -> componentModel.getInnerComponents().stream().filter(child -> child.getIdentifier().equals(OPERATION_ERROR_IDENTIFIER)).forEach(param -> {
        final String namespace = xmlDslModel.getPrefix().toUpperCase();
        final String typeName = param.getParameters().get(ERROR_TYPE_ATTRIBUTE);
        if (StringUtils.isBlank(typeName)) {
            throw new IllegalModelDefinitionException(format("The operation [%s] cannot have an <error> with an empty 'type' attribute", operationName));
        }
        if (typeName.contains(NAMESPACE_SEPARATOR)) {
            throw new IllegalModelDefinitionException(format("The operation [%s] cannot have an <error> [%s] that contains a reserved character [%s]", operationName, typeName, NAMESPACE_SEPARATOR));
        }
        operationDeclarer.withErrorModel(ErrorModelBuilder.newError(typeName, namespace).withParent(ErrorModelBuilder.newError(ANY).build()).build());
    }));
}
Also used : PRIMITIVE_TYPES(org.mule.metadata.catalog.api.PrimitiveTypesTypeLoader.PRIMITIVE_TYPES) BEHAVIOUR(org.mule.runtime.api.meta.model.parameter.ParameterRole.BEHAVIOUR) ErrorModelBuilder(org.mule.runtime.api.meta.model.error.ErrorModelBuilder) ParameterRole(org.mule.runtime.api.meta.model.parameter.ParameterRole) Optional.of(java.util.Optional.of) ConnectionProviderDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ConnectionProviderDeclarer) StreamResult(javax.xml.transform.stream.StreamResult) Thread.currentThread(java.lang.Thread.currentThread) StringUtils(org.apache.commons.lang3.StringUtils) ConfigurationDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ConfigurationDeclarer) Collections.singletonList(java.util.Collections.singletonList) SpiServiceRegistry(org.mule.runtime.core.api.registry.SpiServiceRegistry) Document(org.w3c.dom.Document) Map(java.util.Map) StringUtils.isEmpty(org.apache.commons.lang3.StringUtils.isEmpty) NullDslResolvingContext(org.mule.runtime.internal.dsl.NullDslResolvingContext) IllegalParameterModelDefinitionException(org.mule.runtime.extension.api.exception.IllegalParameterModelDefinitionException) ConnectionProvider(org.mule.runtime.api.connection.ConnectionProvider) ByteArrayOutputStream(org.apache.commons.io.output.ByteArrayOutputStream) Set(java.util.Set) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) TestConnectionGlobalElementModelProperty(org.mule.runtime.config.internal.dsl.model.extension.xml.property.TestConnectionGlobalElementModelProperty) DisplayModel(org.mule.runtime.api.meta.model.display.DisplayModel) IOUtils(org.apache.commons.io.IOUtils) DeclarationOperation(org.mule.runtime.extension.api.loader.xml.declaration.DeclarationOperation) MacroExpansionModulesModel.getUsedNamespaces(org.mule.runtime.config.internal.dsl.model.extension.xml.MacroExpansionModulesModel.getUsedNamespaces) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) XmlModelUtils.createXmlLanguageModel(org.mule.runtime.extension.api.util.XmlModelUtils.createXmlLanguageModel) Category(org.mule.runtime.api.meta.Category) PrivateOperationsModelProperty(org.mule.runtime.config.internal.dsl.model.extension.xml.property.PrivateOperationsModelProperty) LayoutModel(org.mule.runtime.api.meta.model.display.LayoutModel) OperationComponentModelModelProperty(org.mule.runtime.config.internal.dsl.model.extension.xml.property.OperationComponentModelModelProperty) MetadataType(org.mule.metadata.api.model.MetadataType) DslSyntaxResolver(org.mule.runtime.extension.api.dsl.syntax.resolver.DslSyntaxResolver) DirectedGraph(org.jgrapht.DirectedGraph) HasOperationDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.HasOperationDeclarer) Optional.empty(java.util.Optional.empty) TransformerException(javax.xml.transform.TransformerException) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) BaseTypeBuilder(org.mule.metadata.api.builder.BaseTypeBuilder) TreeSet(java.util.TreeSet) Placement(org.mule.runtime.extension.api.annotation.param.display.Placement) String.join(java.lang.String.join) LayoutModel.builder(org.mule.runtime.api.meta.model.display.LayoutModel.builder) CycleDetector(org.jgrapht.alg.CycleDetector) DefaultEdge(org.jgrapht.graph.DefaultEdge) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) XmlExtensionModelProperty(org.mule.runtime.extension.api.property.XmlExtensionModelProperty) ANY(org.mule.runtime.core.api.exception.Errors.ComponentIdentifiers.Handleable.ANY) GlobalElementComponentModelModelProperty(org.mule.runtime.config.internal.dsl.model.extension.xml.property.GlobalElementComponentModelModelProperty) IOException(java.io.IOException) ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) ConnectionManagementType(org.mule.runtime.api.meta.model.connection.ConnectionManagementType) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) NoReconnectionStrategyModelProperty(org.mule.runtime.extension.internal.property.NoReconnectionStrategyModelProperty) Boolean.parseBoolean(java.lang.Boolean.parseBoolean) ParameterDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclarer) TransformerFactory(javax.xml.transform.TransformerFactory) ComponentIdentifier(org.mule.runtime.api.component.ComponentIdentifier) MacroExpansionModulesModel(org.mule.runtime.config.internal.dsl.model.extension.xml.MacroExpansionModulesModel) URL(java.net.URL) NamedObject(org.mule.runtime.api.meta.NamedObject) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) XmlApplicationParser(org.mule.runtime.config.api.dsl.processor.xml.XmlApplicationParser) ByteArrayInputStream(java.io.ByteArrayInputStream) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) MacroExpansionModuleModel(org.mule.runtime.config.internal.dsl.model.extension.xml.MacroExpansionModuleModel) ComponentModelReader(org.mule.runtime.config.internal.dsl.model.ComponentModelReader) XmlConfigurationDocumentLoader(org.mule.runtime.config.api.XmlConfigurationDocumentLoader) EnvironmentPropertiesConfigurationProvider(org.mule.runtime.config.internal.dsl.model.config.EnvironmentPropertiesConfigurationProvider) ImmutableMap(com.google.common.collect.ImmutableMap) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Sets(com.google.common.collect.Sets) List(java.util.List) XmlDslModel(org.mule.runtime.api.meta.model.XmlDslModel) Optional(java.util.Optional) ExtensionDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ExtensionDeclarer) NoOpXmlErrorHandler(org.mule.runtime.config.internal.util.NoOpXmlErrorHandler) IllegalModelDefinitionException(org.mule.runtime.extension.api.exception.IllegalModelDefinitionException) OperationDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.OperationDeclarer) JAVA(org.mule.metadata.api.model.MetadataFormat.JAVA) HashMap(java.util.HashMap) HashSet(java.util.HashSet) TypeResolverException(org.mule.metadata.catalog.api.TypeResolverException) TNS_PREFIX(org.mule.runtime.config.internal.dsl.model.extension.xml.MacroExpansionModuleModel.TNS_PREFIX) ConfigLine(org.mule.runtime.config.api.dsl.processor.ConfigLine) TypeResolver(org.mule.metadata.catalog.api.TypeResolver) DefaultDirectedGraph(org.jgrapht.graph.DefaultDirectedGraph) Optional.ofNullable(java.util.Optional.ofNullable) ParameterizedDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.ParameterizedDeclarer) MODULE_CONNECTION_GLOBAL_ELEMENT_NAME(org.mule.runtime.core.internal.processor.chain.ModuleOperationMessageProcessorChainBuilder.MODULE_CONNECTION_GLOBAL_ELEMENT_NAME) ExtensionLoadingContext(org.mule.runtime.extension.api.loader.ExtensionLoadingContext) DefaultConfigurationPropertiesResolver(org.mule.runtime.config.internal.dsl.model.config.DefaultConfigurationPropertiesResolver) XmlConfigurationDocumentLoader.schemaValidatingDocumentLoader(org.mule.runtime.config.api.XmlConfigurationDocumentLoader.schemaValidatingDocumentLoader) XMLNS_ATTRIBUTE(javax.xml.XMLConstants.XMLNS_ATTRIBUTE) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) ComponentModel(org.mule.runtime.config.internal.model.ComponentModel) OutputDeclarer(org.mule.runtime.api.meta.model.declaration.fluent.OutputDeclarer) Collections(java.util.Collections) IllegalModelDefinitionException(org.mule.runtime.extension.api.exception.IllegalModelDefinitionException) ComponentModel(org.mule.runtime.config.internal.model.ComponentModel)

Example 53 with EMPTY

use of org.apache.commons.lang3.StringUtils.EMPTY in project mule by mulesoft.

the class ApplicationModel method validateErrorMappings.

private void validateErrorMappings() {
    executeOnEveryComponentTree(componentModel -> {
        List<ComponentModel> errorMappings = componentModel.getInnerComponents().stream().filter(c -> c.getIdentifier().equals(ERROR_MAPPING_IDENTIFIER)).collect(toList());
        if (!errorMappings.isEmpty()) {
            List<ComponentModel> anyMappings = errorMappings.stream().filter(this::isErrorMappingWithSourceAny).collect(toList());
            if (anyMappings.size() > 1) {
                throw new MuleRuntimeException(createStaticMessage("Only one mapping for 'ANY' or an empty source type is allowed."));
            } else if (anyMappings.size() == 1 && !isErrorMappingWithSourceAny(errorMappings.get(errorMappings.size() - 1))) {
                throw new MuleRuntimeException(createStaticMessage("Only the last error mapping can have 'ANY' or an empty source type."));
            }
            List<String> sources = errorMappings.stream().map(model -> model.getParameters().get(SOURCE_TYPE)).collect(toList());
            List<String> distinctSources = sources.stream().distinct().collect(toList());
            if (sources.size() != distinctSources.size()) {
                throw new MuleRuntimeException(createStaticMessage(format("Repeated source types are not allowed. Offending types are '%s'.", on("', '").join(disjunction(sources, distinctSources)))));
            }
        }
    });
}
Also used : ResourceProvider(org.mule.runtime.config.api.dsl.model.ResourceProvider) MacroExpansionModulesModel(org.mule.runtime.config.internal.dsl.model.extension.xml.MacroExpansionModulesModel) CORE_PREFIX(org.mule.runtime.internal.dsl.DslConstants.CORE_PREFIX) MULE_ROOT_ELEMENT(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_ROOT_ELEMENT) Optional.of(java.util.Optional.of) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) ConfigurationProperty(org.mule.runtime.config.api.dsl.model.properties.ConfigurationProperty) Collections.singletonList(java.util.Collections.singletonList) ClassUtils(org.apache.commons.lang3.ClassUtils) DefaultConfigurationParameters(org.mule.runtime.config.internal.dsl.model.DefaultConfigurationParameters) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) MULE_EE_DOMAIN_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_EE_DOMAIN_IDENTIFIER) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) DslElementModelFactory(org.mule.runtime.config.api.dsl.model.DslElementModelFactory) ERROR_HANDLER_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.ERROR_HANDLER_IDENTIFIER) ComponentModelReader(org.mule.runtime.config.internal.dsl.model.ComponentModelReader) CompositeConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.CompositeConfigurationPropertiesProvider) PropertiesResolverConfigurationProperties(org.mule.runtime.config.internal.dsl.model.config.PropertiesResolverConfigurationProperties) EnvironmentPropertiesConfigurationProvider(org.mule.runtime.config.internal.dsl.model.config.EnvironmentPropertiesConfigurationProvider) MULE_DOMAIN_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_DOMAIN_IDENTIFIER) DEFAULT_EXPRESSION_PREFIX(org.mule.runtime.core.api.el.ExpressionManager.DEFAULT_EXPRESSION_PREFIX) ImmutableSet(com.google.common.collect.ImmutableSet) ComponentModelHelper.resolveComponentType(org.mule.runtime.config.internal.dsl.spring.ComponentModelHelper.resolveComponentType) MapConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.MapConfigurationPropertiesProvider) TypedComponentIdentifier(org.mule.runtime.api.component.TypedComponentIdentifier) ImmutableMap(com.google.common.collect.ImmutableMap) Set(java.util.Set) UNKNOWN(org.mule.runtime.api.component.TypedComponentIdentifier.ComponentType.UNKNOWN) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) ServiceLoader(java.util.ServiceLoader) SOURCE_TYPE(org.mule.runtime.config.internal.dsl.spring.BeanDefinitionFactory.SOURCE_TYPE) NameValidationUtil.verifyStringDoesNotContainsReservedCharacters(org.mule.runtime.internal.util.NameValidationUtil.verifyStringDoesNotContainsReservedCharacters) String.format(java.lang.String.format) FileConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.FileConfigurationPropertiesProvider) ERROR_HANDLER(org.mule.runtime.config.api.dsl.CoreDslConstants.ERROR_HANDLER) I18nMessageFactory(org.mule.runtime.api.i18n.I18nMessageFactory) XmlCustomAttributeHandler(org.mule.runtime.config.internal.dsl.processor.xml.XmlCustomAttributeHandler) ComponentBuildingDefinition(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition) List(java.util.List) ElementDeclaration(org.mule.runtime.app.declaration.api.ElementDeclaration) GlobalPropertyConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.GlobalPropertyConfigurationPropertiesProvider) Optional(java.util.Optional) QName(javax.xml.namespace.QName) MuleExtensionModelProvider(org.mule.runtime.core.api.extension.MuleExtensionModelProvider) ComponentIdentifier.builder(org.mule.runtime.api.component.ComponentIdentifier.builder) Optional.empty(java.util.Optional.empty) ComponentBuildingDefinitionRegistry(org.mule.runtime.config.api.dsl.model.ComponentBuildingDefinitionRegistry) DefaultComponentLocation(org.mule.runtime.dsl.api.component.config.DefaultComponentLocation) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) LifecycleUtils.initialiseIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded) ConfigurationProperties(org.mule.runtime.api.component.ConfigurationProperties) ComponentConfiguration(org.mule.runtime.dsl.api.component.config.ComponentConfiguration) ComponentLocationVisitor(org.mule.runtime.config.internal.dsl.model.ComponentLocationVisitor) NameUtils.pluralize(org.mule.runtime.extension.api.util.NameUtils.pluralize) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) MULE_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_IDENTIFIER) ConfigurationPropertiesProvider(org.mule.runtime.config.api.dsl.model.properties.ConfigurationPropertiesProvider) ArtifactDeclaration(org.mule.runtime.app.declaration.api.ArtifactDeclaration) Component(org.mule.runtime.api.component.Component) Node(org.w3c.dom.Node) BiConsumer(java.util.function.BiConsumer) FLOW_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.FLOW_IDENTIFIER) RuntimeConfigurationException(org.mule.runtime.config.internal.dsl.model.config.RuntimeConfigurationException) ConfigLine(org.mule.runtime.config.api.dsl.processor.ConfigLine) ConfigFile(org.mule.runtime.config.api.dsl.processor.ConfigFile) DefaultConfigurationProperty(org.mule.runtime.config.internal.dsl.model.config.DefaultConfigurationProperty) LinkedList(java.util.LinkedList) Collections.emptyMap(java.util.Collections.emptyMap) Collections.emptySet(java.util.Collections.emptySet) ConfigurationException(org.mule.runtime.core.api.config.ConfigurationException) Optional.ofNullable(java.util.Optional.ofNullable) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) NameUtils.hyphenize(org.mule.runtime.extension.api.util.NameUtils.hyphenize) ConfigurationParameters(org.mule.runtime.config.api.dsl.model.ConfigurationParameters) ExtensionModelHelper(org.mule.runtime.config.internal.dsl.model.ExtensionModelHelper) ArtifactConfig(org.mule.runtime.config.api.dsl.processor.ArtifactConfig) DefaultConfigurationPropertiesResolver(org.mule.runtime.config.internal.dsl.model.config.DefaultConfigurationPropertiesResolver) Joiner.on(com.google.common.base.Joiner.on) ObjectTypeVisitor(org.mule.runtime.config.internal.dsl.processor.ObjectTypeVisitor) AbstractComponent(org.mule.runtime.api.component.AbstractComponent) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ConfigurationPropertiesResolver(org.mule.runtime.config.internal.dsl.model.config.ConfigurationPropertiesResolver) FLOW_REF_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.FLOW_REF_IDENTIFIER) Consumer(java.util.function.Consumer) Collectors.toList(java.util.stream.Collectors.toList) ConfigurationPropertiesProviderFactory(org.mule.runtime.config.api.dsl.model.properties.ConfigurationPropertiesProviderFactory) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) CollectionUtils.disjunction(org.apache.commons.collections.CollectionUtils.disjunction) ComponentIdentifier(org.mule.runtime.api.component.ComponentIdentifier) ANY_IDENTIFIER(org.mule.runtime.core.api.exception.Errors.Identifiers.ANY_IDENTIFIER) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException)

Example 54 with EMPTY

use of org.apache.commons.lang3.StringUtils.EMPTY in project mule by mulesoft.

the class ApplicationModel method createConfigurationAttributeResolver.

private void createConfigurationAttributeResolver(ArtifactConfig artifactConfig, Optional<ConfigurationProperties> parentConfigurationProperties, Map<String, String> deploymentProperties) {
    EnvironmentPropertiesConfigurationProvider environmentPropertiesConfigurationProvider = new EnvironmentPropertiesConfigurationProvider();
    ConfigurationPropertiesProvider globalPropertiesConfigurationAttributeProvider = createProviderFromGlobalProperties(artifactConfig);
    DefaultConfigurationPropertiesResolver localResolver = new DefaultConfigurationPropertiesResolver(of(new DefaultConfigurationPropertiesResolver(of(new DefaultConfigurationPropertiesResolver(empty(), environmentPropertiesConfigurationProvider)), globalPropertiesConfigurationAttributeProvider)), environmentPropertiesConfigurationProvider);
    List<ConfigurationPropertiesProvider> configConfigurationPropertiesProviders = getConfigurationPropertiesProvidersFromComponents(artifactConfig, localResolver);
    FileConfigurationPropertiesProvider externalPropertiesConfigurationProvider = new FileConfigurationPropertiesProvider(externalResourceProvider, "External files");
    Optional<ConfigurationPropertiesResolver> parentConfigurationPropertiesResolver = of(localResolver);
    if (parentConfigurationProperties.isPresent()) {
        parentConfigurationPropertiesResolver = of(new DefaultConfigurationPropertiesResolver(empty(), new ConfigurationPropertiesProvider() {

            @Override
            public Optional<ConfigurationProperty> getConfigurationProperty(String configurationAttributeKey) {
                return parentConfigurationProperties.get().resolveProperty(configurationAttributeKey).map(value -> new DefaultConfigurationProperty(parentConfigurationProperties, configurationAttributeKey, value));
            }

            @Override
            public String getDescription() {
                return "Domain properties";
            }
        }));
    }
    if (!configConfigurationPropertiesProviders.isEmpty()) {
        CompositeConfigurationPropertiesProvider configurationAttributesProvider = new CompositeConfigurationPropertiesProvider(configConfigurationPropertiesProviders);
        parentConfigurationPropertiesResolver = of(new DefaultConfigurationPropertiesResolver(parentConfigurationPropertiesResolver, configurationAttributesProvider));
    }
    DefaultConfigurationPropertiesResolver globalPropertiesConfigurationPropertiesResolver = new DefaultConfigurationPropertiesResolver(parentConfigurationPropertiesResolver, globalPropertiesConfigurationAttributeProvider);
    DefaultConfigurationPropertiesResolver systemPropertiesResolver = new DefaultConfigurationPropertiesResolver(of(globalPropertiesConfigurationPropertiesResolver), environmentPropertiesConfigurationProvider);
    DefaultConfigurationPropertiesResolver externalPropertiesResolver = new DefaultConfigurationPropertiesResolver(of(systemPropertiesResolver), externalPropertiesConfigurationProvider);
    if (deploymentProperties.isEmpty()) {
        this.configurationProperties = new PropertiesResolverConfigurationProperties(externalPropertiesResolver);
    } else {
        this.configurationProperties = new PropertiesResolverConfigurationProperties(new DefaultConfigurationPropertiesResolver(of(externalPropertiesResolver), new MapConfigurationPropertiesProvider(deploymentProperties, "Deployment properties")));
    }
}
Also used : ResourceProvider(org.mule.runtime.config.api.dsl.model.ResourceProvider) MacroExpansionModulesModel(org.mule.runtime.config.internal.dsl.model.extension.xml.MacroExpansionModulesModel) CORE_PREFIX(org.mule.runtime.internal.dsl.DslConstants.CORE_PREFIX) MULE_ROOT_ELEMENT(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_ROOT_ELEMENT) Optional.of(java.util.Optional.of) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) ConfigurationProperty(org.mule.runtime.config.api.dsl.model.properties.ConfigurationProperty) Collections.singletonList(java.util.Collections.singletonList) ClassUtils(org.apache.commons.lang3.ClassUtils) DefaultConfigurationParameters(org.mule.runtime.config.internal.dsl.model.DefaultConfigurationParameters) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) MULE_EE_DOMAIN_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_EE_DOMAIN_IDENTIFIER) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) DslElementModelFactory(org.mule.runtime.config.api.dsl.model.DslElementModelFactory) ERROR_HANDLER_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.ERROR_HANDLER_IDENTIFIER) ComponentModelReader(org.mule.runtime.config.internal.dsl.model.ComponentModelReader) CompositeConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.CompositeConfigurationPropertiesProvider) PropertiesResolverConfigurationProperties(org.mule.runtime.config.internal.dsl.model.config.PropertiesResolverConfigurationProperties) EnvironmentPropertiesConfigurationProvider(org.mule.runtime.config.internal.dsl.model.config.EnvironmentPropertiesConfigurationProvider) MULE_DOMAIN_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_DOMAIN_IDENTIFIER) DEFAULT_EXPRESSION_PREFIX(org.mule.runtime.core.api.el.ExpressionManager.DEFAULT_EXPRESSION_PREFIX) ImmutableSet(com.google.common.collect.ImmutableSet) ComponentModelHelper.resolveComponentType(org.mule.runtime.config.internal.dsl.spring.ComponentModelHelper.resolveComponentType) MapConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.MapConfigurationPropertiesProvider) TypedComponentIdentifier(org.mule.runtime.api.component.TypedComponentIdentifier) ImmutableMap(com.google.common.collect.ImmutableMap) Set(java.util.Set) UNKNOWN(org.mule.runtime.api.component.TypedComponentIdentifier.ComponentType.UNKNOWN) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) ServiceLoader(java.util.ServiceLoader) SOURCE_TYPE(org.mule.runtime.config.internal.dsl.spring.BeanDefinitionFactory.SOURCE_TYPE) NameValidationUtil.verifyStringDoesNotContainsReservedCharacters(org.mule.runtime.internal.util.NameValidationUtil.verifyStringDoesNotContainsReservedCharacters) String.format(java.lang.String.format) FileConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.FileConfigurationPropertiesProvider) ERROR_HANDLER(org.mule.runtime.config.api.dsl.CoreDslConstants.ERROR_HANDLER) I18nMessageFactory(org.mule.runtime.api.i18n.I18nMessageFactory) XmlCustomAttributeHandler(org.mule.runtime.config.internal.dsl.processor.xml.XmlCustomAttributeHandler) ComponentBuildingDefinition(org.mule.runtime.dsl.api.component.ComponentBuildingDefinition) List(java.util.List) ElementDeclaration(org.mule.runtime.app.declaration.api.ElementDeclaration) GlobalPropertyConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.GlobalPropertyConfigurationPropertiesProvider) Optional(java.util.Optional) QName(javax.xml.namespace.QName) MuleExtensionModelProvider(org.mule.runtime.core.api.extension.MuleExtensionModelProvider) ComponentIdentifier.builder(org.mule.runtime.api.component.ComponentIdentifier.builder) Optional.empty(java.util.Optional.empty) ComponentBuildingDefinitionRegistry(org.mule.runtime.config.api.dsl.model.ComponentBuildingDefinitionRegistry) DefaultComponentLocation(org.mule.runtime.dsl.api.component.config.DefaultComponentLocation) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) LifecycleUtils.initialiseIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded) ConfigurationProperties(org.mule.runtime.api.component.ConfigurationProperties) ComponentConfiguration(org.mule.runtime.dsl.api.component.config.ComponentConfiguration) ComponentLocationVisitor(org.mule.runtime.config.internal.dsl.model.ComponentLocationVisitor) NameUtils.pluralize(org.mule.runtime.extension.api.util.NameUtils.pluralize) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) MULE_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_IDENTIFIER) ConfigurationPropertiesProvider(org.mule.runtime.config.api.dsl.model.properties.ConfigurationPropertiesProvider) ArtifactDeclaration(org.mule.runtime.app.declaration.api.ArtifactDeclaration) Component(org.mule.runtime.api.component.Component) Node(org.w3c.dom.Node) BiConsumer(java.util.function.BiConsumer) FLOW_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.FLOW_IDENTIFIER) RuntimeConfigurationException(org.mule.runtime.config.internal.dsl.model.config.RuntimeConfigurationException) ConfigLine(org.mule.runtime.config.api.dsl.processor.ConfigLine) ConfigFile(org.mule.runtime.config.api.dsl.processor.ConfigFile) DefaultConfigurationProperty(org.mule.runtime.config.internal.dsl.model.config.DefaultConfigurationProperty) LinkedList(java.util.LinkedList) Collections.emptyMap(java.util.Collections.emptyMap) Collections.emptySet(java.util.Collections.emptySet) ConfigurationException(org.mule.runtime.core.api.config.ConfigurationException) Optional.ofNullable(java.util.Optional.ofNullable) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) NameUtils.hyphenize(org.mule.runtime.extension.api.util.NameUtils.hyphenize) ConfigurationParameters(org.mule.runtime.config.api.dsl.model.ConfigurationParameters) ExtensionModelHelper(org.mule.runtime.config.internal.dsl.model.ExtensionModelHelper) ArtifactConfig(org.mule.runtime.config.api.dsl.processor.ArtifactConfig) DefaultConfigurationPropertiesResolver(org.mule.runtime.config.internal.dsl.model.config.DefaultConfigurationPropertiesResolver) Joiner.on(com.google.common.base.Joiner.on) ObjectTypeVisitor(org.mule.runtime.config.internal.dsl.processor.ObjectTypeVisitor) AbstractComponent(org.mule.runtime.api.component.AbstractComponent) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ConfigurationPropertiesResolver(org.mule.runtime.config.internal.dsl.model.config.ConfigurationPropertiesResolver) FLOW_REF_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.FLOW_REF_IDENTIFIER) Consumer(java.util.function.Consumer) Collectors.toList(java.util.stream.Collectors.toList) ConfigurationPropertiesProviderFactory(org.mule.runtime.config.api.dsl.model.properties.ConfigurationPropertiesProviderFactory) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) CollectionUtils.disjunction(org.apache.commons.collections.CollectionUtils.disjunction) ComponentIdentifier(org.mule.runtime.api.component.ComponentIdentifier) ANY_IDENTIFIER(org.mule.runtime.core.api.exception.Errors.Identifiers.ANY_IDENTIFIER) MapConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.MapConfigurationPropertiesProvider) Optional(java.util.Optional) DefaultConfigurationProperty(org.mule.runtime.config.internal.dsl.model.config.DefaultConfigurationProperty) CompositeConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.CompositeConfigurationPropertiesProvider) MapConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.MapConfigurationPropertiesProvider) FileConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.FileConfigurationPropertiesProvider) GlobalPropertyConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.GlobalPropertyConfigurationPropertiesProvider) ConfigurationPropertiesProvider(org.mule.runtime.config.api.dsl.model.properties.ConfigurationPropertiesProvider) EnvironmentPropertiesConfigurationProvider(org.mule.runtime.config.internal.dsl.model.config.EnvironmentPropertiesConfigurationProvider) FileConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.FileConfigurationPropertiesProvider) DefaultConfigurationPropertiesResolver(org.mule.runtime.config.internal.dsl.model.config.DefaultConfigurationPropertiesResolver) ConfigurationPropertiesResolver(org.mule.runtime.config.internal.dsl.model.config.ConfigurationPropertiesResolver) DefaultConfigurationPropertiesResolver(org.mule.runtime.config.internal.dsl.model.config.DefaultConfigurationPropertiesResolver) CompositeConfigurationPropertiesProvider(org.mule.runtime.config.internal.dsl.model.config.CompositeConfigurationPropertiesProvider) PropertiesResolverConfigurationProperties(org.mule.runtime.config.internal.dsl.model.config.PropertiesResolverConfigurationProperties)

Example 55 with EMPTY

use of org.apache.commons.lang3.StringUtils.EMPTY in project cassandra by apache.

the class SecondaryIndexManager method indexPartition.

/**
     * When building an index against existing data in sstables, add the given partition to the index
     */
public void indexPartition(DecoratedKey key, Set<Index> indexes, int pageSize) {
    if (logger.isTraceEnabled())
        logger.trace("Indexing partition {}", baseCfs.metadata().partitionKeyType.getString(key.getKey()));
    if (!indexes.isEmpty()) {
        SinglePartitionReadCommand cmd = SinglePartitionReadCommand.fullPartitionRead(baseCfs.metadata(), FBUtilities.nowInSeconds(), key);
        int nowInSec = cmd.nowInSec();
        boolean readStatic = false;
        SinglePartitionPager pager = new SinglePartitionPager(cmd, null, ProtocolVersion.CURRENT);
        while (!pager.isExhausted()) {
            try (ReadExecutionController controller = cmd.executionController();
                OpOrder.Group writeGroup = Keyspace.writeOrder.start();
                UnfilteredPartitionIterator page = pager.fetchPageUnfiltered(baseCfs.metadata(), pageSize, controller)) {
                if (!page.hasNext())
                    break;
                try (UnfilteredRowIterator partition = page.next()) {
                    Set<Index.Indexer> indexers = indexes.stream().map(index -> index.indexerFor(key, partition.columns(), nowInSec, writeGroup, IndexTransaction.Type.UPDATE)).filter(Objects::nonNull).collect(Collectors.toSet());
                    // Short-circuit empty partitions if static row is processed or isn't read
                    if (!readStatic && partition.isEmpty() && partition.staticRow().isEmpty())
                        break;
                    indexers.forEach(Index.Indexer::begin);
                    if (!readStatic) {
                        if (!partition.staticRow().isEmpty())
                            indexers.forEach(indexer -> indexer.insertRow(partition.staticRow()));
                        indexers.forEach((Index.Indexer i) -> i.partitionDelete(partition.partitionLevelDeletion()));
                        readStatic = true;
                    }
                    MutableDeletionInfo.Builder deletionBuilder = MutableDeletionInfo.builder(partition.partitionLevelDeletion(), baseCfs.getComparator(), false);
                    while (partition.hasNext()) {
                        Unfiltered unfilteredRow = partition.next();
                        if (unfilteredRow.isRow()) {
                            Row row = (Row) unfilteredRow;
                            indexers.forEach(indexer -> indexer.insertRow(row));
                        } else {
                            assert unfilteredRow.isRangeTombstoneMarker();
                            RangeTombstoneMarker marker = (RangeTombstoneMarker) unfilteredRow;
                            deletionBuilder.add(marker);
                        }
                    }
                    MutableDeletionInfo deletionInfo = deletionBuilder.build();
                    if (deletionInfo.hasRanges()) {
                        Iterator<RangeTombstone> iter = deletionInfo.rangeIterator(false);
                        while (iter.hasNext()) indexers.forEach(indexer -> indexer.rangeTombstone(iter.next()));
                    }
                    indexers.forEach(Index.Indexer::finish);
                }
            }
        }
    }
}
Also used : java.util(java.util) Iterables(com.google.common.collect.Iterables) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) JMXEnabledThreadPoolExecutor(org.apache.cassandra.concurrent.JMXEnabledThreadPoolExecutor) CompactionManager(org.apache.cassandra.db.compaction.CompactionManager) ColumnMetadata(org.apache.cassandra.schema.ColumnMetadata) SSTableSet(org.apache.cassandra.db.lifecycle.SSTableSet) LoggerFactory(org.slf4j.LoggerFactory) org.apache.cassandra.db(org.apache.cassandra.db) Constructor(java.lang.reflect.Constructor) Function(java.util.function.Function) StringUtils(org.apache.commons.lang3.StringUtils) SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) Indexes(org.apache.cassandra.schema.Indexes) org.apache.cassandra.db.rows(org.apache.cassandra.db.rows) OpOrder(org.apache.cassandra.utils.concurrent.OpOrder) Strings(com.google.common.base.Strings) org.apache.cassandra.index.transactions(org.apache.cassandra.index.transactions) IndexTarget(org.apache.cassandra.cql3.statements.IndexTarget) ProtocolVersion(org.apache.cassandra.transport.ProtocolVersion) Refs(org.apache.cassandra.utils.concurrent.Refs) DatabaseDescriptor(org.apache.cassandra.config.DatabaseDescriptor) InvalidRequestException(org.apache.cassandra.exceptions.InvalidRequestException) org.apache.cassandra.db.partitions(org.apache.cassandra.db.partitions) Longs(com.google.common.primitives.Longs) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) RowFilter(org.apache.cassandra.db.filter.RowFilter) FBUtilities(org.apache.cassandra.utils.FBUtilities) IndexMetadata(org.apache.cassandra.schema.IndexMetadata) java.util.concurrent(java.util.concurrent) Tracing(org.apache.cassandra.tracing.Tracing) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) Futures(com.google.common.util.concurrent.Futures) NamedThreadFactory(org.apache.cassandra.concurrent.NamedThreadFactory) CassandraIndex(org.apache.cassandra.index.internal.CassandraIndex) Stream(java.util.stream.Stream) SinglePartitionPager(org.apache.cassandra.service.pager.SinglePartitionPager) StageManager(org.apache.cassandra.concurrent.StageManager) Joiner(com.google.common.base.Joiner) View(org.apache.cassandra.db.lifecycle.View) SinglePartitionPager(org.apache.cassandra.service.pager.SinglePartitionPager) OpOrder(org.apache.cassandra.utils.concurrent.OpOrder)

Aggregations

List (java.util.List)44 Map (java.util.Map)42 ArrayList (java.util.ArrayList)41 StringUtils (org.apache.commons.lang3.StringUtils)38 Collectors (java.util.stream.Collectors)37 HashMap (java.util.HashMap)33 IOException (java.io.IOException)27 Set (java.util.Set)25 HashSet (java.util.HashSet)22 LoggerFactory (org.slf4j.LoggerFactory)22 Pair (org.apache.commons.lang3.tuple.Pair)20 Logger (org.slf4j.Logger)20 Optional (java.util.Optional)19 Collections (java.util.Collections)17 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)17 java.util (java.util)15 Arrays.asList (java.util.Arrays.asList)14 Collection (java.util.Collection)14 Stream (java.util.stream.Stream)14 Arrays (java.util.Arrays)12