Package com.sun.sgs.app

Examples of com.sun.sgs.app.Channel


  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

      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

    @Test
    public void testChannelWriteReadObject() throws Exception {
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() throws Exception {
    Channel savedChannel =
        channelService.createChannel("x", null, Delivery.RELIABLE);
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(savedChannel);
    out.flush();
    out.close();
   
    ByteArrayInputStream bin =
        new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bin);
    Channel channel = (Channel) in.readObject();

    if (!savedChannel.equals(channel)) {
        fail("Expected channel: " + savedChannel +
       ", got " + channel);
    }
View Full Code Here

   
    // -- Test Channel.getName --

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

  }
    }

    @Test
    public void testChannelGetNameMismatchedTxn() throws Exception {
  final Channel channel = createChannel();
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    try {
        channel.getName();
        fail("Expected TransactionNotActiveException");
    } catch (TransactionNotActiveException e) {
        System.err.println(e);
    }
      }
View Full Code Here

    @Test
    public void testChannelGetName() throws Exception {
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    String name = "foo";
    Channel channel = channelService.createChannel(
        name, null, Delivery.RELIABLE);
    if (!name.equals(channel.getName())) {
        fail("Expected: " + name + ", got: " + channel.getName());
    }
      }
  }, taskOwner);
    }
View Full Code Here

    @Test
    public void testChannelGetNameClosedChannel() throws Exception {
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    String name = "foo";
    Channel channel = channelService.createChannel(
        name, null, Delivery.RELIABLE);
    dataService.removeObject(channel);
    try {
        channel.getName();
        fail("Expected IllegalStateException");
    } catch (IllegalStateException e) {
        System.err.println(e);
    }
      }
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.