Package org.apache.vinci.transport

Examples of org.apache.vinci.transport.VinciFrame


    return modifyService(S, VNS.dirCmdUpdateService);
  }

  // Generic service interaction method
  public boolean modifyService(Service S, String type) {
    VinciFrame out = new VinciFrame();
    out.fadd("vinci:COMMAND", type);
    out.fadd("SERVICE", S.toFrame());

    VinciFrame resp = (VinciFrame) transmit(out);

    checkError(resp);

    return (resp.fgetString("STATUS").toLowerCase().trim().equals("ok"));
  }
View Full Code Here


    return modifyAlias(VNS.dirCmdAddAlias, name, null);
  }

  // Generic alias interaction method
  public boolean modifyAlias(String type, String name, String target) {
    VinciFrame out = new VinciFrame();
    out.fadd("vinci:COMMAND", type);
    VinciFrame srv = new VinciFrame();
    smartAdd(srv, "NAME", name);
    smartAdd(srv, "TARGET", target);
    out.fadd("SERVICE", srv);

    VinciFrame resp = (VinciFrame) transmit(out);

    checkError(resp);

    return (resp.fgetString("STATUS").toLowerCase().trim().equals("ok"));
  }
View Full Code Here

      } catch (Exception e) {
        throw new RuntimeException("Could not resolve local host");
      }
    }

    VinciFrame out = (VinciFrame) new VinciFrame().fadd("vinci:COMMAND",
            VNSConstants.SERVEON_COMMAND).fadd("SERVICE", name).fadd("HOST", host).fadd("LEVEL",
            level).fadd("INSTANCE", instance);

    VinciFrame resp = (VinciFrame) transmit(out);

    checkError(resp);

    int[] result = new int[3];
    result[0] = resp.fgetInt("PORT");
    result[1] = resp.fgetInt("LEVEL");
    result[2] = resp.fgetInt("INSTANCE");

    return result;
  }
View Full Code Here

  private Transportable transmit(Transportable T) {
    try {
      return BaseClient.rpc(T, vnsHost, vnsPort);
    } catch (Exception e) {
      VinciFrame F = new VinciFrame();
      F.fadd("vinci:ERROR", e.toString());
      return F;
    }
  }
