Examples of EmsConnection


Examples of org.mc4j.ems.connection.EmsConnection

        if (AvailabilityType.UP == result) {
            // When the connector is stopped its associated GlobalRequestProcessor will not exist. We test
            // for availability by checking the existence of objectName Catalina:type=GlobalRequestProcessor,name=%handler%[%address%]-%port%.
            String objectName = getGlobalRequestProcessorName();
            EmsConnection connection = getEmsConnection();
            ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(objectName);
            List<EmsBean> beans = connection.queryBeans(queryUtility.getTranslatedQuery());

            result = (beans.isEmpty()) ? AvailabilityType.DOWN : AvailabilityType.UP;
        }

        return result;
View Full Code Here

Examples of org.mc4j.ems.connection.EmsConnection

            }
        }
    }

    private Double getSessionMetric(String metricName) {
        EmsConnection jmxConnection = getEmsConnection();
        String servletMBeanNames = QUERY_TEMPLATE_SESSION;
        Configuration config = getResourceContext().getPluginConfiguration();
        servletMBeanNames = servletMBeanNames.replace("%PATH%", config.getSimpleValue(PROPERTY_CONTEXT_ROOT, ""));
        servletMBeanNames = servletMBeanNames.replace("%HOST%", config.getSimpleValue(PROPERTY_VHOST, ""));
        ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(servletMBeanNames);
        List<EmsBean> mBeans = jmxConnection.queryBeans(queryUtility.getTranslatedQuery());
        String property = metricName.substring(METRIC_PREFIX_SESSION.length());
        Double ret = Double.NaN;

        if (mBeans.size() > 0) { // TODO flag error if != 1 ?
            EmsBean eBean = mBeans.get(0);
View Full Code Here

Examples of org.mc4j.ems.connection.EmsConnection

        return ret;
    }

    private Double getServletMetric(String metricName) {

        EmsConnection jmxConnection = getEmsConnection();

        String servletMBeanNames = QUERY_TEMPLATE_SERVLET;
        Configuration config = getResourceContext().getPluginConfiguration();
        servletMBeanNames = servletMBeanNames.replace("%WEBMODULE%", config.getSimpleValue(PROPERTY_NAME, ""));
        ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(servletMBeanNames);
        List<EmsBean> mBeans = jmxConnection.queryBeans(queryUtility.getTranslatedQuery());

        long min = Long.MAX_VALUE;
        long max = 0;
        long processingTime = 0;
        int requestCount = 0;
View Full Code Here

Examples of org.mc4j.ems.connection.EmsConnection

    private EmsBean getWebModuleMBean() {
        String webModuleMBeanName = getWebModuleMBeanName();
        EmsBean result = null;

        if (null != webModuleMBeanName) {
            EmsConnection conn = getEmsConnection();
            if (null != conn) {
                ObjectNameQueryUtility queryUtility = new ObjectNameQueryUtility(webModuleMBeanName);
                List<EmsBean> mBeans = conn.queryBeans(queryUtility.getTranslatedQuery());
                // There should only be one mBean for this match.
                if (mBeans.size() == 1) {
                    result = mBeans.get(0);
                }
            }
View Full Code Here

Examples of org.mc4j.ems.connection.EmsConnection

        String STOPPED = "STOPPED";
        String STARTED = "STARTED";
    }

    private List<EmsBean> getVHosts() {
        EmsConnection emsConnection = getEmsConnection();
        String query = QUERY_TEMPLATE_HOST;
        query = query.replace("%PATH%",
            getResourceContext().getPluginConfiguration().getSimpleValue(PROPERTY_CONTEXT_ROOT, ""));
        ObjectNameQueryUtility queryUtil = new ObjectNameQueryUtility(query);
        List<EmsBean> mBeans = emsConnection.queryBeans(queryUtil.getTranslatedQuery());
        return mBeans;
    }
View Full Code Here

Examples of org.mc4j.ems.connection.EmsConnection

    @Override
    public AvailabilityType getAvailability() {

        try {
            EmsConnection conn = getEmsConnection();
            if (conn == null) {
                return AvailabilityType.DOWN;
            }
            conn.queryBeans("java.lang:*"); // just make a request over the connection to make sure its valid
            return AvailabilityType.UP;
        } catch (Throwable t) {
            try {
                this.connection.close(); // try to clean up
            } catch (Throwable ignore) {
View Full Code Here

Examples of org.mc4j.ems.connection.EmsConnection

    public void stop() {
    }

    @Override
    public EmsConnection getEmsConnection() {
        EmsConnection emsConnection = null;

        try {
            emsConnection = loadConnection();
        } catch (Exception e) {
            LOG.error("Component attempting to access a connection that could not be loaded: " + e.getCause());
View Full Code Here

Examples of org.mc4j.ems.connection.EmsConnection

    private ResourceContext<T> resourceContext;

    // JMXComponent Implementation  --------------------------------------------

    public EmsConnection getEmsConnection() {
        EmsConnection emsConnection = null;

        try {
            emsConnection = loadConnection();
        } catch (Exception e) {
            if (log.isTraceEnabled()) {
View Full Code Here

Examples of org.mc4j.ems.connection.EmsConnection

    }

    public AvailabilityType getAvailability() {
        AvailabilityType avail;
        try {
            EmsConnection connection = loadConnection();
            EmsBean bean = connection.getBean("Catalina:type=Server");

            // this is necessary to prove that that not only the connection exists but is servicing requests.
            bean.getAttribute("serverInfo").refresh();
            avail = AvailabilityType.UP;
        } catch (Exception e) {
View Full Code Here

Examples of org.mc4j.ems.connection.EmsConnection

            int delimIndex = name.lastIndexOf(':');
            String beanName = name.substring(0, delimIndex);
            String attributeName = name.substring(delimIndex + 1);
            try {
                // Bean is cached by EMS, so no problem with getting the bean from the connection on each call
                EmsConnection emsConnection = loadConnection();
                EmsBean bean = emsConnection.getBean(beanName);
                EmsAttribute attribute = bean.getAttribute(attributeName);

                Object valueObject = attribute.refresh();
                if (valueObject instanceof Number) {
                    Number value = (Number) valueObject;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.