Hi Gerald,

Don't know if/how you solved your problem... It isn't clear to me what is
going wrong. If you still have issues, I suggest trying to isolate it in a
smaller application that we could test/debug.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Technical Lead ~ http://www.restlet.org
Noelios Technologies ~ http://www.noelios.com




-----Message d'origine-----
De : [email protected] [mailto:[email protected]] 
Envoyé : mercredi 21 avril 2010 05:53
À : [email protected]
Objet : Proxy Server Master and Slave

Hi,
    My main project was to develop a load balancing cache manager that can
be registered to a master web service for load balancing.
     It is working fine when the master is just responding to one task
application "cache", but then we tried to attach another application to the
master and this is the problem. 
     
////////////////////////////////////////////////////////////////////////////
////
Main
////////////////////////////////////////////////////////////////////////////
////

public static void main(String[] args) throws Exception{
  Component component=new Component();
  component.getServers().add( Protocol.HTTP, 8182 ); // Private
  component.getServers().add( Protocol.HTTP, 8183); // Public
                
  //Add a new HTTP client
  component.getClients().add( Protocol.HTTP );
                
  InetAddress inet = InetAddress.getLocalHost();
  String cannonicalHostName = inet.getCanonicalHostName();
                
 /**
  *  Create virtual Host for Private use
  *  like registering slaves
  */
  VirtualHost privateHost = new VirtualHost(component.getContext());
  privateHost.setHostDomain(cannonicalHostName);
  privateHost.setHostPort("8182");
                
  VirtualHost proxyHost = new VirtualHost(component.getContext());
  proxyHost.setHostDomain(cannonicalHostName);
  proxyHost.setHostPort("8183");
  proxyHost.setRoutingMode(Router.MODE_NEXT_MATCH);
  /**
   * cache application
   *  internal routing
   *    /webservice/PEITCache
   */ 
  proxyHost.attach(new
PEDWProxy("http://rbaa0282562.apr.dhcp.ti.com:50011";));
  proxyHost.attach(new
PEDWProxy("http://rbaa0282562.apr.dhcp.ti.com:50012";));

  /**
   * foreign application
   *  internal routing
   *   /webservice/foreign
   */ 
  proxyHost.attach(new
PEDWProxy("http://peitlab01.dallab.design.ti.com:30090";));

  
  component.getHosts().add(privateHost);
  component.getHosts().add(proxyHost);
                
  //proxyHost.setRoutingMode(Router.MODE_CUSTOM);
  component.start();            
}

////////////////////////////////////////////////////////////////////////
public class PEDWProxy extends Application
{
  public String hostAddress = "";
  
  public PEDWProxy(String hostAddress) {
    super();
    this.hostAddress = hostAddress;
  }
  /**
   * Creates a root Restlet that will receive all incoming calls.
   */
  @Override
  public Restlet createInboundRoot() {
    // Create a root router  
    Router router = new Router(getContext());
                
    String target = hostAddress + "{rr}";
        
    Redirector redirector = new Redirector(getContext(), target,
Redirector.MODE_SERVER_OUTBOUND);
                
    // Attach the extractor to the router  
    router.attachDefault(redirector);
                
    return router;
  }
}
////////////////////////////////////////////////////////////////////////
First Problem:
Scenario
First Request: http://localhost:8183/webservice/PEITCache 
  --> response ok, redirected to http://rbaa0282562.apr.dhcp.ti.com:50011

Second Request: http://localhost:8183/webservice/PEITCache 
 --> response ok, http://rbaa0282562.apr.dhcp.ti.com:50012

Third Request:  http://localhost:8183/webservice/PEITCache 
   --> response bad, tried to redirect to
http://peitlab01.dallab.design.ti.com:30090, in which i'm expecting that the
request will be redirected to the redirected to
http://rbaa0282562.apr.dhcp.ti.com:50011 or redirected to
http://rbaa0282562.apr.dhcp.ti.com:50012


////////////////////////////////////////////////////////////////////////
Second Problem:
Scenario:
       I shutdown the web service in
http://rbaa0282562.apr.dhcp.ti.com:50012
First Request: http://localhost:8183/webservice/PEITCache 
  --> response ok, redirected to http://rbaa0282562.apr.dhcp.ti.com:50011
Second Request: http://localhost:8183/webservice/PEITCache
  --> it waits indefinitely for the response coming from
http://rbaa0282562.apr.dhcp.ti.com:50012 which was at shutdown state, how
can I resolve this problem...

       Thanks

Sincerely,
Gerald Ternola

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=25911
05

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2611177

Reply via email to