Package com.espertech.esper.client

Examples of com.espertech.esper.client.ConfigurationException


        dmlQuery.setStream(stream);
        dmlQuery.setConnection(connection);
        dmlQuery.setSql(sql);
        dmlQuery.setBindings(bindings);
        if (sql == null) {
            throw new ConfigurationException("Sql is a required element");
        }
        configuration.getDmlQueries().add(dmlQuery);
    }
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

        if (workqueueName == null) {
            return EXEC_SAME_THREAD;
        }
        ExecutorService svc = services.get(workqueueName);
        if (svc == null) {
            throw new ConfigurationException("Executor by name '"+ workqueueName + "' has not been defined");
        }
        return svc;
    }
View Full Code Here

        }
        final String finalUpsertName = upsertName;

        EventType eventType = engineSPI.getEventAdapterService().getExistsTypeByName(upsert.getStream());
        if (eventType == null) {
            throw new ConfigurationException("Event type by name '" + upsert.getStream() + "' not found");
        }

        try {
            DatabaseConnectionFactory connectionFactory = databaseConfigSvc.getConnectionFactory(upsert.getConnection());

            String[] keys = new String[upsert.getKeys().size()];
            int[] keyTypes = new int[upsert.getKeys().size()];
            EventPropertyGetter[] keyGetters = new EventPropertyGetter[upsert.getKeys().size()];

            int index = 0;
            for (Column key : upsert.getKeys()) {
                keys[index] = key.getColumn();
                keyTypes[index] = SQLTypeMapUtil.getSQLTypeByName(key.getType());
                keyGetters[index] = eventType.getGetter(key.getProperty());
                if (keyGetters[index] == null) {
                    throw new ConfigurationException("Property name '" + key.getProperty() + "' not found for type '" + eventType + "'");
                }
                index++;
            }

            String[] values = new String[upsert.getValues().size()];
            int[] valueTypes = new int[upsert.getValues().size()];
            EventPropertyGetter[] valueGetters = new EventPropertyGetter[upsert.getValues().size()];

            index = 0;
            for (Column value : upsert.getValues()) {
                values[index] = value.getColumn();
                valueTypes[index] = SQLTypeMapUtil.getSQLTypeByName(value.getType());
                valueGetters[index] = eventType.getGetter(value.getProperty());

                if (valueGetters[index] == null) {
                    throw new ConfigurationException("Property name '" + value.getProperty() + "' not found for type '" + eventType + "'");
                }
                index++;
            }

            StoreExceptionHandler handler = new StoreExceptionHandler() {
                public void handle(String message, SQLException ex)
                {
                    log.error("Error executing '" + finalUpsertName + "'");
                }
            };

            MultiKeyMultiValueTable table = new MultiKeyMultiValueTable(upsert.getTableName(), keys, keyTypes,
                    values, valueTypes, handler);

            RunnableUpsertContext context = new RunnableUpsertContext(upsertName, connectionFactory, table, keyGetters, valueGetters, upsert.getRetry(), upsert.getRetryIntervalSec());
            return new RunnableUpsertFactory(context);
        }
        catch (ConfigurationException ex) {
            throw ex;
        }
        catch (Throwable t) {
            throw new ConfigurationException("Error configuring " + upsertName + " :" + t.getMessage());
        }
    }
View Full Code Here

        }
        final String finalDmlName = dmlName;

        EventType eventType = engineSPI.getEventAdapterService().getExistsTypeByName(dmlQuery.getStream());
        if (eventType == null) {
            throw new ConfigurationException("Event type by name '" + dmlQuery.getStream() + "' not found");
        }

        try {
            DatabaseConnectionFactory connectionFactory = databaseConfigSvc.getConnectionFactory(dmlQuery.getConnection());

            Map<Integer, BindingEntry> bindings = new HashMap<Integer, BindingEntry>();
            for (BindingParameter params : dmlQuery.getBindings()) {
                EventPropertyGetter valueGetter = eventType.getGetter(params.getPropertyName());
                bindings.put(params.getPosition(), new BindingEntry(valueGetter));
            }

            StoreExceptionHandler handler = new StoreExceptionHandler() {
                public void handle(String message, SQLException ex)
                {
                    log.error("Error executing '" + finalDmlName + "'");
                }
            };

            DMLStatement dmlStmt = new DMLStatement(handler, dmlQuery.getSql(), bindings);

            RunnableDMLContext context = new RunnableDMLContext(dmlName, connectionFactory, dmlStmt, dmlQuery.getRetry(), dmlQuery.getRetryIntervalSec());
            return new RunnableDMLFactory(context);
        }
        catch (ConfigurationException ex) {
            throw ex;
        }
        catch (Throwable t) {
            throw new ConfigurationException("Error configuring " + dmlName + " :" + t.getMessage());
        }
    }
