Forums de discussion

Sharding 6.1.2 not working correct

Cristian Petrula, modifié il y a 10 années.

Sharding 6.1.2 not working correct

Junior Member Publications: 29 Date d'inscription: 26/08/13 Publications récentes
Hello I am using Liferay 6.1.2 GA3, Java 7 and JBoss eap 6.1 and I have problems with shards. I made all the configurations for 3 shards: default and two others, all db-s are created, tables are created but I noticed that in shards company table and shard table are empty. When I create a new portal instance and specify his shard it is created but stored in company table from default shard. The same for the date from shard table. What can I check to see what is wrong.
Cristian Petrula, modifié il y a 10 années.

RE: Sharding 6.1.2 not working correct

Junior Member Publications: 29 Date d'inscription: 26/08/13 Publications récentes
I have solved my issue. Sharding works fine I just had to specify from the code what shard to use. Only on shard_default company and shard tables have data.

if (ShardUtil.isEnabled()) {
CompanyThreadLocal.setCompanyId(companyId);
LOG.info("Set shard for company " + companyId);
}

this code makes sure that you are using the correct shard
thumbnail
Alberto Chaparro, modifié il y a 10 années.

RE: Sharding 6.1.2 not working correct (Réponse)

Liferay Master Publications: 549 Date d'inscription: 25/04/11 Publications récentes
Hi Cristian,

That's right, there are several entities that only contain data in the shard by default, they are the following one:
- ClassName
- Company
- CounterFinder
- Counter
- PortalPreferences
- Release
- ResourceAction
- ServiceComponent
- Shard
- VirtualHostPersistence

You can consult this information for each version in the file:
portal-impl/src/com/liferay/portal/dao/shard/advice/ShardPersistenceAdvice.java

Cheers.
thumbnail
Vilmos Papp, modifié il y a 10 années.

RE: Sharding 6.1.2 not working correct (Réponse)

Liferay Master Publications: 529 Date d'inscription: 21/10/10 Publications récentes
Hi Cristian,

I would suggest you to use the following pattern if you want to specify the shard to use:


try {
    ShardUtil.pushCompanyService(companyIdToUse);

    /* call your methods here */

}
finally {
    ShardUtil.popCompanyService();
}


This way you will have the proper shard for your services/methods but you will not break the other functions which should use the default shard for example.
Dmitriy Miller, modifié il y a 8 années.

RE: Sharding 6.1.2 not working correct

New Member Publications: 6 Date d'inscription: 27/07/15 Publications récentes
in what file do you paste this code?
thumbnail
Vilmos Papp, modifié il y a 8 années.

RE: Sharding 6.1.2 not working correct

Liferay Master Publications: 529 Date d'inscription: 21/10/10 Publications récentes
It depends on your code.