免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: 无风之谷
打印 上一主题 下一主题

[WebLogic] 中间件WebLogic/Tuxedo/GoldenGate的排错与优化(获奖名单已公布) [复制链接]

论坛徽章:
0
101 [报告]
发表于 2012-05-18 21:09 |只看该作者
本帖最后由 三人行必有吾师 于 2012-05-19 07:54 编辑

回复 92# 鸣禽云霞出海曙
至于WebLogic,前面有位同学说得好,可以反编译weblogic.jar文件;先解压缩,再用Jad之类的工具,基本上可以倒腾出个大概;只是其中没有了注释和变量名的准确定义,所以需要读代码的能力超强。。。

其实WebLogic的代码和大家熟悉的Java代码类似(不过NativeIO那块有JNI调C),比如ClusterService.java
  1. package weblogic.cluster;

  2. import java.io.IOException;
  3. import java.net.InetAddress;
  4. import java.net.UnknownHostException;
  5. import java.util.Collection;

  6. import weblogic.cluster.replication.ReplicationManager;
  7. import weblogic.common.internal.VersionInfo;
  8. import weblogic.kernel.Kernel;
  9. import weblogic.management.Admin;
  10. import weblogic.management.configuration.ClusterMBean;
  11. import weblogic.management.configuration.ServerMBean;
  12. import weblogic.rjvm.JVMID;
  13. import weblogic.rmi.spi.RMIRuntime;
  14. import weblogic.server.Server;
  15. import weblogic.server.ServerLifeCycle;
  16. import weblogic.server.ServerLifecycleException;


  17. /**
  18. * Implements lifecycle for internal cluster service.  This controls
  19. * features of the cluster subsystem that are used by other subsystems.
  20. * It is inialized early in server startup to ensure that other
  21. * subsystems can use can access its services during initialization.
  22. * This class also the ClusterServices interface, which gives other
  23. * subsystems access to clustering machinery.
  24. *
  25. * @author Copyright (c) 1996-98 by WebLogic, Inc. All Rights Reserved.
  26. * @author Copyright (c) 1999-2000 by BEA WebXpress. All Rights Reserved.
  27. */

  28. final public class ClusterService implements ServerLifeCycle, ClusterServices
  29. {
  30.   private static ClusterService singleton = null;
  31.   private static boolean clusterMemberInitialized = false;

  32.   /* package */ static final String MULTICAST_QUEUE = "Multicast";

  33.   private static final ClusterTextTextFormatter formatter =
  34.     new ClusterTextTextFormatter();

  35.   public ClusterService() {
  36.     singleton = this;
  37.   }

  38.   /** This accessor is ONLY for the server initialization mechanism.
  39.    *  If you are a client, use the static getServices() call instead.
  40.    */
  41.   public static ClusterService getClusterService() {
  42.     return singleton;
  43.   }

  44.   private ClusterMBean clusterMBean;
  45.   private MemberAttributes localAttributes;
  46.   private static boolean isServerInCluster = false;
  47.   private String clusterName;

  48.   public void initialize()
  49.     throws ServerLifecycleException
  50.   {
  51.     ServerMBean serverMBean = Server.getConfig();
  52.     clusterMBean = serverMBean.getCluster();

  53.     String machineName = (serverMBean.getMachine() == null) ?
  54.       Kernel.getConfig().getName() : serverMBean.getMachine().getName();
  55.     if (clusterMBean != null) {
  56.       // Set ServerInfo on local server
  57.       weblogic.rmi.cluster.ServerInfoManager.theOne().addServer(
  58.         serverMBean.getName(),
  59.         RMIRuntime.getLocalHostID(),
  60.         serverMBean.getClusterWeight()
  61.       );
  62.       // Figure out the multicast address for the cluster
  63.       clusterName = clusterMBean.getName();
  64.       String address = clusterMBean.getMulticastAddress();
  65.       if (address == null || address.equals("")) {
  66.         // may be null if config entry is missing
  67.         // do not provide any default multicast address but flag a config error
  68.         ClusterLogger.logMissingClusterMulticastAddressError(clusterName);
  69.         // we can not go ahead, stop the ongoing startupMode
  70.         throw new ServerLifecycleException(
  71.           "configuration problem - missing multicast address for cluster: " +
  72.           clusterName);
  73.       }
  74.         
  75.       
  76.       // Check cluster address
  77.       String clusterAddress = clusterMBean.getClusterAddress();
  78.       boolean clusterAddressResolved = true;
  79.       if (clusterAddress != null) {
  80.         int nodeNumber = 0;
  81.         String[] nodeAddress = weblogic.utils.StringUtils.splitCompletely(
  82.                                     clusterAddress, ",", false);
  83.         char delimiter = (char) (new String(":")).charAt(0);  
  84.         try {
  85.           if (nodeAddress.length>1) {
  86.             // Honor comma seperated ip list for cluster address.
  87.             // This is allowed only for Development mode.
  88.             while(nodeNumber<nodeAddress.length) {
  89.               // handle port number at the end
  90.               String nodeNameOrAddress = weblogic.utils.StringUtils.upto(
  91.                     nodeAddress[nodeNumber],delimiter);
  92.                               
  93.               InetAddress.getByName(nodeNameOrAddress);
  94.               nodeNumber++;
  95.             }
  96.           } else {
  97.             // We are in production mode.
  98.             // We should have a DNS entry properly setup
  99.             InetAddress.getByName(clusterAddress);
  100.           }  
  101.           weblogic.rjvm.JVMID.localID().setClusterAddress(clusterAddress);
  102.         } catch (UnknownHostException e) {
  103.           if (nodeAddress.length>1) {
  104.             ClusterLogger.logCannotResolveClusterAddressWarning(
  105.               clusterAddress+": Unknown host: "+nodeAddress[nodeNumber]);
  106.           } else {
  107.             ClusterLogger.logCannotResolveClusterAddressWarning(
  108.               clusterAddress);
  109.           }
  110.         }
  111.       }
  112.       // Check the license and if OK, initialize everything
  113.       try {
  114.         checkProcess();
  115.         // Set up the local attributes. If any of these values ever
  116.         // change, stuff them into the localAttributes object and call
  117.         // AttributeManager.theOne().sendAttributes(localAttributes).
  118.         // The code is in place to carry the object to the other
  119.         // cluster members and fire ClusterMembersChangeEvent.UPDATE.
  120.         // A few tasks remain before this will be useful however.
  121.         // 1) There is no machinery in place to notify consumers of
  122.         //    localAttributes on the *local* server.
  123.         // 2) ClusterMembersListeners on the remote servers may
  124.         //    not have code to respond to UPDATE events.
  125.         // 3) The code has not been tested.

  126.         localAttributes = new MemberAttributes(
  127.           (JVMID) RMIRuntime.getLocalHostID(), serverMBean.getName(),
  128.           serverMBean.getListenAddress(), machineName,
  129.           VersionInfo.theOne().getReleaseVersion(), System.currentTimeMillis(),
  130.           serverMBean.getClusterWeight(),
  131.           serverMBean.getReplicationGroup(),
  132.           serverMBean.getPreferredSecondaryGroup(),
  133.           Admin.getInstance().getActiveDomain().getName(),
  134.           clusterName);
  135.         
  136.         MulticastManager.initialize(
  137.           clusterMBean.getMulticastAddress(),
  138.           Server.getConfig().getInterfaceAddress(),
  139.           clusterMBean.getMulticastPort(),
  140.           (byte)clusterMBean.getMulticastTTL(),
  141.           clusterMBean.getMulticastSendDelay()
  142.         );
  143.         
  144.         // Initialize the managers and the cluster runtime MBean.
  145.         AnnouncementManager.initialize(
  146.           clusterMBean.getServiceAgeThresholdSeconds()
  147.         );
  148.         MemberManager.initialize(localAttributes.joinTime());
  149.         AttributeManager.initialize(localAttributes);
  150.         ReplicationManager.initialize(
  151.           machineName,
  152.           serverMBean.getReplicationGroup(),
  153.           serverMBean.getPreferredSecondaryGroup()
  154.         );
  155.         ClusterRuntime.initialize(Server.getConfig().getName(), clusterName);
  156.         // We use only one thread to ensure ordered processing
  157.         Kernel.addExecuteQueue(MULTICAST_QUEUE, 1);
  158.         isServerInCluster = true;
  159.       } catch (com.bea.utils.misc.ProcessException le) {
  160.         ClusterLogger.logNoClusterLicenseError(le);
  161.         throw new ServerLifecycleException(le.getMessage());
  162.       } catch (IOException ioe) {
  163.         ClusterLogger.logFailedToJoinClusterError(
  164.           clusterName, clusterMBean.getMulticastAddress(), ioe);
  165.         throw new ServerLifecycleException(ioe);
  166.       }
  167.     }
  168.   }

  169.   public void prepareToSuspend()
  170.     throws ServerLifecycleException
  171.   {
  172.   }

  173.   public void forceSuspend() throws ServerLifecycleException {
  174.     if (isServerInCluster)
  175.       MulticastManager.theOne().forceSuspend();
  176.   }

  177.   public void resume() throws ServerLifecycleException {
  178.     if (isServerInCluster)
  179.       MulticastManager.theOne().resume();
  180.   }

  181.   public void shutdown() throws ServerLifecycleException
  182.   {
  183.     if (clusterMBean != null) {
  184.       MemberManager.theOne().shutdown();
  185.       AnnouncementManager.theOne().shutdown();
  186.     }
  187.   }
  188.    
  189.   ///////////////////////////////////
  190.   // For ClusterServices Interface //
  191.   ///////////////////////////////////

  192.   /** Returns null if the server is either not configured to run in a
  193.    *  cluster or the cluster mechanisms could not be started.
  194.    *  The cluster mechanisms are considered started for this purpose
  195.    *  if this service was initialized successfuly.
  196.    */
  197.   public static ClusterServices getServices() {
  198.     if (isServerInCluster)
  199.       return getClusterService();
  200.     else
  201.       return null;
  202.   }

  203.   /* package */ MulticastSession createMulticastSession(int senderID,
  204.     RecoverListener listener,
  205.     int cacheSize,
  206.     boolean useHTTPForStateDumps) {
  207.     return MulticastManager.theOne().createSender(senderID, listener, cacheSize, useHTTPForStateDumps);
  208.   }
  209.   public MulticastSession createMulticastSession(RecoverListener listener,
  210.     int cacheSize, boolean useHTTPForStateDumps) {
  211.     return createMulticastSession(-1, listener, cacheSize, useHTTPForStateDumps);
  212.   }

  213.   public ClusterMemberInfo getLocalMember() {
  214.     return localAttributes;
  215.   }

  216.   public Collection getRemoteMembers() {
  217.     return MemberManager.theOne().getRemoteMembers();
  218.   }

  219.   public void addClusterMembersListener(ClusterMembersChangeListener listener) {
  220.     MemberManager.theOne().addClusterMembersListener(listener);
  221.   }

  222.   public void removeClusterMembersListener(ClusterMembersChangeListener listener) {
  223.     MemberManager.theOne().removeClusterMembersListener(listener);
  224.   }

  225.   public void addHeartbeatMessage(GroupMessage message)
  226.   {
  227.     MulticastManager.theOne().addItem(message);
  228.   }

  229.   public void removeHeartbeatMessage(GroupMessage message)
  230.   {
  231.     MulticastManager.theOne().removeItem(message);
  232.   }

  233.   // check license
  234.   private static boolean l_did  = false;  
  235.   private void checkProcess() throws com.bea.utils.misc.ProcessException {
  236.     if (!l_did) {
  237.       String l_comp = "Cluster";
  238.       com.bea.utils.misc.Process l_lic;
  239.       java.util.Properties l_prop = new java.util.Properties();        
  240.       l_prop.put("product", weblogic.version.getPLInfo()[0]);
  241.       l_prop.put("release",   weblogic.version.getPLInfo()[1]);
  242.       l_prop.put("component", l_comp);
  243.       l_prop.put("ip", "");
  244.       try {
  245.         l_lic = com.bea.utils.misc.ProcessManager.memCheck(l_prop);
  246.         formatter.startingClusterService();
  247.       } catch (com.bea.utils.misc.ProcessException l_ex) {
  248.         System.err.println("\n\n$$$$$$$$$$$$$$$$ \u004c\u0069\u0063\u0065\u006e\u0073\u0065 \u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e $$$$$$$$$$$$$$$$\n\n");
  249.         System.err.println("Unable to start Cluster Service!");
  250.         System.err.println(l_ex.getMessage());
  251.         System.err.println("\n\n$$$$$$$$$$$$$$$$ \u004c\u0069\u0063\u0065\u006e\u0073\u0065 \u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e $$$$$$$$$$$$$$$$\n\n");
  252.         throw l_ex;
  253.       } finally {
  254.         l_did = true;
  255.       }
  256.     }
  257.   }
  258. }
