Examples of GatewayProcess


Examples of eu.admire.clienttoolkit.GatewayProcess

            }
    }
    System.out.println("gtw = " + mGateway.toString());
    String dispelFile = args[0]; //Util.getFileContentAsString(args[0]);
    System.out.println(dispelFile);
    GatewayProcess mGatewayProcess = mGateway.submit(dispelFile);

    // now can either wait for results (blocking) or sign up for
    // notifications (non-blocking)

    // 0 - blocking wait; 1 - wait with timeout; 2 - non-blocking
    int example = 0;
    switch (example) {
   
    // *****************************************************
    // waiting for results
    // *****************************************************

    case 0:
      try {
        mGatewayProcess.waitForResults();
        return mGatewayProcess.getResults();
      } catch (InterruptedException e) {
        e.printStackTrace();
      } finally {
        // then destroy the process itself
        mGatewayProcess.destroy();
      }
      break;

    // *****************************************************
    // waiting for results with timeout
    // *****************************************************

    case 1:
      long timeout = 100 * 1000;
      try {
        mGatewayProcess.waitForResults(timeout);
        if (hasErrors(mGatewayProcess.getErrors()))
        {
            return null;
        }
        for (Result r : mGatewayProcess.getResults().values()) {
          return mGatewayProcess.getResults();

        }
      } catch (InterruptedException e) {
        e.printStackTrace();
      } catch (TimeoutException e) {
        System.out.println("Ooops! Timed out!");
      } finally {
        // then destroy the process itself
        mGatewayProcess.destroy();
      }
      break;

    // *****************************************************
    // subscribing for results
    // *****************************************************

    // when subscribing also need to implement ResultObserver interface
    // resultsReady method, example below
    case 2:
      mGatewayProcess.subscribeForResults(this);
      System.out.println("Hurray! Got my prompt back!!");
      break;
    }

    return null;
View Full Code Here

