本文整理汇总了Java中com.cloud.utils.concurrency.NamedThreadFactory类的典型用法代码示例。如果您正苦于以下问题:Java NamedThreadFactory类的具体用法?Java NamedThreadFactory怎么用?Java NamedThreadFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NamedThreadFactory类属于com.cloud.utils.concurrency包,在下文中一共展示了NamedThreadFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Agent
import com.cloud.utils.concurrency.NamedThreadFactory; //导入依赖的package包/类
public Agent(final AgentProperties agentProperties, final BackoffAlgorithm backOffAlgorithm, final ServerResource resource) throws ConfigurationException {
this.agentProperties = agentProperties;
this.backOffAlgorithm = backOffAlgorithm;
this.resource = resource;
resource.setAgentControl(this);
hostRotator.addAll(agentProperties.getHosts());
createNioClient(agentProperties);
logger.debug("Adding shutdown hook");
Runtime.getRuntime().addShutdownHook(new ShutdownThread(this));
_urgentTaskPool = new ThreadPoolExecutor(agentProperties.getPingRetries(), 2 * agentProperties.getPingRetries(), 10, TimeUnit.MINUTES, new SynchronousQueue<>(),
new NamedThreadFactory("UrgentTask"));
_executor =
new ThreadPoolExecutor(agentProperties.getWorkers(), 5 * agentProperties.getWorkers(), 1, TimeUnit.DAYS, new LinkedBlockingQueue<>(),
new NamedThreadFactory("agentRequest-Handler"));
logger.info("Agent [id = " + (_id != null ? _id : "new") + " : type = " + getResourceName() + " : zone = " + agentProperties.getZone() + " : pod = "
+ agentProperties.getPod() + " : workers = " + agentProperties.getWorkers() + " : host = " + agentProperties.getHosts() + " : port = " + agentProperties.getPort());
}
示例2: configure
import com.cloud.utils.concurrency.NamedThreadFactory; //导入依赖的package包/类
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
final Map<String, String> configs = _configDao.getConfiguration("management-server", params);
_sslCopy = Boolean.parseBoolean(configs.get("secstorage.encrypt.copy"));
final 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);
final String cleanupInterval = configs.get("extract.url.cleanup.interval");
_cleanupInterval = NumbersUtil.parseInt(cleanupInterval, 7200);
final String urlExpirationInterval = configs.get("extract.url.expiration.interval");
_urlExpirationInterval = NumbersUtil.parseInt(urlExpirationInterval, 14400);
final String workers = (String) params.get("expunge.workers");
final int wrks = NumbersUtil.parseInt(workers, 1);
_executor = Executors.newScheduledThreadPool(wrks, new NamedThreadFactory("UploadMonitor-Scavenger"));
return true;
}
示例3: configure
import com.cloud.utils.concurrency.NamedThreadFactory; //导入依赖的package包/类
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
_name = name;
_configParams = params;
_gcExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Container-Cluster-Scavenger"));
_stateScanner = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Container-Cluster-State-Scanner"));
final KeystoreVO keyStoreVO = keystoreDao.findByName(CCS_ROOTCA_KEYPAIR);
if (keyStoreVO == null) {
try {
final KeyPair keyPair = generateRandomKeyPair();
final String rootCACert = x509CertificateToPem(generateRootCACertificate(keyPair));
final String rootCAKey = rsaPrivateKeyToPem(keyPair.getPrivate());
keystoreDao.save(CCS_ROOTCA_KEYPAIR, rootCACert, rootCAKey, "");
s_logger.info("No Container Cluster CA stores found, created and saved a keypair with certificate: \n" + rootCACert);
} catch (NoSuchProviderException | NoSuchAlgorithmException | CertificateEncodingException | SignatureException | InvalidKeyException | IOException e) {
s_logger.error("Unable to create and save CCS rootCA keypair: " + e.toString());
}
}
return true;
}
示例4: Agent
import com.cloud.utils.concurrency.NamedThreadFactory; //导入依赖的package包/类
public Agent(final IAgentShell shell) {
_shell = shell;
_link = null;
_connection = new NioClient("Agent", _shell.getHost(), _shell.getPort(), _shell.getWorkers(), this);
Runtime.getRuntime().addShutdownHook(new ShutdownThread(this));
_ugentTaskPool =
new ThreadPoolExecutor(shell.getPingRetries(), 2 * shell.getPingRetries(), 10, TimeUnit.MINUTES, new SynchronousQueue<Runnable>(), new NamedThreadFactory(
"UgentTask"));
_executor =
new ThreadPoolExecutor(_shell.getWorkers(), 5 * _shell.getWorkers(), 1, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory(
"agentRequest-Handler"));
}
示例5: start
import com.cloud.utils.concurrency.NamedThreadFactory; //导入依赖的package包/类
@Override
public boolean start() {
if (isConfiguredAndStarted) {
return true;
}
backgroundPollTaskScheduler = Executors.newScheduledThreadPool(submittedTasks.size() + 1, new NamedThreadFactory("BackgroundTaskPollManager"));
for (final BackgroundPollTask task : submittedTasks) {
Long delay = task.getDelay();
if (delay == null) {
delay = getRoundDelay();
}
backgroundPollTaskScheduler.scheduleWithFixedDelay(task, getInitialDelay(), delay, TimeUnit.MILLISECONDS);
LOG.debug("Scheduled background poll task: " + task.getClass().getName());
}
isConfiguredAndStarted = true;
return true;
}
示例6: configure
import com.cloud.utils.concurrency.NamedThreadFactory; //导入依赖的package包/类
@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;
}
示例7: configure
import com.cloud.utils.concurrency.NamedThreadFactory; //导入依赖的package包/类
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
String value = _configDao.getValue(Config.BackupSnapshotWait.toString());
Type.HOURLY.setMax(SnapshotHourlyMax.value());
Type.DAILY.setMax(SnapshotDailyMax.value());
Type.WEEKLY.setMax(SnapshotWeeklyMax.value());
Type.MONTHLY.setMax(SnapshotMonthlyMax.value());
_totalRetries = NumbersUtil.parseInt(_configDao.getValue("total.retries"), 4);
_pauseInterval = 2 * NumbersUtil.parseInt(_configDao.getValue("ping.interval"), 60);
snapshotBackupRetries = BackupRetryAttempts.value();
snapshotBackupRetryInterval = BackupRetryInterval.value();
backupSnapshotExecutor = Executors.newScheduledThreadPool(10, new NamedThreadFactory("BackupSnapshotTask"));
s_logger.info("Snapshot Manager is configured.");
return true;
}
示例8: initialize
import com.cloud.utils.concurrency.NamedThreadFactory; //导入依赖的package包/类
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());
}
}
});
}
示例9: configure
import com.cloud.utils.concurrency.NamedThreadFactory; //导入依赖的package包/类
@Override
public boolean configure(final String name, final Map<String, Object> xmlParams) throws ConfigurationException {
ReservationContextImpl.init(_entityMgr);
VirtualMachineProfileImpl.init(_entityMgr);
VmWorkMigrate.init(_entityMgr, _zoneRepository);
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Vm-Operations-Cleanup"));
_nodeId = ManagementServerNode.getManagementServerId();
_agentMgr.registerForHostEvents(this, true, true, true);
_messageBus.subscribe(VirtualMachineManager.Topics.VM_POWER_STATE, MessageDispatcher.getDispatcher(this));
return true;
}
示例10: configure
import com.cloud.utils.concurrency.NamedThreadFactory; //导入依赖的package包/类
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
s_logger.info("Ping Timeout is " + PingTimeout.value());
final int threads = DirectAgentLoadSize.value();
_nodeId = ManagementServerNode.getManagementServerId();
s_logger.info("Configuring AgentManagerImpl. management server node id(msid): " + _nodeId);
final long lastPing = (System.currentTimeMillis() >> 10) - (long) (PingTimeout.value() * PingInterval.value());
_hostDao.markHostsAsDisconnected(_nodeId, lastPing);
registerForHostEvents(new BehindOnPingListener(), true, true, false);
_executor = new ThreadPoolExecutor(threads, threads, 60l, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new NamedThreadFactory("AgentTaskPool"));
_connectExecutor = new ThreadPoolExecutor(100, 500, 60l, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new NamedThreadFactory("AgentConnectTaskPool"));
// allow core threads to time out even when there are no items in the queue
_connectExecutor.allowCoreThreadTimeOut(true);
_connection = new NioServer("AgentManager", Port.value(), Workers.value() + 10, this);
s_logger.info("Listening on " + Port.value() + " with " + Workers.value() + " workers");
// executes all agent commands other than cron and ping
_directAgentExecutor = new ScheduledThreadPoolExecutor(DirectAgentPoolSize.value(), new NamedThreadFactory("DirectAgent"));
// executes cron and ping agent commands
_cronJobExecutor = new ScheduledThreadPoolExecutor(DirectAgentPoolSize.value(), new NamedThreadFactory("DirectAgentCronJob"));
s_logger.debug("Created DirectAgentAttache pool with size: " + DirectAgentPoolSize.value());
_directAgentThreadCap = Math.round(DirectAgentPoolSize.value() * DirectAgentThreadCap.value()) + 1; // add 1 to always make the value > 0
_monitorExecutor = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("AgentMonitor"));
return true;
}
示例11: configure
import com.cloud.utils.concurrency.NamedThreadFactory; //导入依赖的package包/类
@Override
@DB
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
AssignIpAddressSearch = _ipAddressDao.createSearchBuilder();
AssignIpAddressSearch.and("dc", AssignIpAddressSearch.entity().getDataCenterId(), Op.EQ);
AssignIpAddressSearch.and("allocated", AssignIpAddressSearch.entity().getAllocatedTime(), Op.NULL);
AssignIpAddressSearch.and("vlanId", AssignIpAddressSearch.entity().getVlanId(), Op.IN);
final SearchBuilder<VlanVO> vlanSearch = _vlanDao.createSearchBuilder();
vlanSearch.and("type", vlanSearch.entity().getVlanType(), Op.EQ);
vlanSearch.and("networkId", vlanSearch.entity().getNetworkId(), Op.EQ);
AssignIpAddressSearch.join("vlan", vlanSearch, vlanSearch.entity().getId(), AssignIpAddressSearch.entity().getVlanId(), JoinType.INNER);
AssignIpAddressSearch.done();
AssignIpAddressFromPodVlanSearch = _ipAddressDao.createSearchBuilder();
AssignIpAddressFromPodVlanSearch.and("dc", AssignIpAddressFromPodVlanSearch.entity().getDataCenterId(), Op.EQ);
AssignIpAddressFromPodVlanSearch.and("allocated", AssignIpAddressFromPodVlanSearch.entity().getAllocatedTime(), Op.NULL);
AssignIpAddressFromPodVlanSearch.and("vlanId", AssignIpAddressFromPodVlanSearch.entity().getVlanId(), Op.IN);
final SearchBuilder<VlanVO> podVlanSearch = _vlanDao.createSearchBuilder();
podVlanSearch.and("type", podVlanSearch.entity().getVlanType(), Op.EQ);
podVlanSearch.and("networkId", podVlanSearch.entity().getNetworkId(), Op.EQ);
final SearchBuilder<PodVlanMapVO> podVlanMapSB = _podVlanMapDao.createSearchBuilder();
podVlanMapSB.and("podId", podVlanMapSB.entity().getPodId(), Op.EQ);
AssignIpAddressFromPodVlanSearch.join("podVlanMapSB", podVlanMapSB, podVlanMapSB.entity().getVlanDbId(), AssignIpAddressFromPodVlanSearch.entity().getVlanId(),
JoinType.INNER);
AssignIpAddressFromPodVlanSearch.join("vlan", podVlanSearch, podVlanSearch.entity().getId(), AssignIpAddressFromPodVlanSearch.entity().getVlanId(), JoinType.INNER);
AssignIpAddressFromPodVlanSearch.done();
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Network-Scavenger"));
_agentMgr.registerForHostEvents(this, true, false, true);
s_logger.info("Network Manager is configured.");
return true;
}
示例12: configure
import com.cloud.utils.concurrency.NamedThreadFactory; //导入依赖的package包/类
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
cacheReplacementEnabled = Boolean.parseBoolean(configDao.getValue(Config.StorageCacheReplacementEnabled.key()));
cacheReplaceMentInterval = NumbersUtil.parseInt(configDao.getValue(Config.StorageCacheReplacementInterval.key()), 86400);
workers = NumbersUtil.parseInt(configDao.getValue(Config.ExpungeWorkers.key()), 10);
executors = Executors.newScheduledThreadPool(workers, new NamedThreadFactory("StorageCacheManager-cache-replacement"));
return true;
}
示例13: restart
import com.cloud.utils.concurrency.NamedThreadFactory; //导入依赖的package包/类
@Override
public synchronized String restart() {
turnOff();
s_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("InaccurateClock"));
s_executor.scheduleAtFixedRate(new SetTimeTask(), 0, 60, TimeUnit.SECONDS);
return "Restarted";
}
示例14: NioConnection
import com.cloud.utils.concurrency.NamedThreadFactory; //导入依赖的package包/类
public NioConnection(final String name, final int port, final int workers, final HandlerFactory factory) {
_name = name;
_isRunning = false;
_selector = null;
_port = port;
_factory = factory;
_executor = new ThreadPoolExecutor(workers, 5 * workers, 1, TimeUnit.DAYS, new LinkedBlockingQueue<>(), new NamedThreadFactory(name + "-Handler"));
}
示例15: configure
import com.cloud.utils.concurrency.NamedThreadFactory; //导入依赖的package包/类
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
_configs = _configDao.getConfiguration("management-server", params);
if (s_logger.isInfoEnabled()) {
s_logger.info(format("Configuring LBHealthCheck Manager %1$s", name));
}
this.name = name;
_interval = NumbersUtil.parseLong(_configs.get(Config.LBHealthCheck.key()), 600);
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("LBHealthCheck"));
return true;
}