Package com.espertech.esper.client

Examples of com.espertech.esper.client.ConfigurationException


    private void handleAddPluggableObject(String factoryClassName, String namespace, String name, PluggableObjectType type) {

        if (factoryClassName == null)
        {
            throw new ConfigurationException("Factory class name has not been supplied for object '" + name + "'");
        }
        if (namespace == null)
        {
            throw new ConfigurationException("Namespace name has not been supplied for object '" + name + "'");
        }
        if (name == null)
        {
            throw new ConfigurationException("Name has not been supplied for object in namespace '" + namespace + "'");
        }

        Class clazz;
        try
        {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            clazz = Class.forName(factoryClassName, true, cl);
        }
        catch (ClassNotFoundException ex)
        {
            throw new ConfigurationException("View factory class " + factoryClassName + " could not be loaded");
        }

        Map<String, Pair<Class, PluggableObjectType>> namespaceMap = pluggables.get(namespace);
        if (namespaceMap == null)
        {
View Full Code Here


        }

        for (ConfigurationPlugInPatternObject entry : configEntries)
        {
            if (entry.getPatternObjectType() == null) {
                throw new ConfigurationException("Pattern object type has not been supplied for object '" + entry.getName() + "'");
            }

            PluggableObjectType typeEnum;
            if (entry.getPatternObjectType() == ConfigurationPlugInPatternObject.PatternObjectType.GUARD) {
                typeEnum =  PluggableObjectType.PATTERN_GUARD;
View Full Code Here

    {
        if (variantStreamConfig.getTypeVariance() == ConfigurationVariantStream.TypeVariance.PREDEFINED)
        {
            if (variantStreamConfig.getVariantTypeNames().isEmpty())
            {
                throw new ConfigurationException("Invalid variant stream configuration, no event type name has been added and default type variance requires at least one type, for name '" + variantStreamname + "'");
            }
        }

        Set<EventType> types = new LinkedHashSet<EventType>();
        for (String typeName : variantStreamConfig.getVariantTypeNames())
        {
            EventType type = eventAdapterService.getExistsTypeByName(typeName);
            if (type == null)
            {
                throw new ConfigurationException("Event type by name '" + typeName + "' could not be found for use in variant stream configuration by name '" + variantStreamname + "'");
            }
            types.add(type);
        }

        EventType[] eventTypes = types.toArray(new EventType[types.size()]);
View Full Code Here

    protected static RevisionSpec validateRevision(String revisioneventTypeName, ConfigurationRevisionEventType config, EventAdapterService eventAdapterService)
            throws ConfigurationException
    {
        if ((config.getNameBaseEventTypes() == null) || (config.getNameBaseEventTypes().size() == 0))
        {
            throw new ConfigurationException("Required base event type name is not set in the configuration for revision event type '" + revisioneventTypeName + "'");
        }

        if (config.getNameBaseEventTypes().size() > 1)
        {
            throw new ConfigurationException("Only one base event type name may be added to revision event type '" + revisioneventTypeName + "', multiple base types are not yet supported");
        }

        // get base types
        String baseeventTypeName = config.getNameBaseEventTypes().iterator().next();
        EventType baseEventType = eventAdapterService.getExistsTypeByName(baseeventTypeName);
        if (baseEventType == null)
        {
            throw new ConfigurationException("Could not locate event type for name '" + baseeventTypeName + "' in the configuration for revision event type '" + revisioneventTypeName + "'");
        }

        // get name types
        EventType[] deltaTypes = new EventType[config.getNameDeltaEventTypes().size()];
        String[] deltaNames = new String[config.getNameDeltaEventTypes().size()];
        int count = 0;
        for (String deltaName : config.getNameDeltaEventTypes())
        {
            EventType deltaEventType = eventAdapterService.getExistsTypeByName(deltaName);
            if (deltaEventType == null)
            {
                throw new ConfigurationException("Could not locate event type for name '" + deltaName + "' in the configuration for revision event type '" + revisioneventTypeName + "'");
            }
            deltaTypes[count] = deltaEventType;
            deltaNames[count] = deltaName;
            count++;
        }

        // the key properties must be set
        if ((config.getKeyPropertyNames() == null) || (config.getKeyPropertyNames().length == 0))
        {
            throw new ConfigurationException("Required key properties are not set in the configuration for revision event type '" + revisioneventTypeName + "'");
        }

        // make sure the key properties exist the base type and all delta types
        checkKeysExist(baseEventType, baseeventTypeName, config.getKeyPropertyNames(), revisioneventTypeName);
        for (int i = 0; i < deltaTypes.length; i++)
        {
            checkKeysExist(deltaTypes[i], deltaNames[i], config.getKeyPropertyNames(), revisioneventTypeName);
        }

        // key property names shared between base and delta must have the same type
        String keyPropertyNames[] = PropertyUtility.copyAndSort(config.getKeyPropertyNames());
        for (String key : keyPropertyNames)
        {
            Class typeProperty = baseEventType.getPropertyType(key);
            for (EventType dtype : deltaTypes)
            {
                Class dtypeProperty = dtype.getPropertyType(key);
                if ((dtypeProperty != null) && (typeProperty != dtypeProperty))
                {
                    throw new ConfigurationException("Key property named '" + key + "' does not have the same type for base and delta types of revision event type '" + revisioneventTypeName + "'");
                }
            }
        }

        // In the "declared" type the change set properties consist of only :
        //   (base event type properties) minus (key properties) minus (properties only on base event type)
        if (config.getPropertyRevision() == ConfigurationRevisionEventType.PropertyRevision.OVERLAY_DECLARED)
        {
            // determine non-key properties: those overridden by any delta, and those simply only present on the base event type
            String nonkeyPropertyNames[] = PropertyUtility.uniqueExclusiveSort(baseEventType.getPropertyNames(), keyPropertyNames);
            Set<String> baseEventOnlyProperties = new HashSet<String>();
            Set<String> changesetPropertyNames = new HashSet<String>();
            for (String nonKey : nonkeyPropertyNames)
            {
                boolean overriddenProperty = false;
                for (EventType type : deltaTypes)
                {
                    if (type.isProperty(nonKey))
                    {
                        changesetPropertyNames.add(nonKey);
                        overriddenProperty = true;
                        break;
                    }
                }
                if (!overriddenProperty)
                {
                    baseEventOnlyProperties.add(nonKey);
                }
            }

            String changesetProperties[] = changesetPropertyNames.toArray(new String[changesetPropertyNames.size()]);
            String baseEventOnlyPropertyNames[] = baseEventOnlyProperties.toArray(new String[baseEventOnlyProperties.size()]);

            // verify that all changeset properties match event type
            for (String changesetProperty : changesetProperties)
            {
                Class typeProperty = baseEventType.getPropertyType(changesetProperty);
                for (EventType dtype : deltaTypes)
                {
                    Class dtypeProperty = dtype.getPropertyType(changesetProperty);
                    if ((dtypeProperty != null) && (typeProperty != dtypeProperty))
                    {
                        throw new ConfigurationException("Property named '" + changesetProperty + "' does not have the same type for base and delta types of revision event type '" + revisioneventTypeName + "'");
                    }
                }
            }

            return new RevisionSpec(config.getPropertyRevision(), baseEventType, deltaTypes, deltaNames, keyPropertyNames, changesetProperties, baseEventOnlyPropertyNames, false, null);
        }
        else
        {
            // In the "exists" type the change set properties consist of all properties: base event properties plus delta types properties
            Set<String> allProperties = new HashSet<String>();
            allProperties.addAll(Arrays.asList(baseEventType.getPropertyNames()));
            for (EventType deltaType : deltaTypes)
            {
                allProperties.addAll(Arrays.asList(deltaType.getPropertyNames()));
            }

            String[] allPropertiesArr = allProperties.toArray(new String[allProperties.size()]);
            String[] changesetProperties = PropertyUtility.uniqueExclusiveSort(allPropertiesArr, keyPropertyNames);

            // All properties must have the same type, if a property exists for any given type
            boolean hasContributedByDelta = false;
            boolean[] contributedByDelta = new boolean[changesetProperties.length];
            count = 0;
            for (String property : changesetProperties)
            {
                Class basePropertyType = baseEventType.getPropertyType(property);
                Class typeTemp = null;
                if (basePropertyType != null)
                {
                    typeTemp = basePropertyType;
                }
                else
                {
                    hasContributedByDelta = true;
                    contributedByDelta[count] = true;
                }
                for (EventType dtype : deltaTypes)
                {
                    Class dtypeProperty = dtype.getPropertyType(property);
                    if (dtypeProperty != null)
                    {
                        if ((typeTemp != null) && (dtypeProperty != typeTemp))
                        {
                            throw new ConfigurationException("Property named '" + property + "' does not have the same type for base and delta types of revision event type '" + revisioneventTypeName + "'");
                        }

                    }
                    typeTemp = dtypeProperty;
                }
View Full Code Here

                }
            }

            if (!exists)
            {
                throw new ConfigurationException("Key property '" + keyProperty + "' as defined in the configuration for revision event type '" + revisioneventTypeName + "' does not exists in event type '" + name + "'");
            }
        }
    }
View Full Code Here

    public static void validateTimestampProperties(EventType eventType, String startTimestampProperty, String endTimestampProperty)
            throws ConfigurationException {

        if (startTimestampProperty != null) {
            if (eventType.getGetter(startTimestampProperty) == null) {
                throw new ConfigurationException("Declared start timestamp property name '" + startTimestampProperty + "' was not found");
            }
            Class type = eventType.getPropertyType(startTimestampProperty);
            if (!JavaClassHelper.isDatetimeClass(type)) {
                throw new ConfigurationException("Declared start timestamp property '" + startTimestampProperty + "' is expected to return a Date, Calendar or long-typed value but returns '" + type.getName() + "'");
            }
        }

        if (endTimestampProperty != null) {
            if (startTimestampProperty == null) {
                throw new ConfigurationException("Declared end timestamp property requires that a start timestamp property is also declared");
            }
            if (eventType.getGetter(endTimestampProperty) == null) {
                throw new ConfigurationException("Declared end timestamp property name '" + endTimestampProperty + "' was not found");
            }
            Class type = eventType.getPropertyType(endTimestampProperty);
            if (!JavaClassHelper.isDatetimeClass(type)) {
                throw new ConfigurationException("Declared end timestamp property '" + endTimestampProperty + "' is expected to return a Date, Calendar or long-typed value but returns '" + type.getName() + "'");
            }
            Class startType = eventType.getPropertyType(startTimestampProperty);
            if (JavaClassHelper.getBoxedType(startType) != JavaClassHelper.getBoxedType(type)) {
                throw new ConfigurationException("Declared end timestamp property '" + endTimestampProperty + "' is expected to have the same property type as the start-timestamp property '" + startTimestampProperty + "'");
            }
        }
    }
View Full Code Here

                ClassLoader cl = Thread.currentThread().getContextClassLoader();
                clazz = Class.forName(boxedClassName, true, cl);
            }
            catch (ClassNotFoundException ex)
            {
                throw new ConfigurationException("Unable to load class '" + boxedClassName + "', class not found", ex);
            }

            propertyTypes.put((String) entry.getKey(), clazz);
        }
        return propertyTypes;
View Full Code Here

    private static String getRequiredAttribute(Node node, String key)
    {
        Node valueNode = node.getAttributes().getNamedItem(key);
        if (valueNode == null)
        {
            throw new ConfigurationException("Required attribute by name '" + key + "' not found");
        }
        return valueNode.getTextContent();
    }
View Full Code Here

    public void setMetricsReportingStmtDisabled(String statementName) throws ConfigurationException
    {
        StatementMetricHandle handle = statementMetricHandles.get(statementName);
        if (handle == null)
        {
            throw new ConfigurationException("Statement by name '" + statementName + "' not found in metrics collection");
        }
        handle.setEnabled(false);
    }
View Full Code Here

    public void setMetricsReportingStmtEnabled(String statementName) throws ConfigurationException
    {
        StatementMetricHandle handle = statementMetricHandles.get(statementName);
        if (handle == null)
        {
            throw new ConfigurationException("Statement by name '" + statementName + "' not found in metrics collection");
        }
        handle.setEnabled(true);
    }
View Full Code Here

TOP

Related Classes of com.espertech.esper.client.ConfigurationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.