Package com.google.code.yanf4j.nio

Examples of com.google.code.yanf4j.nio.TCPController.bind()


  @Test
  public void testFailureMode_HasStandbyNode() throws Exception {
    TCPController memServer1 = new TCPController();
    memServer1.setHandler(new MockHandler("response from server1"));
    memServer1.setCodecFactory(new TextLineCodecFactory());
    memServer1.bind(new InetSocketAddress(4799));

    TCPController memServer2 = new TCPController();
    memServer2.setHandler(new MockHandler("response from server2"));
    memServer2.setCodecFactory(new TextLineCodecFactory());
    memServer2.bind(new InetSocketAddress(4798));
View Full Code Here


    memServer1.bind(new InetSocketAddress(4799));

    TCPController memServer2 = new TCPController();
    memServer2.setHandler(new MockHandler("response from server2"));
    memServer2.setCodecFactory(new TextLineCodecFactory());
    memServer2.bind(new InetSocketAddress(4798));

    MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil
        .getAddressMap("localhost:4799,localhost:4798"));
    // It must be in failure mode
    builder.setFailureMode(true);
View Full Code Here

  public void testFailureMode_OneServerDownOnStartup() throws Exception {

    TCPController memServer2 = new TCPController();
    memServer2.setHandler(new MockHandler("response from server2"));
    memServer2.setCodecFactory(new TextLineCodecFactory());
    memServer2.bind(new InetSocketAddress(4798));

    MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil
        .getAddressMap("localhost:4799 localhost:4798"));
    // It must be in failure mode
    builder.setFailureMode(true);
View Full Code Here

      assertEquals(1, client.getConnector().getSessionByAddress(
          AddrUtil.getOneAddress("localhost:4799")).size());
      memServer1 = new TCPController();
      memServer1.setHandler(new MockHandler("response from server1"));
      memServer1.setCodecFactory(new TextLineCodecFactory());
      memServer1.bind(new InetSocketAddress(4799));
      Thread.sleep(5000);
      assertEquals(1, client.getConnector().getSessionByAddress(
          AddrUtil.getOneAddress("localhost:4799")).size());
      assertEquals("response from server2", client.get("a"));
      assertEquals("response from server1", client.get("b"));
View Full Code Here

  @Test
  public void testFailureMode_StandbyNodeDown_Recover() throws Exception {
    TCPController memServer1 = new TCPController();
    memServer1.setHandler(new MockHandler("response from server1"));
    memServer1.setCodecFactory(new TextLineCodecFactory());
    memServer1.bind(new InetSocketAddress(4799));

    TCPController memServer2 = new TCPController();
    memServer2.setHandler(new MockHandler("response from server2"));
    memServer2.setCodecFactory(new TextLineCodecFactory());
    memServer2.bind(new InetSocketAddress(4798));
View Full Code Here

    memServer1.bind(new InetSocketAddress(4799));

    TCPController memServer2 = new TCPController();
    memServer2.setHandler(new MockHandler("response from server2"));
    memServer2.setCodecFactory(new TextLineCodecFactory());
    memServer2.bind(new InetSocketAddress(4798));

    MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil
        .getAddressMap("localhost:4799,localhost:4798"));
    // It must be in failure mode
    builder.setFailureMode(true);
View Full Code Here

      }
      // restart server2
      memServer2 = new TCPController();
      memServer2.setHandler(new MockHandler("response from server2"));
      memServer2.setCodecFactory(new TextLineCodecFactory());
      memServer2.bind(new InetSocketAddress(4798));
      Thread.sleep(5000);
      assertEquals("response from server2", client.get("a"));

      // restart server1
      memServer1 = new TCPController();
View Full Code Here

  @Test
  public void testFailureMode_NoStandbyNode() throws Exception {
    TCPController memServer1 = new TCPController();
    memServer1.setHandler(new MockHandler("response from server1"));
    memServer1.setCodecFactory(new TextLineCodecFactory());
    memServer1.bind(new InetSocketAddress(4799));

    MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil
        .getAddressMap("localhost:4799"));
    builder.setFailureMode(true);
    MemcachedClient client = builder.build();
View Full Code Here

  @Test
  public void testNotFailureMode_HasStandbyNode() throws Exception {
    TCPController memServer1 = new TCPController();
    memServer1.setHandler(new MockHandler("response from server1"));
    memServer1.setCodecFactory(new TextLineCodecFactory());
    memServer1.bind(new InetSocketAddress(4799));

    TCPController memServer2 = new TCPController();
    memServer2.setHandler(new MockHandler("response from server2"));
    memServer2.setCodecFactory(new TextLineCodecFactory());
    memServer2.bind(new InetSocketAddress(4798));
View Full Code Here

    memServer1.bind(new InetSocketAddress(4799));

    TCPController memServer2 = new TCPController();
    memServer2.setHandler(new MockHandler("response from server2"));
    memServer2.setCodecFactory(new TextLineCodecFactory());
    memServer2.bind(new InetSocketAddress(4798));

    MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil
        .getAddressMap("localhost:4799,localhost:4798"));
    MemcachedClient client = builder.build();
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.