Created
January 6, 2022 14:08
-
-
Save junwen12221/a049b69ecbc206007dcae9a991a96bd3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//package io.mycat.mysqlclient; | |
// | |
//import io.mycat.MySQLPacketUtil; | |
//import io.mycat.beans.mysql.MySQLPayloadWriter; | |
//import io.mycat.beans.mysql.packet.AuthPacket; | |
//import io.mycat.beans.mysql.packet.HandshakePacket; | |
//import io.mycat.config.MySQLServerCapabilityFlags; | |
//import io.mycat.vertx.ConnectHandler; | |
//import io.mycat.vertx.VertxMySQLPacketResolver2; | |
//import io.netty.buffer.ByteBuf; | |
//import io.reactivex.rxjava3.core.Observable; | |
//import io.reactivex.rxjava3.functions.Action; | |
//import io.reactivex.rxjava3.functions.Consumer; | |
//import io.vertx.core.*; | |
//import io.vertx.core.buffer.Buffer; | |
//import io.vertx.core.net.NetClient; | |
//import io.vertx.core.net.NetSocket; | |
//import io.vertx.mysqlclient.SslMode; | |
//import io.vertx.mysqlclient.impl.MySQLDatabaseMetadata; | |
//import io.vertx.mysqlclient.impl.command.InitialHandshakeCommand; | |
//import io.vertx.mysqlclient.impl.protocol.CapabilitiesFlag; | |
//import io.vertx.mysqlclient.impl.util.BufferUtils; | |
//import io.vertx.mysqlclient.impl.util.CachingSha2Authenticator; | |
//import io.vertx.mysqlclient.impl.util.Native41Authenticator; | |
//import io.vertx.sqlclient.impl.command.CommandResponse; | |
//import scala.runtime.VolatileDoubleRef; | |
// | |
//import java.nio.charset.StandardCharsets; | |
//import java.util.Collections; | |
//import java.util.List; | |
//import java.util.Map; | |
//import java.util.concurrent.TimeUnit; | |
//import java.util.function.Function; | |
//import java.util.stream.Collectors; | |
//import java.util.stream.Stream; | |
// | |
//import static io.vertx.mysqlclient.impl.protocol.CapabilitiesFlag.*; | |
//import static io.vertx.mysqlclient.impl.protocol.Packets.PACKET_PAYLOAD_LENGTH_LIMIT; | |
// | |
//public class Client { | |
// | |
// | |
// | |
// | |
// public static void main(String[] args) { | |
// Vertx vertx = Vertx.vertx(); | |
// | |
// NetClient netClient = vertx.createNetClient(); | |
// Future<NetSocket> netSocketFuture = netClient.connect(3306, "127.0.0.1"); | |
// netSocketFuture.onSuccess(new Handler<NetSocket>() { | |
// long start = System.currentTimeMillis(); | |
// long end ; | |
// long count =100000; | |
// @Override | |
// public void handle(NetSocket netSocket) { | |
// | |
// ConnectHandler connectHandler = new ConnectHandler(netSocket,(short) 0); | |
// Future<VertxConnection> vertxConnectionFuture = connectHandler.handleInitialHandshake(); | |
// vertxConnectionFuture.onSuccess(new Handler<VertxConnection>() { | |
// @Override | |
// public void handle(VertxConnection vertxConnection) { | |
// | |
// Future<Void> future = Future.succeededFuture(); | |
// for (int i = 0; i < count; i++) { | |
// future = future.flatMap(unused -> Future.future(promise -> { | |
// vertxConnection.queryAsObjectArray() | |
// Observable<byte[][]> query = vertxConnection.queryAsRowSet("SELECT * FROM `information_schema`.`CHARACTER_SETS` LIMIT 1; "); | |
// query.doOnComplete(new Action() { | |
// @Override | |
// public void run() throws Throwable { | |
// | |
// promise.tryComplete(); | |
// // System.out.println("-------------------------end--------------------------"); | |
// | |
// } | |
// }).forEach(c->{ | |
//// List<String> collect = Stream.of(c).map(r -> new String(r)).collect(Collectors.toList()); | |
//// System.out.println(collect); | |
// }); | |
// })); | |
// } | |
// future.onComplete(new Handler<AsyncResult<Void>>() { | |
// @Override | |
// public void handle(AsyncResult<Void> event) { | |
// end = System.currentTimeMillis(); | |
// double qps = count * 1.0 / ((end - start)) * 1000; | |
// System.out.println("-------------------------qps--------------------------"); | |
// System.out.println(qps); | |
// } | |
// }); | |
// | |
// | |
// // vertxConnection.queryAsRow("SELECT * FROM `information_schema`.`CHARACTER_SETS` LIMIT 0, 1000; "); | |
// System.out.println(); | |
// } | |
// }); | |
// } | |
// }); | |
// } | |
//// | |
//// public static void main(String[] args) { | |
//// Vertx vertx = Vertx.vertx(); | |
//// | |
//// NetClient netClient = vertx.createNetClient(); | |
//// Future<NetSocket> netSocketFuture = netClient.connect(3306, "127.0.0.1"); | |
//// netSocketFuture.onSuccess(new Handler<NetSocket>() { | |
//// long start = System.currentTimeMillis(); | |
//// long end ; | |
//// long count =100000; | |
//// @Override | |
//// public void handle(NetSocket netSocket) { | |
//// | |
//// ConnectHandler connectHandler = new ConnectHandler(netSocket); | |
//// Future<VertxConnection> vertxConnectionFuture = connectHandler.handleInitialHandshake(); | |
//// vertxConnectionFuture.onSuccess(new Handler<VertxConnection>() { | |
//// @Override | |
//// public void handle(VertxConnection vertxConnection) { | |
//// | |
//// Future<Void> future = Future.succeededFuture(); | |
//// for (int i = 0; i < count; i++) { | |
//// future = future.flatMap(unused -> Future.future(promise -> { | |
//// Observable<Buffer> query = vertxConnection.query("SELECT * FROM `information_schema`.`CHARACTER_SETS` LIMIT 1; "); | |
//// query.doOnComplete(new Action() { | |
//// @Override | |
//// public void run() throws Throwable { | |
//// | |
//// promise.tryComplete(); | |
//// // System.out.println("-------------------------end--------------------------"); | |
//// | |
//// } | |
//// }).forEach(c->{}); | |
//// })); | |
//// } | |
//// future.onComplete(new Handler<AsyncResult<Void>>() { | |
//// @Override | |
//// public void handle(AsyncResult<Void> event) { | |
//// end = System.currentTimeMillis(); | |
//// double qps = count * 1.0 / ((end - start)) * 1000; | |
//// System.out.println("-------------------------qps--------------------------"); | |
//// System.out.println(qps); | |
//// } | |
//// }); | |
//// | |
//// | |
//// // vertxConnection.queryAsRow("SELECT * FROM `information_schema`.`CHARACTER_SETS` LIMIT 0, 1000; "); | |
//// System.out.println(); | |
//// } | |
//// }); | |
//// } | |
//// }); | |
//// } | |
//} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment