// wait until a connection to the driver is properly establishedwhile (!client.hasAvailableConnection()) Thread.sleep(10L);JMXDriverConnectionWrapper jmxDriver = null;while ((jmxDriver = client.getClientConnection().getJmxConnection()) == null) Thread.sleep(10L);// wait until a JMX connection to the driver is establishedwhile (!jmxDriver.isConnected()) Thread.sleep(10L);
public class MyNotificationListener implements NotificationListener { @Override public void handleNotification(Notification notification, Object handback) { TaskExecutionNotification taskNotif = (TaskExecutionNotification) notification; boolean userDefined = taskNotif.getTaskInformation().getCpuTime() < 0; // ..... }}
handback - An opaque object which helps the listener to associate information regarding the MBean emitter. This object is passed to the addNotificationListener call and resent, without modification, to the listener
JPPFClient jppfClient = new JPPFClient();JPPFJob job = new JPPFJob();JPPFResultCollector collector = new JPPFResultCollector(job) { @Override public synchronized void resultsReceived(TaskResultEvent event) { super.resultsReceived(event); // Get the partial results from a single node List<Task<?>> myResults = event.getTasks(); // ... work with the results }};job.setResultListener(collector);jppfClient.submitJob(job);
JobListener jobListener = new JobListenerAdapter() { @Override public void jobReturned(JobEvent event) { // synchronize over potentially parallel calls, e.g. when the client has multiple connections to the server synchronized(event.getJob()) { // get the partial results List<Task<?>> myResults = event.getJobTasks(); // ... work with the results } }};job.addJobListener(jobListener);jppfClient.submitJob(job);