Skip to content

Commit b0cd1b8

Browse files
committed
Fixup main build errors
1 parent de683a5 commit b0cd1b8

File tree

5 files changed

+39
-48
lines changed

5 files changed

+39
-48
lines changed

engine/storage/volume/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/BasePrimaryDataStoreLifeCycleImpl.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
2626
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
2727
import org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper;
28-
import org.apache.log4j.Logger;
2928

3029
import com.cloud.agent.AgentManager;
3130
import com.cloud.agent.api.Answer;
@@ -39,9 +38,12 @@
3938
import com.cloud.storage.StoragePoolHostVO;
4039
import com.cloud.storage.dao.StoragePoolHostDao;
4140
import com.cloud.utils.Pair;
41+
import org.apache.logging.log4j.LogManager;
42+
import org.apache.logging.log4j.Logger;
4243

4344
public class BasePrimaryDataStoreLifeCycleImpl {
44-
private static final Logger s_logger = Logger.getLogger(BasePrimaryDataStoreLifeCycleImpl.class);
45+
private static final Logger logger = LogManager.getLogger(BasePrimaryDataStoreLifeCycleImpl.class);
46+
4547
@Inject
4648
AgentManager agentMgr;
4749
@Inject
@@ -70,13 +72,13 @@ private List<HostVO> getPoolHostsList(ClusterScope clusterScope, HypervisorType
7072

7173
public void changeStoragePoolScopeToZone(DataStore store, ClusterScope clusterScope, HypervisorType hypervisorType) {
7274
List<HostVO> hosts = getPoolHostsList(clusterScope, hypervisorType);
73-
s_logger.debug("Changing scope of the storage pool to Zone");
75+
logger.debug("Changing scope of the storage pool to Zone");
7476
if (hosts != null) {
7577
for (HostVO host : hosts) {
7678
try {
7779
storageMgr.connectHostToSharedPool(host.getId(), store.getId());
7880
} catch (Exception e) {
79-
s_logger.warn("Unable to establish a connection between " + host + " and " + store, e);
81+
logger.warn("Unable to establish a connection between " + host + " and " + store, e);
8082
}
8183
}
8284
}
@@ -85,7 +87,7 @@ public void changeStoragePoolScopeToZone(DataStore store, ClusterScope clusterSc
8587

8688
public void changeStoragePoolScopeToCluster(DataStore store, ClusterScope clusterScope, HypervisorType hypervisorType) {
8789
Pair<List<StoragePoolHostVO>, Integer> hostPoolRecords = storagePoolHostDao.listByPoolIdNotInCluster(clusterScope.getScopeId(), store.getId());
88-
s_logger.debug("Changing scope of the storage pool to Cluster");
90+
logger.debug("Changing scope of the storage pool to Cluster");
8991
if (hostPoolRecords.second() > 0) {
9092
StoragePool pool = (StoragePool) store;
9193
for (StoragePoolHostVO host : hostPoolRecords.first()) {
@@ -94,7 +96,7 @@ public void changeStoragePoolScopeToCluster(DataStore store, ClusterScope cluste
9496

9597
if (answer != null) {
9698
if (!answer.getResult()) {
97-
s_logger.debug("Failed to delete storage pool: " + answer.getResult());
99+
logger.debug("Failed to delete storage pool: " + answer.getResult());
98100
} else if (HypervisorType.KVM != hypervisorType) {
99101
break;
100102
}

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckConvertInstanceCommandWrapper.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
//
1919
package com.cloud.hypervisor.kvm.resource.wrapper;
2020

21-
import org.apache.log4j.Logger;
22-
2321
import com.cloud.agent.api.Answer;
2422
import com.cloud.agent.api.CheckConvertInstanceAnswer;
2523
import com.cloud.agent.api.CheckConvertInstanceCommand;
@@ -30,21 +28,19 @@
3028
@ResourceWrapper(handles = CheckConvertInstanceCommand.class)
3129
public class LibvirtCheckConvertInstanceCommandWrapper extends CommandWrapper<CheckConvertInstanceCommand, Answer, LibvirtComputingResource> {
3230

33-
private static final Logger s_logger = Logger.getLogger(LibvirtCheckConvertInstanceCommandWrapper.class);
34-
3531
@Override
3632
public Answer execute(CheckConvertInstanceCommand cmd, LibvirtComputingResource serverResource) {
3733
if (!serverResource.hostSupportsInstanceConversion()) {
3834
String msg = String.format("Cannot convert the instance from VMware as the virt-v2v binary is not found on host %s. " +
3935
"Please install virt-v2v%s on the host before attempting the instance conversion.", serverResource.getPrivateIp(), serverResource.isUbuntuHost()? ", nbdkit" : "");
40-
s_logger.info(msg);
36+
logger.info(msg);
4137
return new CheckConvertInstanceAnswer(cmd, false, msg);
4238
}
4339

4440
if (cmd.getCheckWindowsGuestConversionSupport() && !serverResource.hostSupportsWindowsGuestConversion()) {
4541
String msg = String.format("Cannot convert the instance from VMware as the virtio-win package is not found on host %s. " +
4642
"Please install virtio-win package on the host before attempting the windows guest instance conversion.", serverResource.getPrivateIp());
47-
s_logger.info(msg);
43+
logger.info(msg);
4844
return new CheckConvertInstanceAnswer(cmd, false, msg);
4945
}
5046

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareStorageClientCommandWrapper.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
import java.util.Map;
2323

24-
import org.apache.log4j.Logger;
25-
2624
import com.cloud.agent.api.Answer;
2725
import com.cloud.agent.api.PrepareStorageClientAnswer;
2826
import com.cloud.agent.api.PrepareStorageClientCommand;
@@ -35,15 +33,13 @@
3533
@ResourceWrapper(handles = PrepareStorageClientCommand.class)
3634
public class LibvirtPrepareStorageClientCommandWrapper extends CommandWrapper<PrepareStorageClientCommand, Answer, LibvirtComputingResource> {
3735

38-
private static final Logger s_logger = Logger.getLogger(LibvirtPrepareStorageClientCommandWrapper.class);
39-
4036
@Override
4137
public Answer execute(PrepareStorageClientCommand cmd, LibvirtComputingResource libvirtComputingResource) {
4238
final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr();
4339
Ternary<Boolean, Map<String, String>, String> prepareStorageClientResult = storagePoolMgr.prepareStorageClient(cmd.getPoolType(), cmd.getPoolUuid(), cmd.getDetails());
4440
if (!prepareStorageClientResult.first()) {
4541
String msg = prepareStorageClientResult.third();
46-
s_logger.debug("Unable to prepare storage client, due to: " + msg);
42+
logger.debug("Unable to prepare storage client, due to: " + msg);
4743
return new PrepareStorageClientAnswer(cmd, false, msg);
4844
}
4945
Map<String, String> details = prepareStorageClientResult.second();

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUnprepareStorageClientCommandWrapper.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
package com.cloud.hypervisor.kvm.resource.wrapper;
2121

22-
import org.apache.log4j.Logger;
23-
2422
import com.cloud.agent.api.Answer;
2523
import com.cloud.agent.api.UnprepareStorageClientAnswer;
2624
import com.cloud.agent.api.UnprepareStorageClientCommand;
@@ -33,15 +31,13 @@
3331
@ResourceWrapper(handles = UnprepareStorageClientCommand.class)
3432
public class LibvirtUnprepareStorageClientCommandWrapper extends CommandWrapper<UnprepareStorageClientCommand, Answer, LibvirtComputingResource> {
3533

36-
private static final Logger s_logger = Logger.getLogger(LibvirtUnprepareStorageClientCommandWrapper.class);
37-
3834
@Override
3935
public Answer execute(UnprepareStorageClientCommand cmd, LibvirtComputingResource libvirtComputingResource) {
4036
final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr();
4137
Pair<Boolean, String> unprepareStorageClientResult = storagePoolMgr.unprepareStorageClient(cmd.getPoolType(), cmd.getPoolUuid());
4238
if (!unprepareStorageClientResult.first()) {
4339
String msg = unprepareStorageClientResult.second();
44-
s_logger.debug("Couldn't unprepare storage client, due to: " + msg);
40+
logger.debug("Couldn't unprepare storage client, due to: " + msg);
4541
return new UnprepareStorageClientAnswer(cmd, false, msg);
4642
}
4743
return new UnprepareStorageClientAnswer(cmd, true);

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/manager/ScaleIOSDCManagerImpl.java

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
3131
import org.apache.commons.collections.MapUtils;
3232
import org.apache.commons.lang3.StringUtils;
33-
import org.apache.log4j.Logger;
33+
import org.apache.logging.log4j.LogManager;
34+
import org.apache.logging.log4j.Logger;
3435
import org.springframework.stereotype.Component;
3536

3637
import com.cloud.agent.AgentManager;
@@ -51,7 +52,7 @@
5152

5253
@Component
5354
public class ScaleIOSDCManagerImpl implements ScaleIOSDCManager {
54-
private static final Logger LOGGER = Logger.getLogger(ScaleIOSDCManagerImpl.class);
55+
private static final Logger logger = LogManager.getLogger(ScaleIOSDCManagerImpl.class);
5556

5657
@Inject
5758
AgentManager agentManager;
@@ -79,14 +80,14 @@ public boolean areSDCConnectionsWithinLimit(Long storagePoolId) {
7980

8081
int connectedSdcsCount = getScaleIOClient(storagePoolId).getConnectedSdcsCount();
8182
if (connectedSdcsCount < connectedClientsLimit) {
82-
LOGGER.debug(String.format("Current connected SDCs count: %d - SDC connections are within the limit (%d) on PowerFlex Storage with pool id: %d", connectedSdcsCount, connectedClientsLimit, storagePoolId));
83+
logger.debug(String.format("Current connected SDCs count: %d - SDC connections are within the limit (%d) on PowerFlex Storage with pool id: %d", connectedSdcsCount, connectedClientsLimit, storagePoolId));
8384
return true;
8485
}
85-
LOGGER.debug(String.format("Current connected SDCs count: %d - SDC connections limit (%d) reached on PowerFlex Storage with pool id: %d", connectedSdcsCount, connectedClientsLimit, storagePoolId));
86+
logger.debug(String.format("Current connected SDCs count: %d - SDC connections limit (%d) reached on PowerFlex Storage with pool id: %d", connectedSdcsCount, connectedClientsLimit, storagePoolId));
8687
return false;
8788
} catch (Exception e) {
8889
String errMsg = "Unable to check SDC connections for the PowerFlex storage pool with id: " + storagePoolId + " due to " + e.getMessage();
89-
LOGGER.warn(errMsg, e);
90+
logger.warn(errMsg, e);
9091
return false;
9192
}
9293
}
@@ -109,33 +110,33 @@ public String prepareSDC(Host host, DataStore dataStore) {
109110

110111
int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600);
111112
if (!hostIdStorageSystemIdLock.lock(storagePoolMaxWaitSeconds)) {
112-
LOGGER.debug("Unable to prepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString);
113+
logger.debug("Unable to prepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString);
113114
throw new CloudRuntimeException("Unable to prepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString);
114115
}
115116

116117
long poolId = dataStore.getId();
117118
long hostId = host.getId();
118119
String sdcId = getConnectedSdc(poolId, hostId);
119120
if (StringUtils.isNotBlank(sdcId)) {
120-
LOGGER.debug(String.format("SDC %s already connected for the pool: %d on host: %d, no need to prepare/start it", sdcId, poolId, hostId));
121+
logger.debug(String.format("SDC %s already connected for the pool: %d on host: %d, no need to prepare/start it", sdcId, poolId, hostId));
121122
return sdcId;
122123
}
123124

124125
String storageSystemIdLockString = String.format(POWERFLEX_SDC_SYSTEMID_LOCK_FORMAT, systemId);
125126
storageSystemIdLock = GlobalLock.getInternLock(storageSystemIdLockString);
126127
if (storageSystemIdLock == null) {
127-
LOGGER.error("Unable to prepare SDC, couldn't get global lock on: " + storageSystemIdLockString);
128+
logger.error("Unable to prepare SDC, couldn't get global lock on: " + storageSystemIdLockString);
128129
throw new CloudRuntimeException("Unable to prepare SDC, couldn't get global lock on " + storageSystemIdLockString);
129130
}
130131

131132
if (!storageSystemIdLock.lock(storagePoolMaxWaitSeconds)) {
132-
LOGGER.error("Unable to prepare SDC, couldn't lock on " + storageSystemIdLockString);
133+
logger.error("Unable to prepare SDC, couldn't lock on " + storageSystemIdLockString);
133134
throw new CloudRuntimeException("Unable to prepare SDC, couldn't lock on " + storageSystemIdLockString);
134135
}
135136

136137
if (!areSDCConnectionsWithinLimit(poolId)) {
137138
String errorMsg = String.format("Unable to check SDC connections or the connections limit reached for Powerflex storage (System ID: %s)", systemId);
138-
LOGGER.error(errorMsg);
139+
logger.error(errorMsg);
139140
throw new CloudRuntimeException(errorMsg);
140141
}
141142

@@ -174,7 +175,7 @@ public String prepareSDC(Host host, DataStore dataStore) {
174175
}
175176

176177
private String prepareSDCOnHost(Host host, DataStore dataStore, String systemId) {
177-
LOGGER.debug(String.format("Preparing SDC on the host %s (%s)", host.getId(), host.getName()));
178+
logger.debug(String.format("Preparing SDC on the host %s (%s)", host.getId(), host.getName()));
178179
Map<String,String> details = new HashMap<>();
179180
details.put(ScaleIOGatewayClient.STORAGE_POOL_SYSTEM_ID, systemId);
180181
PrepareStorageClientCommand cmd = new PrepareStorageClientCommand(((PrimaryDataStore) dataStore).getPoolType(), dataStore.getUuid(), details);
@@ -186,25 +187,25 @@ private String prepareSDCOnHost(Host host, DataStore dataStore, String systemId)
186187
prepareStorageClientAnswer = (PrepareStorageClientAnswer) agentManager.send(host.getId(), cmd);
187188
} catch (AgentUnavailableException | OperationTimedoutException e) {
188189
String err = String.format("Failed to prepare SDC on the host %s, due to: %s", host.getName(), e.getMessage());
189-
LOGGER.error(err);
190+
logger.error(err);
190191
throw new CloudRuntimeException(err);
191192
}
192193

193194
if (prepareStorageClientAnswer == null) {
194195
String err = String.format("Unable to prepare SDC on the host %s", host.getName());
195-
LOGGER.error(err);
196+
logger.error(err);
196197
throw new CloudRuntimeException(err);
197198
}
198199

199200
if (!prepareStorageClientAnswer.getResult()) {
200201
String err = String.format("Unable to prepare SDC on the host %s, due to: %s", host.getName(), prepareStorageClientAnswer.getDetails());
201-
LOGGER.error(err);
202+
logger.error(err);
202203
throw new CloudRuntimeException(err);
203204
}
204205

205206
Map<String,String> poolDetails = prepareStorageClientAnswer.getDetailsMap();
206207
if (MapUtils.isEmpty(poolDetails)) {
207-
LOGGER.warn(String.format("PowerFlex storage SDC details not found on the host: %s, try (re)install SDC and restart agent", host.getId()));
208+
logger.warn(String.format("PowerFlex storage SDC details not found on the host: %s, try (re)install SDC and restart agent", host.getId()));
208209
return null;
209210
}
210211

@@ -217,7 +218,7 @@ private String prepareSDCOnHost(Host host, DataStore dataStore, String systemId)
217218
}
218219

219220
if (StringUtils.isBlank(sdcId)) {
220-
LOGGER.warn(String.format("Couldn't retrieve PowerFlex storage SDC details from the host: %s, try (re)install SDC and restart agent", host.getId()));
221+
logger.warn(String.format("Couldn't retrieve PowerFlex storage SDC details from the host: %s, try (re)install SDC and restart agent", host.getId()));
221222
return null;
222223
}
223224

@@ -241,15 +242,15 @@ public boolean stopSDC(Host host, DataStore dataStore) {
241242

242243
int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600);
243244
if (!lock.lock(storagePoolMaxWaitSeconds)) {
244-
LOGGER.debug("Unable to unprepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString);
245+
logger.debug("Unable to unprepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString);
245246
throw new CloudRuntimeException("Unable to unprepare SDC, couldn't lock on " + hostIdStorageSystemIdLockString);
246247
}
247248

248249
long poolId = dataStore.getId();
249250
long hostId = host.getId();
250251
String sdcId = getConnectedSdc(poolId, hostId);
251252
if (StringUtils.isBlank(sdcId)) {
252-
LOGGER.debug("SDC not connected, no need to unprepare it");
253+
logger.debug("SDC not connected, no need to unprepare it");
253254
return true;
254255
}
255256

@@ -263,7 +264,7 @@ public boolean stopSDC(Host host, DataStore dataStore) {
263264
}
264265

265266
private boolean unprepareSDCOnHost(Host host, DataStore dataStore) {
266-
LOGGER.debug(String.format("Unpreparing SDC on the host %s (%s)", host.getId(), host.getName()));
267+
logger.debug(String.format("Unpreparing SDC on the host %s (%s)", host.getId(), host.getName()));
267268
UnprepareStorageClientCommand cmd = new UnprepareStorageClientCommand(((PrimaryDataStore) dataStore).getPoolType(), dataStore.getUuid());
268269
int timeoutSeconds = 60;
269270
cmd.setWait(timeoutSeconds);
@@ -273,25 +274,25 @@ private boolean unprepareSDCOnHost(Host host, DataStore dataStore) {
273274
unprepareStorageClientAnswer = agentManager.send(host.getId(), cmd);
274275
} catch (AgentUnavailableException | OperationTimedoutException e) {
275276
String err = String.format("Failed to unprepare SDC on the host %s due to: %s", host.getName(), e.getMessage());
276-
LOGGER.error(err);
277+
logger.error(err);
277278
return false;
278279
}
279280

280281
if (!unprepareStorageClientAnswer.getResult()) {
281282
String err = String.format("Unable to unprepare SDC on the the host %s due to: %s", host.getName(), unprepareStorageClientAnswer.getDetails());
282-
LOGGER.error(err);
283+
logger.error(err);
283284
return false;
284285
}
285286
return true;
286287
}
287288

288289
private String getHostSdcId(String sdcGuid, long poolId) {
289290
try {
290-
LOGGER.debug(String.format("Try to get host SDC Id for pool: %s, with SDC guid %s", poolId, sdcGuid));
291+
logger.debug(String.format("Try to get host SDC Id for pool: %s, with SDC guid %s", poolId, sdcGuid));
291292
ScaleIOGatewayClient client = getScaleIOClient(poolId);
292293
return client.getSdcIdByGuid(sdcGuid);
293294
} catch (Exception e) {
294-
LOGGER.error(String.format("Failed to get host SDC Id for pool: %s", poolId), e);
295+
logger.error(String.format("Failed to get host SDC Id for pool: %s", poolId), e);
295296
throw new CloudRuntimeException(String.format("Failed to establish connection with PowerFlex Gateway to get host SDC Id for pool: %s", poolId));
296297
}
297298
}
@@ -308,14 +309,14 @@ private String getConnectedSdc(long poolId, long hostId) {
308309
return poolHostVO.getLocalPath();
309310
}
310311
} catch (Exception e) {
311-
LOGGER.warn("Unable to get connected SDC for the host: " + hostId + " and storage pool: " + poolId + " due to " + e.getMessage(), e);
312+
logger.warn("Unable to get connected SDC for the host: " + hostId + " and storage pool: " + poolId + " due to " + e.getMessage(), e);
312313
}
313314

314315
return null;
315316
}
316317

317318
private boolean hostSdcConnected(String sdcId, long poolId, int waitTimeInSecs) {
318-
LOGGER.debug(String.format("Waiting (for %d secs) for the SDC %s of the pool id: %d to connect", waitTimeInSecs, sdcId, poolId));
319+
logger.debug(String.format("Waiting (for %d secs) for the SDC %s of the pool id: %d to connect", waitTimeInSecs, sdcId, poolId));
319320
int timeBetweenTries = 1000; // Try more frequently (every sec) and return early if connected
320321
while (waitTimeInSecs > 0) {
321322
if (isHostSdcConnected(sdcId, poolId)) {
@@ -335,7 +336,7 @@ private boolean isHostSdcConnected(String sdcId, long poolId) {
335336
final ScaleIOGatewayClient client = getScaleIOClient(poolId);
336337
return client.isSdcConnected(sdcId);
337338
} catch (Exception e) {
338-
LOGGER.error("Failed to check host SDC connection", e);
339+
logger.error("Failed to check host SDC connection", e);
339340
throw new CloudRuntimeException("Failed to establish connection with PowerFlex Gateway to check host SDC connection");
340341
}
341342
}

0 commit comments

Comments
 (0)