Multiple Tigase servers launched by one JVM

Submitted by Anonymous on Fri, 2007-05-18 07:36.

Hi everybody

I try to setup a monitoring network without any centralized infrastructure. I plan to use XMPP as the primary comunication protocol to organize the independent nodes.

In order to run unit tests simulating multiple machines on the same server I have to setup multiple independend instances of the tigase server on the same box (different sockets of course).

Currently I am using the XMPPServer.main(..) call to startup the server.

I have a couple of questions concerning having multiple servers running at the same time.

  • Is it possible to run multiple instances of the same server in the same JVM (different threads and sockets of course) while sharing all config files (eg. user-repository.xml)
  • How do I vary the port when starting up the server? Is there an undocumented commandline switch which I can use to vary the port or do I have to vary the config file? Is maybe another API call better suitable to start a server when started by a java application?
  • How do I shutdown gracefully a thread running tigase server (preferably by an api call not an XMPP message)? (I am not interested in something ugly such as Thread.stop())
  • Where do I report bugs (from time to time i get java exceptions on the console)

Thanks for any suggestion/answer in advance

Regards
Martin

Trackback URL for this post:

http://www.tigase.org/en/trackback/1270
kobit's picture
Submitted by kobit on Fri, 2007-05-25 11:46.

As I mentioned earlier I am going to rewrite this part. And the design is already ready.

I am not offended at all, this is very valid point. I don't like this part of Tigase code. Similar functionality - run-time configuration is also implemented in tigase.server.sreceiver package but this package is implemented in right way so new Configurator will be based in this code.


Submitted by mgwerder@primecalc.com (not verified) on Fri, 2007-05-25 11:39.

OK ... I managed to setup different ports at runtime but this piece of code could definitely use some attention.

Just out of interest: Do you plan to replace this rather central part of the code by something .... prettier (no offence ment but I can see here a couple of dangers [keyword:thread safety])

Regards
Martin

kobit's picture
Submitted by kobit on Thu, 2007-05-24 14:23.

Hello, you are doing "strange" things to Tigase ;-)

The bad news is that Configurator class is the most messy code in the whole Tigase project. This is the place where ideas are usually get formed.
There is also no well established API for manipulating configuration the way you do. The good news is that I have an idea how to improve it and this work is scheduled for near future.

In mean time I would suggest to you to look in code of 2 methods:
public void setup(String name) and public void setup(Configurable component). That should give you an idea how to manipulate and change component configuration at runtime.

The line:
Map<String, Object> prop = repository.getProperties(compId); is the key. Print out content of this Map and then you will see what settings to modify. Probably just replace all occurrences of 5222 with your port number.
prop Map is exactly what Component accepts as a configuration parameters.

The only problem you might have is that values are Objects and they don't usually map directly to String. Look in tigase XML config file to see what is the real type of particular parameter.

And the last suggestion: configuration details guide might help you understand what is going on.

If you have any more problems, don't hesitate to ask...


Submitted by mgwerder@primecalc.com (not verified) on Thu, 2007-05-24 13:50.

OK
I am creating a Configurator like this

<snip>
String initialConfig =".level=ALL\n"+
"handlers=java.util.logging.ConsoleHandler\n"+
"java.util.logging.ConsoleHandler.formatter=tigase.util.LogFormatter\n";
Configurator.loadLogManagerConfig(initialConfig);
config = new Configurator(configFile, new String[0]);
</snip>

When changing the port I have either

  • to rename the existing c2s/connections/5222 node (which I have not a clue how to achieve that)
  • or create new node by using setValue(...) (if I do so it complains in tigase.server.ConnectionManager$ConnectionListenerImpl.getIfcs that there was a class cast exception [which is logic; it is String not String[])

Any help would be apreciated.

kobit's picture
Submitted by kobit on Fri, 2007-05-18 15:45.

Yes, all this is possible and should be quite easy achievable.


Submitted by mgwerder@primecalc.com (not verified) on Fri, 2007-05-18 09:59.

Damit ... This piece of code (yes ... I am talking about the server) is really good.

In other words you mean I can ...

  1. create a message router
  2. load a basic config
  3. do changes in the memory config (eg. change port)
  4. pass config to the router
  5. start the router (which will load all subsequent components specified in the config)
  6. do whatever I want with the server
  7. stop the router component to tear down the whole server with all threads

Is that correct or did I miss something?

Regards
Martin

kobit's picture
Submitted by kobit on Fri, 2007-05-18 08:36.

Let me answer your questions starting from the simplest:

1. The best place to report bugs is our bug tracker: Trac alternatively you can report bugs or any problem here on this forum.

All other questions require some basic understanding of Tigase server architecture. I will explain it briefly here but I recommend to download presentation of the server architecture: Tigase presentation.

Basically everything in Tigase is a component. You can load and stop components at runtime. You can load as many components as you like each of them may use different port numbers.

The basic component is: MessageRouter. It doesn't use and TCP/IP ports. It just takes care of data packets to forward them from source address to destination address. You can have only one such component active for each Tigase server instance.

MessageRouter can load, unload, start and stop all other components:

  • ClientConnectionManager component responsible for managing TCP/IP connections from Jabber/XMPP clients. Can listen on as many TCP/IP ports as you like. It is responsible to load as many instances as you like each for different set of TCP/I ports.
  • SessionManager component responsible for managing user sessions. Can handle sessions for many virtual domains. It is possible to load as many instances as you like, each for different set of virtual domains.
  • ServerConnectionManager component responsible for managing TCP/IP connections from other Jabber/XMPP servers. Can listen on as many TCP/IP ports as you like. It is responsible to load as many instances as you like each for different set of TCP/I ports.
  • ComponentConnectionManager component responsible for managing TCP/IP connections from Jabber/XMPP external components (XEP-0114). Can listen on many ports but can manage connection to only single external component. It is responsible to load as many instances as you like, each for different set of TCP/I ports and different external component.

There are also a few different components specialized to send big number of stanzas taken from database for example or for distributing messages to many users, just like mailing list.

I would recommend to read first basic information about API and then a little more about configuration.

Going back to your questions. Everything is possible but there are many ways to do this and selecting the best way depends on particular case.
I mean either I should know more details to recommend something or you should know more about Tigase to choose something.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.