Package com.googlecode.psiprobe.model

Examples of com.googlecode.psiprobe.model.ApplicationResource


            try {
                Set dsNames = server.queryNames(new ObjectName("jboss.jca:service=ManagedConnectionPool,*"), null);
                for (Iterator it = dsNames.iterator(); it.hasNext();) {
                    ObjectName managedConnectionPoolOName = (ObjectName) it.next();

                    ApplicationResource resource = new ApplicationResource();
                    resource.setName(managedConnectionPoolOName.getKeyProperty("name"));
                    resource.setType("jboss");
                    String criteria = (String) server.getAttribute(managedConnectionPoolOName, "Criteria");
                    if ("ByApplication".equals(criteria)) {
                        resource.setAuth("Application");
                    } else if ("ByContainerAndApplication".equals(criteria)) {
                        resource.setAuth("Both");
                    } else {
                        resource.setAuth("Container");
                    }
                    DataSourceInfo dsInfo = new DataSourceInfo();
                    dsInfo.setMaxConnections(((Integer) server.getAttribute(managedConnectionPoolOName, "MaxSize")).intValue());
                    dsInfo.setEstablishedConnections(((Integer) server.getAttribute(managedConnectionPoolOName, "ConnectionCount")).intValue());
                    dsInfo.setBusyConnections(((Long) server.getAttribute(managedConnectionPoolOName, "InUseConnectionCount")).intValue());


                    ObjectName connectionFactoryOName = new ObjectName("jboss.jca:service=ManagedConnectionFactory,name=" + resource.getName());
                    Element elm = (Element) server.getAttribute(connectionFactoryOName, "ManagedConnectionFactoryProperties");

                    if (elm != null) {
                        NodeList nl = elm.getChildNodes();
                        for (int i = 0; i < nl.getLength(); i++) {
                            Node n = nl.item(i);
                            Node na = n.getAttributes().getNamedItem("name");
                            if (na != null) {
                                if ("ConnectionURL".equals(na.getNodeValue())) {
                                    dsInfo.setJdbcURL(n.getFirstChild().getNodeValue());
                                }

                                if ("UserName".equals(na.getNodeValue())) {
                                    dsInfo.setUsername(n.getFirstChild().getNodeValue());
                                }

                                //
                                // JMS datasource
                                //
                                if ("JmsProviderAdapterJNDI".equals(na.getNodeValue())) {
                                    dsInfo.setJdbcURL(n.getFirstChild().getNodeValue());
                                    resource.setType("jms");
                                }
                            }
                        }
                    }

                    dsInfo.setResettable(true);

                    resource.setDataSourceInfo(dsInfo);
                    resources.add(resource);
                }
            } catch (Exception e) {
                //
                logger.fatal("There was an error querying JBoss JMX server:", e);
View Full Code Here


        if (server != null) {
            try {
                Set dsNames = server.queryNames(new ObjectName("Catalina:type=Resource,resourcetype=Global,*"), null);
                for (Iterator it = dsNames.iterator(); it.hasNext();) {
                    ObjectName objectName = (ObjectName) it.next();
                    ApplicationResource resource = new ApplicationResource();

                    logger.info("reading resource: " + objectName);
                    resource.setName(getStringAttribute(server, objectName, "name"));
                    resource.setType(getStringAttribute(server, objectName, "type"));
                    resource.setScope(getStringAttribute(server, objectName, "scope"));
                    resource.setAuth(getStringAttribute(server, objectName, "auth"));
                    resource.setDescription(getStringAttribute(server, objectName, "description"));

                    lookupResource(resource, true, true);

                    resources.add(resource);
                }
View Full Code Here

            try {
                ContextResource[] resources = context.getNamingResources().findResources();
                for (int i = 0; i < resources.length; i++) {
                    ContextResource contextResource = resources[i];
                    ApplicationResource resource = new ApplicationResource();

                    logger.info("reading resource: " + contextResource.getName());
                    resource.setApplicationName(context.getName());
                    resource.setName(contextResource.getName());
                    resource.setType(contextResource.getType());
                    resource.setScope(contextResource.getScope());
                    resource.setAuth(contextResource.getAuth());
                    resource.setDescription(contextResource.getDescription());

                    lookupResource(resource, contextBound, false);

                    resourceList.add(resource);
                }

                ContextResourceLink[] resourceLinks = context.getNamingResources().findResourceLinks();
                for (int i = 0; i < resourceLinks.length; i++) {
                    ContextResourceLink link = resourceLinks[i];

                    ApplicationResource resource = new ApplicationResource();
                    logger.debug("reading resourceLink: " + link.getName());
                    resource.setApplicationName(context.getName());
                    resource.setName(link.getName());
                    resource.setType(link.getType());
                    resource.setLinkTo(link.getGlobal());

                    lookupResource(resource, contextBound, false);
                   
                    resourceList.add(resource);
                }
View Full Code Here

        if (containerWrapper == null) {
            logger.error("Cannot collect data source stats. Container wrapper is not set.");
        } else {
            List dataSources = getContainerWrapper().getDataSources();
            for (int i = 0; i < dataSources.size(); i++) {
                ApplicationResource ds = (ApplicationResource) dataSources.get(i);
                String appName = ds.getApplicationName();
                String name = (appName == null ? "" : appName) + "/" + ds.getName();
                DataSourceInfo dsi = ds.getDataSourceInfo();
                int numEstablished = dsi.getEstablishedConnections();
                int numBusy = dsi.getBusyConnections();
                logger.trace("Collecting stats for datasource: " + name);
                buildAbsoluteStats(PREFIX_ESTABLISHED + name, numEstablished, currentTime);
                buildAbsoluteStats(PREFIX_BUSY + name, numBusy, currentTime);
View Full Code Here

        if (containerWrapper == null) {
            logger.error("Cannot reset application stats. Container wrapper is not set.");
        } else {
            List dataSources = getContainerWrapper().getDataSources();
            for (int i = 0; i < dataSources.size(); i++) {
                ApplicationResource ds = (ApplicationResource) dataSources.get(i);
                reset(ds.getName());
            }
        }
    }
View Full Code Here

        return resources;
    }

    protected void filterDataSources(List resources, List dataSources) {
        for (Iterator it = resources.iterator(); it.hasNext(); ) {
            ApplicationResource res = (ApplicationResource) it.next();
            if (res.getDataSourceInfo() != null) {
                dataSources.add(res);
            }
        }
    }
View Full Code Here

                List applicationResources = getContainerWrapper().getResourceResolver().getApplicationResources(appContext);

                for (Iterator it2 = applicationResources.iterator(); it2.hasNext();) {

                    ApplicationResource appResource = (ApplicationResource) it2.next();

                    DataSourceInfo dsi = appResource.getDataSourceInfo();
                    if (dsi != null && dsi.getBusyScore() > tomcatTestReport.getDatasourceUsageScore()) {
                        tomcatTestReport.setContextName(appContext.getName());
                        tomcatTestReport.setDatasourceUsageScore(dsi.getBusyScore());
                        tomcatTestReport.setDataSourceName(appResource.getName());
                    }
                }
            }

            tomcatTestReport.setWebappAvailabilityTest(allContextsAvailable ?
                    TomcatTestReport.TEST_PASSED : TomcatTestReport.TEST_FAILED);

        } else {
            List l = getContainerWrapper().getResourceResolver().getApplicationResources();
            for (int i = 0; i < l.size(); i++) {
                ApplicationResource resource = (ApplicationResource)l.get(i);
                DataSourceInfo dsi = resource.getDataSourceInfo();
                if (dsi != null && dsi.getBusyScore() > tomcatTestReport.getDatasourceUsageScore()) {
                    tomcatTestReport.setDatasourceUsageScore(dsi.getBusyScore());
                    tomcatTestReport.setDataSourceName(resource.getName());
                }
            }
        }
        tomcatTestReport.setDatasourceTest(TomcatTestReport.TEST_PASSED);
View Full Code Here

            appResources = resolver.getApplicationResources(context);
        } catch (NamingException e) {
            throw new RuntimeException(e);
        }
        for (Iterator it = appResources.iterator(); it.hasNext();) {
            ApplicationResource appResource = (ApplicationResource) it.next();
            if (appResource.getDataSourceInfo() != null) {
                scores[0] = Math.max(scores[0], appResource.getDataSourceInfo().getBusyScore());
                scores[1] = Math.max(scores[1], appResource.getDataSourceInfo().getEstablishedScore());
            }
        }
        return scores;
    }
View Full Code Here

        return new ModelAndView(getViewName(), "dataSourceGroups", dataSourceGroups);
    }

    protected void filterValidDataSources(List resources, List dataSources) {
        for (Iterator i = resources.iterator(); i.hasNext(); ) {
            ApplicationResource res = (ApplicationResource) i.next();
            if (res.isLookedUp()
                    && res.getDataSourceInfo() != null
                    && res.getDataSourceInfo().getJdbcURL() != null) {
                dataSources.add(res.getDataSourceInfo());
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.googlecode.psiprobe.model.ApplicationResource

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.