use of com.github.ambry.config.AccountStatsMySqlConfig in project ambry by linkedin.
the class AccountStatsMySqlStoreTest method testLocalBackupFile.
@Test
public void testLocalBackupFile() throws IOException {
// First, make sure there is no local backup file.
Path tempDir = Files.createTempDirectory("AccountStatsMySqlStoreTest");
Path localBackupFilePath = tempDir.resolve("localbackup");
Properties prop = new Properties();
prop.setProperty(AccountStatsMySqlConfig.LOCAL_BACKUP_FILE_PATH, localBackupFilePath.toString());
AccountStatsMySqlConfig accountStatsMySqlConfig = new AccountStatsMySqlConfig(new VerifiableProperties(prop));
AccountStatsMySqlStore store = new AccountStatsMySqlStore(accountStatsMySqlConfig, mockDataSource, clusterName, hostname, null, new MetricRegistry());
assertNull(store.getPreviousHostAccountStorageStatsWrapper());
// Second, save a backup file.
HostAccountStorageStats hostAccountStorageStats = new HostAccountStorageStats(StorageStatsUtilTest.generateRandomHostAccountStorageStats(10, 10, 10, 10000L, 2, 10));
StatsHeader header = new StatsHeader(StatsHeader.StatsDescription.STORED_DATA_SIZE, System.currentTimeMillis(), 10, 10, null);
HostAccountStorageStatsWrapper statsWrapper = new HostAccountStorageStatsWrapper(header, hostAccountStorageStats);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.writeValue(localBackupFilePath.toFile(), statsWrapper);
store = new AccountStatsMySqlStore(accountStatsMySqlConfig, mockDataSource, clusterName, hostname, null, new MetricRegistry());
HostAccountStorageStatsWrapper backupWrapper = store.getPreviousHostAccountStorageStatsWrapper();
assertNotNull(backupWrapper);
assertStatsHeader(backupWrapper.getHeader(), 10, 10);
Assert.assertEquals(hostAccountStorageStats.getStorageStats(), backupWrapper.getStats().getStorageStats());
}
use of com.github.ambry.config.AccountStatsMySqlConfig in project ambry by linkedin.
the class HostnameHelperTest method testHostnameHelperBasic.
@Test
public void testHostnameHelperBasic() throws Exception {
String[] domains = { ".github.com", ".travis.com", "noleadingdot.com", " needtrim.com ", " " };
AccountStatsMySqlConfig config = createAccountStatsMySqlConfig(String.join(",", domains));
int port = 1000;
HostnameHelper helper = new HostnameHelper(config, port);
Assert.assertEquals("ambry-test1_1000", helper.simplifyHostname("ambry-test1.github.com"));
Assert.assertEquals("ambry-test1_1000", helper.simplifyHostname("ambry-test1.travis.com"));
Assert.assertEquals("ambry-test1_1000", helper.simplifyHostname("ambry-test1.noleadingdot.com"));
Assert.assertEquals("ambry-test1_1000", helper.simplifyHostname("ambry-test1.needtrim.com"));
Assert.assertEquals("ambry-test1.example.com_1000", helper.simplifyHostname("ambry-test1.example.com"));
}
use of com.github.ambry.config.AccountStatsMySqlConfig in project ambry by linkedin.
the class HostnameHelperTest method createAccountStatsMySqlConfig.
private AccountStatsMySqlConfig createAccountStatsMySqlConfig(String domainNamesToRemove) {
Properties properties = new Properties();
properties.setProperty(AccountStatsMySqlConfig.DOMAIN_NAMES_TO_REMOVE, domainNamesToRemove);
return new AccountStatsMySqlConfig(new VerifiableProperties(properties));
}
Aggregations