View Javadoc

1   /*
2    * Copyright (c) 1998-2002 The Jgroup Team.
3    *
4    * This program is free software; you can redistribute it and/or modify
5    * it under the terms of the GNU Lesser General Public License version 2 as
6    * published by the Free Software Foundation.
7    *
8    * This program is distributed in the hope that it will be useful,
9    * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   * GNU Lesser General Public License for more details.
12   *
13   * You should have received a copy of the GNU Lesser General Public License
14   * along with this program; if not, write to the Free Software
15   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16   *
17   */
18  
19  package jgroup.test.performance.arm;
20  
21  import java.rmi.RemoteException;
22  
23  import jgroup.core.GroupManager;
24  import jgroup.core.protocols.Multicast;
25  import jgroup.core.registry.DependableRegistry;
26  import jgroup.core.registry.RegistryFactory;
27  import jgroup.test.performance.SpeedTest;
28  import jgroup.util.Network;
29  
30  /**
31   *  Server to test chained invocations.
32   *
33   *  @author Hein Meling
34   *  @since Jgroup 1.2
35   */
36  public class ChainedServer
37    implements ChainedInvocationTest
38  {
39  
40    ////////////////////////////////////////////////////////////////////////////////////////////
41    // Fields (non-shared state)
42    ////////////////////////////////////////////////////////////////////////////////////////////
43  
44    private SpeedTest test;
45  
46  
47    ////////////////////////////////////////////////////////////////////////////////////////////
48    // Constructor
49    ////////////////////////////////////////////////////////////////////////////////////////////
50  
51    public ChainedServer()
52      throws Exception
53    {
54      GroupManager gm = GroupManager.getGroupManager(this);
55      DependableRegistry registry = RegistryFactory.getRegistry();
56      test = (SpeedTest) registry.lookup("ARM/ReplicatedServer");
57      System.out.println("ChainedServer initialized");
58    }
59  
60  
61    ////////////////////////////////////////////////////////////////////////////////////////////
62    // Main method
63    ////////////////////////////////////////////////////////////////////////////////////////////
64  
65    public static void main(String[] argv)
66      throws Exception
67    {
68      ChainedServer server = new ChainedServer();
69    }
70  
71  
72    ////////////////////////////////////////////////////////////////////////////////////////////
73    // ChainedInvocationTest methods
74    ////////////////////////////////////////////////////////////////////////////////////////////
75  
76    /* (non-Javadoc)
77     * @see jgroup.test.performance.arm.ChainedInvocationTest#chainResult(java.lang.String)
78     */
79    @Multicast public String chainResult(String input)
80      throws RemoteException
81    {
82      System.out.println("received: " + input);
83      return test.mtest(input + Network.getLocalMachineName());
84    }
85  
86  } // END ChainedServer