use of org.fisco.bcos.channel.client.Service in project web3sdk by FISCO-BCOS.
the class Channel2ClientMultiBin method main.
public static void main(String[] args) throws Exception {
if (args.length < parameterNum) {
System.out.println("param: target topic total number of request");
return;
}
String topic = args[0];
Integer count = 1;
String filename = args[1];
int flag = -128;
byte[] byteflag = Channel2ClientBin.intToByteArray(flag);
int filelength = filename.length();
byte[] bytelength = Channel2ClientBin.intToByteArray(filelength);
byte[] bytefilename = filename.getBytes();
byte[] contentfile = Channel2ClientBin.toByteArrFromFile(filename);
byte[] content = Channel2ClientBin.byteCat(Channel2ClientBin.byteCat(Channel2ClientBin.byteCat(byteflag, bytelength), bytefilename), contentfile);
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
logger.debug("init client");
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
Service service = context.getBean(Service.class);
service.run();
System.out.println("3s ...");
Thread.sleep(1000);
System.out.println("2s ...");
Thread.sleep(1000);
System.out.println("1s ...");
Thread.sleep(1000);
System.out.println("start test");
System.out.println("===================================================================");
for (Integer i = 0; i < count; ++i) {
Thread.sleep(2000);
ChannelRequest request = new ChannelRequest();
request.setToTopic(topic);
request.setMessageID(service.newSeq());
request.setTimeout(5000);
request.setContent(content);
System.out.println(df.format(LocalDateTime.now()) + " multicast request seq:" + String.valueOf(request.getMessageID()) + ", filename:" + filename);
service.asyncMulticastChannelMessage2(request);
}
}
use of org.fisco.bcos.channel.client.Service in project web3sdk by FISCO-BCOS.
the class Channel2ClientNeedVerify method main.
public static void main(String[] args) throws Exception {
if (args.length < parameterNum) {
System.out.println("param: target topic total number of request");
return;
}
String topic = args[0];
Integer count = Integer.parseInt(args[1]);
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
logger.debug("init client");
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
Service service = context.getBean(Service.class);
service.run();
System.out.println("3s ...");
Thread.sleep(1000);
System.out.println("2s ...");
Thread.sleep(1000);
System.out.println("1s ...");
Thread.sleep(1000);
System.out.println("start test");
System.out.println("===================================================================");
ChannelRequest request = new ChannelRequest();
for (Integer i = 0; i < count; ++i) {
Thread.sleep(2000);
request.setToTopic(topic);
request.setMessageID(service.newSeq());
request.setTimeout(5000);
String content = "request seq:" + request.getMessageID();
request.setContent(content.getBytes());
System.out.println(df.format(LocalDateTime.now()) + " request seq:" + request.getMessageID() + ", Content:" + request.getContent() + " content:" + Arrays.toString(request.getContentByteArray()));
ChannelResponse response = service.sendChannelMessageForVerifyTopic(request);
System.out.println(df.format(LocalDateTime.now()) + "response seq:" + response.getMessageID() + ", ErrorCode:" + response.getErrorCode() + ", Content:" + response.getContent());
}
}
use of org.fisco.bcos.channel.client.Service in project web3sdk by FISCO-BCOS.
the class Channel2ServerNeedVerify method main.
public static void main(String[] args) throws Exception {
if (args.length < 1) {
System.out.println("Param: topic");
return;
}
String topic = args[0];
logger.debug("init Server");
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
Service service = context.getBean(Service.class);
service.setNeedVerifyTopics(topic);
PushCallback cb = new PushCallback();
service.setPushCallback(cb);
System.out.println("3s...");
Thread.sleep(1000);
System.out.println("2s...");
Thread.sleep(1000);
System.out.println("1s...");
Thread.sleep(1000);
System.out.println("start test");
System.out.println("===================================================================");
service.run();
}
use of org.fisco.bcos.channel.client.Service in project web3sdk by FISCO-BCOS.
the class PerformanceDTTest method initialize.
public void initialize(String groupId) throws Exception {
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
Service service = context.getBean(Service.class);
service.setGroupId(Integer.parseInt(groupId));
service.run();
ChannelEthereumService channelEthereumService = new ChannelEthereumService();
channelEthereumService.setChannelService(service);
Web3AsyncThreadPoolSize.web3AsyncCorePoolSize = 3000;
Web3AsyncThreadPoolSize.web3AsyncPoolSize = 2000;
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(500);
web3 = Web3j.build(channelEthereumService, 15 * 100, scheduledExecutorService, Integer.parseInt(groupId));
credentials = GenCredential.create();
transactionManager = Contract.getTheTransactionManager(web3, credentials);
}
Aggregations