Mariadb with Vaadin Flow

We will talk a little about @Push de Vaadin Flow, MariaDB

The challenge by Alejandro Duarte brought back a lot of memories 😅 when I did something similar by updating a ProgressBar with Vaadin when uploading a file.

He mentions how a progressbar could be included.

Challenge: Try using the ProgressBar class, the @Push annotation, and the UI.access(Command) method to show the progress in the browser.

Many times users must intuitively know if something is processing in the background, "loading" in short, and that is achieved by showing the client side some kind of progress, of any kind, in order to help them.

The beginnings of processing hashes

mariadb configuration

mariadb logo blue transparent

Alejandro’s post is already some time old and when creating the container, things have changed:

docker run -d -p 3306:3306 \
--shm-size=512m \
-e PM1=mcs1 \ (1)
--hostname=mcs1 \
--name mariadb_columnstore mariadb/columnstore
1 This parameter was required, and is the Primary Database Node.

Optional volume of NFS

docker run -d -p 3306:3306 \
-v /media/share-nfs/mariadb:/var/lib/mysql \ (1)
--shm-size=512m -e PM1=mcs1 --hostname=mcs1 --name mariadb_columnstore mariadb/columnstore
1 Setting a volume, but internally pointing to an NFS directory, which already exists on this host, as we do right here, very useful also in case of recreating the container we would have our data a little more secure.
docker exec -it mariadb_columnstore provision mcs1
Waiting for PM1 To Be Initialized ..... done
Adding PM(s) To Cluster ... done
Restarting Cluster ... done
Validating ColumnStore Engine ... done
In case of system reboot, we must start the container and then the exec command above.

We give priviliegos to the user

docker exec mariadb_columnstore mariadb -e "GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'passw00rd';"

Remote access on local network

Add permissions for any IP within the local network

GRANT ALL PRIVILEGES ON your_database.* TO 'user'@'192.168.1.%' IDENTIFIED BY 'passw00rd';

Ensure that the generic permission is properly configured.

GRANT ALL PRIVILEGES ON your_database.* TO 'user'@'%' IDENTIFIED BY 'passw00rd';

Purge privileges of that user

FLUSH PRIVELEGES;

Apply changes

SELECT user, host FROM mysql.user WHERE user = 'user';
user host

user_reactive

192.168.1.%

user_reactive

%

We waited a little while and it should allow us to connect.

dbeaver connection success

Connecting from console to mariadb

mariadb -h 127.0.0.1 -P 3306 -u user -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 11.1.1-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Changing the route

You can move the database to a drive with the NFS protocol on the network, this, many do not recommend, but others do.

In this case on my odroid I have a self-mountable drive with more space, in the media directory, and this points to the NFS server on my NAS.

We were able to create a jail on FreeBSD also with MariaDB but for the moment, we are testing Odroid to see metrics and other things, this being fully docker compatible, maybe by installing ZFS we could use jails.

[root@mcs1 /]# mysql -h 127.0.0.1 -P 3306 -u user -p -e "SELECT @@datadir;"
mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead
Enter password:
+-----------------+
| @@datadir       |
+-----------------+
| /var/lib/mysql/ |
+-----------------+
[root@mcs1 /]#
Here we can visualize the var/lib/mysql in the NFS share

nfs var lib mysl

Buffer increase

Alejandro’s recommendation was useful for this case, where we want to improve the performance when saving data, and more knowing that we are with the db in a remote area.

[mysqld]
innodb_buffer_pool_size=1G

The ProgressBar

Here we show the ProgressBar in the UI while generating data in MariaDB, using this dependency.

<dependency>
	<groupId>com.vaadin</groupId>
	<artifactId>exampledata</artifactId>
	<version>6.2.0</version>
</dependency>

One million

And we would have more rows, with that data several things could be done…​

1millionrow