Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes related to mutl-domain deployments #238

Merged
merged 20 commits into from
Oct 10, 2014
Merged

Fixes related to mutl-domain deployments #238

merged 20 commits into from
Oct 10, 2014

Conversation

abmargb
Copy link
Collaborator

@abmargb abmargb commented Sep 27, 2014

Now the external-domain-checker returns a list of local domains that can be reused between calls of ChannelManager.isLocalDomain(), ChannelManager.isLocalJid() or ChannelManager.isLocalNode().
It drastically improves the perfomance of disco#items, purging remote cache, etc,... and allows for a selective query of local nodes.

Since HSQLDB is not fully compliant with postgres, I had to Mockito.spy the SQL connection object in the tests in order to replace ~ with regexp_matches.

@lloydwatkin
Copy link
Member

Can you merge in master please ?

if (false == nodeId.matches("/user/.+@.+/.+")) {
logger.debug("Node " + nodeId + " has an invalid format");
throw new IllegalArgumentException(INVALID_NODE);
}
String domain = new JID(nodeId.split("/")[2]).getDomain();
return isLocalDomain(domain);
return isLocalDomain(domain, localDomains);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we passing this value around as an argument when it can just be called internally?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It helps solving the performance issues we currently have. In cases we need to check if a lot of nodes are local - for example, in a for loop - we just need to execute the local-domain-checker once, and then pass this list around.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are we doing checks like this? I'm sure there's a better solution for this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/buddycloud/buddycloud-server-java/blob/multi-domain-fixes/src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/discoitems/DiscoItemsGet.java#L78.

The alternate solution would be to create a areLocalDomains() method returning a List of objects (or a map) that associates domains to the information stating they are local or not.

If we don't provide anything similar we simply lose the performance benefits of returning a csv in the local-domain-checker.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not pass the local domains through to the database query for retrieving local domains? (At most you'll have a standard and topics domain, but even that can be looped). That way it'll be quick in the DB and the code will be less complex.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's exaclty what I did in the first place, but I thought we wanted to check it in a more explicit way, i.e. in the PacketProcessor itself.

Good. So I'll create a ChannelManager.getLocalNodeList() method that will make this simpler.

Conflicts:
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/items/special/FirehoseGet.java
@@ -250,6 +250,11 @@ public void createPersonalChannel(JID owner) throws NodeStoreException {
}

@Override
public boolean isLocalDomain(String domain) {
return LocalDomainChecker.isLocal(domain, configuration);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to get the local domain data via the Configuration object? This reduces the dependencies for the channel manager and means we are always getting 'configuration' data from the same place?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, good point. I'm changing this.

@lloydwatkin
Copy link
Member

A few comments, one potentially important.

Tests failed but I think that was due to an internet hiccup rather than your code. Have restarted the travisci run.

@abmargb
Copy link
Collaborator Author

abmargb commented Oct 4, 2014

@lloydwatkin Indeed it was. Thanks for the comments.

@abmargb
Copy link
Collaborator Author

abmargb commented Oct 6, 2014

I have removed the Configuration dependency from the ChannelManager. This change had a huge impact in the tests - that's why it took me a while to get all tests fixed.

I've also noticed sometimes we refer the configuration object as non-singleton. I'd rather not use the Configuration as a singleton anywhere, since it makes tests more unpredictable. But let's just try to follow one style or another. I've raised an issue about this: #241.

Conflicts:
	src/main/java/org/buddycloud/channelserver/ChannelsEngine.java
	src/main/java/org/buddycloud/channelserver/Configuration.java
	src/main/java/org/buddycloud/channelserver/channel/ChannelManager.java
	src/main/java/org/buddycloud/channelserver/channel/ChannelManagerFactoryImpl.java
	src/main/java/org/buddycloud/channelserver/channel/ChannelManagerImpl.java
	src/main/java/org/buddycloud/channelserver/channel/LocalDomainChecker.java
	src/main/java/org/buddycloud/channelserver/db/NodeStore.java
	src/main/java/org/buddycloud/channelserver/db/jdbc/JDBCNodeStore.java
	src/main/java/org/buddycloud/channelserver/db/jdbc/dialect/Sql92NodeStoreDialect.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/discoinfo/DiscoInfoGet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/discoitems/DiscoItemsGet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/mam/MessageArchiveManagement.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/AffiliationsGet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/NodeConfigureGet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/NodeThreadsGet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/RecentItemsGet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/RepliesGet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/SubscriptionsGet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/ThreadGet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/UserItemsGet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/items/NodeItemsGet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/items/SpecialItemsGet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/items/special/FirehoseGet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/result/ItemsResult.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/result/SubscriptionsResult.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/AffiliationEvent.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/ItemDelete.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/NodeConfigure.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/NodeCreate.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/NodeDelete.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/SubscribeSet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/SubscriptionEvent.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/UnsubscribeSet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/register/RegisterSet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/register/UnregisterSet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/search/Search.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/search/SearchGet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/search/SearchSet.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/message/event/AbstractMessageProcessor.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/message/event/AffiliationProcessor.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/message/event/ConfigurationProcessor.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/message/event/DeleteProcessor.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/message/event/ItemsProcessor.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/message/event/RetractItemProcessor.java
	src/main/java/org/buddycloud/channelserver/packetprocessor/message/event/SubscriptionProcessor.java
	src/test/java/org/buddycloud/channelserver/channel/ChannelManagerImplTest.java
	src/test/java/org/buddycloud/channelserver/channel/TestHelper.java
	src/test/java/org/buddycloud/channelserver/channel/validate/AtomEntryTest.java
	src/test/java/org/buddycloud/channelserver/db/jdbc/DatabaseTester.java
	src/test/java/org/buddycloud/channelserver/db/jdbc/JDBCNodeStoreAbstract.java
	src/test/java/org/buddycloud/channelserver/db/jdbc/JDBCNodeStoreTest.java
	src/test/java/org/buddycloud/channelserver/packetHandler/iq/TestHandler.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/discoitems/DiscoItemsGetTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/mam/MessageArchiveManagementTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/NodeConfigureGetTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/NodeThreadsGetTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/SubscriptionsGetTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/items/NodeItemsGetTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/items/UserSingleItemGetTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/get/items/special/FirehoseGetTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/result/ItemsResultTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/AffiliationEventTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/ItemDeleteTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/NodeConfigureTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/NodeCreateTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/NodeDeleteTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/PublishTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/SubscribeSetTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/SubscriptionEventTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/pubsub/set/UnsubscribeSetTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/register/RegisterSetTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/register/UnregisterSetTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/search/SearchGetTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/iq/namespace/search/SearchSetTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/message/event/AffiliationProcessorTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/message/event/ConfigurationProcessorTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/message/event/DeleteProcessorTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/message/event/ItemsProcessorTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/message/event/NotificationSendingMockTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/message/event/RetractItemProcessorTest.java
	src/test/java/org/buddycloud/channelserver/packetprocessor/message/event/SubscriptionProcessorTest.java
@coveralls
Copy link

Coverage Status

Coverage increased (+0.22%) when pulling bc01763 on multi-domain-fixes into bdb00aa on master.

abmargb added a commit that referenced this pull request Oct 10, 2014
Fixes related to mutl-domain deployments
@abmargb abmargb merged commit 60f0952 into master Oct 10, 2014
@abmargb abmargb deleted the multi-domain-fixes branch October 10, 2014 02:27
@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) when pulling 102761c on multi-domain-fixes into bdb00aa on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants