Package org.apache.nutch.io

Examples of org.apache.nutch.io.Writable


  /** Called for each call. */
  public abstract Writable call(Writable param) throws IOException;

 
  private Writable makeParam() {
    Writable param;                               // construct param
    try {
      param = (Writable)paramClass.newInstance();
    } catch (InstantiationException e) {
      throw new RuntimeException(e.toString());
    } catch (IllegalAccessException e) {
View Full Code Here


          }
       
          if (LOG.isLoggable(Level.FINE))
            LOG.fine(getName() + " got #" + id);
       
          Writable param = makeParam();           // read param
          param.readFields(in);       
       
          Call call = new Call(id, param, this);
       
          synchronized (callQueue) {
            callQueue.addLast(call);              // queue the call
View Full Code Here

          if (LOG.isLoggable(Level.FINE))
            LOG.fine(getName() + ": has #" + call.id + " from " +
                     call.connection.socket.getInetAddress().getHostAddress());
         
          String error = null;
          Writable value = null;
          try {
            value = call(call.param);             // make the call
          } catch (IOException e) {
            LOG.log(Level.INFO, getName() + " call error: " + e, e);
            error = e.getMessage();
          } catch (Exception e) {
            LOG.log(Level.INFO, getName() + " call error: " + e, e);
            error = e.toString();
          }
           
          DataOutputStream out = call.connection.out;
          synchronized (out) {
            out.writeInt(call.id);                // write call id
            out.writeBoolean(error!=null);        // write error flag
            if (error != null)
              value = new UTF8(error);
            value.write(out);                     // write value
            out.flush();
          }

        } catch (Exception e) {
          LOG.log(Level.INFO, getName() + " caught: " + e, e);
View Full Code Here

    }
    return connection;
  }

  private Writable makeValue() {
    Writable value;                             // construct value
    try {
      value = (Writable)valueClass.newInstance();
    } catch (InstantiationException e) {
      throw new RuntimeException(e.toString());
    } catch (IllegalAccessException e) {
View Full Code Here

            UTF8 utf8 = new UTF8();
            utf8.readFields(in);                  // read error string
            call.error = utf8.toString();
            call.value = null;
          } else {
            Writable value = makeValue();
            value.readFields(in);                 // read value
            call.value = value;
            call.error = null;
          }
          call.callComplete();                   // deliver result to caller
        }
View Full Code Here

TOP

Related Classes of org.apache.nutch.io.Writable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.