复制代码
里面大家可以看到原始的WebLogic Inc.的标记,这其实也符合历史事实;因为WebLogic最早也是BEA买来的,那个时候产品不叫WebLogic,被并购的公司叫WebLogic
  1. *
  2. * @author Copyright (c) 1996-98 by WebLogic, Inc. All Rights Reserved.
  3. * @author Copyright (c) 1999-2000 by BEA WebXpress. All Rights Reserved.
  4. */
复制代码
另外,象最后一段是校验License的逻辑,意味着最早的WebLogic中,要是想跑Cluster的话,是需要单独额外的License字段授权的。


这个方面我们就先到这里吧,敏感话题,以后不再碰和涉及;不过一定还会经常回来

论坛徽章:
0
102 [报告]
发表于 2012-05-21 16:44 |只看该作者
才看到,戴工可好

论坛徽章:
0
103 [报告]
发表于 2012-05-22 09:12 |只看该作者
WebLogic和Tuxedo都怎么互联互通呢?

论坛徽章:
0
104 [报告]
发表于 2012-05-23 09:45 |只看该作者
Tuxedo支持WebService吗,效果如何?

论坛徽章:
0
105 [报告]
发表于 2012-05-26 13:44 |只看该作者
看来暂时是用不上这些高深的东西了

论坛徽章:
0
106 [报告]
发表于 2012-05-27 09:04 |只看该作者
如果跟导师讲不清楚,那么就把他搞胡涂吧!

