• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to detect when server gets down and connect to second server with RMI

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to detect when server gets down!


I'm creating simple TCP server/client chat, when a client sends a text
the server receives it and sends it to all connected clients

I want to create redundant server, when one server gets down, clients should connect to the
second server automatically,
how to use RMI to achieve this! I want the client side detects when the server is down at any time and directly connect to the other one


This is what I have currently:


server side:
first class:
accepts new socket from client and add it to arrayList of sockets
create object of ClientThread that implements thread, and pass the socket to it



second class:
Extends Thread and has run() method which receives text from one client and loop through the ArrayList of
sockets that created in first class and send to all connected sockets.
the ArrayList in first class is public and I access it like:



Client side:
has only one class that extends JFrame and implements AcionListener,
- it has a method that create sockets to server,and read any thing comes from server
- sending text to server is in actionPerform of Send button
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

A Alabdullah wrote:...
I want to create redundant server, when one server gets down, clients should connect to the
second server automatically,...


Typically in enterprise this would be achieved with HA/LB as the requests will be routed to any other server via LB at the server side.

...how to use RMI to achieve this! I want the client side detects when the server is down at any time and directly connect to the other one...


This would add additional overhead at the client side on the other hand. But if you need it you would have to check for heartbeat of the set of defined servers and route requests accordingly at the client side.

 
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jmx notification should fullfill your need. It would let the client know (via rmi) when one server goes down.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic