comparison src/main/java/org/monetdb/mcl/net/MapiSocket.java @ 903:778959b2e0a4

Send ClientInfo on startup Configurable through the client_info=bool, client_application=NAME, client_remark=MESSAGE properties.
author Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
date Fri, 14 Jun 2024 15:57:49 +0200 (10 months ago)
parents 5a59910e8f87
children 2d880f90be2a
comparison
equal deleted inserted replaced
902:65d42db0c831 903:778959b2e0a4
23 import java.io.Writer; 23 import java.io.Writer;
24 import java.net.*; 24 import java.net.*;
25 import java.nio.charset.StandardCharsets; 25 import java.nio.charset.StandardCharsets;
26 import java.security.MessageDigest; 26 import java.security.MessageDigest;
27 import java.security.NoSuchAlgorithmException; 27 import java.security.NoSuchAlgorithmException;
28 import java.sql.SQLClientInfoException;
28 import java.util.*; 29 import java.util.*;
29 30
30 import javax.net.ssl.SSLException; 31 import javax.net.ssl.SSLException;
31 32
32 import org.monetdb.mcl.MCLException; 33 import org.monetdb.mcl.MCLException;
115 private BufferedMCLReader reader; 116 private BufferedMCLReader reader;
116 /** MCLWriter on the OutputStream */ 117 /** MCLWriter on the OutputStream */
117 private BufferedMCLWriter writer; 118 private BufferedMCLWriter writer;
118 /** protocol version of the connection */ 119 /** protocol version of the connection */
119 private int version; 120 private int version;
121 private ClientInfo clientInfo;
120 122
121 /** Whether we should follow redirects. 123 /** Whether we should follow redirects.
122 * Not sure why this needs to be separate 124 * Not sure why this needs to be separate
123 * from 'ttl' but someone someday explicitly documented setTtl 125 * from 'ttl' but someone someday explicitly documented setTtl
124 * with 'to disable completely, use followRedirects' so 126 * with 'to disable completely, use followRedirects' so
495 // String endianPart = parts[4]; 497 // String endianPart = parts[4];
496 String passwordHashPart = parts[5]; 498 String passwordHashPart = parts[5];
497 String optionsPart = parts.length > 6 ? parts[6] : null; 499 String optionsPart = parts.length > 6 ? parts[6] : null;
498 // String binaryPart = parts.length > 7 ? parts[7] : null; 500 // String binaryPart = parts.length > 7 ? parts[7] : null;
499 501
502 if (parts.length > 9 && target.isClientInfo()) {
503 clientInfo = new ClientInfo();
504 try {
505 clientInfo.set("ApplicationName", target.getClientApplication());
506 clientInfo.set("ClientRemark", target.getClientRemark());
507 } catch (SQLClientInfoException e) {
508 String keys = String.join(", ", e.getFailedProperties().keySet());
509 throw new MCLException("Could not set ClientInfo properties: " + keys, e);
510 }
511 }
512
500 String userResponse; 513 String userResponse;
501 String password = target.getPassword(); 514 String password = target.getPassword();
502 if (serverTypePart.equals("merovingian") && !target.getLanguage().equals("control")) { 515 if (serverTypePart.equals("merovingian") && !target.getLanguage().equals("control")) {
503 userResponse = "merovingian"; 516 userResponse = "merovingian";
504 password = "merovingian"; 517 password = "merovingian";
769 782
770 public boolean isDebug() { 783 public boolean isDebug() {
771 return target.isDebug(); 784 return target.isDebug();
772 } 785 }
773 786
787 public boolean hasClientInfo() {
788 return clientInfo != null;
789 }
790
791 public ClientInfo getClientInfo() {
792 if (clientInfo == null)
793 clientInfo = new ClientInfo();
794 return clientInfo;
795 }
774 796
775 /** 797 /**
776 * Inner class that is used to write data on a normal stream as a 798 * Inner class that is used to write data on a normal stream as a
777 * blocked stream. A call to the flush() method will write a 799 * blocked stream. A call to the flush() method will write a
778 * "final" block to the underlying stream. Non-final blocks are 800 * "final" block to the underlying stream. Non-final blocks are