Examples of eu.admire.clienttoolkit.core.GatewayProcess

            else
            {
                String dispel = GraphConverter.convertToDISPEL(entry.getValue());
                LOG.debug("Remote DISPEL:\n" + dispel);
                Gateway gateway = null;
                GatewayProcess process = null;
                try
                {
                    gateway = GatewayFactory.get(location.getAddress());
                    process = gateway.submit(dispel);
                }
                catch (URISyntaxException e)
                {
                    LOG.error("Remote gateway address is invalid: " +
                            location.getAddress());
                    throw new InitialisationFailedException();
                }
                catch (ServerException e)
                {
                    LOG.error("Problems with remote gateway", e);
                    throw new InitialisationFailedException();
                }           
                LOG.debug("Submitted remote DISPEL request to " + location +
                          ", process = " + process.toString());
               
                for(RemoteProcessListener rpl : mRemoteProcessListeners)
                {
                    rpl.processCreated(process.toString());
                }
               
                process.subscribeForResults(this);
                mRemoteProcesses.add(process);
            }
        }
        try
        {
View Full Code Here

Examples of eu.admire.clienttoolkit.core.GatewayProcess

        String ret = "";
   
        switch (index) {
            case STATUS_COLUMN:
                if (obj instanceof NamedProcess) {
                  GatewayProcess gw = ((NamedProcess) obj
                      ).getGatewayProcess();
                  if (gw.getStatus() == ProcessingStatus.PROCESSING
                      && !gw.getResults().isEmpty()) {
                    ret = "PROCESSING (Results Available)";
                  } else {
                    ret = gw.getStatus().toString();
                  }
                } else if (obj instanceof ResultLeaf) {
                  ret = ((ResultLeaf) obj).status().toString();
                }
                break;
View Full Code Here

Examples of eu.admire.clienttoolkit.core.GatewayProcess

            children = mProcesses.values().toArray();
       
        } else if (parent instanceof NamedProcess) {
       
            NamedProcess np = ((NamedProcess)parent);
            GatewayProcess gp = np.getGatewayProcess();

            Result[] results = gp.getResults().values().toArray(
                    new Result[0]);
            ResultLeaf[] resultLeaves = new ResultLeaf[results.length];

            //TODO: Probably wrong place to be creating objects
            for (int i=0; i < results.length; i++) {
View Full Code Here

Examples of eu.admire.clienttoolkit.core.GatewayProcess

            ret = !mProcesses.values().isEmpty();
       
        } else if (parent instanceof NamedProcess) {
       
            NamedProcess dp = (NamedProcess) parent;
            GatewayProcess gp = dp.getGatewayProcess();
           
            //Don't test for isDone - can have results before then
            Map<String, Result> results = gp.getResults();
            ret = (results != null) && (!results.isEmpty());
           
        }
   
        return ret;
View Full Code Here

Examples of eu.admire.clienttoolkit.core.GatewayProcess

       
        // if ip:port forwarding needs to be done to work around firewall problems
        // on the GATEWAY use the following method
        // mGateway.setForwardAddress(new InetSocketAddress("193.122.18.162", 8310));
       
        GatewayProcess mGatewayProcess = mGateway.submit(dispelFile);
       
        // if ip:port forwarding needs to be done to work around firewall problems
        // on the OGSADAI-USMT use the following method
        // mGatewayProcess.setForwardAddress(new InetSocketAddress("193.122.18.162", 8300));
       
        // now can either wait for results (blocking) or sign up for
        // notifications (non-blocking)

        // 0 - blocking wait; 1 - wait with timeout; 2 - non-blocking
        int example = 0;
        try
        {
        switch (example) {
       
            // *****************************************************
            // waiting for results
            // *****************************************************
   
            case 0:
                mGatewayProcess.waitForResults();
                Errors errors = mGatewayProcess.getErrors();
                if (hasErrors(errors))
                {
                    return;
                }
               
                for (Result r : mGatewayProcess.getResults().values())
                {
                    System.out.println("Result name = " + r.getName());
                    System.out.println("Value = " + Util.getAsString(r));
                    r.close();
                }
            break;

        // *****************************************************
        // waiting for results with timeout
        // *****************************************************

            case 1:
                long timeout = 100 * 1000;
                mGatewayProcess.waitForResults(timeout);
                if (hasErrors(mGatewayProcess.getErrors()))
                {
                    return;
                }
                for (Result r : mGatewayProcess.getResults().values())
                {
                    System.out.println("Result name = " + r.getName());
                    System.out.println("Value = " + Util.getAsString(r));
                    r.close();
                }
            break;

            // *****************************************************
            // subscribing for results
            // *****************************************************
   
            // when subscribing also need to implement ResultObserver interface
            // resultsReady method, example below
            case 2:
                mGatewayProcess.subscribeForResults(this);
                break;
            }
        }
        finally
        {
            // then destroy the process itself
            mGatewayProcess.destroyProcess();
        }

    }
View Full Code Here

Examples of eu.admire.clienttoolkit.core.GatewayProcess

    public void run()
    {
        try {
            Gateway gw = GatewayFactory.get(mGatewayURL);

            GatewayProcess gatewayProcess = gw.submit(
                    Util.getFileContentAsString(
                            mDispel.getLocation().toString()));
            GatewayProcessManager.getInstance().register(gatewayProcess,
                    mDispel.getName());
View Full Code Here

Examples of eu.admire.clienttoolkit.core.GatewayProcess

  @Test
  public void testSubmittingDISPEL() throws Exception
  {
      Gateway g = GatewayFactory.get(GATEWAY_ADDRESS);
      GatewayProcess p = g.submit(DISPEL_REQUEST);
      try
      {
          p.waitForResults();
         
          Map<String, Result> results = p.getResults();
          Result result = results.get("results");
          assertNotNull(result);
          String resultStr = Util.getAsString(result);
          assertEquals("Received wrong result", "[Hello World2!]", resultStr);
         
          Errors e = p.getErrors();
          assertNull("Caught a compile time error", e.getCompiletime());
          assertNull("Caught a runtime error", e.getRuntime());
          assertNull("Caught a registration error", e.getRegistration());
          assertNull("Caught a system error", e.getSystem());
   
          assertEquals(ProcessingStatus.COMPLETED, p.getStatus());
         
            // list all processes and check that this one in the list
          List<String> processes = g.getGatewayProcesses();
          boolean contained = false;
          for (String process : processes)
          {
              if (p.getAddress().endsWith(process))
              {
                  contained = true;
                  break;
              }
          }
          assertTrue("Process not found in list of all processes.", contained);
      }
      finally
      {
          p.destroyProcess();
      }   
  }
View Full Code Here

Examples of eu.admire.clienttoolkit.core.GatewayProcess

            "Echo echo = new Echo;\n" +
            "|- \"Hello World2!\" -| => echo.input;\n" +
            "DeliverToNull deliver = new DeliverToNull;\n" +
            "echo.output => deliver.input;\n" +
            "submit echo;";
        GatewayProcess p = g.submit(dispelRequest);
        try
        {
            p.waitForResults();
           
            Map<String, Result> results = p.getResults();
            assertTrue(results.isEmpty());
           
            Errors e = p.getErrors();
            assertNull("Caught a compile time error", e.getCompiletime());
            assertNull("Caught a runtime error", e.getRuntime());
            assertNull("Caught a registration error", e.getRegistration());
            assertNull("Caught a system error", e.getSystem());
        }
        finally
        {
            p.destroyProcess();
        }
       
    }
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.