Package org.tarantool.pool

Examples of org.tarantool.pool.SocketChannelPooledConnectionFactory


  public static final int TEMPLATE_CALL_SPACE = 127;

  @Test
  public void testCycle() throws ParseException, MalformedURLException {
    User user = new User();
    SocketChannelPooledConnectionFactory connectionFactory = new SocketChannelPooledConnectionFactory("localhost", 33313, 1, 10);
    Mapping<User> mapping = new Mapping<User>(User.class, TEMPLATE_SPACE, "id", "phone", "point", "iq", "height", "lifeFormId", "salary", "birthday",
        "name", "sign", "male");

    TarantoolTemplate template = new TarantoolTemplate(connectionFactory);
    template.addMapping(mapping);
    assertNotNull(template.save(user).insertOrReplaceAndGet());
    try {
      template.save(user).insert();
      fail();
    } catch (TarantoolException ignored) {

    }
    assertEquals(1, template.save(user).replace());
    assertNotNull(template.find(User.class, 0, "id").condition(user.getId()).list());
    assertEquals(user.getPhone() + 1L, template.update(User.class, user.getId()).add("phone", 1).updateAndGet().getPhone());

    connectionFactory.free();
    return;
  }
View Full Code Here


  }

  @Test
  public void testCycle2() throws ParseException, MalformedURLException {
    User user = new User();
    SocketChannelPooledConnectionFactory connectionFactory = new SocketChannelPooledConnectionFactory("localhost", 33313, 1, 10);
    TarantoolTemplate template = new TarantoolTemplate(connectionFactory);
    assertNotNull(template.save(user).insertOrReplaceAndGet());
    try {
      template.save(user).insert();
      fail();
    } catch (TarantoolException ignored) {

    }
    assertEquals(1, template.save(user).replace());
    assertNotNull(template.find(User.class, 0, "id").condition(user.getId()).list());
    assertNotNull(template.find(User.class, 1).condition(user.getName()).one());
    assertEquals(user.getPhone() + 1L, template.update(User.class, user.getId()).add("phone", 1).updateAndGet().getPhone());

    connectionFactory.free();
    return;
  }
View Full Code Here

  @Test
  public void testCycle3() throws MalformedURLException {
    Mapping<User> mapping = new Mapping7<User>(User.class, 125, "id", "phone", "point", "iq", "height", "lifeFormId", "salary", "birthday", "name", "sign",
        "male");
    TarantoolTemplate tpl = new TarantoolTemplate7(new SocketChannelPooledConnectionFactory("localhost", 33313, 1, 10));
    tpl.addMapping(mapping);
    try {
      tpl.find(User.class).condition("string");
      fail();
    } catch (IllegalArgumentException ignored) {
View Full Code Here

  }

  @Test
  public void testCall() throws MalformedURLException {
    Mapping<User> mapping = new Mapping<User>(User.class, 126, "id", "phone");
    SocketChannelPooledConnectionFactory connectionFactory = new SocketChannelPooledConnectionFactory("localhost", 33313, 1, 10);
    TarantoolTemplate template = new TarantoolTemplate(connectionFactory);
    template.addMapping(mapping);
    template.call(User.class, "box.delete", "126", 4321).callForOne();
    assertNotNull(template.call(User.class, "box.insert", "126", 4321, 323323L).callForOne());
    assertNull(template.call(User.class, "box.select", 126, 0, 4321).luaMode(true).callForOne());
View Full Code Here

import org.tarantool.snapshot.XLogReader.XLogEntry;

public class TestSnapshotAndXLog {
  // @Test
  public void insertTestTuples() {
    SocketChannelPooledConnectionFactory factory = new SocketChannelPooledConnectionFactory();
    TarantoolConnection connection = factory.getConnection();
    TupleSupport ts = new TupleSupport();
    for (int i = 0; i < 10; i++) {
      Tuple tuple = ts.create(i, Long.parseLong("98765432" + i), "Hello world " + i + "!");
      connection.insert(0, tuple);
    }
View Full Code Here

TOP

Related Classes of org.tarantool.pool.SocketChannelPooledConnectionFactory

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.