use of psiprobe.model.DataSourceInfo in project psi-probe by psi-probe.
the class ListAllJdbcResourceGroupsController method handleRequestInternal.
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
List<DataSourceInfoGroup> dataSourceGroups = new ArrayList<>();
List<DataSourceInfo> dataSources = new ArrayList<>();
List<ApplicationResource> privateResources = getContainerWrapper().getPrivateDataSources();
List<ApplicationResource> globalResources = getContainerWrapper().getGlobalDataSources();
// filter out anything that is not a datasource
// and use only those datasources that are properly configured
// as aggregated totals would not make any sense otherwise
filterValidDataSources(privateResources, dataSources);
filterValidDataSources(globalResources, dataSources);
// sort datasources by JDBC URL
Collections.sort(dataSources, new Comparator<DataSourceInfo>() {
@Override
public int compare(DataSourceInfo ds1, DataSourceInfo ds2) {
String jdbcUrl1 = ds1.getJdbcUrl();
String jdbcUrl2 = ds2.getJdbcUrl();
return jdbcUrl1.compareToIgnoreCase(jdbcUrl2);
}
});
// group datasources by JDBC URL and calculate aggregated totals
DataSourceInfoGroup dsGroup = null;
for (DataSourceInfo ds : dataSources) {
if (dsGroup == null || !dsGroup.getJdbcUrl().equalsIgnoreCase(ds.getJdbcUrl())) {
dsGroup = new DataSourceInfoGroup().builder(ds);
dataSourceGroups.add(dsGroup);
} else {
dsGroup.addDataSourceInfo(ds);
}
}
return new ModelAndView(getViewName(), "dataSourceGroups", dataSourceGroups);
}
use of psiprobe.model.DataSourceInfo in project psi-probe by psi-probe.
the class Tomcat85DbcpDatasourceAccessor method getInfo.
@Override
public DataSourceInfo getInfo(Object resource) throws Exception {
DataSourceInfo dataSourceInfo = null;
if (canMap(resource)) {
BasicDataSource source = (BasicDataSource) resource;
dataSourceInfo = new DataSourceInfo();
dataSourceInfo.setBusyConnections(source.getNumActive());
dataSourceInfo.setEstablishedConnections(source.getNumIdle() + source.getNumActive());
dataSourceInfo.setMaxConnections(source.getMaxTotal());
dataSourceInfo.setJdbcUrl(source.getUrl());
dataSourceInfo.setUsername(source.getUsername());
dataSourceInfo.setResettable(false);
dataSourceInfo.setType("tomcat-dbcp2");
}
return dataSourceInfo;
}
use of psiprobe.model.DataSourceInfo in project psi-probe by psi-probe.
the class Tomcat9DbcpDatasourceAccessor method getInfo.
@Override
public DataSourceInfo getInfo(Object resource) throws Exception {
DataSourceInfo dataSourceInfo = null;
if (canMap(resource)) {
BasicDataSource source = (BasicDataSource) resource;
dataSourceInfo = new DataSourceInfo();
dataSourceInfo.setBusyConnections(source.getNumActive());
dataSourceInfo.setEstablishedConnections(source.getNumIdle() + source.getNumActive());
dataSourceInfo.setMaxConnections(source.getMaxTotal());
dataSourceInfo.setJdbcUrl(source.getUrl());
dataSourceInfo.setUsername(source.getUsername());
dataSourceInfo.setResettable(false);
dataSourceInfo.setType("tomcat-dbcp2");
}
return dataSourceInfo;
}
use of psiprobe.model.DataSourceInfo in project psi-probe by psi-probe.
the class Tomcat7DbcpDatasourceAccessor method getInfo.
@Override
public DataSourceInfo getInfo(Object resource) throws Exception {
DataSourceInfo dataSourceInfo = null;
if (canMap(resource)) {
BasicDataSource source = (BasicDataSource) resource;
dataSourceInfo = new DataSourceInfo();
dataSourceInfo.setBusyConnections(source.getNumActive());
dataSourceInfo.setEstablishedConnections(source.getNumIdle() + source.getNumActive());
dataSourceInfo.setMaxConnections(source.getMaxActive());
dataSourceInfo.setJdbcUrl(source.getUrl());
dataSourceInfo.setUsername(source.getUsername());
dataSourceInfo.setResettable(false);
dataSourceInfo.setType("tomcat-dbcp");
}
return dataSourceInfo;
}
use of psiprobe.model.DataSourceInfo in project psi-probe by psi-probe.
the class JBossResourceResolverBean method getApplicationResources.
@Override
public List<ApplicationResource> getApplicationResources() throws NamingException {
List<ApplicationResource> resources = new ArrayList<>();
MBeanServer server = getMBeanServer();
if (server != null) {
try {
Set<ObjectName> dsNames = server.queryNames(new ObjectName("jboss.jca:service=ManagedConnectionPool,*"), null);
for (ObjectName managedConnectionPoolOName : dsNames) {
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"));
dsInfo.setEstablishedConnections((Integer) server.getAttribute(managedConnectionPoolOName, "ConnectionCount"));
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 node = nl.item(i);
Node na = node.getAttributes().getNamedItem("name");
if (na != null) {
if ("ConnectionURL".equals(na.getNodeValue())) {
dsInfo.setJdbcUrl(node.getFirstChild().getNodeValue());
}
if ("UserName".equals(na.getNodeValue())) {
dsInfo.setUsername(node.getFirstChild().getNodeValue());
}
// JMS datasource
if ("JmsProviderAdapterJNDI".equals(na.getNodeValue())) {
dsInfo.setJdbcUrl(node.getFirstChild().getNodeValue());
resource.setType("jms");
}
}
}
}
dsInfo.setResettable(true);
resource.setDataSourceInfo(dsInfo);
resources.add(resource);
}
} catch (Exception e) {
logger.error("There was an error querying JBoss JMX server:", e);
}
}
return resources;
}
Aggregations