Walery Wysotsky

Jul 222023
 

Quarkus framework has its own logging system, based on JBoss logging. There is a more or less simple system with configuration via properties (or yaml). In simple cases, features from default Quarkus logging are enough, but for complex cases, like MDC, log separation, etc standard Quarkus logging capability is insufficient.

Another thing that brings some problems is tests, especially in gradle, because there is no way to specify the logging level by package name for tests (at least it doesn’t work for me up to Quarkus v. 3.2.0).

So at least one solution – use another logging framework you like. It can be Logback, Log4J or even JUL. By the way, there is already developed option for using logback.xml as a log configuration source, but only in a static way – transcode logback.xml into standard Quarkus logging settings at the build stage.

In this case for using another logging framework we need to replace the existing one.

  • Remove unnecessary packages from the build: build.gradle
configurations.all {
 exclude group: 'org.jboss.logging', module: 'jboss-logmanager-embedded'
 exclude group: 'org.jboss.logging', module: 'commons-logging-jboss-logging'
 exclude group: 'org.jboss.slf4j', module: 'slf4j-jboss-logmanager'
 exclude group: 'org.slf4j', module: 'slf4j-jdk14'
}
  • Add required dependencies: build.gradle
dependencies {
...
 implementation "org.slf4j:slf4j-api:${slf4jVersion}"
 implementation "ch.qos.logback:logback-core:${logbackVersion}"
 implementation "ch.qos.logback:logback-classic:${logbackVersion}"
...
}
  • Use the required logging provider on the application start command
java -Dorg.jboss.logging.provider=slf4j -jar quarkus-runner.jar

Also sometimes we need to tune logging in gradle test task: build.gradle

test {
  systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager"
  systemProperty "org.jboss.logging.provider", "slf4j"
// one file for multimodule project
  systemProperty 'logback.configurationFile', "${rootDir}/src/test/resources/logback-test.xml"
}

Apr 182020
 

One time I needed to use a counter for some heavy loaded process in multithread environment. As usual, I use the class java.util.concurrent.atomic.AtomicInteger, the methods incrementAndGet and decrementAndGet. But when I put these methods in only two places, absolutely synchronized by calls (increment and decrement counter in short time gap), I got a strange behavior with the counter – it constantly goes down to negative values. When I tried to view source code (OpenJDK 8), I saw this:

/**
     * Atomically increments by one the current value.
     *
     * @return the updated value
     */
    public final int incrementAndGet() {
        return unsafe.getAndAddInt(this, valueOffset, 1) + 1;
    }

So, instead of incrementing value concurrently and returning new value after this, we have a function call, which returns a current value and increments value by one in the same place. May be this function (getAndAddInt) really increments value of AtomicInteger… or may be not, in this place we don’t know, because we know nothing about new value – we simply return old value + 1.

I found the same behavior in OpenJDK11 source code:

public final int incrementAndGet() {
    return U.getAndAddInt(this, VALUE, 1) + 1;
}

And the same code up to OpenJDK14: https://github.com/openjdk/jdk14u/blob/master/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java

Moreover, I wrote simple code with a volatile field and two methods for increasing/decreasing this field with ReentrantLock. And using this methods in the same places, where I used AtomicInteger methods, I got a different result – my counter was increased and decreased and had more plausible value, than AtomicInteger.

May 192018
 

For connect to virtual machine screen via VNC you need:

  1. Retrieve VM domain number (execute in XenServer console):
    xe vm-list params=dom-id name-label=[vm name] | grep dom-id
  2. Retrieve VNC port for this domain (execute in XenServer console):
    xenstore-read /local/domain/[domain]/console/vnc-port
  3. Make remote connection ([port] – last two digits from previous output), execute in remote console:
    vncviewer -via root@[xenserver] localhost:[port]

All together from remote console xen_vm_screen.sh:

#!/bin/bash
XEN_HOST=$1
VM=$2
XEN_USER=root
DOMAIN=`ssh $XEN_USER@$XEN_HOST "xe vm-list params=dom-id name-label=$VM | awk -F ':' '{gsub(/[ \t]+/, \"\", \\\$2); print \\\$2}'"`
VM_PORT=`ssh $XEN_USER@$XEN_HOST "xenstore-read /local/domain/$DOMAIN/console/vnc-port"`
vncviewer -via $XEN_USER@$XEN_HOST localhost:${VM_PORT:2:2}

