Examples of VinciFrame


Examples of org.apache.vinci.transport.VinciFrame

   * @see org.apache.uima.resource.service.ResourceServiceStb#callGetMetaData()
   */
  public ResourceMetaData callGetMetaData() throws ResourceServiceException {
    try {
      // create Vinci Frame
      VinciFrame queryFrame = new VinciFrame();
      // Add Vinci Command, so that the receiving service knows what to do
      queryFrame.fadd("vinci:COMMAND", "GetMeta");
      // Send the request to the service and wait for response

      if (debug) {
        System.out.println("Calling GetMeta");
      }

      mVinciClient.setTransportableFactory(AFrame.getAFrameFactory());
      VinciFrame resultFrame = mVinciClient.rpc(queryFrame, mGetMetaDataTimeout);

      if (debug) {
        System.out.println("Success");
      }

      // Extract the data from Vinci Response frame
      // System.out.println(resultFrame.toXML()); //DEBUG

      // Remove things from the result frame that are not the MetaData objects we expect.
      // In the future other things may go in here.
      int i = 0;
      while (i < resultFrame.getKeyValuePairCount()) {
        String key = resultFrame.getKeyValuePair(i).getKey();
        if (key.length() < 8 || !key.substring(key.length() - 8).equalsIgnoreCase("metadata")) {
          resultFrame.fdrop(key);
        } else {
          i++;
        }
      }

View Full Code Here

Examples of org.apache.vinci.transport.VinciFrame

        return null; // oneway method call; do NOT return anythingl
        // not even an empty frame
      } else if (Constants.COLLECTION_PROCESS_COMPLETE.equals(op)) {
        ct.cleanup();
        mAE.collectionProcessComplete();
        return new VinciFrame(); // no return value - return empty
        // frame
      } else if (Constants.IS_STATELESS.equals(op)) {
        ct.cleanup();
        return new AFrame().fadd("Result", mAE.isStateless());
      } else if (Constants.IS_READONLY.equals(op)) {
        ct.cleanup();
        return new AFrame().fadd("Result", mAE.isReadOnly());
      } else if (Constants.GET_SUPPORTED_XCAS_VERSIONS.equals(op)) {
        return new AFrame().fadd("Result", Constants.SUPPORTED_XCAS_VERSIONS_RESPONSE);
      } else if (Constants.SHUTDOWN.equals(op)) {
        stop();
        System.exit(1);
      }
      ct.cleanup();
      return new VinciFrame().fadd("Error", "Invalid Operation:" + op);
    } catch (Exception e) {
      e.printStackTrace();
      UIMAFramework.getLogger().log(Level.WARNING, e.getMessage(), e);
      // send back a Vinci frame with an Error key, whose value is the
      // exception message. Be careful not to try to send a null message,
      // since VinciFrame.fadd(key,null) does not add the key at all.
      String msg = e.getMessage();
      if (msg == null) {
        msg = "Error Processing Request";
      }
      return new VinciFrame().fadd("Error", msg);
    }
  }
View Full Code Here

Examples of org.apache.vinci.transport.VinciFrame

      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
View Full Code Here

Examples of org.apache.vinci.transport.VinciFrame

    return new ServiceInfo(result);
  }

  // Methods to perform service lookup
  public ServiceInfo[] lookup(String name, int level, String host, String instance, String ws) {
    VinciFrame req = new VinciFrame();

    req.fadd("vinci:COMMAND", VNSConstants.RESOLVE_COMMAND).fadd("SERVICE", name).fadd("LEVEL",
            level).fadd("HOST", host).fadd("INSTANCE", instance).fadd("WORKSPACE", ws);

    System.out.println(req.toXML());
    VinciFrame resp = (VinciFrame) transmit(req);

    checkError(resp);

    return constructServiceInfo(resp.fget("SERVER"), resp.fgetString("LEVEL"), name);
  }
View Full Code Here

