本文整理汇总了Java中org.apache.commons.lang3.time.StopWatch类的典型用法代码示例。如果您正苦于以下问题:Java StopWatch类的具体用法?Java StopWatch怎么用?Java StopWatch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StopWatch类属于org.apache.commons.lang3.time包,在下文中一共展示了StopWatch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createKafkaConsumer
import org.apache.commons.lang3.time.StopWatch; //导入依赖的package包/类
/**
* Create topic consumer.
* @param tenant the kafka topic
*/
public void createKafkaConsumer(String tenant) {
StopWatch stopWatch = StopWatch.createStarted();
try {
log.info("START - SETUP:CreateTenant:kafka consumer tenantKey: {}", tenant);
ConcurrentMessageListenerContainer<String, String> container = consumers.get(tenant);
if (container != null) {
if (!container.isRunning()) {
container.start();
}
} else {
ContainerProperties containerProps = new ContainerProperties(tenant);
container = new ConcurrentMessageListenerContainer<>(consumerFactory, containerProps);
container.setupMessageListener((MessageListener<String, String>) consumer::consumeEvent);
container.setBeanName(tenant);
container.start();
consumers.put(tenant, container);
}
log.info("STOP - SETUP:CreateTenant:kafka consumer tenantKey: {}, result: OK, time = {} ms",
tenant, stopWatch.getTime());
} catch (Exception e) {
log.error("STOP - SETUP:CreateTenant:kafka consumer tenantKey: {}, result: FAIL, error: {}, time = {} ms",
tenant, e.getMessage(), stopWatch.getTime(), e);
}
}
示例2: createTenant
import org.apache.commons.lang3.time.StopWatch; //导入依赖的package包/类
/**
* Create tenant.
* @param tenant tenant key
*/
public void createTenant(String tenant) {
StopWatch stopWatch = StopWatch.createStarted();
log.info("START - SETUP:CreateTenant: tenantKey: {}", tenant);
try {
tenantListRepository.addTenant(tenant);
databaseService.create(tenant);
databaseService.migrate(tenant);
addUaaSpecification(tenant);
addLoginsSpecification(tenant);
log.info("STOP - SETUP:CreateTenant: tenantKey: {}, result: OK, time = {} ms",
tenant, stopWatch.getTime());
} catch (Exception e) {
log.info("STOP - SETUP:CreateTenant: tenantKey: {}, result: FAIL, error: {}, time = {} ms",
tenant, e.getMessage(), stopWatch.getTime());
throw e;
}
}
示例3: deleteTenant
import org.apache.commons.lang3.time.StopWatch; //导入依赖的package包/类
/**
* Delete tenant.
* @param tenant tenant key
*/
public void deleteTenant(String tenant) {
StopWatch stopWatch = StopWatch.createStarted();
log.info("START - SETUP:DeleteTenant: tenantKey: {}", tenant);
try {
databaseService.drop(tenant);
tenantListRepository.deleteTenant(tenant);
tenantConfigRepository.deleteConfig(tenant.toUpperCase(),
"/" + applicationProperties.getTenantPropertiesName());
tenantConfigRepository.deleteConfig(tenant.toUpperCase(),
"/" + applicationProperties.getTenantLoginPropertiesName());
log.info("STOP - SETUP:DeleteTenant: tenantKey: {}, result: OK, time = {} ms",
tenant, stopWatch.getTime());
} catch (Exception e) {
log.info("STOP - SETUP:DeleteTenant: tenantKey: {}, result: FAIL, error: {}, time = {} ms",
tenant, e.getMessage(), stopWatch.getTime());
throw e;
}
}
示例4: migrate
import org.apache.commons.lang3.time.StopWatch; //导入依赖的package包/类
/**
* Migrate database with liquibase.
* @param tenantKey the tenant key
*/
@SneakyThrows
public void migrate(String tenantKey) {
final StopWatch stopWatch = createStarted();
try {
log.info("START - SETUP:CreateTenant:liquibase tenantKey: {}", tenantKey);
SpringLiquibase liquibase = new SpringLiquibase();
liquibase.setResourceLoader(resourceLoader);
liquibase.setDataSource(dataSource);
liquibase.setChangeLog(CHANGE_LOG_PATH);
liquibase.setContexts(liquibaseProperties.getContexts());
liquibase.setDefaultSchema(tenantKey);
liquibase.setDropFirst(liquibaseProperties.isDropFirst());
liquibase.setChangeLogParameters(DatabaseUtil.defaultParams(tenantKey));
liquibase.setShouldRun(true);
liquibase.afterPropertiesSet();
log.info("STOP - SETUP:CreateTenant:liquibase tenantKey: {}, result: OK, time = {} ms", tenantKey,
stopWatch.getTime());
} catch (Exception e) {
log.info("STOP - SETUP:CreateTenant:liquibase tenantKey: {}, result: FAIL, error: {}, time = {} ms",
tenantKey, e.getMessage(), stopWatch.getTime());
throw e;
}
}
示例5: drop
import org.apache.commons.lang3.time.StopWatch; //导入依赖的package包/类
/**
* Drop database schema for tenant.
*
* @param tenantKey - the tenant key
*/
@SneakyThrows
public void drop(String tenantKey) {
StopWatch stopWatch = createStarted();
log.info("START - SETUP:DeleteTenant:schema tenantKey: {}", tenantKey);
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement()) {
statement.executeUpdate(String.format(schemaDropResolver.getSchemaDropCommand(), tenantKey));
log.info("STOP - SETUP:DeleteTenant:schema tenantKey: {}, result: OK, time = {} ms",
tenantKey, stopWatch.getTime());
} catch (Exception e) {
log.info("STOP - SETUP:DeleteTenant:schema tenantKey: {}, result: FAIL, error: {}, time = {} ms",
tenantKey, e.getMessage(), stopWatch.getTime());
throw e;
}
}
示例6: start
import org.apache.commons.lang3.time.StopWatch; //导入依赖的package包/类
public void start() throws Exception {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
//游戏基础框架服务启动
frameworkInit();
//游戏业务初始化
gameLogicInit();
stopWatch.stop();
logger.error("游戏服务启动,耗时[{}]毫秒", stopWatch.getTime());
//mbean监控
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
GameMonitorMXBean controller = new GameMonitor();
mbs.registerMBean(controller, new ObjectName("GameMXBean:name=GameMonitor"));
}
示例7: logBeforeService
import org.apache.commons.lang3.time.StopWatch; //导入依赖的package包/类
/**
* Aspect for logging before service calls.
*
* @param joinPoint joinPoint
* @return method result
* @throws Throwable throwable
*/
@SneakyThrows
@Around("servicePointcut() && !excluded()")
public Object logBeforeService(ProceedingJoinPoint joinPoint) {
StopWatch stopWatch = StopWatch.createStarted();
try {
logStart(joinPoint);
Object result = joinPoint.proceed();
logStop(joinPoint, result, stopWatch);
return result;
} catch (Exception e) {
logError(joinPoint, e, stopWatch);
throw e;
}
}
示例8: createTenant
import org.apache.commons.lang3.time.StopWatch; //导入依赖的package包/类
/**
* Create tenant.
*
* @param tenant the tenant
* @return the tenant
*/
public Tenant createTenant(Tenant tenant) {
StopWatch stopWatch = createStarted();
log.info("START - SETUP:CreateTenant: tenantKey: {}", tenant.getTenantKey());
try {
tenantDatabaseService.create(tenant);
tenantDashboardService.create(tenant);
log.info("STOP - SETUP:CreateTenant: tenantKey: {}, result: OK, time = {} ms",
tenant.getTenantKey(), stopWatch.getTime());
return tenant;
} catch (Exception e) {
log.info("STOP - SETUP:CreateTenant: tenantKey: {}, result: FAIL, error: {}, time = {} ms",
tenant.getTenantKey(), e.getMessage(), stopWatch.getTime());
throw e;
}
}
示例9: create
import org.apache.commons.lang3.time.StopWatch; //导入依赖的package包/类
/**
* Create default dashboard.
* @param tenant - the tenant
*/
public void create(Tenant tenant) {
final StopWatch stopWatch = StopWatch.createStarted();
final String tenantKey = tenant.getTenantKey();
TenantInfo info = TenantContext.getCurrent();
try {
log.info("START - SETUP:CreateTenant:dashboard tenantKey: {}", tenantKey);
TenantContext.setCurrentQuite(tenantKey);
Dashboard dashboard = new Dashboard();
dashboard.setName(tenantKey.toLowerCase());
dashboard.setOwner(tenantKey.toLowerCase());
dashboard.setIsPublic(false);
dashboardService.save(dashboard);
log.info("STOP - SETUP:CreateTenant:dashboard tenantKey: {}, result: OK, time = {} ms", tenantKey,
stopWatch.getTime());
} catch (Exception e) {
log.info("STOP - SETUP:CreateTenant:dashboard tenantKey: {}, result: FAIL, error: {}, time = {} ms",
tenantKey, e.getMessage(), stopWatch.getTime());
throw e;
} finally {
TenantContext.setCurrentQuite(info);
}
}
示例10: addTenant
import org.apache.commons.lang3.time.StopWatch; //导入依赖的package包/类
public void addTenant(Tenant tenant) {
StopWatch stopWatch = StopWatch.createStarted();
log.info("START - SETUP:CreateTenant: tenantKey: {}", tenant);
try {
String tenantName = tenant.getTenantKey().toUpperCase();
tenantListRepository.addTenant(tenantName);
tenantDatabaseService.create(tenant);
tenantElasticService.create(tenant);
addEntitySpecification(tenantName);
addWebAppSpecification(tenantName);
log.info("STOP - SETUP:CreateTenant: tenantKey: {}, result: OK, time = {} ms",
tenant, stopWatch.getTime());
} catch (Exception e) {
log.info("STOP - SETUP:CreateTenant: tenantKey: {}, result: FAIL, error: {}, time = {} ms",
tenant, e.getMessage(), stopWatch.getTime());
throw e;
}
}
示例11: deleteTenant
import org.apache.commons.lang3.time.StopWatch; //导入依赖的package包/类
public void deleteTenant(String tenantKey) {
StopWatch stopWatch = StopWatch.createStarted();
log.info("START - SETUP:DeleteTenant: tenantKey: {}", tenantKey);
try {
tenantDatabaseService.drop(tenantKey);
tenantElasticService.delete(tenantKey);
tenantListRepository.deleteTenant(tenantKey.toLowerCase());
String specificationName = applicationProperties.getSpecificationName();
tenantConfigRepository.deleteConfig(tenantKey.toUpperCase(), "/" + specificationName);
String webappSpecificationName = applicationProperties.getSpecificationWebappName();
webappTenantConfigRepository.deleteConfig(tenantKey.toUpperCase(), "/" + webappSpecificationName);
log.info("STOP - SETUP:DeleteTenant: tenantKey: {}, result: OK, time = {} ms",
tenantKey, stopWatch.getTime());
} catch (Exception e) {
log.info("STOP - SETUP:DeleteTenant: tenantKey: {}, result: FAIL, error: {}, time = {} ms",
tenantKey, e.getMessage(), stopWatch.getTime());
throw e;
}
}
示例12: create
import org.apache.commons.lang3.time.StopWatch; //导入依赖的package包/类
/**
* Create database schema for tenant.
*
* @param tenant - the tenant
*/
public void create(Tenant tenant) {
StopWatch stopWatch = createStarted();
log.info("START - SETUP:CreateTenant:schema tenantKey={}", tenant.getTenantKey());
DatabaseUtil.createSchema(dataSource, tenant.getTenantKey());
log.info("STOP - SETUP:CreateTenant:schema tenantKey={}, time={}ms", tenant.getTenantKey(),
stopWatch.getTime());
try {
stopWatch.reset();
stopWatch.start();
log.info("START - SETUP:CreateTenant:liquibase tenantKey={}", tenant.getTenantKey());
SpringLiquibase liquibase = new SpringLiquibase();
liquibase.setResourceLoader(resourceLoader);
liquibase.setDataSource(dataSource);
liquibase.setChangeLog(CHANGE_LOG_PATH);
liquibase.setContexts(liquibaseProperties.getContexts());
liquibase.setDefaultSchema(tenant.getTenantKey());
liquibase.setDropFirst(liquibaseProperties.isDropFirst());
liquibase.setShouldRun(true);
liquibase.afterPropertiesSet();
log.info("STOP - SETUP:CreateTenant:liquibase tenantKey={}, time={}ms", tenant.getTenantKey(),
stopWatch.getTime());
} catch (LiquibaseException e) {
throw new RuntimeException("Can not migrate database for creation tenant " + tenant.getTenantKey(), e);
}
}
示例13: createTenant
import org.apache.commons.lang3.time.StopWatch; //导入依赖的package包/类
/**
* Create new tenant.
* @param tenant the new tenant name
*/
public void createTenant(String tenant) {
StopWatch stopWatch = StopWatch.createStarted();
log.info("START - SETUP:CreateTenant: tenantKey: {}", tenant);
try {
tenantListRepository.addTenant(tenant.toLowerCase());
cassandraService.createCassandraKeyspace(tenant);
cassandraService.migrateCassandra(tenant);
kafkaService.createKafkaTopic(tenant);
kafkaService.sendCommand(tenant, Constants.CREATE_COMMAND);
addTimelineSpecification(tenant.toUpperCase());
log.info("STOP - SETUP:CreateTenant: tenantKey: {}, result: OK, time = {} ms",
tenant, stopWatch.getTime());
} catch (Exception e) {
log.info("STOP - SETUP:CreateTenant: tenantKey: {}, result: FAIL, error: {}, time = {} ms",
tenant, e.getMessage(), stopWatch.getTime());
throw e;
}
}
示例14: deleteTenant
import org.apache.commons.lang3.time.StopWatch; //导入依赖的package包/类
/**
* Delete tenant.
* @param tenant the tenant name
*/
public void deleteTenant(String tenant) {
StopWatch stopWatch = StopWatch.createStarted();
log.info("START - SETUP:DeleteTenant: tenantKey: {}", tenant);
try {
cassandraService.dropCassandraKeyspace(tenant);
kafkaService.deleteKafkaTopic(tenant);
kafkaService.sendCommand(tenant, Constants.DELETE_COMMAND);
tenantListRepository.deleteTenant(tenant.toLowerCase());
String specificationName = applicationProperties.getTenantPropertiesName();
tenantConfigRepository.deleteConfig(tenant.toUpperCase(), "/" + specificationName);
log.info("STOP - SETUP:DeleteTenant: tenantKey: {}, result: OK, time = {} ms",
tenant, stopWatch.getTime());
} catch (Exception e) {
log.info("STOP - SETUP:DeleteTenant: tenantKey: {}, result: FAIL, error: {}, time = {} ms",
tenant, e.getMessage(), stopWatch.getTime());
throw e;
}
}
示例15: deleteKafkaConsumer
import org.apache.commons.lang3.time.StopWatch; //导入依赖的package包/类
/**
* Delete topic consumer.
* @param tenant the kafka topic
*/
public void deleteKafkaConsumer(String tenant) {
StopWatch stopWatch = StopWatch.createStarted();
try {
log.info("START - SETUP:DeleteTenant:kafka consumer tenantKey: {}", tenant);
if (consumers.get(tenant) != null) {
consumers.get(tenant).stop();
consumers.remove(tenant);
}
log.info("STOP - SETUP:DeleteTenant:kafka consumer tenantKey: {}, result: OK, time = {} ms",
tenant, stopWatch.getTime());
} catch (Exception e) {
log.error("STOP - SETUP:DeleteTenant:kafka consumer tenantKey: {}, result: FAIL, error: {}, time = {} ms",
tenant, e.getMessage(), stopWatch.getTime(), e);
}
}