KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > performance > util > CreateWLSConfig


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tctest.performance.util;
5
6 import java.io.BufferedOutputStream JavaDoc;
7 import java.io.BufferedReader JavaDoc;
8 import java.io.FileInputStream JavaDoc;
9 import java.io.FileOutputStream JavaDoc;
10 import java.io.InputStreamReader JavaDoc;
11
12 public final class CreateWLSConfig {
13
14   private final StringBuffer JavaDoc data;
15   private static final int L2 = 1;
16   private static final int L1 = 2;
17   private static final String JavaDoc WLS_CONFIG = "config_clustered.xml";
18
19   private CreateWLSConfig() {
20     data = new StringBuffer JavaDoc();
21   }
22
23   public static void main(String JavaDoc[] args) throws Exception JavaDoc {
24     if (args.length == 0) {
25       System.err.println("Please supply the file path to the file named hosts");
26       return;
27     }
28     String JavaDoc[][] hosts = new String JavaDoc[4][];
29     BufferedReader JavaDoc in = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(new FileInputStream JavaDoc(args[0])));
30     for (int i = 0; i < 3; i++) {
31       String JavaDoc line = in.readLine();
32       String JavaDoc[] labelPart = line.split("\\s");
33       if (labelPart.length == 2) hosts[i] = labelPart[1].split(":");
34     }
35     in.close();
36     CreateWLSConfig config = new CreateWLSConfig();
37     config.buildConfig(hosts);
38     
39     BufferedOutputStream JavaDoc out = new BufferedOutputStream JavaDoc(new FileOutputStream JavaDoc(WLS_CONFIG));
40     out.write(config.toString().getBytes());
41     out.flush();
42     out.close();
43   }
44
45   private void buildConfig(String JavaDoc[][] hosts) {
46     ad("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
47     ad("<Domain Name=\"tcdomain\" ConfigurationVersion=\"8.1.6.0\">");
48     ad(" <EmbeddedLDAP CredentialEncrypted=\"{3DES}NSVQgtn7xdojOWXyb7G46ESr89OP3EubgrJNnmMOBLQ=\" Name=\"mydomain\"/>");
49     ad(" <SecurityConfiguration");
50     ad(" CredentialEncrypted=\"{3DES}ehgR79weUhgb3Uauun9I821FdlseLqNSuAZFU6LPcCoem4SER8l3n3nFL/RuiNRWQXkreaQaqmg6aIkXeI7NRqb29Aq+YDHf\"");
51     ad(" Name=\"mydomain\" RealmBootStrapVersion=\"1\"/>");
52     ad(" <Security Name=\"tcdomain\" PasswordPolicy=\"wl_default_password_policy\" Realm=\"wl_default_realm\" RealmSetup=\"true\"/>");
53     ad(" <Realm FileRealm=\"wl_default_file_realm\" Name=\"wl_default_realm\"/>");
54     ad(" <FileRealm Name=\"wl_default_file_realm\"/>");
55     ad(" <PasswordPolicy Name=\"wl_default_password_policy\"/>");
56     ad("");
57     ad(" <Application Name=\"_appsdir_ROOT_dir\" Path=\"applications\"");
58     ad(" StagingMode=\"nostage\" TwoPhase=\"true\">");
59     ad(" <WebAppComponent Name=\"ROOT\" Targets=\"tc-cluster\" URI=\"ROOT\"/>");
60     ad(" </Application>");
61     ad(" <Application Name=\"_appsdir_perftest_war\"");
62     ad(" Path=\"applications\"");
63     ad(" StagingMode=\"nostage\" TwoPhase=\"true\">");
64     ad(" <WebAppComponent Name=\"perftest\" Targets=\"tc-cluster\" URI=\"perftest.war\"/>");
65     ad(" </Application>");
66     ad("");
67     ad(" <Cluster Name=\"tc-cluster\" MulticastAddress=\"224.0.0.8\"/>");
68     ad(" <Server Name=\"tc-wls-admin-server\" ListenAddress=\"" + hosts[L2][0] + "\"");
69     ad(" ListenPort=\"7001\" Machine=\"" + hosts[L2][0] + "-machine\"");
70     ad(" ReliableDeliveryPolicy=\"RMDefaultPolicy\" NativeIOEnabled=\"true\">");
71     ad(" <SSL Name=\"tc-wls-admin-server\" Enabled=\"false\" HostnameVerificationIgnored=\"false\"/>");
72     ad(" </Server>");
73     ad("");
74     for (int i = 0; i < hosts[L1].length; i++) {
75       ad(" <Server Name=\"" + hosts[L1][i] + "-managed\" Cluster=\"tc-cluster\"");
76       ad(" ListenAddress=\"" + hosts[L1][i] + "\" ListenPort=\"8080\" Machine=\"" + hosts[L1][i]
77          + "-machine\" NativeIOEnabled=\"true\">");
78       ad(" <NetworkAccessPoint Name=\"sipchannel\" ListenPort=\"5060\" Protocol=\"t3\"/>");
79       ad(" <SSL Name=\"" + hosts[L1][i] + "-managed\" Enabled=\"false\"/>");
80       ad(" <ExecuteQueue Name=\"weblogic.kernel.Default\" ThreadCount=\"15\"/>");
81       ad(" <ExecuteQueue Name=\"sip.transport.Default\"/>");
82       ad(" <ExecuteQueue Name=\"sip.tracing.local\" QueueLength=\"1024\"");
83       ad(" ThreadCount=\"1\" ThreadsMaximum=\"1\" ThreadsMinimum=\"1\"/>");
84       ad(" <ExecuteQueue Name=\"sip.tracing.domain\" QueueLength=\"1024\"");
85       ad(" ThreadCount=\"1\" ThreadsMaximum=\"1\" ThreadsMinimum=\"1\"/>");
86       ad(" <ExecuteQueue Name=\"sip.timer.Default\" QueueLength=\"1024\" ThreadCount=\"3\"/>");
87       ad(" </Server>");
88     }
89     ad("");
90     for (int i = 0; i < hosts[L1].length; i++) {
91       ad(" <MigratableTarget Name=\"" + hosts[L1][i] + "-managed (migratable)\"");
92       ad(" Cluster=\"tc-cluster\" UserPreferredServer=\"" + hosts[L1][i] + "-managed\"/>");
93     }
94     ad("");
95     for (int i = 0; i < hosts[L1].length; i++) {
96       ad(" <Machine Name=\"" + hosts[L1][i] + "-machine\">");
97       ad(" <NodeManager Name=\"" + hosts[L1][i] + "-machine\" ListenAddress=\"" + hosts[L1][i] + "\"/>");
98       ad(" </Machine>");
99     }
100     ad(" <!-- L2 MACHINE -->");
101     ad(" <Machine Name=\"" + hosts[L2][0] + "-machine\">");
102     ad(" <NodeManager Name=\"" + hosts[L2][0] + "-machine\" ListenAddress=\"" + hosts[L2][0] + "\"/>");
103     ad(" </Machine>");
104     ad("");
105     ad(" <JMSFileStore Name=\"FileStore\" Directory=\"rmfilestore\"/>");
106     ad(" <WSReliableDeliveryPolicy Name=\"RMDefaultPolicy\" Store=\"FileStore\"");
107     ad(" DefaultRetryCount=\"10\" DefaultTimeToLive=\"60000\"/>");
108     ad("</Domain>");
109   }
110
111   private void ad(String JavaDoc appender) {
112     data.append(appender + "\n");
113   }
114
115   public String JavaDoc toString() {
116     return data.toString();
117   }
118 }
119
Popular Tags