use of com.cloud.utils.concurrency.NamedThreadFactory in project cloudstack by apache.
the class MockAgentManagerImpl method configure.
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
try {
random = SecureRandom.getInstance("SHA1PRNG");
_executor = new ThreadPoolExecutor(1, 5, 1, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory("Simulator-Agent-Mgr"));
} catch (NoSuchAlgorithmException e) {
s_logger.debug("Failed to initialize random:" + e.toString());
return false;
}
return true;
}
use of com.cloud.utils.concurrency.NamedThreadFactory in project cloudstack by apache.
the class ClientTransportProvider method initialize.
public void initialize(String serverAddress, int serverPort) {
_serverAddress = serverAddress;
_serverPort = serverPort;
_executor = Executors.newFixedThreadPool(_poolSize, new NamedThreadFactory("Transport-Worker"));
_connection = new ClientTransportConnection(this);
_executor.execute(new ManagedContextRunnable() {
@Override
protected void runInContext() {
try {
_connection.connect(_serverAddress, _serverPort);
} catch (Throwable e) {
s_logger.info("[ignored]" + "error during ipc client initialization: " + e.getLocalizedMessage());
}
}
});
}
use of com.cloud.utils.concurrency.NamedThreadFactory in project cloudstack by apache.
the class TemplateManagerImplTest method testTemplateScheduledForDownloadInDisabledPool.
@Test
public void testTemplateScheduledForDownloadInDisabledPool() {
VMTemplateVO mockTemplate = mock(VMTemplateVO.class);
StoragePoolVO mockPool = mock(StoragePoolVO.class);
PrimaryDataStore mockPrimaryDataStore = mock(PrimaryDataStore.class);
VMTemplateStoragePoolVO mockTemplateStore = mock(VMTemplateStoragePoolVO.class);
when(mockPrimaryDataStore.getId()).thenReturn(2l);
when(mockPool.getId()).thenReturn(2l);
when(mockPool.getStatus()).thenReturn(StoragePoolStatus.Disabled);
when(mockPool.getDataCenterId()).thenReturn(1l);
when(mockTemplate.getId()).thenReturn(202l);
when(mockTemplateStore.getDownloadState()).thenReturn(VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
when(vmTemplateDao.findById(anyLong())).thenReturn(mockTemplate);
when(dataStoreManager.getPrimaryDataStore(anyLong())).thenReturn(mockPrimaryDataStore);
when(vmTemplateDao.findById(anyLong(), anyBoolean())).thenReturn(mockTemplate);
when(vmTemplatePoolDao.findByPoolTemplate(anyLong(), anyLong())).thenReturn(mockTemplateStore);
when(primaryDataStoreDao.findById(anyLong())).thenReturn(mockPool);
doNothing().when(mockTemplateStore).setMarkedForGC(anyBoolean());
ExecutorService preloadExecutor = new CustomThreadPoolExecutor(8, 8, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new NamedThreadFactory("Template-Preloader"));
templateManager._preloadExecutor = preloadExecutor;
templateManager.prepareTemplate(202, 1, 2l);
assertTrue("Test template is not scheduled for seeding on disabled pool", ((CustomThreadPoolExecutor) preloadExecutor).getCount() == 0);
}
use of com.cloud.utils.concurrency.NamedThreadFactory in project cloudstack by apache.
the class NioConnection method start.
public void start() throws NioConnectionException {
_todos = new ArrayList<ChangeRequest>();
try {
init();
} catch (final ConnectException e) {
s_logger.warn("Unable to connect to remote: is there a server running on port " + _port);
return;
} catch (final IOException e) {
s_logger.error("Unable to initialize the threads.", e);
throw new NioConnectionException(e.getMessage(), e);
} catch (final Exception e) {
s_logger.error("Unable to initialize the threads due to unknown exception.", e);
throw new NioConnectionException(e.getMessage(), e);
}
_isStartup = true;
_threadExecutor = Executors.newSingleThreadExecutor(new NamedThreadFactory(this._name + "-NioConnectionHandler"));
_isRunning = true;
_futureTask = _threadExecutor.submit(this);
}
use of com.cloud.utils.concurrency.NamedThreadFactory in project cloudstack by apache.
the class UploadMonitorImpl method configure.
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
final Map<String, String> configs = _configDao.getConfiguration("management-server", params);
_sslCopy = Boolean.parseBoolean(configs.get("secstorage.encrypt.copy"));
String cert = configs.get("secstorage.secure.copy.cert");
if ("realhostip.com".equalsIgnoreCase(cert)) {
s_logger.warn("Only realhostip.com ssl cert is supported, ignoring self-signed and other certs");
}
_ssvmUrlDomain = configs.get("secstorage.ssl.cert.domain");
_agentMgr.registerForHostEvents(new UploadListener(this), true, false, false);
String cleanupInterval = configs.get("extract.url.cleanup.interval");
_cleanupInterval = NumbersUtil.parseInt(cleanupInterval, 7200);
String urlExpirationInterval = configs.get("extract.url.expiration.interval");
_urlExpirationInterval = NumbersUtil.parseInt(urlExpirationInterval, 14400);
String workers = (String) params.get("expunge.workers");
int wrks = NumbersUtil.parseInt(workers, 1);
_executor = Executors.newScheduledThreadPool(wrks, new NamedThreadFactory("UploadMonitor-Scavenger"));
return true;
}
Aggregations