@Test(expected = ConnectionException.class) public void testProcessConnectStoragePoolFailureOnHost() throws Exception { Mockito.when(poolDao.listBy(Mockito.anyLong(), Mockito.anyLong(), Mockito.anyLong(), Mockito.any(ScopeType.class))).thenReturn(Collections.singletonList(pool)); Mockito.when(poolDao.findZoneWideStoragePoolsByTags(Mockito.anyLong(), Mockito.any(String[].class))).thenReturn(Collections.<StoragePoolVO>emptyList()); Mockito.when(poolDao.findZoneWideStoragePoolsByHypervisor(Mockito.anyLong(), Mockito.any(HypervisorType.class))).thenReturn(Collections.<StoragePoolVO>emptyList()); Mockito.doThrow(new StorageUnavailableException("unable to mount storage", 123L)).when(storageManager).connectHostToSharedPool(Mockito.anyLong(), Mockito.anyLong()); storagePoolMonitor.processConnect(host, cmds, false); }
@Override public void processConnect(final Host host, final StartupCommand[] startupCommands, final boolean forRebalance) throws ConnectionException { for (final StartupCommand startupCommand : startupCommands) { if (startupCommand instanceof StartupRoutingCommand) { final StartupRoutingCommand scCmd = (StartupRoutingCommand) startupCommand; if (scCmd.getHypervisorType() == HypervisorType.XenServer || scCmd.getHypervisorType() == HypervisorType.KVM) { final List<StoragePoolVO> pools = _poolDao.listBy(host.getDataCenterId(), host.getPodId(), host.getClusterId(), ScopeType.CLUSTER); final List<StoragePoolVO> zoneStoragePoolsByTags = _poolDao.findZoneWideStoragePoolsByTags(host.getDataCenterId(), null); final List<StoragePoolVO> zoneStoragePoolsByHypervisor = _poolDao.findZoneWideStoragePoolsByHypervisor(host.getDataCenterId(), scCmd.getHypervisorType()); zoneStoragePoolsByTags.retainAll(zoneStoragePoolsByHypervisor); pools.addAll(zoneStoragePoolsByTags); final List<StoragePoolVO> zoneStoragePoolsByAnyHypervisor = _poolDao.findZoneWideStoragePoolsByHypervisor(host.getDataCenterId(), HypervisorType.Any); pools.addAll(zoneStoragePoolsByAnyHypervisor); for (final StoragePoolVO pool : pools) { if (pool.getStatus() != StoragePoolStatus.Up) { continue; } if (!pool.isShared()) { continue; } if (pool.getPoolType() == StoragePoolType.OCFS2 && !_ocfs2Mgr.prepareNodes(pool.getClusterId())) { throw new ConnectionException(true, "Unable to prepare OCFS2 nodes for pool " + pool.getId()); } final Long hostId = host.getId(); s_logger.debug("Host " + hostId + " connected, connecting host to shared pool id " + pool.getId() + " and sending storage pool information ..."); try { _storageManager.connectHostToSharedPool(hostId, pool.getId()); _storageManager.createCapacityEntry(pool.getId()); } catch (final Exception e) { throw new ConnectionException(true, "Unable to connect host " + hostId + " to storage pool id " + pool.getId() + " due to " + e.toString(), e); } } } } } }
StoragePoolMonitor implements Listener { @Override public void processConnect(final Host host, final StartupCommand[] startupCommands, final boolean forRebalance) throws ConnectionException { for (final StartupCommand startupCommand : startupCommands) { if (startupCommand instanceof StartupRoutingCommand) { final StartupRoutingCommand scCmd = (StartupRoutingCommand) startupCommand; if (scCmd.getHypervisorType() == HypervisorType.XenServer || scCmd.getHypervisorType() == HypervisorType.KVM) { final List<StoragePoolVO> pools = _poolDao.listBy(host.getDataCenterId(), host.getPodId(), host.getClusterId(), ScopeType.CLUSTER); final List<StoragePoolVO> zoneStoragePoolsByTags = _poolDao.findZoneWideStoragePoolsByTags(host.getDataCenterId(), null); final List<StoragePoolVO> zoneStoragePoolsByHypervisor = _poolDao.findZoneWideStoragePoolsByHypervisor(host.getDataCenterId(), scCmd.getHypervisorType()); zoneStoragePoolsByTags.retainAll(zoneStoragePoolsByHypervisor); pools.addAll(zoneStoragePoolsByTags); final List<StoragePoolVO> zoneStoragePoolsByAnyHypervisor = _poolDao.findZoneWideStoragePoolsByHypervisor(host.getDataCenterId(), HypervisorType.Any); pools.addAll(zoneStoragePoolsByAnyHypervisor); for (final StoragePoolVO pool : pools) { if (pool.getStatus() != StoragePoolStatus.Up) { continue; } if (!pool.isShared()) { continue; } if (pool.getPoolType() == StoragePoolType.OCFS2 && !_ocfs2Mgr.prepareNodes(pool.getClusterId())) { throw new ConnectionException(true, "Unable to prepare OCFS2 nodes for pool " + pool.getId()); } final Long hostId = host.getId(); s_logger.debug("Host " + hostId + " connected, connecting host to shared pool id " + pool.getId() + " and sending storage pool information ..."); try { _storageManager.connectHostToSharedPool(hostId, pool.getId()); _storageManager.createCapacityEntry(pool.getId()); } catch (final Exception e) { throw new ConnectionException(true, "Unable to connect host " + hostId + " to storage pool id " + pool.getId() + " due to " + e.toString(), e); } } } } } } }
StoragePoolMonitor implements Listener { @Override public void processConnect(final Host host, final StartupCommand[] startupCommands, final boolean forRebalance) throws ConnectionException { for (final StartupCommand startupCommand : startupCommands) { if (startupCommand instanceof StartupRoutingCommand) { final StartupRoutingCommand scCmd = (StartupRoutingCommand) startupCommand; if (scCmd.getHypervisorType() == HypervisorType.XenServer || scCmd.getHypervisorType() == HypervisorType.KVM) { final List<StoragePoolVO> pools = _poolDao.listBy(host.getDataCenterId(), host.getPodId(), host.getClusterId(), ScopeType.CLUSTER); final List<StoragePoolVO> zoneStoragePoolsByTags = _poolDao.findZoneWideStoragePoolsByTags(host.getDataCenterId(), null); final List<StoragePoolVO> zoneStoragePoolsByHypervisor = _poolDao.findZoneWideStoragePoolsByHypervisor(host.getDataCenterId(), scCmd.getHypervisorType()); zoneStoragePoolsByTags.retainAll(zoneStoragePoolsByHypervisor); pools.addAll(zoneStoragePoolsByTags); final List<StoragePoolVO> zoneStoragePoolsByAnyHypervisor = _poolDao.findZoneWideStoragePoolsByHypervisor(host.getDataCenterId(), HypervisorType.Any); pools.addAll(zoneStoragePoolsByAnyHypervisor); for (final StoragePoolVO pool : pools) { if (pool.getStatus() != StoragePoolStatus.Up) { continue; } if (!pool.isShared()) { continue; } if (pool.getPoolType() == StoragePoolType.OCFS2 && !_ocfs2Mgr.prepareNodes(pool.getClusterId())) { throw new ConnectionException(true, "Unable to prepare OCFS2 nodes for pool " + pool.getId()); } final Long hostId = host.getId(); s_logger.debug("Host " + hostId + " connected, connecting host to shared pool id " + pool.getId() + " and sending storage pool information ..."); try { _storageManager.connectHostToSharedPool(hostId, pool.getId()); _storageManager.createCapacityEntry(pool.getId()); } catch (final Exception e) { throw new ConnectionException(true, "Unable to connect host " + hostId + " to storage pool id " + pool.getId() + " due to " + e.toString(), e); } } } } } } StoragePoolMonitor(final StorageManagerImpl mgr, final PrimaryDataStoreDao poolDao); }
StoragePoolMonitor implements Listener { @Override public void processConnect(final Host host, final StartupCommand[] startupCommands, final boolean forRebalance) throws ConnectionException { for (final StartupCommand startupCommand : startupCommands) { if (startupCommand instanceof StartupRoutingCommand) { final StartupRoutingCommand scCmd = (StartupRoutingCommand) startupCommand; if (scCmd.getHypervisorType() == HypervisorType.XenServer || scCmd.getHypervisorType() == HypervisorType.KVM) { final List<StoragePoolVO> pools = _poolDao.listBy(host.getDataCenterId(), host.getPodId(), host.getClusterId(), ScopeType.CLUSTER); final List<StoragePoolVO> zoneStoragePoolsByTags = _poolDao.findZoneWideStoragePoolsByTags(host.getDataCenterId(), null); final List<StoragePoolVO> zoneStoragePoolsByHypervisor = _poolDao.findZoneWideStoragePoolsByHypervisor(host.getDataCenterId(), scCmd.getHypervisorType()); zoneStoragePoolsByTags.retainAll(zoneStoragePoolsByHypervisor); pools.addAll(zoneStoragePoolsByTags); final List<StoragePoolVO> zoneStoragePoolsByAnyHypervisor = _poolDao.findZoneWideStoragePoolsByHypervisor(host.getDataCenterId(), HypervisorType.Any); pools.addAll(zoneStoragePoolsByAnyHypervisor); for (final StoragePoolVO pool : pools) { if (pool.getStatus() != StoragePoolStatus.Up) { continue; } if (!pool.isShared()) { continue; } if (pool.getPoolType() == StoragePoolType.OCFS2 && !_ocfs2Mgr.prepareNodes(pool.getClusterId())) { throw new ConnectionException(true, "Unable to prepare OCFS2 nodes for pool " + pool.getId()); } final Long hostId = host.getId(); s_logger.debug("Host " + hostId + " connected, connecting host to shared pool id " + pool.getId() + " and sending storage pool information ..."); try { _storageManager.connectHostToSharedPool(hostId, pool.getId()); _storageManager.createCapacityEntry(pool.getId()); } catch (final Exception e) { throw new ConnectionException(true, "Unable to connect host " + hostId + " to storage pool id " + pool.getId() + " due to " + e.toString(), e); } } } } } } StoragePoolMonitor(final StorageManagerImpl mgr, final PrimaryDataStoreDao poolDao); @Override synchronized boolean processAnswers(final long agentId, final long seq, final Answer[] resp); @Override boolean processCommands(final long agentId, final long seq, final Command[] req); @Override AgentControlAnswer processControlCommand(final long agentId, final AgentControlCommand cmd); @Override void processConnect(final Host host, final StartupCommand[] startupCommands, final boolean forRebalance); @Override synchronized boolean processDisconnect(final long agentId, final HostStatus state); @Override boolean isRecurring(); @Override int getTimeout(); @Override boolean processTimeout(final long agentId, final long seq); }
StoragePoolMonitor implements Listener { @Override public void processConnect(final Host host, final StartupCommand[] startupCommands, final boolean forRebalance) throws ConnectionException { for (final StartupCommand startupCommand : startupCommands) { if (startupCommand instanceof StartupRoutingCommand) { final StartupRoutingCommand scCmd = (StartupRoutingCommand) startupCommand; if (scCmd.getHypervisorType() == HypervisorType.XenServer || scCmd.getHypervisorType() == HypervisorType.KVM) { final List<StoragePoolVO> pools = _poolDao.listBy(host.getDataCenterId(), host.getPodId(), host.getClusterId(), ScopeType.CLUSTER); final List<StoragePoolVO> zoneStoragePoolsByTags = _poolDao.findZoneWideStoragePoolsByTags(host.getDataCenterId(), null); final List<StoragePoolVO> zoneStoragePoolsByHypervisor = _poolDao.findZoneWideStoragePoolsByHypervisor(host.getDataCenterId(), scCmd.getHypervisorType()); zoneStoragePoolsByTags.retainAll(zoneStoragePoolsByHypervisor); pools.addAll(zoneStoragePoolsByTags); final List<StoragePoolVO> zoneStoragePoolsByAnyHypervisor = _poolDao.findZoneWideStoragePoolsByHypervisor(host.getDataCenterId(), HypervisorType.Any); pools.addAll(zoneStoragePoolsByAnyHypervisor); for (final StoragePoolVO pool : pools) { if (pool.getStatus() != StoragePoolStatus.Up) { continue; } if (!pool.isShared()) { continue; } if (pool.getPoolType() == StoragePoolType.OCFS2 && !_ocfs2Mgr.prepareNodes(pool.getClusterId())) { throw new ConnectionException(true, "Unable to prepare OCFS2 nodes for pool " + pool.getId()); } final Long hostId = host.getId(); s_logger.debug("Host " + hostId + " connected, connecting host to shared pool id " + pool.getId() + " and sending storage pool information ..."); try { _storageManager.connectHostToSharedPool(hostId, pool.getId()); _storageManager.createCapacityEntry(pool.getId()); } catch (final Exception e) { throw new ConnectionException(true, "Unable to connect host " + hostId + " to storage pool id " + pool.getId() + " due to " + e.toString(), e); } } } } } } StoragePoolMonitor(final StorageManagerImpl mgr, final PrimaryDataStoreDao poolDao); @Override synchronized boolean processAnswers(final long agentId, final long seq, final Answer[] resp); @Override boolean processCommands(final long agentId, final long seq, final Command[] req); @Override AgentControlAnswer processControlCommand(final long agentId, final AgentControlCommand cmd); @Override void processConnect(final Host host, final StartupCommand[] startupCommands, final boolean forRebalance); @Override synchronized boolean processDisconnect(final long agentId, final HostStatus state); @Override boolean isRecurring(); @Override int getTimeout(); @Override boolean processTimeout(final long agentId, final long seq);  }