本文整理汇总了Java中com.taobao.diamond.mockserver.MockServer类的典型用法代码示例。如果您正苦于以下问题:Java MockServer类的具体用法?Java MockServer怎么用?Java MockServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockServer类属于com.taobao.diamond.mockserver包,在下文中一共展示了MockServer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initHttpClient
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
protected void initHttpClient() {
if (MockServer.isTestMode()) {
return;
}
HostConfiguration hostConfiguration = new HostConfiguration();
hostConfiguration.setHost(diamondConfigure.getDomainNameList().get(this.domainNamePos.get()),
diamondConfigure.getPort());
MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
connectionManager.closeIdleConnections(diamondConfigure.getPollingIntervalTime() * 4000);
HttpConnectionManagerParams params = new HttpConnectionManagerParams();
params.setStaleCheckingEnabled(diamondConfigure.isConnectionStaleCheckingEnabled());
params.setMaxConnectionsPerHost(hostConfiguration, diamondConfigure.getMaxHostConnections());
params.setMaxTotalConnections(diamondConfigure.getMaxTotalConnections());
params.setConnectionTimeout(diamondConfigure.getConnectionTimeout());
// 设置读超时为1分钟,
// [email protected]
params.setSoTimeout(60 * 1000);
connectionManager.setParams(params);
httpClient = new HttpClient(connectionManager);
httpClient.setHostConfiguration(hostConfiguration);
}
开发者ID:lysu,项目名称:diamond,代码行数:25,代码来源:DefaultDiamondSubscriber.java
示例2: getAvailableConfigureInfomation
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
public String getAvailableConfigureInfomation(String dataId, String group, long timeout) {
// 尝试先从本地和网络获取配置信息
try {
String result = getConfigureInfomation(dataId, group, timeout);
if (result != null && result.length() > 0) {
return result;
}
}
catch (Throwable t) {
log.error(t.getMessage(), t);
}
// 测试模式不使用本地dump
if (MockServer.isTestMode()) {
return null;
}
return getSnapshotConfiginfomation(dataId, group);
}
开发者ID:lysu,项目名称:diamond,代码行数:19,代码来源:DefaultDiamondSubscriber.java
示例3: lessThanReadRestraintByDynamicTest
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
@Test
public void lessThanReadRestraintByDynamicTest() throws InterruptedException {
if (ASTATICISM_TEST) {
return;
}
int executCount = 10;
int readCount = RandomUtils.nextInt(executCount);
MockServer.setConfigInfo(TAtomConstants.getAppDataId(APPNAME, DBKEY_0),
" maxPoolSize=100\r\nuserName=tddl\r\nminPoolSize=1\r\nreadRestrictTimes=" + executCount + "\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
String sql = "select * from normaltbl_0001 where pk=?";
for (int i = 0; i < readCount; i++) {
try {
Map rs = tddlJT.queryForMap(sql, new Object[] { RANDOM_ID });
Assert.assertEquals(time, String.valueOf(rs.get("gmt_create")));
executCount--;
} catch (DataAccessException ex) {
}
}
Assert.assertTrue(executCount >= 0);
}
开发者ID:beebeandwer,项目名称:TDDL,代码行数:26,代码来源:AtomReadRestraintTest.java
示例4: moreThanReadRestraintTest
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
@Test
public void moreThanReadRestraintTest() throws InterruptedException {
if (ASTATICISM_TEST) {
return;
}
int readCount = 20;
int executCount = 10;
MockServer.setConfigInfo(TAtomConstants.getAppDataId(APPNAME, DBKEY_0),
" maxPoolSize=100\r\nuserName=tddl\r\nminPoolSize=1\r\nreadRestrictTimes=" + executCount + "\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
String sql = "select * from normaltbl_0001 where pk=?";
for (int i = 0; i < readCount; i++) {
try {
Map rs = tddlJT.queryForMap(sql, new Object[] { RANDOM_ID });
Assert.assertEquals(time, String.valueOf(rs.get("gmt_create")));
executCount--;
} catch (DataAccessException ex) {
}
}
Assert.assertEquals(0, executCount);
}
开发者ID:beebeandwer,项目名称:TDDL,代码行数:25,代码来源:AtomReadRestraintTest.java
示例5: dynamicChangeGlobalPortTest
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
@Test
public void dynamicChangeGlobalPortTest() throws InterruptedException {
Map re = tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.assertEquals(time, String.valueOf(re.get("gmt_create")));
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(DBKEY_0),
"ip=10.232.31.154\r\nport=3300\r\ndbName=qatest_normal_0\r\ndbType=mysql\r\ndbStatus=RW\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
try {
tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(DBKEY_0),
"ip=10.232.31.154\r\nport=3300\r\ndbName=qatest_normal_0\r\ndbType=mysql\r\ndbStatus=RW\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.fail();
} catch (Exception ex) {
}
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(DBKEY_0),
"ip=10.232.31.154\r\nport=3306\r\ndbName=qatest_normal_0\r\ndbType=mysql\r\ndbStatus=RW\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
re = tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.assertEquals(time, String.valueOf(re.get("gmt_create")));
}
开发者ID:beebeandwer,项目名称:TDDL,代码行数:24,代码来源:AtomDynamicChangeGlobalTest.java
示例6: createTAtomDataSource
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
private TAtomDataSource createTAtomDataSource(String appName, String dbKey, String configName) throws IOException,
TddlException,
Exception {
// 全局配置
String globaStr = PropLoadTestUtil.loadPropFile2String("conf/" + configName + "/globa.properties");
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(dbKey), globaStr);
// 应用配置
String appStr = PropLoadTestUtil.loadPropFile2String("conf/" + configName + "/app.properties");
MockServer.setConfigInfo(TAtomConstants.getAppDataId(appName, dbKey), appStr);
// 解析配置
TAtomDsConfDO tAtomDsConfDO = TAtomConfParser.parserTAtomDsConfDO(globaStr, appStr);
// 密码配置
String passwdStr = PropLoadTestUtil.loadPropFile2String("conf/" + configName + "/passwd.properties");
MockServer.setConfigInfo(TAtomConstants.getPasswdDataId(tAtomDsConfDO.getDbName(),
tAtomDsConfDO.getDbType(),
tAtomDsConfDO.getUserName()), passwdStr);
// 进行初始化
TAtomDataSource tAtomDataSource = new TAtomDataSource();
tAtomDataSource.setAppName(appName);
tAtomDataSource.setDbKey(dbKey);
tAtomDataSource.init();
return tAtomDataSource;
}
开发者ID:loye168,项目名称:tddl5,代码行数:24,代码来源:TAtomDataSourceTest.java
示例7: setGroupMockInfo
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
protected static void setGroupMockInfo(String groupPath, String key) throws Exception {
// 获取group信息
String groupStr = LoadPropsUtil.loadProps2OneLine(groupPath, key);
if (groupStr == null || StringUtils.isBlank(groupStr)) {
throw new Exception("指定path = " + groupPath + ",key = " + key + "的group信息为null或者为空字符。");
}
// 获取atom信息
dataMap = new HashMap<String, String>();
String[] atomArr = groupStr.split(",");
for (String atom : atomArr) {
atom = atom.trim();
atom = atom.substring(0, atom.indexOf(":"));
initAtomConfig(ATOM_PATH + File.separator + atom, APPNAME, atom);
}
// 获取groupkey
dataMap.put(TGroupDataSource.getFullDbGroupKey(key), groupStr);
// 建立MockServer
MockServer.setConfigInfos(dataMap);
// 获取JdbcTemplate
tddlJT = getJT(key);
}
开发者ID:beebeandwer,项目名称:TDDL,代码行数:26,代码来源:GroupTestCase.java
示例8: lessThanWriteRestraintTest
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
@Test
public void lessThanWriteRestraintTest() throws InterruptedException {
if (ASTATICISM_TEST) {
return;
}
int executCount = 10;
int writeCount = RandomUtils.nextInt(executCount);
MockServer.setConfigInfo(TAtomConstants.getAppDataId(APPNAME, DBKEY_0),
" maxPoolSize=100\r\nuserName=tddl\r\nminPoolSize=1\r\nwriteRestrictTimes=" + executCount + "\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
String sql = "update normaltbl_0001 set gmt_create=? where pk=?";
for (int i = 0; i < writeCount; i++) {
try {
int rs = tddlJT.update(sql, new Object[] { nextDay, RANDOM_ID });
Assert.assertEquals(1, rs);
executCount--;
} catch (DataAccessException ex) {
}
}
Assert.assertTrue(executCount >= 0);
}
开发者ID:loye168,项目名称:tddl5,代码行数:25,代码来源:AtomWriteRestraintTest.java
示例9: moreThanWriteRestraintTest
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
@Test
public void moreThanWriteRestraintTest() throws InterruptedException {
if (ASTATICISM_TEST) {
return;
}
int WriteCount = 20;
int executCount = 10;
MockServer.setConfigInfo(TAtomConstants.getAppDataId(APPNAME, DBKEY_0),
" maxPoolSize=100\r\nuserName=tddl\r\nminPoolSize=1\r\nwriteRestrictTimes=" + executCount + "\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
String sql = "update normaltbl_0001 set gmt_create=? where pk=?";
Object[] args = new Object[] { nextDay, RANDOM_ID };
for (int i = 0; i < WriteCount; i++) {
try {
int rs = tddlJT.update(sql, args);
Assert.assertEquals(1, rs);
executCount--;
} catch (DataAccessException ex) {
}
}
Assert.assertEquals(0, executCount);
}
开发者ID:loye168,项目名称:tddl5,代码行数:27,代码来源:AtomWriteRestraintTest.java
示例10: dynamicChangeGlobalIpTest
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
@Test
public void dynamicChangeGlobalIpTest() throws InterruptedException {
Map re = tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.assertEquals(time, String.valueOf(re.get("gmt_create")));
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(DBKEY_0),
"ip=10.13.40.25\r\nport=3306\r\ndbName=qatest_normal_0\r\ndbType=mysql\r\ndbStatus=RW\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
try {
tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(DBKEY_0),
"ip=10.13.40.25\r\nport=3306\r\ndbName=qatest_normal_0\r\ndbType=mysql\r\ndbStatus=RW\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.fail("");
} catch (Exception ex) {
}
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(DBKEY_0),
"ip=10.232.31.154\r\nport=3306\r\ndbName=qatest_normal_0\r\ndbType=mysql\r\ndbStatus=RW\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
re = tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.assertEquals(time, String.valueOf(re.get("gmt_create")));
}
开发者ID:loye168,项目名称:tddl5,代码行数:24,代码来源:AtomDynamicChangeGlobalTest.java
示例11: dynamicChangeGlobalDbNameTest
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
@Test
public void dynamicChangeGlobalDbNameTest() throws InterruptedException {
Map re = tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.assertEquals(time, String.valueOf(re.get("gmt_create")));
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(DBKEY_0),
"ip=10.232.31.154\r\nport=3306\r\ndbName=qatest_normal\r\ndbType=mysql\r\ndbStatus=RW\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
try {
tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(DBKEY_0),
"ip=\r\nport=3306\r\ndbName=qatest_normal\r\ndbType=mysql\r\ndbStatus=RW\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.fail();
} catch (Exception ex) {
}
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(DBKEY_0),
"ip=10.232.31.154\r\nport=3306\r\ndbName=qatest_normal_0\r\ndbType=mysql\r\ndbStatus=RW\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
re = tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.assertEquals(time, String.valueOf(re.get("gmt_create")));
}
开发者ID:beebeandwer,项目名称:TDDL,代码行数:24,代码来源:AtomDynamicChangeGlobalTest.java
示例12: dynamicChangeGlobalDbTypeTest
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
@Ignore("oracle驱动暂时没依赖")
@Test
public void dynamicChangeGlobalDbTypeTest() throws InterruptedException {
Map re = tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.assertEquals(time, String.valueOf(re.get("gmt_create")));
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(DBKEY_0),
"ip=10.232.31.154\r\nport=3306\r\ndbName=qatest_normal_0\r\ndbType=oracle\r\ndbStatus=RW\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
try {
tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(DBKEY_0),
"ip=10.232.31.154\r\nport=3306\r\ndbName=qatest_normal_0\r\ndbType=oracle\r\ndbStatus=RW\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.fail();
} catch (Exception ex) {
}
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(DBKEY_0),
"ip=10.232.31.154\r\nport=3306\r\ndbName=qatest_normal_0\r\ndbType=mysql\r\ndbStatus=RW\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
re = tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.assertEquals(time, String.valueOf(re.get("gmt_create")));
}
开发者ID:loye168,项目名称:tddl5,代码行数:25,代码来源:AtomDynamicChangeGlobalTest.java
示例13: dynamicChangeAppnameTest
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
@Test
public void dynamicChangeAppnameTest() throws Exception {
Map re = tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.assertEquals(time, String.valueOf(re.get("gmt_create")));
MockServer.setConfigInfo(TAtomConstants.getAppDataId(APPNAME, DBKEY_0),
"maxPoolSize=100\r\nuserName=xxxx\r\nminPoolSize=1\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
try {
tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
MockServer.setConfigInfo(TAtomConstants.getAppDataId(APPNAME, DBKEY_0),
"maxPoolSize=100\r\nuserName=xxxx\r\nminPoolSize=1\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.fail();
} catch (Exception ex) {
}
}
开发者ID:loye168,项目名称:tddl5,代码行数:20,代码来源:AtomDynamicChangeAppTest.java
示例14: dynamicChangePswTest
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
@Ignore("druid对passwd变更不会关闭老的正常的链接")
@Test
public void dynamicChangePswTest() throws Exception {
Map re = tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.assertEquals(time, String.valueOf(re.get("gmt_create")));
MockServer.setConfigInfo(TAtomConstants.getPasswdDataId(DBKEY_0, DBTYPE_MYSQL, "tddl"),
"encPasswd=dddddddd\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
try {
tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
MockServer.setConfigInfo(TAtomConstants.getPasswdDataId(DBKEY_0, DBTYPE_MYSQL, "tddl"),
"encPasswd=dddddddd\r\n");
TimeUnit.SECONDS.sleep(SLEEP_TIME);
tddlJT.queryForMap("select * from normaltbl_0001 where pk=?", new Object[] { RANDOM_ID });
Assert.fail();
} catch (Exception ex) {
}
}
开发者ID:loye168,项目名称:tddl5,代码行数:19,代码来源:AtomDynamicChangePswTest.java
示例15: testThreadLocalDataSourceIndex
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
@Test
public void testThreadLocalDataSourceIndex() throws Exception {
try {
TGroupDataSource ds = new TGroupDataSource(GROUP0, APPNAME);
MockServer.setConfigInfo(ds.getFullDbGroupKey(), DSKEY0 + ":rw" + "," + DSKEY1 + ":r");
ds.init();
ThreadLocalMap.put(ThreadLocalString.DATASOURCE_INDEX, 0);
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
assertEquals(stmt.executeUpdate("insert into tddl_test_0000(id,name) values(100,'str')"), 1);
ResultSet rs = stmt.executeQuery("select id,name from tddl_test_0000 where id=100");
assertTrue(rs.next());
// 如果指定了index,忽略rw限制
ThreadLocalMap.put(ThreadLocalString.DATASOURCE_INDEX, 1);
assertEquals(stmt.executeUpdate("insert into tddl_test_0000(id,name) values(100,'str')"), 1);
rs = stmt.executeQuery("select count(*) from tddl_test_0000 where id=100");
assertTrue(rs.next());
assertEquals(rs.getInt(1), 1);
stmt.close();
conn.close();
} finally {
ThreadLocalMap.put(ThreadLocalString.DATASOURCE_INDEX, null);
}
}
开发者ID:loye168,项目名称:tddl5,代码行数:27,代码来源:DataSourceIndexTest.java
示例16: testGroupDataSourceRouteHelper
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
@Test
public void testGroupDataSourceRouteHelper() throws Exception {
try {
TGroupDataSource ds = new TGroupDataSource(GROUP0, APPNAME);
MockServer.setConfigInfo(ds.getFullDbGroupKey(), DSKEY0 + ":rw" + "," + DSKEY1 + ":r");
ds.init();
GroupDataSourceRouteHelper.executeByGroupDataSourceIndex(0);
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
assertEquals(stmt.executeUpdate("insert into tddl_test_0000(id,name) values(100,'str')"), 1);
ResultSet rs = stmt.executeQuery("select id,name from tddl_test_0000 where id=100");
assertTrue(rs.next());
// 如果指定了index,忽略rw限制
ThreadLocalMap.put(ThreadLocalString.DATASOURCE_INDEX, 1);
assertEquals(stmt.executeUpdate("insert into tddl_test_0000(id,name) values(100,'str')"), 1);
rs = stmt.executeQuery("select count(*) from tddl_test_0000 where id=100");
assertTrue(rs.next());
assertEquals(rs.getInt(1), 1);
stmt.close();
conn.close();
} finally {
ThreadLocalMap.put(ThreadLocalString.DATASOURCE_INDEX, null);
}
}
开发者ID:loye168,项目名称:tddl5,代码行数:27,代码来源:DataSourceIndexTest.java
示例17: createTAtomDataSource
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
private TAtomDataSource createTAtomDataSource(String appName, String dbKey, String configName)
throws IOException,
AtomAlreadyInitException,
Exception {
// 全局配置
String globaStr = PropLoadTestUtil.loadPropFile2String("conf/" + configName + "/globa.properties");
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(dbKey), globaStr);
// 应用配置
String appStr = PropLoadTestUtil.loadPropFile2String("conf/" + configName + "/app.properties");
MockServer.setConfigInfo(TAtomConstants.getAppDataId(appName, dbKey), appStr);
// 解析配置
TAtomDsConfDO tAtomDsConfDO = TAtomConfParser.parserTAtomDsConfDO(globaStr, appStr);
// 密码配置
String passwdStr = PropLoadTestUtil.loadPropFile2String("conf/" + configName + "/passwd.properties");
MockServer.setConfigInfo(TAtomConstants.getPasswdDataId(tAtomDsConfDO.getDbName(),
tAtomDsConfDO.getDbType(),
tAtomDsConfDO.getUserName()), passwdStr);
// 进行初始化
TAtomDataSource tAtomDataSource = new TAtomDataSource();
tAtomDataSource.setAppName(appName);
tAtomDataSource.setDbKey(dbKey);
tAtomDataSource.init();
return tAtomDataSource;
}
开发者ID:beebeandwer,项目名称:TDDL,代码行数:25,代码来源:TAtomDataSourceTest.java
示例18: setPollingIntervalTime
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
/**
* 设置轮询的间隔时间。单位:秒
*
* @param pollingIntervalTime
*/
public void setPollingIntervalTime(int pollingIntervalTime) {
if (pollingIntervalTime < Constants.POLLING_INTERVAL_TIME && !MockServer.isTestMode()) {
return;
}
this.pollingIntervalTime = pollingIntervalTime;
}
开发者ID:lysu,项目名称:diamond,代码行数:12,代码来源:DiamondConfigure.java
示例19: acquireServerAddressFromLocal
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
protected void acquireServerAddressFromLocal() {
if (!isRun) {
throw new RuntimeException("ServerAddressProcessor不在运行状态,无法同步获取服务器地址列表");
}
if (MockServer.isTestMode()) {
diamondConfigure.addDomainName("测试模式,没有使用的真实服务器");
return;
}
int acquireCount = 0;
if (diamondConfigure.getDomainNameList().size() == 0) {
reloadServerAddresses();
if (diamondConfigure.getDomainNameList().size() == 0) {
if (!acquireServerAddressOnce(acquireCount)) {
acquireCount++;
if (acquireServerAddressOnce(acquireCount)) {
// 存入本地文件
storeServerAddressesToLocal();
log.info("在同步获取服务器列表时,向日常ConfigServer服务器获取到了服务器列表");
}
else {
throw new RuntimeException("当前没有可用的服务器列表");
}
}
else {
log.info("在同步获取服务器列表时,向线上ConfigServer服务器获取到了服务器列表");
// 存入本地文件
storeServerAddressesToLocal();
}
}
else {
log.info("在同步获取服务器列表时,由于本地指定了服务器列表,不向ConfigServer服务器同步获取服务器列表");
}
}
}
开发者ID:lysu,项目名称:diamond,代码行数:36,代码来源:ServerAddressProcessor.java
示例20: synAcquireServerAddress
import com.taobao.diamond.mockserver.MockServer; //导入依赖的package包/类
protected void synAcquireServerAddress() {
if (!isRun) {
throw new RuntimeException("ServerAddressProcessor不在运行状态,无法同步获取服务器地址列表");
}
if (MockServer.isTestMode()) {
diamondConfigure.addDomainName("测试模式,没有使用的真实服务器");
return;
}
int acquireCount = 0;
if (diamondConfigure.getDomainNameList().size() == 0) {
if (!acquireServerAddressOnce(acquireCount)) {
acquireCount++;
if (acquireServerAddressOnce(acquireCount)) {
// 存入本地文件
storeServerAddressesToLocal();
log.info("在同步获取服务器列表时,向日常ConfigServer服务器获取到了服务器列表");
}
else {
log.info("从本地获取Diamond地址列表");
reloadServerAddresses();
if (diamondConfigure.getDomainNameList().size() == 0)
throw new RuntimeException("当前没有可用的服务器列表");
}
}
else {
log.info("在同步获取服务器列表时,向线上ConfigServer服务器获取到了服务器列表");
// 存入本地文件
storeServerAddressesToLocal();
}
}
}
开发者ID:lysu,项目名称:diamond,代码行数:33,代码来源:ServerAddressProcessor.java
注:本文中的com.taobao.diamond.mockserver.MockServer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论