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 13, 2021, 04:25:06 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: Client submitting one Job at a time using J2EE Connector  (Read 3613 times)

UomoFurioso

  • JPPF Padawan
  • *
  • Posts: 6
Client submitting one Job at a time using J2EE Connector
« on: September 04, 2012, 04:02:36 PM »

Greetings,

I searched the forum for an answer, but only found a post about job queue using J2SE JPPF client:

http://www.jppf.org/forums/index.php/topic,1731.msg4202.html#msg4202

it was very helpful to better understand configuration options and getting my test grid working, but still I can only execute a single job at a time, with others submitted but not queued to the driver, resulting in only one node used while others idle.

I'm building a client based on web services deployed on a JBoss 4.2.3, with the J2EE Connector to submit jobs to a JPPF driver.
I want the WS to be asynchronous, so I'm using (or trying to) non-blocking jobs, relying on listeners to retrieve and manage execution results.

Simply put an external request calls the WS with parameters to build the job. The WS, after parameter parsing, calls a class named JobBuilder that follows the rules depicted in the basic tutorial and discussed in so many threads.

A simplified version of JobBuilder, with all the executed code and some added comments:

Code: [Select]
public class JobBuilder {

    public String submitJob(GridJobRequest gj, long idJob) throws Exception {
        JPPFConnection connection = null;
        String jobId = "-4";
        try {
            // create a JPPF job
            JPPFJob job = new JPPFJob();
            job.setBlocking(false);

            // added lately after reading a post in this forum, but doesn't make any difference
            job.getSLA().setCancelUponClientDisconnect(false);

            // to just give a custom random name
            job.setName("ID"+Math.rint(Math.random()*100000));
           
            // I could be asked to build more than one job, but in my tests it's always only one, with one task
            List<TaskType> tt = gj.getTasks().getTask();
            for (int j = 0; j < tt.size(); j++) {
                String logicName = tt.get(j).getName();

                if (logicName.equalsIgnoreCase("DC")) {
                    // Simple task that waits 10 secs, as per many examples
                    job.addTask(new DemoTask());
                }


            }
            // get a JPPF Connection from helper class
            connection = JPPFHelper.getConnection();
            // Use the connection to submit the JPPF job and obtain a submission ID
            jobId = connection.submit(job);

            // I removed the listeners to simplify the test, but already got this working :)
            // jobId = connection.submit(job, new SubmissionStatusListenerImpl());

            return jobId;
        } catch (Exception e) {
            e.printStackTrace();
            return "-3";
        } finally {
            // close the connection
            JPPFHelper.closeConnection(connection);
        }
    }
}

The J2EE Connector is configured to manually connect to a remote JPPF driver and two nodes are automatically connected to it (the nodes and JBoss server are actually on the same PC).

Here is the configuration file (ra.xml), where I map the driver and the connection pool size:

Code: [Select]
<!-- JPPF Client Configuration -->
<config-property>
<config-property-name>ClientConfiguration</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>
#jppf.drivers = driver1 driver2
jppf.drivers = driver1

#driver1.jppf.server.host = 192.168.90.123
#driver1.jppf.server.host = localhost
driver1.jppf.server.host = 192.168.192.130
driver1.jppf.server.port = 11111
driver1.priority = 10
driver1.jppf.pool.size = 5


#driver2.jppf.server.host = 192.168.90.124
#driver2.jppf.server.port = 11198
#driver2.priority = 10
#driver2.jppf.pool.size = 5

#jppf.management.port = 11098
#driver1.jppf.management.enabled = true
#driver1.jppf.management.host = 192.168.192.130
#jppf.client.max.init.time = 1000
#reconnect.initial.delay = 1
reconnect.max.time = 10
#reconnect.interval = 1

jppf.remote.execution.enabled = true
#jppf.local.execution.enabled = true
#jppf.local.execution.threads = 4

jppf.discovery.enabled = false
#jppf.discovery.group = 230.0.0.1
#jppf.discovery.port = 11111
#jppf.pool.size = 5

#jppf.data.transform.class = org.jppf.data.transform.DESCipherTransform
#jppf.object.stream.builder = org.jppf.serialization.XstreamObjectStreamBuilder
</config-property-value>
</config-property>

and the helper class, named JPPFHelper:

Code: [Select]
public class JPPFHelper {

    // JNDI name of the JPPFConnectionFactory
    private static final String JNDI_NAME = "java:eis/JPPFConnectionFactory";
    private static final JPPFConnectionFactory connectionFactory;

