1 4 package com.tctest.performance.util; 5 6 import java.io.BufferedOutputStream ; 7 import java.io.BufferedReader ; 8 import java.io.FileInputStream ; 9 import java.io.FileOutputStream ; 10 import java.io.InputStreamReader ; 11 12 public final class CreateWLSConfig { 13 14 private final StringBuffer data; 15 private static final int L2 = 1; 16 private static final int L1 = 2; 17 private static final String WLS_CONFIG = "config_clustered.xml"; 18 19 private CreateWLSConfig() { 20 data = new StringBuffer (); 21 } 22 23 public static void main(String [] args) throws Exception { 24 if (args.length == 0) { 25 System.err.println("Please supply the file path to the file named hosts"); 26 return; 27 } 28 String [][] hosts = new String [4][]; 29 BufferedReader in = new BufferedReader (new InputStreamReader (new FileInputStream (args[0]))); 30 for (int i = 0; i < 3; i++) { 31 String line = in.readLine(); 32 String [] 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 out = new BufferedOutputStream (new FileOutputStream (WLS_CONFIG)); 40 out.write(config.toString().getBytes()); 41 out.flush(); 42 out.close(); 43 } 44 45 private void buildConfig(String [][] 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 appender) { 112 data.append(appender + "\n"); 113 } 114 115 public String toString() { 116 return data.toString(); 117 } 118 } 119 | Popular Tags |