Package org.apache.uima.ducc.common

Examples of org.apache.uima.ducc.common.IServiceStatistics


        meta_props.put("service-alive",      "false");
        meta_props.put("service-healthy",    "false");
        meta_props.put("service-statistics", "N/A");
       
        if ( serviceMeta != null ) {
            IServiceStatistics ss = serviceMeta.getServiceStatistics();
            if ( ss != null ) {
                meta_props.put("service-alive",      "" + ss.isAlive());
                meta_props.put("service-healthy",    "" + ss.isHealthy());
                meta_props.put("service-statistics", "" + ss.getInfo());
            }
        }
       
        FileOutputStream fos = null;
        try {           
View Full Code Here


        Options options = new Options();
        addOptions(options);

        CommandLineParser parser = new PosixParser();
        CommandLine commandLine = null;
        IServiceStatistics default_statistics = new ServiceStatistics(false, false, "<N/A>");

    try {
      commandLine = parser.parse(options, args);
    } catch (ParseException e) {
            print("Cannot parse command line:", e);
            return;
    }

        String arguments = commandLine.getOptionValue(ServicePing.Arguments.decode());
        String pingClass = commandLine.getOptionValue(ServicePing.Class.decode());
        String endpoint  = commandLine.getOptionValue(ServicePing.Endpoint.decode());
        String port      = commandLine.getOptionValue(ServicePing.Port.decode());

        Socket sock = null;
    try {
      sock = new Socket("localhost", Integer.parseInt(port));
    } catch (NumberFormatException e2) {
      e2.printStackTrace();
      return;
    } catch (UnknownHostException e2) {
      e2.printStackTrace();
      return;
    } catch (IOException e2) {
      e2.printStackTrace();
      return;
    }       
        print ("ServicePingMain listens on port", sock.getLocalPort());
        InputStream sock_in = null;
    OutputStream sock_out = null;
    try {
      sock_in = sock.getInputStream();
      sock_out = sock.getOutputStream();
    } catch (IOException e2) {
      e2.printStackTrace();
      return;
    }

        ObjectOutputStream oos;
    try {
      oos = new ObjectOutputStream(sock_out);
      oos.flush();
    } 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);
View Full Code Here

            return;
    }


        while ( true ) {
            IServiceStatistics qs = null;
            try {
                qs = m.getStatistics();
            } catch (Throwable t) {
                System.out.println("Cannot collect stats.  The queue may have been deleted. Details:");
                t.printStackTrace();
                return;
            }
            System.out.println(qs.toString());
            try {
        Thread.sleep(3000);
      } catch (InterruptedException e) {
      }
        }
View Full Code Here

    }

    public IServiceStatistics getStatistics()
    {
        String methodName = "getStatistics";
        IServiceStatistics statistics = new ServiceStatistics(false, false, "<NA>");
        nodeIp = "N/A";
        pid = "N/A";

        evaluateBrokerStatistics(statistics);       // if we get here, the get-meta worked well enough

        // Instantiate Uima AS Client
        BaseUIMAAsynchronousEngine_impl uimaAsEngine = new BaseUIMAAsynchronousEngine_impl();
        UimaCbListener listener = new UimaCbListener();
        uimaAsEngine.addStatusCallbackListener(listener);
        Map<String, Object> appCtx = new HashMap<String, Object>();
        appCtx.put(UimaAsynchronousEngine.ServerUri, broker);
        appCtx.put(UimaAsynchronousEngine.ENDPOINT, endpoint);
        appCtx.put(UimaAsynchronousEngine.GetMetaTimeout, meta_timeout);

        try {
            uimaAsEngine.initialize(appCtx);
            statistics.setAlive(true);
            statistics.setHealthy(true && statistics.isHealthy());
            listener.ok();
        } catch( ResourceInitializationException e) {
            listener.timeout();
            doLog(methodName, "Cannot issue getMeta to: " + endpoint + ":" + broker);
            statistics.setHealthy(false);
            statistics.setAlive(false);
        } finally {
            try {
        uimaAsEngine.stop();
      } catch (Throwable e) {
        doLog(methodName, "Exception on UIMA-AS connection stop:" + e.toString());
      }
        }

        monitor.setSource(nodeIp, pid, gmfail);
        statistics.setInfo(monitor.format());

        return statistics;
    }
View Full Code Here

TOP

Related Classes of org.apache.uima.ducc.common.IServiceStatistics

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.