    static {
        // Perform a JNDI lookup of the JPPF connection factory
        JPPFConnectionFactory factory = null;
        try {
            InitialContext ctx = new InitialContext();
           
            Object objref = ctx.lookup(JNDI_NAME);

            if (objref instanceof org.jppf.jca.cci.JPPFConnectionFactory) {
                factory = (org.jppf.jca.cci.JPPFConnectionFactory) objref;
            } else {
                try {
                    factory = (JPPFConnectionFactory) javax.rmi.PortableRemoteObject.narrow(
                            objref, ConnectionFactory.class);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
           
        } catch (Throwable ex) {
            System.err.println("Initial ConnectionFactory creation failed." + ex);
            // throw new Exception(ex);
        }
        connectionFactory = factory;
    }
   
    // Obtain a JPPF connection from the resource adapter's connection pool
    public static JPPFConnection getConnection() throws Exception {
        // get a JPPFConnection from the connection factory
        return (JPPFConnection) connectionFactory.getConnection();
    }
    // Release a connection
    public static void closeConnection(JPPFConnection connection)
            throws ResourceException {
        connection.close();
    }
}

I modified it a bit, but widely tested with the structure proposed in the tutorial apparently doesn't make any difference.

For completeness here's the DemoTask code:

Code: [Select]
public class DemoTask extends JPPFTask implements Serializable {

    private static final long serialVersionUID = -6106765904127535863L;

    public DemoTask() {
        // perform initializations here ...
    }

    @Override
    public void run() {
        try {
            Thread.sleep(10000L);
            setResult("result OK");

            // used to test the job listener
            //setException(new Exception("*** Custom Exception ***"));
        } catch (Exception e) {
            setException(e);
            e.printStackTrace();
            return;
        }
        //setResult("the execution was performed successfully");
    }
}

Starting JBoss I see the connection pool creation and (from outputs I removed in the code) the job creation, submission, connection release and the WS correctly returning without waiting for job execution.

Code: [Select]
...
15:44:00,562 INFO  [AbstractGenericClient] connection [driver1-1] created
15:44:00,593 INFO  [AbstractGenericClient] connection [driver1-2] created
15:44:00,593 INFO  [AbstractGenericClient] connection [driver1-3] created
15:44:00,609 INFO  [AbstractGenericClient] connection [driver1-4] created
15:44:00,609 INFO  [AbstractGenericClient] connection [driver1-5] created
...

... (following log exists for all 5 connections)
15:44:02,125 INFO  [JcaClassServerDelegate] [client: driver1-1] Reconnected to t
he class server
...

When I send three requests to the WS, they all get served and exit after job submission.
From JPPF admin UI I can monitor the job execution and it shows they arrive to the driver sequentially (queue size is never greater than 1), obviously using one node at a time while the other is idle and could get some work from another Job (that's the application main goal).

It all seems very straight and simple to me, but I'm not getting what I expect.

Any suggestion? If I missed to give any useful information I'll be happy to improve this (long) post.

Thank in advance

Uomo Furioso (LG)
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2269
    • JPPF Web site
Re: Client submitting one Job at a time using J2EE Connector
« Reply #1 on: September 05, 2012, 08:47:25 AM »

Hello Uomo,

Thank you for your report.
I was able to reproduce the same behavior, and I registered a bug for this: JPPF-59 Cannot submit multiple jobs concurrently with JCA adaptor .

I am working on it and will keep you updated in this forum thread.

Sincerely,
-Laurent
Logged

UomoFurioso

  • JPPF Padawan
  • *
  • Posts: 6
Re: Client submitting one Job at a time using J2EE Connector
« Reply #2 on: September 05, 2012, 09:29:29 AM »

Good morning Laurent,

thanks a lot for your quick reply.

I forgot to tell I'm working in a JPPF 3.1.1 environment, but I guess it makes little difference now  :)

Have a nice day.

UF
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2269
    • JPPF Web site
Re: Client submitting one Job at a time using J2EE Connector
« Reply #3 on: September 08, 2012, 11:25:59 AM »

Hello,

I have now fixed this issue. It will be delivered in the next maintenance release of JPPF (v3.1.3),  by the end of this month.

Sincerely,
-Laurent
Logged

UomoFurioso

  • JPPF Padawan
  • *
  • Posts: 6
Re: Client submitting one Job at a time using J2EE Connector
« Reply #4 on: September 10, 2012, 09:30:24 AM »

Good morning,

I'm happy to hear good news and looking forward to get JPPF 3.1.3

Sincerely,

UF
Logged

UomoFurioso

  • JPPF Padawan
  • *
  • Posts: 6
Re: Client submitting one Job at a time using J2EE Connector
« Reply #5 on: September 26, 2012, 11:10:15 AM »

Hello,

installed and tested JPPF 3.1.3 as soon as available and now all seems to work as espected.

Thanks a lot  :)

UF
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