mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
bug 7548: re-try the connection between cloud-agent and libvirtd, if the connection is broken.
status 7548: resolved fixed
This commit is contained in:
parent
9e1c4ba779
commit
e7108948ac
@ -37,7 +37,6 @@ import com.cloud.utils.script.Script;
|
||||
|
||||
|
||||
public class KVMHABase {
|
||||
protected Connect _libvirtConnection;
|
||||
private long _timeout = 60000; /*1 minutes*/
|
||||
protected static String _heartBeatPath;
|
||||
protected long _heartBeatUpdateTimeout = 5000; /*5 sec*/
|
||||
@ -111,7 +110,7 @@ public class KVMHABase {
|
||||
StoragePool pool = null;
|
||||
String poolName = null;
|
||||
try {
|
||||
pool = _libvirtConnection.storagePoolLookupByUUIDString(storagePool._poolUUID);
|
||||
pool = LibvirtConnection.getConnection().storagePoolLookupByUUIDString(storagePool._poolUUID);
|
||||
if (pool != null) {
|
||||
StoragePoolInfo spi = pool.getInfo();
|
||||
if (spi.state != StoragePoolState.VIR_STORAGE_POOL_RUNNING) {
|
||||
@ -187,11 +186,11 @@ public class KVMHABase {
|
||||
|
||||
NfsStoragePool pool = new KVMHAMonitor.NfsStoragePool(null,null,null,null, PoolType.PrimaryStorage);
|
||||
|
||||
KVMHAMonitor haWritter = new KVMHAMonitor(pool, null, "192.168.1.163", null);
|
||||
KVMHAMonitor haWritter = new KVMHAMonitor(pool, "192.168.1.163", null);
|
||||
Thread ha = new Thread(haWritter);
|
||||
ha.start();
|
||||
|
||||
KVMHAChecker haChecker = new KVMHAChecker(haWritter.getStoragePools(), null, "192.168.1.163");
|
||||
KVMHAChecker haChecker = new KVMHAChecker(haWritter.getStoragePools(), "192.168.1.163");
|
||||
|
||||
ExecutorService exe = Executors.newFixedThreadPool(1);
|
||||
Future<Boolean> future = exe.submit((Callable<Boolean>)haChecker);
|
||||
|
||||
@ -34,9 +34,8 @@ public class KVMHAChecker extends KVMHABase implements Callable<Boolean> {
|
||||
private List<NfsStoragePool> _pools;
|
||||
private String _hostIP;
|
||||
private long _heartBeatCheckerTimeout = 300000; /*5 minutes*/
|
||||
public KVMHAChecker(List<NfsStoragePool> pools, Connect conn, String host) {
|
||||
public KVMHAChecker(List<NfsStoragePool> pools, String host) {
|
||||
this._pools = pools;
|
||||
this._libvirtConnection = conn;
|
||||
this._hostIP = host;
|
||||
}
|
||||
|
||||
|
||||
@ -35,11 +35,10 @@ public class KVMHAMonitor extends KVMHABase implements Runnable{
|
||||
private String _hostIP; /*private ip address*/
|
||||
|
||||
|
||||
public KVMHAMonitor(NfsStoragePool pool, Connect conn, String host, String scriptPath) {
|
||||
public KVMHAMonitor(NfsStoragePool pool, String host, String scriptPath) {
|
||||
if (pool != null) {
|
||||
this._storagePool.put(pool._poolUUID, pool);
|
||||
}
|
||||
this._libvirtConnection = conn;
|
||||
}
|
||||
this._hostIP = host;
|
||||
this._heartBeatPath = scriptPath;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,29 @@
|
||||
package com.cloud.agent.resource.computing;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libvirt.Connect;
|
||||
import org.libvirt.LibvirtException;
|
||||
|
||||
public class LibvirtConnection {
|
||||
private static final Logger s_logger = Logger.getLogger(LibvirtConnection.class);
|
||||
static private Connect _connection;
|
||||
static private String _hypervisorURI;
|
||||
static public Connect getConnection() throws LibvirtException {
|
||||
if (_connection == null) {
|
||||
_connection = new Connect(_hypervisorURI, false);
|
||||
} else {
|
||||
try {
|
||||
_connection.getVersion();
|
||||
} catch (LibvirtException e) {
|
||||
s_logger.debug("Connection with libvirtd is broken, due to " + e.getMessage());
|
||||
_connection = new Connect(_hypervisorURI, false);
|
||||
}
|
||||
}
|
||||
|
||||
return _connection;
|
||||
}
|
||||
|
||||
static void initialize(String hypervisorURI) {
|
||||
_hypervisorURI = hypervisorURI;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user