use of com.github.ambry.clustermap.HelixStoreOperator in project ambry by linkedin.
the class HelixAccountServiceTest method writeAccountsToHelixPropertyStore.
/**
* Pre-populates a collection of {@link Account}s to the underlying {@link org.apache.helix.store.HelixPropertyStore}
* using {@link com.github.ambry.clustermap.HelixStoreOperator} (not through the {@link HelixAccountService}). This method
* does not check any conflict among the {@link Account}s to write.
* @throws Exception Any unexpected exception.
*/
private void writeAccountsToHelixPropertyStore(Collection<Account> accounts, boolean shouldNotify) throws Exception {
HelixStoreOperator storeOperator = new HelixStoreOperator(mockHelixAccountServiceFactory.getHelixStore(ZK_CONNECT_STRING, storeConfig));
ZNRecord zNRecord = new ZNRecord(String.valueOf(System.currentTimeMillis()));
Map<String, String> accountMap = new HashMap<>();
for (Account account : accounts) {
accountMap.put(String.valueOf(account.getId()), objectMapper.writeValueAsString(new AccountBuilder(account).snapshotVersion(refAccount.getSnapshotVersion() + 1).build()));
}
if (useNewZNodePath) {
String blobID = RouterStore.writeAccountMapToRouter(accountMap, mockRouter);
List<String> list = Collections.singletonList(new RouterStore.BlobIDAndVersion(blobID, 1).toJson());
zNRecord.setListField(RouterStore.ACCOUNT_METADATA_BLOB_IDS_LIST_KEY, list);
storeOperator.write(RouterStore.ACCOUNT_METADATA_BLOB_IDS_PATH, zNRecord);
} else {
zNRecord.setMapField(LegacyMetadataStore.ACCOUNT_METADATA_MAP_KEY, accountMap);
// Write account metadata into HelixPropertyStore.
storeOperator.write(LegacyMetadataStore.FULL_ACCOUNT_METADATA_PATH, zNRecord);
}
if (shouldNotify) {
notifier.publish(ACCOUNT_METADATA_CHANGE_TOPIC, FULL_ACCOUNT_METADATA_CHANGE_MESSAGE);
}
}
use of com.github.ambry.clustermap.HelixStoreOperator in project ambry by linkedin.
the class RouterStoreTest method cleanUp.
/**
* cleanup after each test case.
* @throws Exception Any unexpected exception.
*/
@After
public void cleanUp() throws Exception {
HelixStoreOperator operator = new HelixStoreOperator(helixStore);
if (operator.exist("/")) {
operator.delete("/");
}
if (Files.exists(accountBackupDir)) {
Utils.deleteFileOrDirectory(accountBackupDir.toFile());
}
router.close();
}
Aggregations