Examples of org.apache.vinci.transport.VinciFrame

    return lookup(name, -1, host, instance, ws);
  }

  // Method to perform service resolve
  public ServiceInfo resolve(String name, String host, String ip, String ws, int level, int inst) {
    VinciFrame req = new VinciFrame();
    req.fadd("vinci:COMMAND", VNSConstants.RESOLVE_COMMAND).fadd("SERVICE", name);
    smFrameAdd(req, "HOST", host);
    smFrameAdd(req, "IP", ip);
    smFrameAdd(req, "WORKSPACE", ws);
    req.fadd("LEVEL", level);
    if (inst > 0) {
      req.fadd("INSTANCE", inst);
    }

    VinciFrame resp = (VinciFrame) transmit(req);

    checkError(resp);

    ServiceInfo[] S = constructServiceInfo(resp.fget("SERVER"), resp.fgetString("LEVEL"), name);

    return ((S.length > 0) ? S[R.nextInt(S.length)] : null);
  }
View Full Code Here

Examples of org.apache.vinci.transport.VinciFrame

    if (val != null && tag != null)
      v.fadd(tag, val);
  }

  public ServiceInfo resolve(String name, int level) {
    VinciFrame req = (VinciFrame) new VinciFrame().fadd("vinci:COMMAND",
            VNSConstants.RESOLVE_COMMAND).fadd("SERVICE", name).fadd("LEVEL", level);

    VinciFrame resp = (VinciFrame) transmit(req);

    checkError(resp);

    ServiceInfo[] S = constructServiceInfo(resp.fget("SERVER"), resp.fgetString("LEVEL"), name);

    return ((S.length > 0) ? S[R.nextInt(S.length)] : null);
  }
View Full Code Here

Examples of org.apache.vinci.transport.VinciFrame

    return resolve(name, -1);
  }

  // Method to get the list of services that are registered
  public ServiceInterface[] getList(String prefix, String level) {
    VinciFrame req = new VinciFrame();
    req.fadd("vinci:COMMAND", VNS.dirCmdGetList);
    req.fadd("LEVEL", level);
    smartAdd(req, "PREFIX", prefix);

    VinciFrame resp = (VinciFrame) transmit(req);

    checkError(resp);

    ArrayList A = resp.fget("SERVICE");
    Hashtable H;
    QueryableFrame Q;
    ServiceInterface[] S = new ServiceInterface[A.size()];
    for (int i = 0; i < A.size(); i++) {
      Q = (QueryableFrame) A.get(i);
View Full Code Here

Examples of org.apache.vinci.transport.VinciFrame

    return getList(null, level);
  }

  // Method to get the registered service names
  public String[] getNames(String prefix, String level) {
    VinciFrame req = new VinciFrame();
    req.fadd("vinci:COMMAND", VNS.dirCmdGetNames);
    req.fadd("LEVEL", level);
    smartAdd(req, "PREFIX", prefix);

    VinciFrame resp = (VinciFrame) transmit(req);

    checkError(resp);

    ArrayList A = resp.fget("SERVICE");
    String[] S = new String[A.size()];
    for (int i = 0; i < A.size(); i++) {
      S[i] = ((FrameLeaf) A.get(i)).toString().trim();
    }
View Full Code Here

Examples of org.apache.vinci.transport.VinciFrame

    return getNames(null, level);
  }

  // Method to get the hits for a particular service
  public int getHits(String type) {
    VinciFrame out = new VinciFrame();
    out.fadd("vinci:COMMAND", VNS.dirCmdGetHits);
    smartAdd(out, "TYPE", type);
    VinciFrame resp = (VinciFrame) transmit(out);

    checkError(resp);

    return (resp.fgetInt("HITS"));
  }
View Full Code Here

Examples of org.apache.vinci.transport.VinciFrame

    return getHits(null);
  }

  // Method to get all the hits
  public HitsList getAllHits() {
    VinciFrame out = new VinciFrame();
    out.fadd("vinci:COMMAND", VNS.dirCmdGetHits);
    out.fadd("TYPE", "all");

    VinciFrame resp = (VinciFrame) transmit(out);

    checkError(resp);

    HitsList H = new HitsList();
    H.totalhits = resp.fgetInt("TOTAL");
    H.starttime = resp.fgetString("STARTED");
    ArrayList A = resp.fget("HITS");
    H.hits = new int[A.size()];
    H.types = new String[A.size()];

    QueryableFrame Q;
    for (int i = 0; i < H.hits.length; i++) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.