Fix warnings.
This commit is contained in:
parent
23703bad3c
commit
3708244571
3 changed files with 10 additions and 7 deletions
|
|
@ -3,22 +3,18 @@ package org.jdrupes.vmoperator.manager;
|
||||||
import io.kubernetes.client.Discovery.APIResource;
|
import io.kubernetes.client.Discovery.APIResource;
|
||||||
import io.kubernetes.client.openapi.ApiException;
|
import io.kubernetes.client.openapi.ApiException;
|
||||||
import io.kubernetes.client.util.generic.options.ListOptions;
|
import io.kubernetes.client.util.generic.options.ListOptions;
|
||||||
|
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.jdrupes.vmoperator.common.Constants.APP_NAME;
|
import static org.jdrupes.vmoperator.common.Constants.APP_NAME;
|
||||||
import static org.jdrupes.vmoperator.common.Constants.VM_OP_GROUP;
|
import static org.jdrupes.vmoperator.common.Constants.VM_OP_GROUP;
|
||||||
import static org.jdrupes.vmoperator.common.Constants.VM_OP_KIND_VM;
|
import static org.jdrupes.vmoperator.common.Constants.VM_OP_KIND_VM;
|
||||||
import static org.jdrupes.vmoperator.common.Constants.VM_OP_NAME;
|
import static org.jdrupes.vmoperator.common.Constants.VM_OP_NAME;
|
||||||
|
|
||||||
import org.jdrupes.vmoperator.common.K8s;
|
import org.jdrupes.vmoperator.common.K8s;
|
||||||
import org.jdrupes.vmoperator.common.K8sClient;
|
import org.jdrupes.vmoperator.common.K8sClient;
|
||||||
import org.jdrupes.vmoperator.common.K8sDynamicStub;
|
import org.jdrupes.vmoperator.common.K8sDynamicStub;
|
||||||
import org.jdrupes.vmoperator.common.K8sV1ConfigMapStub;
|
import org.jdrupes.vmoperator.common.K8sV1ConfigMapStub;
|
||||||
import org.jdrupes.vmoperator.common.K8sV1DeploymentStub;
|
import org.jdrupes.vmoperator.common.K8sV1DeploymentStub;
|
||||||
import org.jdrupes.vmoperator.common.K8sV1PodStub;
|
|
||||||
import org.jdrupes.vmoperator.common.K8sV1PvcStub;
|
import org.jdrupes.vmoperator.common.K8sV1PvcStub;
|
||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
|
||||||
|
|
@ -238,6 +238,8 @@ public class QemuMonitor extends Component {
|
||||||
* @param event the event
|
* @param event the event
|
||||||
*/
|
*/
|
||||||
@Handler
|
@Handler
|
||||||
|
@SuppressWarnings({ "PMD.AvoidSynchronizedStatement",
|
||||||
|
"PMD.AvoidDuplicateLiterals" })
|
||||||
public void onClosed(Closed<?> event, SocketIOChannel channel) {
|
public void onClosed(Closed<?> event, SocketIOChannel channel) {
|
||||||
channel.associated(QemuMonitor.class).ifPresent(qm -> {
|
channel.associated(QemuMonitor.class).ifPresent(qm -> {
|
||||||
monitorChannel = null;
|
monitorChannel = null;
|
||||||
|
|
@ -259,7 +261,8 @@ public class QemuMonitor extends Component {
|
||||||
* @param event the event
|
* @param event the event
|
||||||
*/
|
*/
|
||||||
@Handler
|
@Handler
|
||||||
@SuppressWarnings("PMD.AvoidLiteralsInIfCondition")
|
@SuppressWarnings({ "PMD.AvoidLiteralsInIfCondition",
|
||||||
|
"PMD.AvoidSynchronizedStatement" })
|
||||||
public void onExecQmpCommand(MonitorCommand event) {
|
public void onExecQmpCommand(MonitorCommand event) {
|
||||||
var command = event.command();
|
var command = event.command();
|
||||||
logger.fine(() -> "monitor(out): " + command.toString());
|
logger.fine(() -> "monitor(out): " + command.toString());
|
||||||
|
|
@ -290,6 +293,7 @@ public class QemuMonitor extends Component {
|
||||||
* @param event the event
|
* @param event the event
|
||||||
*/
|
*/
|
||||||
@Handler(priority = 100)
|
@Handler(priority = 100)
|
||||||
|
@SuppressWarnings("PMD.AvoidSynchronizedStatement")
|
||||||
public void onStop(Stop event) {
|
public void onStop(Stop event) {
|
||||||
if (monitorChannel != null) {
|
if (monitorChannel != null) {
|
||||||
// We have a connection to Qemu, attempt ACPI shutdown.
|
// We have a connection to Qemu, attempt ACPI shutdown.
|
||||||
|
|
@ -321,6 +325,7 @@ public class QemuMonitor extends Component {
|
||||||
* @param event the event
|
* @param event the event
|
||||||
*/
|
*/
|
||||||
@Handler
|
@Handler
|
||||||
|
@SuppressWarnings("PMD.AvoidSynchronizedStatement")
|
||||||
public void onPowerdownEvent(PowerdownEvent event) {
|
public void onPowerdownEvent(PowerdownEvent event) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
// Cancel confirmation timeout
|
// Cancel confirmation timeout
|
||||||
|
|
@ -349,6 +354,7 @@ public class QemuMonitor extends Component {
|
||||||
* @param event the event
|
* @param event the event
|
||||||
*/
|
*/
|
||||||
@Handler
|
@Handler
|
||||||
|
@SuppressWarnings("PMD.AvoidSynchronizedStatement")
|
||||||
public void onConfigureQemu(ConfigureQemu event) {
|
public void onConfigureQemu(ConfigureQemu event) {
|
||||||
int newTimeout = event.configuration().vm.powerdownTimeout;
|
int newTimeout = event.configuration().vm.powerdownTimeout;
|
||||||
if (powerdownTimeout != newTimeout) {
|
if (powerdownTimeout != newTimeout) {
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
@ -227,7 +227,7 @@ public class Runner extends Component {
|
||||||
CloudInit
|
CloudInit
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Set<QemuPreps> qemuLatch = new HashSet<>();
|
private final Set<QemuPreps> qemuLatch = EnumSet.noneOf(QemuPreps.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new runner.
|
* Instantiates a new runner.
|
||||||
|
|
@ -483,6 +483,7 @@ public class Runner extends Component {
|
||||||
mayBeStartQemu(QemuPreps.Config);
|
mayBeStartQemu(QemuPreps.Config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("PMD.AvoidSynchronizedStatement")
|
||||||
private void mayBeStartQemu(QemuPreps done) {
|
private void mayBeStartQemu(QemuPreps done) {
|
||||||
synchronized (qemuLatch) {
|
synchronized (qemuLatch) {
|
||||||
if (qemuLatch.isEmpty()) {
|
if (qemuLatch.isEmpty()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue