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 
July 12, 2020, 06:07:40 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: Problem in accessing URLs  (Read 4574 times)

Abhilash K

  • JPPF Grand Master
  • ****
  • Posts: 64
Problem in accessing URLs
« on: December 11, 2006, 08:24:39 AM »

Hii,

       I tried to access a URL from my client, but i cant make it.  Is there any other permissions to be set while doing so?  Pls anybody help me, its very urgent.

Regds,
       Abhilash
Logged

Abhilash K

  • JPPF Grand Master
  • ****
  • Posts: 64
Problem in accessing URL through my client
« Reply #1 on: December 11, 2006, 09:33:36 AM »

Dear lolo,

        I tried to access URL information from my client, i will put the code below.  I have my server and node running on another machine, and client in my machine.  Is that any other permissions to be set while using the URL?  my code for the client is as follows.

URLExtractor.java
-------------------------
package sample.url;

import java.util.*;
import java.io.*;
import java.net.*;
import org.apache.log4j.Logger;
import org.jppf.JPPFException;
import org.jppf.client.JPPFClient;
import org.jppf.server.JPPFStats;
import org.jppf.server.protocol.JPPFTask;
import org.jppf.task.storage.*;
import org.jppf.utils.*;

public class URLExtractor
{
   static Logger log = Logger.getLogger(URLExtractor.class);
      
   public static void main(String args[])
   {
      try {
         // JPPF client initialization
         JPPFClient client=new JPPFClient();
                  
         //String strURL = "http://www.marketics.com";
         //URLs myURL=new URLs(strURL);
         
         List<JPPFTask> tasks = new ArrayList<JPPFTask>();
         tasks.add(new ExtractTask());
      
         // submit and get results
         List<JPPFTask> results = client.submit(tasks, null);
         
         //ExtractTask extractTask = (ExtractTask) results.get(0);
         //URL url=(URL) extractTask.getResult();
         //InputStream is= (InputStream) extractTask.getResult();
         
         // Results after reading url
         //System.out.print(url.toExternalForm());
            
         // Statistics
         JPPFStats stats = client.requestStatistics();
         System.out.println("End statistics :\n"+stats.toString());
         System.out.println("\nTasks executed normally\n");
      }
      catch (Exception e) {
         e.printStackTrace();
      }
      
   }
}

----------------------------------------------
ExtractTask.java

package sample.url;

import org.jppf.server.protocol.JPPFTask;
import java.io.*;
import java.net.*;

public class ExtractTask extends JPPFTask {
   
   InputStream is=null;
   URL url;
   int c;
      
   public ExtractTask(){
      //this.url=url;
   }
      
   public void run(){
      try{
         url=new URL("http://www.marketics.com");
         is=url.openStream();
         if(is.available()>0){
            int i=is.available();
            while(((c=is.read())!= -1)&&(--i > 0)){
               System.out.print((char)c);
            }
         }
      }catch(Exception e){
         e.printStackTrace();
      }
      System.out.println("-----------\nTask Done\n------------");
   }
   
   /*public Object getResult(){
      return url;
   }*/
}
---------------------------------------
   its just helding up at


run.url.noui:

run.extracturl:
     [echo] starting the 'URL Extraction Application'
     [java] ClassServerDelegate.init(): Attempting connection to the class serve
r
     [java] ClassServerDelegate.init(): Reconnected to the class server
     [java] JPPFClient.init(): Attempting connection to the JPPF driver
     [java] JPPFClient.init(): Reconnected to the JPPF driver

        and no execution taking place.  while i can run other applications.

        pls get me a solution, its very urgent.

regds,
        abhilash
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2262
    • JPPF Web site
Problem in accessing URLs
« Reply #2 on: December 13, 2006, 09:52:27 PM »

Abiulash,

Please, in your task, make the input stream instance variable transient, as InputStream is not serializable.

-Laurent
Logged

Abhilash K

  • JPPF Grand Master
  • ****
  • Posts: 64
Thanks
« Reply #3 on: December 14, 2006, 05:50:41 AM »

Hii Laurent,

           that prob is solved.  thanks.  but pls let me know how can i solve the parallelisation problem?  should i need to create threads in the run() method?  or suppose i am sending 100 tasks , will it distribute between nodes, or only one node will execute the same?  pls get me a solution for the same.  pls look at my query in the "probs in parallelisation".

Regds,
         abhilash
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