Skip to content

Commit 7d43ce3

Browse files
committed
address comments
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 779d521 commit 7d43ce3

File tree

16 files changed

+59
-46
lines changed

16 files changed

+59
-46
lines changed

agent/conf/agent.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,9 @@ iscsi.session.cleanup.enabled=false
434434
# Implicit host tags managed by agent.properties
435435
# host.tags=
436436

437-
# Timeout(in seconds) for SSL handshake when agent connects to server
437+
# Timeout(in seconds) for SSL handshake when agent connects to server. When no value is set then default value of 30s
438+
# will be used
438439
#ssl.handshake.timeout=
439440

440-
# Wait(in seconds) during agent reconnections
441+
# Wait(in seconds) during agent reconnections. When no value is set then default value of 5s will be used
441442
#backoff.seconds=

agent/src/main/java/com/cloud/agent/Agent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ public void sendStartup(final Link link) {
526526

527527
protected String retrieveHostname() {
528528
if (logger.isTraceEnabled()) {
529-
logger.trace(" Retrieving hostname " + serverResource.getClass().getSimpleName());
529+
logger.trace("Retrieving hostname with resource={}", serverResource.getClass().getSimpleName());
530530
}
531531
final String result = Script.runSimpleBashScript(Script.getExecutableAbsolutePath("hostname"), 500);
532532
if (StringUtils.isNotBlank(result)) {

engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
179179

180180
protected ExecutorService _executor;
181181
protected ThreadPoolExecutor _connectExecutor;
182-
protected ThreadPoolExecutor _directAgentExecutor;
182+
protected ScheduledExecutorService _directAgentExecutor;
183183
protected ScheduledExecutorService _cronJobExecutor;
184184
protected ScheduledExecutorService _monitorExecutor;
185185

@@ -243,12 +243,13 @@ public boolean configure(final String name, final Map<String, Object> params) th
243243
caService, RemoteAgentSslHandshakeTimeout.value());
244244
logger.info("Listening on {} with {} workers.", Port.value(), Workers.value());
245245

246+
final int directAgentPoolSize = DirectAgentPoolSize.value();
246247
// executes all agent commands other than cron and ping
247-
_directAgentExecutor = new ThreadPoolExecutor(Math.max(agentTaskThreads/10, 1), DirectAgentPoolSize.value(), 120L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new NamedThreadFactory("DirectAgent"));
248+
_directAgentExecutor = new ScheduledThreadPoolExecutor(directAgentPoolSize, new NamedThreadFactory("DirectAgent"));
248249
// executes cron and ping agent commands
249-
_cronJobExecutor = new ScheduledThreadPoolExecutor(DirectAgentPoolSize.value(), new NamedThreadFactory("DirectAgentCronJob"));
250-
logger.debug("Created DirectAgentAttache pool with size: {}.", DirectAgentPoolSize.value());
251-
_directAgentThreadCap = Math.round(DirectAgentPoolSize.value() * DirectAgentThreadCap.value()) + 1; // add 1 to always make the value > 0
250+
_cronJobExecutor = new ScheduledThreadPoolExecutor(directAgentPoolSize, new NamedThreadFactory("DirectAgentCronJob"));
251+
logger.debug("Created DirectAgentAttache pool with size: {}.", directAgentPoolSize);
252+
_directAgentThreadCap = Math.round(directAgentPoolSize * DirectAgentThreadCap.value()) + 1; // add 1 to always make the value > 0
252253

253254
_monitorExecutor = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("AgentMonitor"));
254255

@@ -1642,7 +1643,7 @@ public void pullAgentOutMaintenance(final long hostId) {
16421643
}
16431644
}
16441645

