Pentaho JNDI 源名称作为参数(多租户) [英] Pentaho JNDI source name as parameter (Multi-Tennant)

查看:44
本文介绍了Pentaho JNDI 源名称作为参数(多租户)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在过去半个小时里用谷歌搜索了这个,发现了 pentaho 参数等,但似乎没有提出或回答这个问题.

I have googled this for the last half an hour, and found hits for pentaho parameters etc but nothing that appears to ask or answer this question.

我有一组对每个客户都相同的报告,但需要根据运行报告的客户连接到不同的数据库.

I have a set of reports that are the same for each customer, but need to connect to different databases depending upon the customer who is running the report.

所以我的想法是在运行时将 JNDI 数据源名称作为参数传递给报表,以便客户连接到正确的数据库.

So my idea is to pass the JNDI data source name to the report at runtime as a parameter, so that the customer will connect to the correct database.

这是可能的,还是有更好的方法来管理一组通用的报告,这些报告由运行在不同数据库上但在 pentaho 引擎的同一单个实例中的不同客户使用?

Is this possible, or is there a better way of managing a common set of reports that are used by different customers running on different databases but in the same single instance of the pentaho engine ?

推荐答案

好的,我找到了一个更好的解决方案,它使用了很少有记录的多租户功能.

OK, I have found a better solution using the little documented multi-tennant feature.

1) 停止 Pentaho

1) Stop Pentaho

2) 修改 ( pentaho-solutions/system/pentahoObjects.spring.xml )

2) Modify ( pentaho-solutions/system/pentahoObjects.spring.xml )

<!-- Original Code
 <bean id="IDBDatasourceService" class="org.pentaho.platform.engine.services.connection.datasource.dbcp.DynamicallyPooledOrJndiDatasourceService" scope="singleton">
   <property name="pooledDatasourceService" ref="pooledOrJndiDatasourceService" />
   <property name="nonPooledDatasourceService" ref="nonPooledOrJndiDatasourceService" />
 </bean>
 -->

 <!--Begin Tenant -->
   <bean id="IDBDatasourceService" class="org.pentaho.platform.engine.services.connection.datasource.dbcp.tenantaware.TenantAwareLoginParsingDatasourceService"
   scope="singleton">
     <property name="requireTenantId" value="false" />
     <property name="datasourceNameFormat" value="{1}-{0}" />
     <property name="tenantSeparator" value="@" />
     <property name="tenantOnLeft" value="false" />
   </bean>
 <!-- End Tenant -->

3) 为数据源添加后缀 ( biserver-ce/tomcat/webapps/pentaho/META-INF/context.xml )

3) Add Suffix to Data Sources ( biserver-ce/tomcat/webapps/pentaho/META-INF/context.xml )

<Resource
  name="jdbc/MYDBSRC-xxx"
  auth="Container"
  type="javax.sql.DataSource"
  factory="org.apache.commons.dbcp.BasicDataSourceFactory"
  maxActive="20"
  maxIdle="5"
  maxWait="10000"
  username="XXXX"
  password="XXXX"
  driverClassName="net.sourceforge.jtds.jdbc.Driver"
  url="jdbc:jtds:sqlserver://192.168.42.0:1433;DatabaseName=SOMEDB"
/>

<Resource
  name="jdbc/MYDBSRC-aaa"
  auth="Container"
  type="javax.sql.DataSource"
  factory="org.apache.commons.dbcp.BasicDataSourceFactory"
  maxActive="20"
  maxIdle="5"
  maxWait="10000"
  username="XXXX"
  password="XXXX"
  driverClassName="net.sourceforge.jtds.jdbc.Driver"
  url="jdbc:jtds:sqlserver://192.168.42.0:1433;DatabaseName=AOTHERDB"
/>

4) 删除/tomcat/conf/Catalina/localhost/pentaho.xml

4) Delete /tomcat/conf/Catalina/localhost/pentaho.xml

5) 重启 Pentaho,创建一个用户 someone@xxx 等

5) Restart Pentaho, create a user someone@xxx etc etc

6) 使用 JNDI 名称MYDBSRC"创建报告

6) Create a report using the JNDI Name "MYDBSRC"

7) 以某人@xxx 身份登录,您将获得与以用户身份或 user@aaa 身份登录不同的报告/数据源

7) Login as someone@xxx and you will get a different report / datasource than either logging in as user, or user@aaa

Tadah !!

这篇关于Pentaho JNDI 源名称作为参数(多租户)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