use of com.github.ambry.config.HelixPropertyStoreConfig in project ambry by linkedin.
the class HelixAccountServiceTest method setup.
@Before
public void setup() {
helixConfigProps.clear();
helixConfigProps.setProperty(HelixPropertyStoreConfig.HELIX_PROPERTY_STORE_PREFIX + "zk.client.connection.timeout.ms", String.valueOf(ZK_CLIENT_CONNECTION_TIMEOUT_MS));
helixConfigProps.setProperty(HelixPropertyStoreConfig.HELIX_PROPERTY_STORE_PREFIX + "zk.client.session.timeout.ms", String.valueOf(ZK_CLIENT_SESSION_TIMEOUT_MS));
helixConfigProps.setProperty(HelixAccountServiceConfig.ZK_CLIENT_CONNECT_STRING_KEY, ZK_CONNECT_STRING);
helixConfigProps.setProperty(HelixPropertyStoreConfig.HELIX_PROPERTY_STORE_PREFIX + "root.path", STORE_ROOT_PATH);
helixConfigProps.setProperty(HelixAccountServiceConfig.BACKUP_DIRECTORY_KEY, accountBackupDir.toString());
helixConfigProps.setProperty(HelixAccountServiceConfig.USE_NEW_ZNODE_PATH, String.valueOf(useNewZNodePath));
vHelixConfigProps = new VerifiableProperties(helixConfigProps);
storeConfig = new HelixPropertyStoreConfig(vHelixConfigProps);
mockHelixAccountServiceFactory = new MockHelixAccountServiceFactory(vHelixConfigProps, new MetricRegistry(), notifier, null, mockRouter);
}
use of com.github.ambry.config.HelixPropertyStoreConfig in project ambry by linkedin.
the class HelixAccountServiceTest method testDisabledBackups.
/**
* Tests disabling the background thread. By setting the polling interval to 0ms, the accounts should not be fetched.
* Therefore, after the {@link HelixAccountService} starts, there should be a single get call to the
* {@link HelixPropertyStore}.
* @throws Exception
*/
@Test
public void testDisabledBackups() throws Exception {
helixConfigProps.remove(HelixAccountServiceConfig.BACKUP_DIRECTORY_KEY);
vHelixConfigProps = new VerifiableProperties(helixConfigProps);
storeConfig = new HelixPropertyStoreConfig(vHelixConfigProps);
String updaterThreadPrefix = UUID.randomUUID().toString();
MockHelixAccountServiceFactory mockHelixAccountServiceFactory = new MockHelixAccountServiceFactory(vHelixConfigProps, new MetricRegistry(), notifier, updaterThreadPrefix, mockRouter);
accountService = mockHelixAccountServiceFactory.getAccountService();
updateAccountsAndAssertAccountExistence(Collections.singleton(refAccount), 1, true);
}
use of com.github.ambry.config.HelixPropertyStoreConfig in project ambry by linkedin.
the class HelixAccountServiceTest method testDisableBackgroundUpdater.
/**
* Tests disabling the background thread. By setting the polling interval to 0ms, the accounts should not be fetched.
* Therefore, after the {@link HelixAccountService} starts, there should be a single get call to the
* {@link HelixPropertyStore}.
*/
@Test
public void testDisableBackgroundUpdater() {
helixConfigProps.setProperty(HelixAccountServiceConfig.UPDATER_POLLING_INTERVAL_MS_KEY, "0");
vHelixConfigProps = new VerifiableProperties(helixConfigProps);
storeConfig = new HelixPropertyStoreConfig(vHelixConfigProps);
String updaterThreadPrefix = UUID.randomUUID().toString();
MockHelixAccountServiceFactory mockHelixAccountServiceFactory = new MockHelixAccountServiceFactory(vHelixConfigProps, new MetricRegistry(), notifier, updaterThreadPrefix, mockRouter);
accountService = mockHelixAccountServiceFactory.getAccountService();
assertEquals("Wrong number of thread for account updater.", 0, numThreadsByThisName(updaterThreadPrefix));
}
use of com.github.ambry.config.HelixPropertyStoreConfig in project ambry by linkedin.
the class HelixAccountServiceTest method testStartWithBackupFiles.
/**
* Tests starting up a {@link HelixAccountService}, when the corresponding {@code ZooKeeper} does not have any
* {@link ZNRecord} on it but local backup files exists.
* @throws Exception Any unexpected exception
*/
@Test
public void testStartWithBackupFiles() throws Exception {
// use testUpdateAccount function to create backups and then delete helixStore data.
testUpdateAccount();
if (accountService != null) {
accountService.close();
}
deleteStoreIfExists();
// should have some backup files.
if (helixConfigProps.containsKey(HelixAccountServiceConfig.BACKUP_DIRECTORY_KEY)) {
File[] files = accountBackupDir.toFile().listFiles(path -> BackupFileManager.versionFilenamePattern.matcher(path.getName()).find());
assertTrue("UpdateAccount should create backup files", files.length > 0);
helixConfigProps.put(HelixAccountServiceConfig.ENABLE_SERVE_FROM_BACKUP, "true");
vHelixConfigProps = new VerifiableProperties(helixConfigProps);
storeConfig = new HelixPropertyStoreConfig(vHelixConfigProps);
String updaterThreadPrefix = UUID.randomUUID().toString();
MockHelixAccountServiceFactory mockHelixAccountServiceFactory = new MockHelixAccountServiceFactory(vHelixConfigProps, new MetricRegistry(), notifier, updaterThreadPrefix, mockRouter);
accountService = mockHelixAccountServiceFactory.getAccountService();
assertNotNull("Backup files should have data", accountService.getAllAccounts());
assertEquals("Number of accounts from backup mismatch", accountService.getAllAccounts().size(), 1 + NUM_REF_ACCOUNT);
}
}
use of com.github.ambry.config.HelixPropertyStoreConfig in project ambry by linkedin.
the class HelixNotifierTest method getHelixStoreConfig.
/**
* A util method that generates {@link HelixPropertyStoreConfig}.
* @param zkClientConnectString The connect string to connect to a {@code ZooKeeper}.
* @param zkClientSessionTimeoutMs Timeout for a zk session.
* @param zkClientConnectionTimeoutMs Timeout for a zk connection.
* @param storeRootPath The root path of a store in {@code ZooKeeper}.
* @return {@link HelixPropertyStoreConfig} defined by the arguments.
*/
public static HelixPropertyStoreConfig getHelixStoreConfig(String zkClientConnectString, int zkClientSessionTimeoutMs, int zkClientConnectionTimeoutMs, String storeRootPath) {
Properties helixConfigProps = new Properties();
helixConfigProps.setProperty(HelixPropertyStoreConfig.HELIX_PROPERTY_STORE_PREFIX + "zk.client.connection.timeout.ms", String.valueOf(zkClientConnectionTimeoutMs));
helixConfigProps.setProperty(HelixPropertyStoreConfig.HELIX_PROPERTY_STORE_PREFIX + "zk.client.session.timeout.ms", String.valueOf(zkClientSessionTimeoutMs));
helixConfigProps.setProperty(HelixAccountServiceConfig.ZK_CLIENT_CONNECT_STRING_KEY, zkClientConnectString);
helixConfigProps.setProperty(HelixPropertyStoreConfig.HELIX_PROPERTY_STORE_PREFIX + "root.path", storeRootPath);
VerifiableProperties vHelixConfigProps = new VerifiableProperties(helixConfigProps);
return new HelixPropertyStoreConfig(vHelixConfigProps);
}
Aggregations