Package org.apache.vinci.transport

Examples of org.apache.vinci.transport.BaseClient


    try {
      VNSQuery vq = new VNSQuery(args[0], Integer.parseInt(args[1]));

      ArrayList list = vq.getServices(args[2]);
      System.out.println("Got::" + list.size() + " Services");
      BaseClient client = null;
      for (int i = 0; i < list.size(); i++) {
        Object ob = list.get(i);
        if (ob != null) {
          System.out.println(((VinciServiceInfo) ob).toString());
          VinciServiceInfo serviceInfo = (VinciServiceInfo) ob;
          if (serviceInfo != null) {
            try {
              client = new BaseClient(serviceInfo.getHost(), serviceInfo.getPort());
              if (client.isOpen()) {
                System.out.println("Service::" + serviceInfo.getServiceName() + " is alive");
              }
            } catch (ConnectException ce) {
              System.out.println("Service::" + serviceInfo.getServiceName() + " is down");
            }
View Full Code Here


     *           unable to connect to VNS
     */
    public VinciVNSQuery(String aVnsHost, int aVnsPort) throws Exception {
      vnsHost = aVnsHost;
      vnsPort = aVnsPort;
      vnsConnection = new BaseClient(vnsHost, vnsPort);
    }
View Full Code Here

     * @throws Exception -
     *           error while looking up the service
     */
    public ArrayList getVinciServices(String aVinciServiceName) throws Exception {
      ArrayList serviceList = new ArrayList();
      BaseClient client = null;
      // make sure we got a valid connection to VNS
      if (vnsConnection != null && vnsConnection.isOpen()) {
        // Set up VNS query
        VinciFrame queryFrame = new VinciFrame();
        queryFrame.fadd("vinci:COMMAND", "getlist");
        queryFrame.fadd("PREFIX", aVinciServiceName);
        // System.out.println("Query Frame:::"+queryFrame.toXML());
        // Query the VNS
        VinciFrame response = (VinciFrame) vnsConnection.sendAndReceive(queryFrame);
        ArrayList serviceFrames = response.fget("SERVICE");
        // Each service is returned in its own SERVICE frame. So cycle through those now
        // one at a time
        for (int i = 0; i < serviceFrames.size(); i++) {
          VinciFrame serviceFrame = (VinciFrame) serviceFrames.get(i);
          // Copy data from the frame ( host, port etc)
          VinciServiceInfo serviceInfo = getServiceInfo(serviceFrame);
          if (serviceInfo != null) {
            // Test the service for availability. Use only those services that respond. The list
            // may contain stale services that are not running
            try {
              // Establish a brief connection to test for availability. This test fails gracefully
              // Its not an error if the service does not respond. The retry logic is done
              // elsewhere.
              client = new BaseClient(serviceInfo.getHost(), serviceInfo.getPort());
              if (client.isOpen()) {
                if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
                  UIMAFramework.getLogger(this.getClass()).logrb(
                          Level.FINEST,
                          this.getClass().getName(),
                          "initialize",
                          CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                          "UIMA_CPM_service_active_on_port__FINEST",
                          new Object[] { Thread.currentThread().getName(),
                              serviceInfo.getServiceName(), serviceInfo.getHost(),
                              String.valueOf(serviceInfo.getPort()) });
                }
                // Service is ok, so add it to the list
                serviceList.add(serviceInfo);
              }
            } catch (ConnectException ce) {
              if (UIMAFramework.getLogger().isLoggable(Level.WARNING)) {
                UIMAFramework.getLogger(this.getClass()).logrb(
                        Level.WARNING,
                        this.getClass().getName(),
                        "initialize",
                        CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                        "UIMA_CPM_service_not_active_on_port__WARNING",
                        new Object[] { Thread.currentThread().getName(),
                            serviceInfo.getServiceName(), serviceInfo.getHost(),
                            String.valueOf(serviceInfo.getPort()) });
              }
            } finally {
              // Drop the connection if necessary.
              if (client != null) {
                try {
                  client.close();
                } catch (Exception ex) {
                }
              }
            }
          }
View Full Code Here

        if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
          UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                  "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_vns_redirect__FINEST",
                  new Object[] { Thread.currentThread().getName(), publicVNSHost, publicVNSPort });
        }
        BaseClient client = new BaseClient(publicVNSHost, pvnsPort);
        return client.sendAndReceive(in);
      } else {
        if (UIMAFramework.getLogger().isLoggable(Level.WARNING)) {
          UIMAFramework.getLogger(this.getClass()).logrb(Level.WARNING, this.getClass().getName(),
                  "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_unknown_vns_command__WARNING",
View Full Code Here

          UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                  "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_connect_to_service__FINEST",
                  new Object[] { Thread.currentThread().getName(), aHost, String.valueOf(aPort) });
        }
        conn = new BaseClient(aHost, aPort);
        conn.setSocketTimeout(timeout);
        conn.setRetry(false);

        serviceHost = conn.getHost();
        servicePort = String.valueOf(conn.getPort());
View Full Code Here

        if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
          UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                  "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_vns_redirect__FINEST",
                  new Object[] { Thread.currentThread().getName(), publicVNSHost, publicVNSPort });
        }
        BaseClient client = new BaseClient(publicVNSHost, pvnsPort);
        return client.sendAndReceive(in);
      } else {
        if (UIMAFramework.getLogger().isLoggable(Level.WARNING)) {
          UIMAFramework.getLogger(this.getClass()).logrb(Level.WARNING, this.getClass().getName(),
                  "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_unknown_vns_command__WARNING",
View Full Code Here

          UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                  "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_connect_to_service__FINEST",
                  new Object[] { Thread.currentThread().getName(), aHost, String.valueOf(aPort) });
        }
        conn = new BaseClient(aHost, aPort);
        conn.setSocketTimeout(timeout);
        conn.setRetry(false);

        serviceHost = conn.getHost();
        servicePort = String.valueOf(conn.getPort());
View Full Code Here

          UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                  "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_connect_to_service__FINEST",
                  new Object[] { Thread.currentThread().getName(), aHost, String.valueOf(aPort) });
        }
        conn = new BaseClient(aHost, aPort);
        conn.setSocketTimeout(timeout);
        conn.setRetry(false);

        serviceHost = conn.getHost();
        servicePort = String.valueOf(conn.getPort());
View Full Code Here

TOP

Related Classes of org.apache.vinci.transport.BaseClient

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.