I am creating an application in which I have a central (server?) PC.
When at a particular position (or event) in the central PC, a XML file is dumped. The program reads that XML in which remote PC IP is given (any PC).
The command is transmitted to that PC, that PC will execute that command.
The command may be one of various types and for each command that PC has a separate class file.
Per command it will create an object of that type and run the desired method.
Question: What is the best technology with which I can implement this architecture?
Ok, what is your question?
The simplest way to do this may be to use RMI.
However, have you considered using a JMS queue as this would allow you to distribute the work evenly across many PCs without having to allocate a specific PC to a specific task. i.e. you give a queue the tasks you want to perform and the next available PC performs that task.
Take a look at Java RMI
Obligatory Wiki link and quote and why this can apply to your implementation:
The Java Remote Method Invocation
Application Programming Interface
(API), or Java RMI, is a Java
application programming interface that
performs the object-oriented
equivalent of remote procedure calls
(RPC).
(even across machine boundaries)
RMI is also the first that came up in my mind. But I think to give a really good answer we need some more details about what is done on the remote PC. My guess is that you are building a distributed Worker Thread Pattern
Other options can be:
JMS.
Web Services.
Etc.
You have several options.. You can use RMI, you can have a JMS Queue/Topic or even a Http Pub/sub. Each one of these has pros/cons.
With RMI, you can make the remote PCs open a connection to the server on startup to avoid the firewall issues. This way you only need to open the incoming/outgoing ports only on your central PC.
With JMS, you can register a listener from each of the remote PCs to a Topic/Queue opened by your JMS container. Any message you put in the Queue/Topic, you have a message filter set by using IP that way the message will only go to one targeted PC. I like this approach because of the lose coupling between your remote PCs and Central PC. But in this approach, since you don't have an open connection between your remote and your central pc, your Central PC will not have the similar control that you would get in the RMI system.
Related
I have an OpenStack installation in my laptop running in VirtualBox windows. I want to access it from my android client and send some computational queries and retrieve the response. I know all about hotspot and networking, Just tell me about the OpenStack setup part and how the client will connect to it i.e. GET/POST requests or sockets, etc.
#Senol has given you links to documentation for the OpenStack "control plane" APIs. You would use these if you wanted to programatically do things like spin up new VMs, configure security groups, create and attach volumes and so on.
But if you want to do a computational task (say) on an existing OpenStack instance that you created on your DevStack installation ... that's software you need to put together yourself. Basically, you setup something on your instance that can accept requests over its private network. That could be via HTTP / HTTPS requests, or via SSH connections, or ... basically anything that can accept TCP connections, UDP packets and so on.
In short:
Set up OpenStack instance, networking, etc.
Install network capable software stack on instance.
Implement your application "service" to do your compute.
In your case, you appear to want your OpenStack instance to be accessible from the outside. Therefore it either needs a public IP (that your Android client can route to) or you need to do some port forwarding from your laptop's IP / ports to the OpenStack instance's ports on its private network. (This is getting "too broad" ...)
Looks like you've been looking for OpenStack api information. You can reach its APIs by cURL, Openstack Cli, REST clients or OpenStack SDK.
The OpenStack API Documentation can be a good starting point.
I am very new to jxfs things. I have a requirement to call jxfs server which is in cloud server from the jxfs client which is in ATM environment.. How can i call?.. I need to call this one through the Jxfs RMI concept. It would be appreciated one if any example code is available. If atleast you are having code for calling from jxfs server to jxfs client, please post it.
Thanks in advance guys.
One of the interesting things about J/XFS and remote device access (based on RMI) is that it is just matter of configuration.
You need to configure a J/XFS repository in order to handle a remote device (basically set 'remoteAccess' to true).
Then accessing these devices from the programming point of view is just the same as they were local devices.
Architecture is explained here: ftp://ftp.cencenelec.eu/CWA/CEN/WS-J-XFS/cwa14923/cwa14923-01-2004-May.pdf
Details, when programming may differ depending on the J/XFS implementation you are using.
Trying to answer your question below:
Whenever you want to access a device remotely in J/XFS, RMI is used. You need to make the following setup:
On a server (should be accessible) you need to start a JxfsServer. The JxfsServer will use a Read.repository
whith all the ATM's and devices configured on them as workstations, with the right IP addresses.
On the ATM, you need to install:
J/XFS libs
J/XFS device services for the devices on the ATM
Setup the DSstarter:
Will use the SpecificDeviceManagerRMI connecting to the JxfsServer you started before.
On your server (cloud) wherever you are going to use the J/XFS client you can get the remote controls by performing
the J/XFS initialization as follows:
jxfsDM_ = JxfsDeviceManager.getReference();
jxfsDM_.initialize("com.jxfs.forum.communication.rmi.SpecificDeviceManagerRMI,<atmWorkstation>,AppTest,2006;<jxfsserverhostname>,");
Then you can get the remote device controls with getDevice(...), and start using them as if they were local devices.
Please, note that handling RMI ports can be tricky, specially in a secured environment as ATM network. Make sure all the ports you need are open.
I need to develop a software application for a computers in a network in the following scenario:
Computers in a network are monitored by another master computer running a controller program. The controller is a software appln which performs network discovery, gets data from the discovered computers and performs a set of operations on the discovered computers.
I have made progress until this level:
1. Program for network discovery. o/p is IPs of all the active machines on n/w.
2. Basic program implementing RMI(rejected sockets as the program might have diff implementations)
My doubts:
1.Assuming that I need to send the instructions of operation to be executed on client machines with diff IPs, how do I do it with RMI? How do I connect to other clients,in the first place using RMI?
2.After connecting, how do I transmit instructions to and fro the controller?
Please help me out!
You might try reading the JNDI tutorial. It covers aspects of discovering other computers and communicating them at a level that may be useful to your project. The tutorial is located here: http://download.oracle.com/javase/jndi/tutorial/trailmap.html
I have a Java program running on two computers that are both on the same network. I would like to have these applications become aware of each other, so they could communicate directly as opposed to communicating with the server to relay messages.
I believe i may have a solution as to how this would work, but am unable to find any examples to compare my solution against. Do you guys know how this problem is usually solved?
There is a good library that implements the Zeroconf / Bonjour standard in plain java at http://jmdns.sourceforge.net/
This basically relieves you from the protocol burden and allows you to advertise and lookup service providers based in logical names (That's what iTunes or Mac printing does for example).
This book http://www.amazon.com/Zero-Configuration-Networking-Definitive-Guide/dp/0596101007 explains all basic concepts.
You could get them to do a UDP multicast within a LAN environment to identify the programs using protocol messages then have a stored cache of each other's identity and then use TCP to connect and do main exchanging of messages (which is more reliable than UDP). Or you can simply proceed with UDP messaging only if you want to.
You can search for multicasting in Java online.
Some multicast related links:
http://download.oracle.com/javase/1.4.2/docs/api/java/net/MulticastSocket.html
http://www.javafaq.nu/java-article817.html
A good multicast chat software you can reference:
http://sourceforge.net/projects/mc2/
One way would be to send a broadcast to see who's out there, then implement a GUI to show the user what other peers are there and give an option to connect to. (The broadcast will give you the IP address of everybody there.)
Once you know who to connect to, you simply open a TCP connection (or use UDP if it is time-critical) and you're done.
Btw, this is for IPv4 - IPv6 doesn't have broadcast (although something similar).
I've been using RMI for a project I am currently working on and I want to bind from multiple hosts to a single RMI registry.
However when I attempt to do so I get an error saying
java.rmi.AccessException: Registry.Registry.bind disallowed; origin / 192.168.0.9 is non-local host
I did so googling and it seems that RMI stops remote hosts from binding by default, what I want to know is there some way of overriding or bypassing this?
If anyone any suggestions on how to get past this issue they would be highly appreciated, i've tried using different policy files and overriding the security manger but none seem to work.
There's a way to get around the limitation but it is what it is: a work-around. Anyway, feel free to try it out. It works for us.
On the host that is running the central RMI registry run a small service which will bind a remote object with just one remote method: proxyRebind. The implementation of this method simply binds the object that is supplied to it in the central registry (this would not fail because the registry is on the same machine as this service).
All other hosts would simply lookup this remote object and invoke proxyRebind with their own remote objects.
This works because look-up on remotely hosted registries is allowed. Your original attempt failed because binding on remotely hosted registries is not allowed.
Let me know if you need any further clarity on this.
/RS
2 There's a way to get around
the limitation but it is what it is: a
work-around. Anyway, feel free to try
it out. It works for us.
On the host that is running the
central RMI registry run a small
service which will bind a remote
object with just one remote method:
proxyRebind. The implementation of
this method simply binds the object
that is supplied to it in the central
registry (this would not fail because
the registry is on the same machine as
this service).
All other hosts would simply lookup
this remote object and invoke
proxyRebind with their own remote
objects.
This works because look-up on remotely
hosted registries is allowed. Your
original attempt failed because
binding on remotely hosted registries
is not allowed.
Let me know if you need any further
clarity on this.
This perfectly works. The only thing to take care is following should be always set correctly.
-Djava.rmi.server.hostname="LOCAL HOST IP"
I may be misunderstanding your question, if so please let me know.
I have limited experience with Java RMI, we used it in our Design Patterns class with the Proxy Pattern. (Textbook: Headfirst Design Patterns)
We were not able to get our projects working from outside the university network, but they worked perfectly when connected directly to the network. According to our professor, it wasn't possible to use RMI in our implementation over the internet or wan. A solution she suggested was that a VPN would be required. I believe Vladimir is correct in that it has to do with it being a local naming service.
I may be wrong, but it looks like rmiregistry application is essentially a wrapper over local naming service. Which means there is no way to make it point to remote objects.
What you need is a Naming implementation, and clustered at this. Consider to move into J2EE AS clustering solution. JNDI tree is shared within the cluster.
Thanks for everyones answers the solution I came up with in the end was to use the Cajo Framework this gives a very flexible system for distribution and it allowed for me to handle the registry as I saw fit. It can also work behind NATs, firewalls, and HTTP proxies, which is very useful.
I believe that the method of proxying suggested by rndm.buoy will work in some cases but its may be troublesome on some system. RMI seems to have some issues with associating to the wrong Network Interface I particularly had this issue when running on Debian based Linux distributions.