勤奋真能造就财富吗?

论坛徽章:
0
107 [报告]
发表于 2012-05-27 15:06 |只看该作者
回复 103# 永不变的承诺

1. 最早的方式是用Jolt,就是把Tuxedo/WS,写了一套Java版本的远程客户端,同时服务端模拟WSL/WSH,添加了一套JSL/JSH;这个是基于客户端/服务器访问方式的;它的好处是,不局限于WebLogic,只要是Java上的容器都可以,比如竞争对手WebSphere;

2. 后来比较成熟的是WTC,顾名思义,WebLogic和Tuxedo连接器,这个是不需要在Tuxedo这端额外添加什么组件,只是继续用传统的GWTDOMAIN,这个是基于Tuxedo域之间通讯的机制,在Java端模拟的是Tuxedo的远程对等域;它的问题是,由于Java的各种Package封装,其全局事务时很多时候都隐含,会把全局事务不自觉的扩展到Tuxedo这端

3. 再后来是符合规范的JCA框架,这个就是按标准制作了。


   

论坛徽章:
0
108 [报告]
发表于 2012-05-27 15:14 |只看该作者
回复 104# IT-寻梦人

WebLogic比较早就支持Web Service,所以早先有人在WebLogic这端实现Web Service接口,然后通过WTC调用Tuxedo的服务(好象还跟上个回复有关联似的。。);

后来Tuxedo单独开发了SALT,自己就可以独立支持Web Service了;SALT的思路有点象JOLT,不过在服务端配的是GWWS,也是配配定义文件,就将传统的Tuxedo服务,对外发布成Web Service。

从我们实际实施过的经验来看,相对于走网关而言,Inbound还是有明显优势,非常快;Outbound则没有明显优势。

论坛徽章:
0
109 [报告]
发表于 2012-05-27 15:19 |只看该作者
回复 102# sometimeixpub
似是故人来,握手,问好

回复 105# maya_2012
其实看了源代码反而不容易觉得高深了,否则常觉得产品比较神奇

回复 106# shaneqi
问好,看不太懂意思,不过勤奋总是不会错的


   

论坛徽章:
0
110 [报告]
发表于 2012-05-29 13:10 |只看该作者
对于WebService的支持,Oracle有什么专门的产品吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP