Search in sources :

Example 1 with ClientRegistryRefresher

use of voldemort.client.scheduler.ClientRegistryRefresher in project voldemort by voldemort.

the class ZenStoreClient method registerClient.

private ClientRegistryRefresher registerClient(int intervalInSecs) {
    ClientRegistryRefresher refresher = null;
    if (this.sysRepository.getClientRegistryStore() != null) {
        try {
            Version version = this.sysRepository.getClientRegistryStore().putSysStore(clientId, clientInfo.toString());
            refresher = new ClientRegistryRefresher(this.sysRepository, clientId, clientInfo, version);
            GregorianCalendar cal = new GregorianCalendar();
            cal.add(Calendar.SECOND, intervalInSecs);
            if (scheduler != null) {
                scheduler.schedule(makeClientRegistryRefresherJobId(), refresher, cal.getTime(), TimeUnit.MILLISECONDS.convert(intervalInSecs, TimeUnit.SECONDS));
                logger.info("Client registry refresher thread started, refresh interval: " + intervalInSecs + " seconds");
            } else {
                logger.warn("Client registry won't run because scheduler service is not configured");
            }
        } catch (Exception e) {
            logger.warn("Unable to register with the cluster due to the following error:", e);
        }
    } else {
        logger.warn(SystemStoreConstants.SystemStoreName.voldsys$_client_registry.name() + "not found. Unable to registry with voldemort cluster.");
    }
    return refresher;
}
Also used : Version(voldemort.versioning.Version) ClientRegistryRefresher(voldemort.client.scheduler.ClientRegistryRefresher) GregorianCalendar(java.util.GregorianCalendar)

Aggregations

GregorianCalendar (java.util.GregorianCalendar)1 ClientRegistryRefresher (voldemort.client.scheduler.ClientRegistryRefresher)1 Version (voldemort.versioning.Version)1