5 Replies Latest reply: Dec 18, 2012 12:49 AM by MohtashimShaikh RSS

    Datasource does not direct the client to the cluster.

    MohtashimShaikh
      I have a datasource targeted to a cluster with two weblogic managed servers i.e 219.112.112.47:8001 and 219.112.112.48:9001

      The cluster is configured with default settings.

      The datasource has deafult max capacity for the connection pool set to 15.

      Thus, I am expection a total of 15*2=30 connections.

      However, my client code gets only 15 connections that too on a single server(219.112.112.47:8001) and not on both servers of my cluster.

      Below is my code:

      public static void main(String ar[])throws Exception
      {
      InitialContext ic=null;
      try{
      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
      env.put(Context.PROVIDER_URL, 219.112.112.47:8001);
      ic = new InitialContext(env);
      }
      catch(Exception e){
      System.out.println("\n\n\t Unable To Get The InitialContext => "+e);
      }
      Connection con[]=new Connection[100];
      try{

      for(int i=0;i<100;i++)
      {
      DataSource ds=(DataSource)ic.lookup("MyDS"); //Enter your DataSource or MultidataSource JNDI name Here
      con=ds.getConnection();
      System.out.println("\n\n\t GOT CONNECTION con["+i+"]: "+con[i]);
      Thread.sleep(1000);
      }

      Edited by: Mohtashim Shaikh on Dec 13, 2012 9:07 PM

      Edited by: Mohtashim Shaikh on Dec 13, 2012 9:07 PM
        • 1. Re: Datasource does not direct the client to the cluster.
          Jeets
          As the initial context is pointing to only one server, client is getting 15 connections.
          This needs, to targeted to both.

          env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
          env.put(Context.PROVIDER_URL, 219.112.112.47:8001);

          Can you quickly try to change the PROVIDER_URL to env.put(Context.PROVIDER_URL, 219.112.112.47:8001, 219.112.112.48:9001); ?

          Hope this helps.

          Jeets.
          • 2. Re: Datasource does not direct the client to the cluster.
            MohtashimShaikh
            As suggested i tried

            env.put(Context.PROVIDER_URL,"t3://219.112.112.47:8001,219.112.112.48:9001");

            and

            env.put(Context.PROVIDER_URL,"http://219.112.112.47:8001,219.112.112.48:9001");

            However, I still get 15 connections only.

            Observation: The 15 connections are being establish on any one of the two servers in a round robin fashion each time I run my client code i.e in the first run 15 connection on "219.112.112.47:8001" in the second run 15 connections on "219.112.112.48:9001" and the third time it goes back to "219.112.112.47:8001"

            WebLogic Server 10.3.6.0 Tue Nov 15 08:52:36 PST 2011 1441050

            Java Version: 1.6.0_29

            Please help fix !!

            Edited by: Mohtashim Shaikh on Dec 13, 2012 11:32 PM

            Edited by: Mohtashim Shaikh on Dec 13, 2012 11:37 PM
            • 3. Re: Datasource does not direct the client to the cluster.
              Jeets
              In such case use the cluster address and port, and see if its working as desired.
              • 4. Re: Datasource does not direct the client to the cluster.
                MohtashimShaikh
                Can you help me understand what exactly to feed-in the Cluster Address and port and would that require any changes in the client code?

                Sorry for being Naive but wish to be sure.
                • 5. Re: Datasource does not direct the client to the cluster.
                  MohtashimShaikh
                  I gave "219.112.112.47:8001,219.112.112.48:9001" entries in my cluster address keeping the client code same i.e.
                  env.put(Context.PROVIDER_URL,"t3://219.112.112.47:8001,219.112.112.48:9001")
                  and then restarted both the servers in the cluster.

                  I am still getting only 15 connection and now when I run the client code each time all the 15 connections are generated only on one of the two servers consistantly which was not the case when I had not specified the cluster address.

                  I have still made no progress in finding a solution. Kindly help.

                  Edited by: Mohtashim Shaikh on Dec 14, 2012 3:20 AM

                  Edited by: Mohtashim Shaikh on Dec 17, 2012 10:48 PM

                  Edited by: Mohtashim Shaikh on Dec 17, 2012 10:49 PM