Execute it as:

bash ./xen_vm_screen.sh vm_host_name vm_name
Sep 042016
 

Based on Changing a RAID-10 into a RAID-5

It is usually assumed that the best HDD organization on a backup server is a RAID5, since it provides a fairly good price/volume. Unfortunately, increasing of disk count affect to some RAID5 disadvantages, in particular the in reliability and recovery speed. For example if the server has RAID5 of 6 (six) SATA disk drives (even it’s reliable enough, such as WD Re), with one disk replacement, array recovery time is about 10 hours (in my case). At the recovery time reservation is absent, the load on the disks are increased, that increases the probability of failure of the remaining disks, and if all the disks have same series, the probability of another disk will deteriorate during the recovery, increase even more.
In this regard, it was decided to convert the existing disk array from RAID5 to RAID10 with the addition of two drives, that in theory should lead to increasing of server performance and improving reliability.

Continue reading »

Jul 192016
 

Inspired by: Начальная настройка коммутатора HP 1910 серии

It is well known and has been emphasized by HP, many HP switches (HPE) are configured through the web-interface. A little less known is that a full customization for large number of switches is also possible via command line (for example, 1910, 1920).

Continue reading »

Feb 272016
 

When you try to access HP ILO2 console via some new version of OpenSSH you have error.
For OpenSSH v.6
# ssh ilouser@iloserver
Received disconnect from iloserver: 2: Client Disconnect

Solution: add option -o MACs=hmac-sha1 to ssh:

# ssh -o MACs=hmac-sha1 ilouser@iloserver
ilouser@iloserver's password:

For OpenSSH v.7
# ssh ilouser@iloserver
Unable to negotiate with UNKNOWN: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1

Solution: add option -o KexAlgorithms=diffie-hellman-group1-sha1 -o MACs=hmac-sha1 to ssh:

# ssh -o KexAlgorithms=diffie-hellman-group1-sha1 -o MACs=hmac-sha1 ilouser@iloserver
ilouser@iloserver's password:

Feb 272016
 

From Pinoy UNIX Administrations

There are times when you want to have a quick access to the remote console of a server like HP’s ILO but you don’t want (not able) to open a web browser just to access it. But there is an ability to access it via SSH (text console only).

  1. Open a ssh connection to the ILO’s IP address.
    # ssh ilo_admin@ip_address

  2. Enter your ILO admin account and password. After that you will see the ILO prompt.
    hpILO->

  3. To access the remote console of the server at the ILO prompt type “TEXTCONS”
    hpILO->TEXTCONS

  4. You will be presented with the Login: console. Enter your root or user account of the server to gain access.
    Login:
Apr 182014
 

Sometimes when you upgrade firmware of access points (AP) through the UniFi controller interface, AP hung in Upgrading state (eg UniFi AP PRO).
When you restart AP, it does not change state and AP does not reach.
In this case, you need to upgrade AP firmware via command line.
It is assumed the server is installed on Linux

  1. Determine controller version and firmware code:
    Version: execute command on the server

    ls -l /usr/lib/unifi/dl/firmware/BZ2/
    

    resulting directory is version number

    Firmware code determined by the table:
    Continue reading »

Aug 072013
 
  1. In file /etc/yum.repos.d/CentOS-Base.repo in section [base] set enabled=1
  2. sed -i 's/enabled=0/enabled=1/g' /etc/yum.repos.d/CentOS-Base.repo
  3. For XenServer 6.2, 6.5 in file /etc/yum.repos.d/Citrix.repo in section [citrix] set enabled=0
  4. sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/Citrix.repo
  5.  rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/$(uname -i)/epel-release-5-4.noarch.rpm
     cd /tmp
     wget https://yum.puppetlabs.com/el/5/products/$(uname -i)/puppetlabs-release-5-10.noarch.rpm
     rpm -Uvh puppetlabs-release-5-10.noarch.rpm
     yum install puppet
    

    set up /etc/puppet/puppet.conf, after that:

     chkconfig puppet on
     /etc/init.d/puppet start
    

I Also recommend using a xs_patcher to make XenServer up to date.