Search in sources :

Example 1 with BootstrapFailureException

use of voldemort.client.BootstrapFailureException in project voldemort by voldemort.

the class CoordinatorProxyService method initialize.

@Override
protected void initialize() {
    // Initialize the Voldemort Metadata
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setBootstrapUrls(this.coordinatorConfig.getBootstrapURLs());
    storeClientFactory = new SocketStoreClientFactory(clientConfig);
    try {
        initializeAllFatClients();
        // Setup the Async Metadata checker
        SystemStoreRepository sysRepository = new SystemStoreRepository(clientConfig);
        String clusterXml = storeClientFactory.bootstrapMetadataWithRetries(MetadataStore.CLUSTER_KEY);
        sysRepository.createSystemStores(clientConfig, clusterXml, storeClientFactory.getFailureDetector());
        // Create a callback for re-bootstrapping the client
        Callable<Void> rebootstrapCallback = new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                initializeAllFatClients();
                return null;
            }
        };
        asyncMetadataManager = new AsyncMetadataVersionManager(sysRepository, rebootstrapCallback, null);
        schedulerService = new SchedulerService(1, SystemTime.INSTANCE, true);
        schedulerService.schedule(asyncMetadataManager.getClass().getName(), asyncMetadataManager, new Date(), this.coordinatorConfig.getMetadataCheckIntervalInMs());
    } catch (BootstrapFailureException be) {
    /*
             * While testing, the cluster may not be up, but we may still need
             * to verify if the service deploys. Hence, catch a
             * BootstrapFailureException if any, but continue to register the
             * Netty service (and listener).
             * 
             * TODO: Modify the coordinator service to be more lazy. If it
             * cannot initialize the fat clients during initialization, do this
             * when we get an actual request.
             */
    }
}
Also used : SchedulerService(voldemort.common.service.SchedulerService) SocketStoreClientFactory(voldemort.client.SocketStoreClientFactory) BootstrapFailureException(voldemort.client.BootstrapFailureException) SystemStoreRepository(voldemort.client.SystemStoreRepository) AsyncMetadataVersionManager(voldemort.client.scheduler.AsyncMetadataVersionManager) ClientConfig(voldemort.client.ClientConfig) Callable(java.util.concurrent.Callable) Date(java.util.Date)

Example 2 with BootstrapFailureException

use of voldemort.client.BootstrapFailureException in project voldemort by voldemort.

the class FileBasedStoreClientConfigService method putConfigsMap.

@Override
protected Map<String, Properties> putConfigsMap(Map<String, Properties> configsToPut) {
    Map<String, Properties> allConfigs = getAllConfigsMap();
    Map<String, Properties> newConfigs = Maps.newHashMap(allConfigs);
    Map<String, Properties> response = Maps.newHashMap();
    // TODO For now assuming the only Listener is CoordinatorProxyService.
    // Later need to change the API to accept a servicetype as second
    // parameter
    StoreClientConfigServiceListener listener = this.storeClientConfigListeners.get(ServiceType.COORDINATOR_PROXY.getDisplayName());
    for (String storeNameToPut : configsToPut.keySet()) {
        if (allConfigs.containsKey(storeNameToPut)) {
            Properties existingProperties = allConfigs.get(storeNameToPut);
            if (existingProperties.equals(configsToPut.get(storeNameToPut))) {
                response.put(storeNameToPut, STORE_UNCHANGED_PROPS);
            } else {
                try {
                    listener.onStoreConfigAddOrUpdate(storeNameToPut, configsToPut.get(storeNameToPut));
                } catch (Exception e) {
                    String errorMessage = "Got exception when trying to update the fat client for store " + storeNameToPut + " - " + e.getMessage();
                    logger.error(errorMessage);
                    STORE_NOT_UPDATED_PROPS.put(ERROR_MESSAGE_PARAM_KEY, errorMessage);
                    response.put(storeNameToPut, STORE_NOT_UPDATED_PROPS);
                    continue;
                }
                newConfigs.put(storeNameToPut, configsToPut.get(storeNameToPut));
                response.put(storeNameToPut, STORE_UPDATED_PROPS);
            }
        } else {
            // Store does not already exist
            try {
                listener.onStoreConfigAddOrUpdate(storeNameToPut, configsToPut.get(storeNameToPut));
            } catch (BootstrapFailureException bootstrapException) {
                logger.error("The store " + storeNameToPut + " is not served by Voldemort currently. Exception Message - " + bootstrapException.getMessage());
                response.put(storeNameToPut, STORE_NOT_SERVED_BY_VOLDEMORT_PROPS);
                continue;
            } catch (Exception e) {
                String errorMessage = "Got exception when trying to create fat client for store " + storeNameToPut + ". Exception Message - " + e.getMessage();
                logger.error(errorMessage);
                STORE_NOT_CREATED_PROPS.put(ERROR_MESSAGE_PARAM_KEY, errorMessage);
                response.put(storeNameToPut, STORE_NOT_CREATED_PROPS);
                continue;
            }
            newConfigs.put(storeNameToPut, configsToPut.get(storeNameToPut));
            response.put(storeNameToPut, STORE_CREATED_PROPS);
        }
    }
    persistNewConfigFile(newConfigs);
    return response;
}
Also used : BootstrapFailureException(voldemort.client.BootstrapFailureException) Properties(java.util.Properties) IOException(java.io.IOException) BootstrapFailureException(voldemort.client.BootstrapFailureException)

Aggregations

BootstrapFailureException (voldemort.client.BootstrapFailureException)2 IOException (java.io.IOException)1 Date (java.util.Date)1 Properties (java.util.Properties)1 Callable (java.util.concurrent.Callable)1 ClientConfig (voldemort.client.ClientConfig)1 SocketStoreClientFactory (voldemort.client.SocketStoreClientFactory)1 SystemStoreRepository (voldemort.client.SystemStoreRepository)1 AsyncMetadataVersionManager (voldemort.client.scheduler.AsyncMetadataVersionManager)1 SchedulerService (voldemort.common.service.SchedulerService)1