Package org.apache.uima.ducc.cli

Examples of org.apache.uima.ducc.cli.AServicePing


    // resolve the customMeta string inta a class if we can
    //
    AServicePing resolve(String cl, String args, String ep)
    {
      print("ServicePingMain.resolve:", cl, "ep", ep);
      AServicePing pinger = null;
    try {
      @SuppressWarnings("rawtypes")
      Class cls = Class.forName(cl);
      pinger = (AServicePing) cls.newInstance();
      pinger.init(args, ep);
    } catch (Exception e) {
            //print(e);         // To the logs
            e.printStackTrace();
    }
        return pinger;
View Full Code Here


    } catch (IOException e1) {
      e1.printStackTrace();
      return;
    }       

        AServicePing custom = resolve(pingClass, arguments, endpoint);
        if ( custom == null ) {
            print("bad_pinger:", pingClass, endpoint);
            return;
        }

        while ( true ) { 
          if ( debug ) print("ServicePingMeta starts ping.");
         
            byte[] cmd = new byte[1];
            cmd[0] = 0;
            int eof = 0;
      try {
        eof = sock_in.read(cmd);
      } catch (IOException e) {
                handleError(e);
      }
            if ( debug ) print("Read cmd", new String(cmd), "eof", eof);

            if ( eof == -1 ) {
                print("EOF on input pipe.  Exiting");
                custom.stop();
                return;
            }

            try {
        if ( cmd[0] == 'P' ) {
                    IServiceStatistics ss = custom.getStatistics();
                    if ( ss == null ) {
                        ss = default_statistics;
                    }
                    // print("Is alive: " + ss.isAlive());
                    oos.writeObject(ss);
                    oos.flush();

                    // The ObjectOutputStream will cache instances and if all you do is change a
                    // field or two in the object, it won't be detected and the stale object will be
                    // sent.  So you have to reset() the stream, (or use a new object, or use
                    // clone() here also if you want, but this is simplest and safest since we have
                    // no control over what the external pinger gives us.
                    oos.reset();
        } else if ( cmd[0] == 'Q' ) {
            custom.stop();               
            return;
        } else {
            System.err.println("Invalid command recieved: " +  Byte.toString(cmd[0]));
        }
      } catch (Throwable e) {
View Full Code Here

TOP

Related Classes of org.apache.uima.ducc.cli.AServicePing

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.