Package org.jboss.remoting

Examples of org.jboss.remoting.Client


      // enable leasing on client
      Map conf = new HashMap();
      conf.put(Client.ENABLE_LEASE, Boolean.TRUE);
      conf.put(InvokerLocator.CLIENT_LEASE_PERIOD, "999");

      Client client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL, conf);

      client.connect();

      SimpleConnectionListener connListener = new SimpleConnectionListener();
      client.addConnectionListener(connListener);

      ServerManagement.kill(0);

      // wait until failure is detected

      Throwable failure = connListener.getNextFailure(3000);
      assertNotNull(failure);

      // we simulate what Messaging is doing and we

      client.setDisconnectTimeout(0);
      client.disconnect();
     
      // the client should be "dead", in that both the connection validator and the lease pinger
      // are silenced

      assertEquals(-1, client.getPingPeriod());
      assertEquals(-1, client.getLeasePeriod());
   }
View Full Code Here


      if (!isRemote())
      {
         fail("This test should be run in a remote configuration!");
      }

      Client client = null;
      ObjectName subsystemService = null;
      CallbackServerTimeoutTest.SimpleCallbackHandler callbackHandler = null;

      try
      {
         subsystemService = RemotingTestSubsystemService.deployService();

         client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL);

         callbackHandler = new SimpleCallbackHandler();

         client.connect();

         JMSRemotingConnection.
            addInvokerCallbackHandler("test", client, null, serverLocator, callbackHandler);

         client.invoke(new OnewayCallbackTrigger("blip"));

         // make sure we get the callback

         Callback c = callbackHandler.getNextCallback(3000);

         assertNotNull(c);
         assertEquals("blip", c.getParameter());

         // sleep for twice the timeout, to be sure
         long sleepTime = ServerInvoker.DEFAULT_TIMEOUT_PERIOD + 60000;
         log.info("sleeping for " + (sleepTime / 60000) + " minutes ...");

         Thread.sleep(sleepTime);

         log.debug("woke up");

         client.invoke(new OnewayCallbackTrigger("blop"));

         // make sure we get the callback

         c = callbackHandler.getNextCallback(3000);

         assertNotNull(c);
         assertEquals("blop", c.getParameter());

      }
      finally
      {
         if (client != null)
         {
            // Note. Calling Client.disconnect() does remove the InvokerCallbackHandler registered
            // above. For the http transport, the CallbackPoller will continue running, which will
            // generate a lot of ERROR log messages after the server has shut down.
            client.removeListener(callbackHandler);
            client.disconnect();
         }

         RemotingTestSubsystemService.undeployService(subsystemService);
      }
   }
View Full Code Here

      if (!isRemote())
      {
         fail("This test should be run in a remote configuration!");
      }

      Client client = null;
      ObjectName subsystemService = null;
      CallbackServerTimeoutTest.SimpleCallbackHandler callbackHandler = null;

      try
      {
         subsystemService = RemotingTestSubsystemService.deployService();

         client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL);

         callbackHandler = new SimpleCallbackHandler();

         client.connect();

         JMSRemotingConnection.
            addInvokerCallbackHandler("test", client, null, serverLocator, callbackHandler);

         log.info("added listener");

         // sleep for twice the timeout, to be sure
         long sleepTime = ServerInvoker.DEFAULT_TIMEOUT_PERIOD + 60000;

         client.invoke(new OnewayCallbackTrigger("blip", new long[] { 0, sleepTime + 10000 }));

         log.info("sent invocation");

         // make sure we get the callback

         Callback c = callbackHandler.getNextCallback(3000);

         assertNotNull(c);
         assertEquals("blip", c.getParameter());

         log.info("sleeping for " + (sleepTime / 60000) + " minutes ...");

         Thread.sleep(sleepTime);

         log.debug("woke up");

         // make sure we get the second callback

         c = callbackHandler.getNextCallback(20000);

         assertNotNull(c);
         assertEquals("blip1", c.getParameter());

      }
      finally
      {
         if (client != null)
         {
            client.disconnect();
         }

         RemotingTestSubsystemService.undeployService(subsystemService);
      }
   }
