JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF

The open source
grid computing
solution

 Home   About   Features   Download   Documentation   On Github   Forums 
June 04, 2023, 09:09:17 AM *
Welcome,
Please login or register.

Login with username, password and session length
Advanced search  
News: New users, please read this message. Thank you!
  Home Help Search Login Register  
Pages: [1]   Go Down

Author Topic: How to revoke a peer server connection request  (Read 2276 times)

codemonkey

  • JPPF Council Member
  • *****
  • Posts: 138
How to revoke a peer server connection request
« on: February 14, 2013, 03:57:01 AM »

Hi Laurent,
I'm trying to decide the best way to revoke a request from another server to join as a peer should that server not pass a list of criteria, i.e. that server's code base version does not correspond with the version of the server its trying to connect to.

I thought of either a custom mbean or startup class, but it's to my understanding that these methods are invoked after the driver/nodes have initialized, which would mean the peer connection would already have been initialized. Is this correct?

If the above is true, is there a way to catch the incoming connection request and handle it there?

I'd really appreciate any ideas/approach to this.

CM

Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2272
    • JPPF Web site
Re: How to revoke a peer server connection request
« Reply #1 on: February 24, 2013, 09:55:07 AM »

Hello,

In fact, the startup classes and MBeans are started before any node or client can connect, as described in the flow of customizations, so this won't be a problem.

Unfortunately, there is no API that will allow to invalidate node connections from a startup or mbean.
Instead, what you could do is to create a node connection listener and throw a RuntimeException from its nodeConnected() method:

Code: [Select]
public class MyConnectionListener implements NodeConnectionListener {
   @Override
   public void nodeConnected(NodeConnectionEvent event) {
     JPPFManagementInfo info = event.getNodeInformation();
     // peer driver ?
     if (info.isDriver()) {
       boolean ok = true;
       JPPFSystemInformation systemInfo = info.getSystemInfo();
       // ... perform some checks based on the info ...
       if (!ok) throw new IllegalStateException("refusing connection from peer driver");
     }
   }
 
   @Override
   void nodeDisconnected(NodeConnectionEvent event) {
   }
 }

The exception will be propagated back to the code that handles the network I/O and cause to close the connection.
Let me know if this works for you.

Sincerely,
-Laurent
Logged

codemonkey

  • JPPF Council Member
  • *****
  • Posts: 138
Re: How to revoke a peer server connection request
« Reply #2 on: February 25, 2013, 05:12:56 PM »

Hi Laurent, this is great. I started going down the route of using an MBean which is satisfying requirement, but I like this solution much better as its cleaner.

Thanks again!

CM
Logged
Pages: [1]   Go Up
 
JPPF Powered by SMF 2.0 RC5 | SMF © 2006–2011, Simple Machines LLC Get JPPF at SourceForge.net. Fast, secure and Free Open Source software downloads