View Full Code Here

  public static void main(String[] args) {
    System.out.println("Shutting down the service...");
    try {
      String serviceName = args[0];
      VinciFrame query = new VinciFrame();
      query.fadd(Constants.VINCI_COMMAND, Constants.SHUTDOWN);
      VinciClient.rpc(query, serviceName);
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println(e.getMessage());
    }
View Full Code Here

  public static void main(String[] args) {
    System.out.println("Invoking the service...");
    try {
      String serviceName = args[0];
      VinciFrame query = new VinciFrame();
      VinciFrame response;

      if (args.length < 2) {
        query.fadd(Constants.VINCI_COMMAND, Constants.GETMETA);
        response = VinciClient.rpc(query, serviceName);
      } else {

        System.out.println("Analyzing Document...");
        File aFile = new File(args[1]);
        String fileData = FileUtils.file2String(aFile);

        VinciFrame data = new VinciFrame();
        VinciFrame key = new VinciFrame();

        key.fadd(Constants.VINCI_DETAG, fileData);
        data.fadd("KEYS", key);

        query.fadd(Constants.VINCI_COMMAND, Constants.ANNOTATE);
        query.fadd("DATA", data);
View Full Code Here

   *
   */
  public synchronized Transportable eval(Transportable in) throws ServiceException {

    try {
      VinciFrame input = (VinciFrame) in;
      if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
        UIMAFramework.getLogger().log(Level.FINEST, input.toXML());
      }

      String cmd = input.fgetString("vinci:COMMAND");
      if (cmd.equals("shutdown")) {
        if (UIMAFramework.getLogger().isLoggable(Level.INFO)) {
          UIMAFramework.getLogger(this.getClass()).logrb(Level.INFO, this.getClass().getName(),
                  "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_deactivating_vns_port__INFO",
                  new Object[] { Thread.currentThread().getName() });
        }
        this.cleanExit();
        return input;
      } else if (cmd.equals("serveon")) {
        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_process_serveon__FINEST",
                  new Object[] { Thread.currentThread().getName() });
        }
        // String serviceName = input.fgetString("SERVICE");
        int port = getPort();
        input.fdrop("vinci:COMMAND");
        input.fadd("IP", "127.0.0.1");
        input.fadd("PORT", port);

        try {
          if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
            UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                    "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                    "UIMA_CPM_assign_service_port__FINEST",
                    new Object[] { Thread.currentThread().getName(), String.valueOf(port) });
          }
          portQueue.enqueue(String.valueOf(port));
          if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
            UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                    "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                    "UIMA_CPM_assign_service_port_complete__FINEST",
                    new Object[] { Thread.currentThread().getName(), String.valueOf(port) });
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
        if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
          UIMAFramework.getLogger(this.getClass()).log(Level.FINEST, input.toXML());
          UIMAFramework.getLogger().log(Level.FINEST, input.toXML());
        }
        return input;
      } else if (cmd.equals("resolve")) {
        String publicVNSHost = System.getProperty("PVNS_HOST");
        String publicVNSPort = System.getProperty("PVNS_PORT");
        if (publicVNSHost == null || publicVNSHost.trim().length() == 0 || publicVNSPort == null
                || publicVNSPort.trim().length() == 0) {
          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",
                    new Object[] { Thread.currentThread().getName() });
          }
          VinciFrame rtn = new VinciFrame();
          rtn
                  .fadd("vinci:EXCEPTION",
                          "CPM Reply:Public VNS not known. Verify CPMs startup param include -DVNS_HOST and -DVNS_PORT");
          return rtn;
        }
        int pvnsPort = -1;
        try {
          pvnsPort = Integer.parseInt(publicVNSPort);
        } catch (NumberFormatException e) {
          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",
                    new Object[] { Thread.currentThread().getName() });
          }
          VinciFrame rtn = new VinciFrame();
          rtn.fadd("vinci:EXCEPTION", "CPM Reply: Invalid VNS Port value::" + publicVNSPort);
          return rtn;
        }
        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",
                  new Object[] { Thread.currentThread().getName() });
        }
        VinciFrame rtn = new VinciFrame();
        rtn.fadd("vinci:EXCEPTION", "Unknown command");
        return rtn;
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      throw new ServiceException(ex.getMessage());
View Full Code Here

          }

          // Test the connection.
          getAnalysisEngineMetaData();
          try {
            VinciFrame query = new VinciFrame();
            query.fadd("vinci:COMMAND", "GetPid");
            // Send shutdown request to the TAE service
            AFrame resp = (AFrame) conn.sendAndReceive(query);
            if (resp.fgetString("vinci:STATUS") != null
                    && resp.fgetString("vinci:STATUS").equals("OK")) {
              fencedProcessPID = resp.fgetString("PID");
View Full Code Here

    }
    // Added to support WF Miners that have descriptors.
    AFrame resultFrame = null;
    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
      resultFrame = (AFrame) conn.sendAndReceive(queryFrame, AFrame.getAFrameFactory(), timeout);
      if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
        UIMAFramework.getLogger(this.getClass()).logrb(
                Level.FINEST,
View Full Code Here

    if (System.getProperty("FILTER_BATCH") != null) {
      return;
    }
    try {
      if (conn != null && conn.isOpen()) {
        VinciFrame query = new VinciFrame();
        query.fadd("vinci:COMMAND", Constants.BATCH_PROCESS_COMPLETE);
        if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
          UIMAFramework.getLogger(this.getClass()).logrb(
                  Level.FINEST,
                  this.getClass().getName(),
                  "process",
                  CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_send_batch_complete__FINEST",
                  new Object[] { Thread.currentThread().getName(), conn.getHost(),
                      String.valueOf(conn.getPort()), query.toXML() });
        }
        // Send notification to service
        conn.send(query);
      }
    } catch (Exception e) {
View Full Code Here

TOP

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

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.