View Full Code Here

            {
               log.trace("Client cluster view id: " + familyClusterInfo.getCurrentViewId());
               log.trace(printPossibleTargets());
            }

            Client clientInstance = getClient(invocation);

            if (trace)
            {
               log.trace("Making invocation on " + clientInstance.getInvoker().getLocator());
            }
           
            response = clientInstance.invoke(invocation, null);

            HARMIResponse haResponse = null;

            if(response instanceof Exception)
            {
View Full Code Here

    * @param deployment - the encapsulation of the deployment to distribute
    * @throws Exception for any error
    */
   public void distribute(DeploymentID deployment) throws Exception
   {
      Client client = getClient();
      try
      {
         log.debug("Begin distribute: " + deployment);
         final URL contentURL = deployment.getContentURL();
         String[] rnames;
         if(!deployment.isCopyContent()) {           
            final File file = new File(contentURL.toURI());
            if(file.exists() == false) {
               throw new RuntimeException(String.format("file (%s) does not exist. Use 'copyContent = true' " +
                   "to copy the deployment.", contentURL));
            }
         }
         if (deployment.isCopyContent())
         {
            SerializableDeploymentID sdtID = new SerializableDeploymentID(deployment);
            InputStream contentIS = contentURL.openStream();
            sdtID.setContentIS(contentIS);
            String repositoryName = transferDeployment(client, sdtID);
            rnames = new String[]{repositoryName};
         }
         else
         {
            rnames = (String[])invoke(client, "distribute", createArgs(deployment));
         }
         // Update the repository names on the deployment
         deployment.setRepositoryNames(rnames);
         log.debug("End distribute, repositoryNames: "+ Arrays.asList(rnames));
      }
      finally
      {
         client.disconnect();
      }
   }
View Full Code Here

      }
   }

   public String[] getRepositoryNames(DeploymentID dtID) throws Exception
   {
      Client client = getClient();
      try
      {
         log.debug("Begin getRepositoryNames: " + Arrays.asList(dtID.getNames()));
         String[] rnames = (String[]) invoke(client, "getRepositoryNames", createArgs(dtID));
         log.debug("End getRepositoryNames: " + Arrays.asList(rnames));
         return rnames;
      }
      finally
      {
         client.disconnect();
      }
   }
View Full Code Here

      }
   }

   public void redeploy(DeploymentID dtID) throws Exception
   {
      Client client = getClient();
      try
      {
         log.debug("Begin redeploy: " + dtID);
         invoke(client, "redeploy", createArgs(dtID));
         log.debug("End redeploy: "+dtID);
      }
      finally
      {
         client.disconnect();
      }
   }
View Full Code Here

      }
   }

   public void prepare(DeploymentID dtID) throws Exception
   {
      Client client = getClient();
      try
      {
         log.debug("Begin prepare: " + dtID);
         invoke(client, "prepare", createArgs(dtID));
         log.debug("End prepare: "+dtID);
      }
      finally
      {
         client.disconnect();
      }
   }
View Full Code Here

   /**
    * Start a given deployment(s)
    */
   public void start(DeploymentID dtID) throws Exception
   {
      Client client = getClient();
      try
      {
         log.debug("Start: " + dtID);
         invoke(client, "start", createArgs(dtID));
         log.debug("End start: "+dtID);
      }
      finally
      {
         client.disconnect();
      }
   }
View Full Code Here

   /**
    * Stop a given module
    */
   public void stop(DeploymentID dtID) throws Exception
   {
      Client client = getClient();
      try
      {
         log.debug("Begin stop: " + dtID);
         invoke(client, "stop", createArgs(dtID));
         log.debug("End stop");
      }
      finally
      {
         client.disconnect();
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.remoting.Client

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.