Change Password

Input error
Input error
Input error
Submit
v2.x

Server Connection and Authentication

DefaultConnection

DefaultConnection is the default object that sends operation commands to Ultipa Server. Upon starting a project, first create an UltipaClientDriver object; a DefaultConnection object created anytime later will connect to the Ultipa Server defined in the UltipaClientDriver object.

DefaultConnection object can be created in below two ways:

  • via method getConnection() of UltipaClientDriver:
UltipaClientDriver driver = new UltipaClientDriver();
Connection client = driver.getConnection();
String reply = client.sayHello("Talent");
println(reply);
  • via DefaultConnection():
Connection client = new DefaultConnection();
String reply = client.sayHello("Talent");
println(reply);

User Authentication

Server authentication requires users to provide username, password and the file path of CA certificate to the UltipaClientDriver object. Several approaches are available.

UltipaConnUserSecret

Authentication information can be passed to UltipaClientDriver via UltipaConnUserSecret object, the parameters of which are:

UltipaConnUserSecret secret = UltipaConnUserSecret
		.config()
 		.password(password)
 		.username(username)
		.crtFile(crtFile) 
 		.connType(connType)
 		.timeout(timeout)
 		.readLevel(readLevel)
 		.url(host);
Parameter Description
username Username
password Password
crtFile File path of CA certificate, required when connType is ssl
connType Connecton type, either insecure or ssl
timeout Timeout
readLevel Read level, either inconsistency or consistency
url A list of hosts separated with comma, such as localhost:60161,localhost:60162

Example:

UltipaConnUserSecret secret = UltipaConnUserSecret
 	.config()
	.connType("ssl")
	.username("root")
	.password("root")
	.crtFile("F:\\ultipa.crt")
	.timeout(15)
	.url("120.0.1:60162,120.0.1:60163,120.0.1:60161");
UltipaClientDriver driver = new UltipaClientDriver(secret);
Connection client = new DefaultConnection();
String reply = client.sayHello("Ricky");
println(reply);

Response:

"Ricky Welcome To Ultipa!"

Configuration File

Authentication information can also be stored in configuration file. Create a file named ultipa.properties under the classpath of the project, with below content:

ultipa.grpc.pool.conn.type=insecure
ultipa.grpc.pool.conn.username=root
ultipa.grpc.pool.conn.password=root
ultipa.grpc.pool.conn.crtFile=F:\\ultipa.crt
ultipa.grpc.pool.conn.overrideAuthority=ultipa
ultipa.grpc.pool.conn.query.timeout=15
ultipa.grpc.pool.conn.url=120.0.1:60162,120.0.1:60163,120.0.1:60161

The configuration file will be read automatically when UltipaClientDriver object is created.

Example:

UltipaClientDriver driver = new UltipaClientDriver();
Connection client = new DefaultConnection();
String reply = client.sayHello("Ricky");
println(reply);

Response:

"Ricky Welcome To Ultipa!"

Connection Pool

UltipaClientDriver uses Apache common-pool by default. Configure the connection pool before creating UltipaClientDriver object:

GenericObjectPoolConfig<ManagedChannel> poolConfig 
        = new GenericObjectPoolConfig<ManagedChannel>();
poolConfig.setMaxIdle(50);
poolConfig.setMinIdle(2);
poolConfig.setMaxTotal(200);
poolConfig.setMaxWaitMillis(-1);
UltipaClientDriver driver = new UltipaClientDriver(poolConfig);
Connection client = new DefaultConnection();
String reply = client.sayHello("Ricky");
println(reply);

Users can also configure the connection pool in the configuration file. Include below content in the file ultipa.properties:

# Maximum number of idle connections
ultipa.grpc.pool.conn.maxIdle=50
# Minimum number of idle connections
ultipa.grpc.pool.conn.minIdle=22
# Maximum number of total connections
ultipa.grpc.pool.conn.maxTotal=2000
# Minimum idle time of an evictable connection, defalut is 1800000 ms (30 min)
ultipa.grpc.pool.conn.minEvictableIdleTimeMillis=1800000
# Test interval for evictable connections (ms), default is -1 (do not scan)
ultipa.grpc.pool.conn.timeBetweenEvictionRunsMillis=3600000
# Test connections when borrow, default is fasle
ultipa.grpc.pool.conn.testOnBorrow=true
# Test connections when return, default is fasle
ultipa.grpc.pool.conn.testOnReturn=false
# Test connections when idle, default is fasle
ultipa.grpc.pool.conn.testWhileIdle=false
# Maximum wait time, default is -1 (infinite wait)
ultipa.grpc.pool.conn.maxWaitMillis=-1
# Last in first out, default is true
ultipa.grpc.pool.conn.lifo=true
# Block new request when connections are exhausted, default is true (block until timeout), false will popup error
ultipa.grpc.pool.conn.blockWhenExhausted=true
# Number of connections to test each time, default is 3
ultipa.grpc.pool.conn.numTestsPerEvictionRun=3

Singleton v.s. Clusters

The UltipaClientDriver object will automatically switch to distributed mode or stand-alone mode after requesting and judging the URL links by default.