Search in sources :

Example 1 with ACTUALIZE

use of org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationProcessor.AllowableAction.ACTUALIZE in project ignite by apache.

the class DistributedConfigurationProcessor method start.

/**
 * {@inheritDoc}
 */
@Override
public void start() throws IgniteCheckedException {
    GridInternalSubscriptionProcessor isp = ctx.internalSubscriptionProcessor();
    isp.registerDistributedMetastorageListener(new DistributedMetastorageLifecycleListener() {

        @Override
        public void onReadyForRead(ReadableDistributedMetaStorage metastorage) {
            distributedMetastorage = ctx.distributedMetastorage();
            // Listener for handling of cluster wide change of specific properties. Do local update.
            distributedMetastorage.listen((key) -> key.startsWith(DIST_CONF_PREFIX), (String key, Serializable oldVal, Serializable newVal) -> {
                DistributedChangeableProperty prop = props.get(toPropertyKey(key));
                if (prop != null)
                    prop.localUpdate(newVal);
            });
            // Switch to actualize action and actualize already registered properties.
            switchCurrentActionTo(ACTUALIZE);
            // Register and actualize properties waited for this service.
            isp.getDistributedConfigurationListeners().forEach(listener -> listener.onReadyToRegister(DistributedConfigurationProcessor.this));
        }

        @Override
        public void onReadyForWrite(DistributedMetaStorage metastorage) {
            // Switch to cluster wide update action and do it on already registered properties.
            switchCurrentActionTo(CLUSTER_WIDE_UPDATE);
            isp.getDistributedConfigurationListeners().forEach(DistributedConfigurationLifecycleListener::onReadyToWrite);
        }
    });
}
Also used : ReadableDistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage) Arrays(java.util.Arrays) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) DistributedMetastorageLifecycleListener(org.apache.ignite.internal.processors.metastorage.DistributedMetastorageLifecycleListener) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Collectors(java.util.stream.Collectors) GridInternalSubscriptionProcessor(org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor) Serializable(java.io.Serializable) GridKernalContext(org.apache.ignite.internal.GridKernalContext) REGISTER(org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationProcessor.AllowableAction.REGISTER) List(java.util.List) Map(java.util.Map) ReadableDistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage) GridProcessorAdapter(org.apache.ignite.internal.processors.GridProcessorAdapter) ACTUALIZE(org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationProcessor.AllowableAction.ACTUALIZE) CLUSTER_WIDE_UPDATE(org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationProcessor.AllowableAction.CLUSTER_WIDE_UPDATE) Serializable(java.io.Serializable) DistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage) ReadableDistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage) GridInternalSubscriptionProcessor(org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor) DistributedMetastorageLifecycleListener(org.apache.ignite.internal.processors.metastorage.DistributedMetastorageLifecycleListener)

Aggregations

Serializable (java.io.Serializable)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Collectors (java.util.stream.Collectors)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 GridKernalContext (org.apache.ignite.internal.GridKernalContext)1 GridProcessorAdapter (org.apache.ignite.internal.processors.GridProcessorAdapter)1 ACTUALIZE (org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationProcessor.AllowableAction.ACTUALIZE)1 CLUSTER_WIDE_UPDATE (org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationProcessor.AllowableAction.CLUSTER_WIDE_UPDATE)1 REGISTER (org.apache.ignite.internal.processors.configuration.distributed.DistributedConfigurationProcessor.AllowableAction.REGISTER)1 DistributedMetaStorage (org.apache.ignite.internal.processors.metastorage.DistributedMetaStorage)1 DistributedMetastorageLifecycleListener (org.apache.ignite.internal.processors.metastorage.DistributedMetastorageLifecycleListener)1 ReadableDistributedMetaStorage (org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage)1 GridInternalSubscriptionProcessor (org.apache.ignite.internal.processors.subscription.GridInternalSubscriptionProcessor)1 GridFutureAdapter (org.apache.ignite.internal.util.future.GridFutureAdapter)1