JBoss:Developer's Guide
上QQ阅读APP看书,第一时间看更新

Creating a server instance

A server instance is created on a host and belongs to one server group. The server exposes various ports to interact with its services.
Since we want to have many server instances on the same host, we will shift the instances port offset. For BeOSBank projects, we take a convention to add 100 to the base offset while moving from one server to another. This means that all the default ports of the associated socket binding will be shifted for a specific instance.

Host1 server creation can be completed with the following command list: 

[domain@127.0.0.1:9999 /] /host=host1/server-config=node11:add(group=dev01,socket-binding-port-offset=100)
[domain@127.0.0.1:9999 /] /host=host1/server-config=node12:add(group=dev02,socket-binding-port-offset=200)
[domain@127.0.0.1:9999 /] /host=host1/server-config=node13:add(group=dev03,socket-binding-port-offset=300)
[domain@127.0.0.1:9999 /] /host=host1/server-config=node14:add(group=dev04,socket-binding-port-offset=400)

A servers instance on host2 can be created using the same command. Adjust the server names accordingly

Since we are simulating host1 and host2 on the same machine, we cannot have the same offset as described on the previous schema (node11 and node21 on HTTP port 8180). We have to continue adding +100; so, node21 will listen on HTTP port 8580, node22 :8680, and node23 :8780):

[domain@127.0.0.1:9999/]/host=host2/server-config=node21:add(group=dev01, socket-binding-port-offset=500)
[domain@127.0.0.1:9999/]/host=host2/server-config=node22:add(group=dev02,socket-binding-port-offset=600)
[domain@127.0.0.1:9999 /] /host=host2/server-config=node23:add(group=dev03,socket-binding-port-offset=700)
You may have a more verbose result while creating the first server instance on each host:
step-1 => {outcome => success}, step-3 => {outcome => success}, .....step-256 => {outcome => success}

All server nodes are now created. You can start/stop a specific instance or all the instances that belong to a server group:

[domain@127.0.0.1:9999 /] /server-group=dev01:start-servers
{
"outcome" => "success",
"result" => undefined,
"server-groups" => undefined
}
[domain@127.0.0.1:9999 /] /host=host2/server-config=node22:start
{
"outcome" => "success",
"result" => "STARTING"
}
[domain@127.0.0.1:9999 /]

Client: If the domain controller is down, what is the behavior of my instances?
Doctor JBoss: The server instances continue to work perfectly, but administration is not possible on the domain. However, if you had set up a backup domain controller, instances will try to join this one.

You can see the newly created server on the management console by clicking on a specific server group:

Servers groups and instances
The console is available at http://127.0.0.1:9990/console. JBoss remoting port is = 9999, and HTTP interfaces are on 9990 by default.

Client: Thank you for your demonstration! I am very impatient to see my money transfer application running on this domain; however, I have some important questions: how will these two instances run the application concurrently, and do I have to provide two URLs to my customers?

What is the application behavior when one instance goes down for my critical money transfer application? I do not want to lose any transaction data. Can you show me how it works.

Doctor JBoss: Thank you for your questions. We will show you how to develop and deploy clustered applications using JBoss APIs and the JBoss Application Server. This is the purpose of the next section.