/// <summary>Register a listener for tasks completion notifications emitted by all the nodes</summary> /// <param name="client">The JPPF client from which to get a JMX connection</param> /// <returns>An id string assigned to the registered listener</returns> public static string RegisterTaskNotificationListener(JPPFClient client) { // name of the node task monitor MBean string mbeanName = JPPFNodeTaskMonitorMBeanStaticProxy.getMBeanName(); // only receive notifications from .Net-capable nodes ExecutionPolicy dotnetPolicy = new Equal("jppf.dotnet.bridge.initialized", true); NodeSelector selector = new ExecutionPolicySelector(dotnetPolicy); // register the forwarding listener with the driver JMXDriverConnectionWrapper jmx = GetJMXConnection(client); string listenerId = jmx.RegisterFowrwardingNotificationListener(selector, mbeanName, new MyTaskNotificationListener(), "task notification"); Console.WriteLine("registered task notifications listener with listenerId = " + listenerId); // return the listener id so it can be eventually removed later return(listenerId); }
/// <summary>Provision the specified number of slave nodes. /// This method forwards the provisioning request to all relevant nodes via the driver</summary> /// <param name="client">The JPPF client connected to the server</param> /// <param name="nbNodes">The number of slave nodes to provision</param> public static void ProvisionNodes(JPPFClient client, int nbNodes) { // we are invoking the remote provisioning mbeans string mbeanName = JPPFNodeProvisioningMBeanStaticProxy.getMBeanName(); // policy applied on master nodes with a .Net bridge initialized ExecutionPolicy masterPolicy = new Equal("jppf.node.provisioning.master", true).and(new Equal("jppf.dotnet.bridge.initialized", true)); NodeSelector masterSelector = new ExecutionPolicySelector(masterPolicy); // parameters to the MBean method java.lang.Object[] parameters = { new java.lang.Integer(nbNodes), null }; // Java signature of the remote MBean method to invoke java.lang.String[] signature = { "int", "org.jppf.utils.TypedProperties" }; // send the request via the forwarding mbean JMXDriverConnectionWrapper jmx = GetJMXConnection(client); JPPFNodeForwardingMBeanStaticProxy proxy = new JPPFNodeForwardingMBeanStaticProxy(jmx); proxy.forwardInvoke(masterSelector, mbeanName, "provisionSlaveNodes", parameters, signature); }