1645-
public ThreadPoolExecutor getDirectAgentPool() {
1646+
public ScheduledExecutorService getDirectAgentPool() {
16461647
return _directAgentExecutor;
16471648
}
16481649

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3803,7 +3803,6 @@ public int getTimeout() {
38033803
public boolean processCommands(final long agentId, final long seq, final Command[] cmds) {
38043804
boolean processed = false;
38053805
for (final Command cmd : cmds) {
3806-
// FIXME: PingRoutingCommand handler is DB & CPU hotspot
38073806
if (cmd instanceof PingRoutingCommand) {
38083807
final PingRoutingCommand ping = (PingRoutingCommand)cmd;
38093808
if (ping.getHostVmStateReport() != null) {

engine/schema/src/main/java/com/cloud/dc/dao/ClusterDao.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,4 @@ public interface ClusterDao extends GenericDao<ClusterVO, Long> {
5959
List<CPU.CPUArch> getClustersArchsByZone(long zoneId);
6060

6161
List<ClusterVO> listClustersByArchAndZoneId(long zoneId, CPU.CPUArch arch);
62-
63-
List<Long> listAllIds();
6462
}

engine/schema/src/main/java/com/cloud/dc/dao/ClusterDaoImpl.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,10 @@ public List<HypervisorType> getAvailableHypervisorInZone(Long zoneId) {
171171
sc.setParameters("zoneId", zoneId);
172172
}
173173
List<ClusterVO> clusters = listBy(sc);
174-
List<HypervisorType> distinctHypervisors = new ArrayList<>(4);
175-
for (ClusterVO cluster : clusters) {
176-
distinctHypervisors.add(cluster.getHypervisorType());
177-
}
178-
179-
return distinctHypervisors;
174+
return clusters.stream()
175+
.map(ClusterVO::getHypervisorType)
176+
.distinct()
177+
.collect(Collectors.toList());
180178
}
181179

182180
@Override
@@ -346,12 +344,4 @@ public List<ClusterVO> listClustersByArchAndZoneId(long zoneId, CPU.CPUArch arch
346344
sc.setParameters("arch", arch);
347345
return listBy(sc);
348346
}
349-
350-
@Override
351-
public List<Long> listAllIds() {
352-
GenericSearchBuilder<ClusterVO, Long> sb = createSearchBuilder(Long.class);
353-
sb.selectFields(sb.entity().getId());
354-
sb.done();
355-
return customSearch(sb.create(), null);
356-
}
357347
}

engine/schema/src/main/java/com/cloud/host/dao/HostDao.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@ List<Long> findHostIdsByZoneClusterResourceStateTypeAndHypervisorType(final Long
192192
final List<ResourceState> resourceStates, final List<Type> types,
193193
final List<Hypervisor.HypervisorType> hypervisorTypes);
194194

195-
List<Long> listAllIds();
196-
197195
List<HypervisorType> listDistinctHypervisorTypes(final Long zoneId);
198196

199197
List<HostVO> listByIds(final List<Long> ids);

engine/schema/src/main/java/com/cloud/host/dao/HostDaoImpl.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,11 +1743,6 @@ public List<Long> findHostIdsByZoneClusterResourceStateTypeAndHypervisorType(fin
17431743
return customSearch(sc, null);
17441744
}
17451745

1746-
@Override
1747-
public List<Long> listAllIds() {
1748-
return listIdsBy(null, null, null, null, null, null, null);
1749-
}
1750-
17511746
@Override
17521747
public List<HypervisorType> listDistinctHypervisorTypes(final Long zoneId) {
17531748
GenericSearchBuilder<HostVO, HypervisorType> sb = createSearchBuilder(HypervisorType.class);

engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,4 @@ Pair<List<Long>, Integer> searchForIdsAndCount(Long storagePoolId, String storag
154154
String keyword, Filter searchFilter);
155155

156156
List<StoragePoolVO> listByIds(List<Long> ids);
157-
158-
List<Long> listAllIds();
159157
}

engine/schema/src/main/java/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -800,12 +800,4 @@ private SearchCriteria<StoragePoolVO> createStoragePoolSearchCriteria(Long stora
800800
sc.setParameters("parent", 0);
801801
return sc;
802802
}
803-
804-
@Override
805-
public List<Long> listAllIds() {
806-
GenericSearchBuilder<StoragePoolVO, Long> sb = createSearchBuilder(Long.class);
807-
sb.selectFields(sb.entity().getId());
808-
sb.done();
809-
return customSearch(sb.create(), null);
810-
}
811803
}

0 commit comments

Comments
 (0)