use of rpc.turbo.benchmark.bean.User in project turbo-rpc by hank-whu.
the class MapVsThreadLocalBenchmark method directGet.
@Benchmark
@BenchmarkMode({ Mode.Throughput })
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public User directGet() {
User user = directUser;
if (user != null && user.getId() == 12345L) {
return user;
}
user = userService.getUser(12345L).join();
directUser = user;
return user;
}
use of rpc.turbo.benchmark.bean.User in project turbo-rpc by hank-whu.
the class KryoByteBufTest method main.
public static void main(String[] args) {
Kryo kryo = new Kryo();
// kryo.setWarnUnregisteredClasses(true);
// kryo.setReferences(false);
kryo.register(IntObj.class);
kryo.register(StringUTF8Obj.class);
kryo.register(LocalDateTimeObj.class);
kryo.register(ComplexObj.class);
kryo.register(int[].class);
kryo.register(ArrayList.class);
kryo.register(ArrayListObj.class);
ByteBufAllocator allocator = new PooledByteBufAllocator(true);
ByteBuf buffer = allocator.directBuffer(2, 1024 * 1024 * 8);
System.out.println("buffer.nioBufferCount: " + buffer.nioBufferCount());
System.out.println(buffer.nioBuffer(0, buffer.capacity()));
ByteBufOutput output = new ByteBufOutput(buffer);
UserService userService = new UserServiceServerImpl();
User user = userService.getUser(Long.MAX_VALUE).join();
while (true) {
buffer.clear();
output.setBuffer(buffer);
kryo.writeObject(output, user);
ByteBufInput input = new ByteBufInput(buffer);
User u = kryo.readObject(input, User.class);
System.out.println(u);
}
// buffer.clear();
// output.setBuffer(buffer);
// kryo.writeObject(output, user);
// System.out.println("user writeObject: " + output.total());
//
// ByteBufInput input = new ByteBufInput(buffer);
// System.out.println("user readableBytes: " + buffer.readableBytes());
// System.out.println("user readerIndex: " + buffer.readerIndex());
// System.out.println(kryo.readObject(input, User.class));
}
use of rpc.turbo.benchmark.bean.User in project turbo-rpc by hank-whu.
the class AbstractClient method createUser.
public Object createUser() throws Exception {
int id = counter.getAndIncrement();
User user = _serviceUserService.getUser(id).join();
return getUserService().createUser(user).join();
}
use of rpc.turbo.benchmark.bean.User in project turbo-rpc by hank-whu.
the class TruboClientBootTest method test.
@PostConstruct
public void test() {
System.out.println(Arrays.toString(applicationContext.getBeanNamesForType(UserService.class)));
System.out.println("userService: " + userService.getClass().getName());
System.out.println("userService2: " + userService2.getClass().getName());
System.out.println("existUser:");
boolean existUser = userService.existUser("hank.whu@gmail.com").join();
System.out.println(existUser);
System.out.println("=====================");
System.out.println();
System.out.println("getUser:");
User user = userService.getUser(1).join();
System.out.println(user);
System.out.println("=====================");
System.out.println();
System.out.println("createUser:");
System.out.println(userService2.createUser(user).join());
System.out.println("=====================");
System.out.println();
System.out.println("listUser:");
System.out.println(userService.listUser(1).join());
System.out.println("=====================");
System.out.println();
}
use of rpc.turbo.benchmark.bean.User in project turbo-rpc by hank-whu.
the class UserServiceServerImpl method getUser.
@Override
public CompletableFuture<User> getUser(long id) {
user = new User();
user.setId(id);
user.setName("Doug Lea");
user.setSex(1);
user.setBirthday(LocalDate.of(1968, 12, 8));
user.setEmail("dong.lea@gmail.com");
user.setMobile("18612345678");
user.setAddress("北京市 中关村 中关村大街1号 鼎好大厦 1605");
user.setIcon("https://www.baidu.com/img/bd_logo1.png");
user.setStatus(1);
user.setCreateTime(LocalDateTime.now());
user.setUpdateTime(user.getCreateTime());
List<Integer> permissions = new ArrayList<>(List.of(1, 2, 3, 4, 5, 6, 7, 8, 19, 88, 86, 89, 90, 91, 92));
user.setPermissions(permissions);
return CompletableFuture.completedFuture(user);
}
Aggregations