Package com.sun.sgs.app

Examples of com.sun.sgs.app.Channel


    public void testChannelSendNullMessage() throws Exception {
  final String channelName = "test";
  createChannel(channelName);
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    Channel channel = getChannel(channelName);
    try {
        channel.send(null, null);
        fail("Expected NullPointerException");
    } catch (NullPointerException e) {
        System.err.println(e);
    }
      }
View Full Code Here


    ChannelListener listener =
        new ValidatingChannelListener();
    dataService.setBinding(listenerName, listener);
    ClientSession session =
        (ClientSession) dataService.getBinding(user);
    Channel channel =
        channelService.createChannel(
      channelName, listener, Delivery.RELIABLE);
    channel.join(session);
      }
  }, taskOwner);

  // Wait for the client to join, and then send a channel message.
  client.assertJoinedChannel(channelName);
View Full Code Here

  int numIterations = 100;
  long startTime = System.currentTimeMillis();
  for (int i = 0; i < numIterations; i++) {
      txnScheduler.runTask(new TestAbstractKernelRunnable() {
    public void run() {
        Channel channel = channelService.getChannel(channelName);
        DataManager dataManager = AppContext.getDataManager();
        ClientSession session = (ClientSession)
      dataManager.getBinding(sessionKey);
        channel.join(session);
        channel.leave(session);
    }}, taskOwner);
  }
  long endTime = System.currentTimeMillis();
  System.err.println("join/leave, iterations: " + numIterations +
         ", elapsed time: " + (endTime - startTime) +
View Full Code Here

    // -- Test Channel.close --

    @Test
    public void testChannelCloseNoTxn() throws Exception {
  Channel channel = createChannel();
  try {
      dataService.removeObject(channel);
      fail("Expected TransactionNotActiveException");
  } catch (TransactionNotActiveException e) {
      System.err.println(e);
View Full Code Here

  int count = getObjectCount();
  createChannel(channelName);
  printServiceBindings("after channel create");
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    Channel channel = getChannel(channelName);
    dataService.removeObject(channel);
      }
  }, taskOwner);
  Thread.sleep(100);
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    Channel channel = getChannel(channelName);
    if (getChannel(channelName) != null) {
        fail("obtained closed channel");
    }
      }
  }, taskOwner);
View Full Code Here

  int count = getObjectCount();
  // Create channel with managed ChannelListener.
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    ManagedChannelListener listener = new ManagedChannelListener();
    Channel channel = AppContext.getChannelManager().
        createChannel(channelName, listener, Delivery.RELIABLE);
    DataManager dataManager = AppContext.getDataManager();
    dataManager.setBinding(channelName, channel);
    dataManager.setBinding(listenerName, listener);
      }
  }, taskOwner);
  printServiceBindings("after channel create");
  // Remove managed channel listener and close channel.
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    DataManager dataManager = AppContext.getDataManager();
    ManagedChannelListener listener = (ManagedChannelListener)
        dataManager.getBinding(listenerName);
    Channel channel = (Channel) dataManager.getBinding(channelName);
    dataManager.removeBinding(listenerName);
    if (removeListener) {
        dataManager.removeObject(listener);
    }
    dataManager.removeObject(channel);
      }
  }, taskOwner);
  Thread.sleep(100);
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    Channel channel = getChannel(channelName);
    if (getChannel(channelName) != null) {
        fail("obtained closed channel");
    }
      }
  }, taskOwner);
View Full Code Here

      client.sendChannelMessage(channelName, 0);
      checkChannelMessagesReceived(client, channelName, 1);
 
      txnScheduler.runTask(new TestAbstractKernelRunnable() {
    public void run() {
        Channel channel = getChannel(channelName);
        dataService.removeObject(channel);
    } }, taskOwner);
      Thread.sleep(100);
      txnScheduler.runTask(new TestAbstractKernelRunnable() {
          public void run() {
        Channel channel = getChannel(channelName);
        if (getChannel(channelName) != null) {
      fail("obtained closed channel");
        }
    } }, taskOwner);
      printServiceBindings("after channel close");
View Full Code Here

   
    private void closeChannel(final String name) throws Exception {

  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    Channel channel = channelService.getChannel(name);
    dataService.removeObject(channel);
      }}, taskOwner);
    }
View Full Code Here

  final String channelName, final String... users)
  throws Exception
    {
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    Channel channel = getChannel(channelName);
    for (String user : users) {
        ClientSession session =
      (ClientSession) dataService.getBinding(user);
        channel.join(session);
    }
      }
  }, taskOwner);
    }
View Full Code Here

   final String channelName, final String... users)
  throws Exception
    {
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    Channel channel = getChannel(channelName);
    for (String user : users) {
        ClientSession session =
      (ClientSession) dataService.getBinding(user);
        channel.leave(session);
    }
      }
  }, taskOwner);
    }
View Full Code Here

TOP

Related Classes of com.sun.sgs.app.Channel

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.