View Full Code Here

        // Start requests (output adapter)
        for (Request request : config.getRequests()) {

            EventType eventType = engineSPI.getEventAdapterService().getExistsTypeByName(request.getStream());
            if (eventType == null) {
                throw new ConfigurationException("Event type by name '" + request.getStream() + "' not found");
            }

            try {
                EsperIOHTTPSubscription subs = new EsperIOHTTPSubscription(request.getStream(), request.getUri());
                subs.seteventTypeName(request.getStream());
                subs.setSubscriptionName("EsperIOHTTP-" + request.getUri());
                subs.registerAdapter(engineSPI);
            }
            catch (Throwable t) {
                log.error("Error starting HTTP Request definition for URI " + request.getUri() + "'" + t.getMessage(), t);
            }
        }

        // Configure services (input adapter)
        Set<Integer> ports = new HashSet<Integer>();
        for (Map.Entry<String, Service> entry : config.getServices().entrySet()) {
            if (services.containsKey(entry.getKey())) {
                throw new ConfigurationException("A service by name '" + entry.getKey() + "' has already been configured.");
            }

            int port = entry.getValue().getPort();
            if (ports.contains(port)) {
                throw new ConfigurationException("A service for port '" + port + "' has already been configured.");
            }
            ports.add(port);

            EsperHttpServiceBase httpService;
            if (entry.getValue().isNio()) {
                try {
                    Class.forName("org.apache.http.nio.NHttpServiceHandler");
                } catch (ClassNotFoundException e) {
                    throw new ConfigurationException("NIO Handler not found in classpath, please ensure httpcore-nio exists in classpath.");
                }
                httpService = new EsperHttpServiceNIO(entry.getKey(), entry.getValue());
            }
            else {
                httpService = new EsperHttpServiceClassic(entry.getKey(), entry.getValue());
            }
            services.put(entry.getKey(), httpService);
        }

        // Add handlers (input adapter)
        for (GetHandler handler : config.getGetHandlers()) {
            if (!services.containsKey(handler.getService())) {
                throw new ConfigurationException("A service by name '" + handler.getService() + "' has not been configured.");
            }
            EsperHttpServiceBase httpService = services.get(handler.getService());
            httpService.add(handler);
        }
View Full Code Here

        {
            obj = clazz.newInstance();
        }
        catch (InstantiationException e)
        {
            throw new ConfigurationException("Class '" + clazz + "' cannot be instantiated");
        }
        catch (IllegalAccessException e)
        {
            throw new ConfigurationException("Illegal access instantiating class '" + clazz + "'");
        }

        // find method : static DataSource createDataSource(Properties properties)
        Method method;
        try
        {
            method = clazz.getMethod("createDataSource", Properties.class);
        }
        catch (NoSuchMethodException e)
        {
            throw new ConfigurationException("Class '" + clazz + "' does not provide a static method by name createDataSource accepting a single Properties object as parameter");
        }
        if (method == null)
        {
            throw new ConfigurationException("Class '" + clazz + "' does not provide a static method by name createDataSource accepting a single Properties object as parameter");           
        }
        if (method.getReturnType() != DataSource.class)
        {
            throw new ConfigurationException("On class '" + clazz + "' the static method by name createDataSource does not return a DataSource");                       
        }

        Object result;
        try
        {
            result = method.invoke(obj, dsConfig.getProperties());
        }
        catch (IllegalAccessException e)
        {
            throw new ConfigurationException("Class '" + clazz + "' failed in method createDataSource :" + e.getMessage(), e);
        }
        catch (InvocationTargetException e)
        {
            throw new ConfigurationException("Class '" + clazz + "' failed in method createDataSource :" + e.getMessage(), e);
        }
        if (result == null)
        {
            throw new ConfigurationException("Method createDataSource returned a null value for DataSource");
        }

        dataSource = (DataSource) result;
    }
View Full Code Here

        {
            throw ex;
        }
        catch (Exception ex)
        {
            throw new ConfigurationException("Failed to read schema '" + schemaResource + "' : " + ex.getMessage(), ex);
        }

        // Map schema to internal representation
        return map(model, maxRecusiveDepth);
    }
View Full Code Here

        // Uses Xerxes internal classes
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        registry.addSource(new DOMXSImplementationSourceImpl());
        Object xsImplementation = registry.getDOMImplementation("XS-Loader");
        if (xsImplementation == null) {
            throw new ConfigurationException("Failed to retrieve XS-Loader implementation from registry obtained via DOMImplementationRegistry.newInstance, please check that registry.getDOMImplementation(\"XS-Loader\") returns an instance");
        }
        if (!JavaClassHelper.isImplementsInterface(xsImplementation.getClass(), XSImplementation.class)) {
            String message = "The XS-Loader instance returned by the DOM registry class '" + xsImplementation.getClass().getName() + "' does not implement the interface '" + XSImplementation.class.getName() + "'; If you have a another Xerces distribution in your classpath please ensure the classpath order loads the JRE Xerces distribution or set the DOMImplementationRegistry.PROPERTY system property";
            throw new ConfigurationException(message);
        }
        XSImplementation impl =(XSImplementation) xsImplementation;
        XSLoader schemaLoader = impl.createXSLoader(null);
        XSModel xsModel;
        if (input != null) {
            xsModel = schemaLoader.load(input);
        }
        else {
            xsModel = schemaLoader.loadURI(baseURI);
        }

        if (xsModel == null)
        {
            throw new ConfigurationException("Failed to read schema via URL '" + schemaResource + '\'');
        }

        return xsModel;
    }
View Full Code Here

            for (String name : entry.getValue().keySet())
            {
                if (namespaceMap.containsKey(name))
                {
                    throw new ConfigurationException("Duplicate object detected in namespace '" + entry.getKey() +
                                "' by name '" + name + "'");
                }
            }

            namespaceMap.putAll(entry.getValue());
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.