public synchronized void initialize()

in src/main/java/com/netflix/bdp/s3mper/listing/ConsistentListingAspect.java [101:154]


    public synchronized void initialize(JoinPoint jp) throws Exception {

        URI uri = (URI) jp.getArgs()[0];
        Configuration conf = (Configuration) jp.getArgs()[1];
        
        updateConfig(conf);
        
        //Check again after updating configs
        if(disabled) {
            return;
        }
        
        if(metastore == null) {
            log.debug("Initializing S3mper Metastore");
            
            //FIXME: This is defaulted to the dynamodb metastore impl, but shouldn't 
            //       reference it directly like this.
            Class<?> metaImpl = conf.getClass("s3mper.metastore.impl", com.netflix.bdp.s3mper.metastore.impl.DynamoDBMetastore.class);

            try {
                metastore = Metastore.getFilesystemMetastore(conf);
                metastore.initalize(uri, conf);
            } catch (Exception e) {
                disable();

                if(failOnError) {
                    throw e;
                } 
            }
        } else {
            log.debug("S3mper Metastore already initialized.");
        }
        
        if(alertDispatcher == null) {
            log.debug("Initializing Alert Dispatcher");
            
            try {
                Class<?> dispatcherImpl = conf.getClass("s3mper.dispatcher.impl", com.netflix.bdp.s3mper.alert.impl.CloudWatchAlertDispatcher.class);
                
                alertDispatcher = (AlertDispatcher) ReflectionUtils.newInstance(dispatcherImpl, conf);
                alertDispatcher.init(uri, conf);
            } catch (Exception e) {
                log.error("Error initializing s3mper alert dispatcher", e);

                disable();

                if(failOnError) {
                    throw e;
                }
            }
        } else {
            alertDispatcher.setConfig(conf);
        }
    }