author | katleman |
Thu, 29 Dec 2011 15:14:45 -0800 | |
changeset 11330 | 084a13b20cf3 |
parent 5506 | 202f599c92aa |
child 13256 | 5886d7607acd |
permissions | -rw-r--r-- |
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
||
24 |
/** |
|
25 |
* |
|
26 |
* |
|
27 |
* Client that will run in its own vm and tell the main CheckFQDN test |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
28 |
* program what its rmi host name is, name obtained from TCPEndpoint. |
2 | 29 |
*/ |
30 |
||
31 |
import java.rmi.*; |
|
32 |
import java.rmi.server.*; |
|
33 |
import sun.rmi.transport.tcp.TCPEndpoint; |
|
34 |
||
35 |
/** |
|
36 |
* Get the local endpoint: make sure that this process does |
|
37 |
* not take too much time and that the resulting localhost |
|
38 |
* string is correct for the property set on an execed vm process. |
|
39 |
*/ |
|
40 |
public class CheckFQDNClient implements Runnable { |
|
41 |
||
42 |
final static int NAME_SERVICE_TIME_OUT = 12000; |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
43 |
|
2 | 44 |
static TCPEndpoint ep = null; |
45 |
||
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
46 |
/** |
2 | 47 |
* main, lookup remote object and tell it the rmi |
48 |
* hostname of this client vm. |
|
49 |
*/ |
|
50 |
public static void main (String args[]) { |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
51 |
|
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
52 |
// start a registry and register a copy of this in it. |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
53 |
TellServerName tell; |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
54 |
String hostname = null; |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
55 |
|
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
56 |
try { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
57 |
hostname = retrieveServerName(); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
58 |
System.err.println("Client host name: " + |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
59 |
hostname); |
2 | 60 |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
61 |
tell = (TellServerName) Naming.lookup("rmi://:" + |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
62 |
TestLibrary.REGISTRY_PORT |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
63 |
+ "/CheckFQDN"); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
64 |
tell.tellServerName(hostname); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
65 |
System.err.println("client has exited"); |
2 | 66 |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
67 |
} catch (Exception e ) { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
68 |
throw new RuntimeException(e.getMessage()); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
69 |
} |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
70 |
System.exit(0); |
2 | 71 |
} |
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
72 |
|
2 | 73 |
/* what is the rmi hostname for this vm? */ |
74 |
public static String retrieveServerName () { |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
75 |
try { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
76 |
|
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
77 |
CheckFQDNClient chk = new CheckFQDNClient(); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
78 |
|
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
79 |
synchronized(chk) { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
80 |
(new Thread (chk)).start(); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
81 |
chk.wait(NAME_SERVICE_TIME_OUT); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
82 |
} |
2 | 83 |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
84 |
if (ep == null) { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
85 |
throw new RuntimeException |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
86 |
("Timeout getting the local endpoint."); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
87 |
} |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
88 |
|
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
89 |
// this is the name used by rmi for the client hostname |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
90 |
return ep.getHost(); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
91 |
|
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
92 |
}catch (Exception e){ |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
93 |
throw new RuntimeException (e.getMessage()); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
94 |
} |
2 | 95 |
} |
96 |
||
97 |
/* thread to geth the rmi hostname of this vm */ |
|
98 |
public void run () { |
|
309
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
99 |
try { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
100 |
synchronized(this) { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
101 |
ep = TCPEndpoint.getLocalEndpoint(0); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
102 |
} |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
103 |
} catch (Exception e) { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
104 |
throw new RuntimeException(); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
105 |
} finally { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
106 |
synchronized(this) { |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
107 |
this.notify(); |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
108 |
} |
bda219d843f6
6627823: Missed whitespace normalization files: jdk/test/java/rmi
ohair
parents:
2
diff
changeset
|
109 |
} |
2 | 110 |
} |
111 |
} |