Search in sources :

Example 6 with VirtualHostNode

use of org.apache.qpid.server.model.VirtualHostNode in project qpid-broker-j by apache.

the class ProvidedStoreVirtualHostImpl method onValidate.

@Override
public void onValidate() {
    super.onValidate();
    VirtualHostNode<?> virtualHostNode = (VirtualHostNode) getParent();
    DurableConfigurationStore configurationStore = virtualHostNode.getConfigurationStore();
    if (!(configurationStore instanceof MessageStoreProvider)) {
        throw new IllegalConfigurationException(VIRTUAL_HOST_TYPE + " virtual host can only be used where the node's store (" + configurationStore.getClass().getName() + ") is a message store provider. ");
    }
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) MessageStoreProvider(org.apache.qpid.server.store.MessageStoreProvider) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode)

Example 7 with VirtualHostNode

use of org.apache.qpid.server.model.VirtualHostNode in project qpid-broker-j by apache.

the class AbstractVirtualHost method onOpen.

@Override
protected void onOpen() {
    super.onOpen();
    registerSystemNodes();
    _messageStore = createMessageStore();
    _messageStoreLogSubject = new MessageStoreLogSubject(getName(), _messageStore.getClass().getSimpleName());
    _messageStore.addEventListener(this, Event.PERSISTENT_MESSAGE_SIZE_OVERFULL);
    _messageStore.addEventListener(this, Event.PERSISTENT_MESSAGE_SIZE_UNDERFULL);
    _fileSystemMaxUsagePercent = getContextValue(Integer.class, Broker.STORE_FILESYSTEM_MAX_USAGE_PERCENT);
    _flowToDiskCheckPeriod = getContextValue(Long.class, FLOW_TO_DISK_CHECK_PERIOD);
    _isDiscardGlobalSharedSubscriptionLinksOnDetach = getContextValue(Boolean.class, DISCARD_GLOBAL_SHARED_SUBSCRIPTION_LINKS_ON_DETACH);
    QpidServiceLoader serviceLoader = new QpidServiceLoader();
    for (ConnectionValidator validator : serviceLoader.instancesOf(ConnectionValidator.class)) {
        if ((_enabledConnectionValidators.isEmpty() && (_disabledConnectionValidators.isEmpty()) || !_disabledConnectionValidators.contains(validator.getType())) || _enabledConnectionValidators.contains(validator.getType())) {
            _connectionValidators.add(validator);
        }
    }
    PreferencesRoot preferencesRoot = (VirtualHostNode) getParent();
    _preferenceStore = preferencesRoot.createPreferenceStore();
    _linkRegistry = createLinkRegistry();
    createHousekeepingExecutor();
    openConnectionLimiter();
}
Also used : QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader) PreferencesRoot(org.apache.qpid.server.store.preferences.PreferencesRoot) AtomicLong(java.util.concurrent.atomic.AtomicLong) MessageStoreLogSubject(org.apache.qpid.server.logging.subjects.MessageStoreLogSubject) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ConnectionValidator(org.apache.qpid.server.plugin.ConnectionValidator) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode)

Example 8 with VirtualHostNode

use of org.apache.qpid.server.model.VirtualHostNode in project qpid-broker-j by apache.

the class VirtualHostStoreUpgraderAndRecoverer method recover.

private void recover(final ConfiguredObject<?> recoveryRoot, final DurableConfigurationStore durableConfigurationStore, final List<ConfiguredObjectRecord> records, final boolean isNew) {
    new GenericRecoverer(recoveryRoot).recover(records, isNew);
    final StoreConfigurationChangeListener configChangeListener = new StoreConfigurationChangeListener(durableConfigurationStore);
    if (_virtualHostNode.getVirtualHost() != null) {
        applyRecursively(_virtualHostNode.getVirtualHost(), new RecursiveAction<ConfiguredObject<?>>() {

            @Override
            public boolean applyToChildren(final ConfiguredObject<?> object) {
                return object.isDurable();
            }

            @Override
            public void performAction(final ConfiguredObject<?> object) {
                object.addChangeListener(configChangeListener);
            }
        });
    }
    if (recoveryRoot instanceof VirtualHostNode) {
        _virtualHostNode.addChangeListener(new AbstractConfigurationChangeListener() {

            @Override
            public void childAdded(final ConfiguredObject<?> object, final ConfiguredObject<?> child) {
                if (child instanceof VirtualHost) {
                    applyRecursively(child, new RecursiveAction<ConfiguredObject<?>>() {

                        @Override
                        public boolean applyToChildren(final ConfiguredObject<?> object) {
                            return object.isDurable();
                        }

                        @Override
                        public void performAction(final ConfiguredObject<?> object) {
                            if (object.isDurable()) {
                                durableConfigurationStore.update(true, object.asObjectRecord());
                                object.addChangeListener(configChangeListener);
                            }
                        }
                    });
                }
            }

            @Override
            public void childRemoved(final ConfiguredObject<?> object, final ConfiguredObject<?> child) {
                if (child instanceof VirtualHost) {
                    child.removeChangeListener(configChangeListener);
                }
            }
        });
        if (isNew) {
            if (_virtualHostNode instanceof AbstractConfiguredObject) {
                ((AbstractConfiguredObject) _virtualHostNode).forceUpdateAllSecureAttributes();
            }
        }
    }
}
Also used : AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) VirtualHost(org.apache.qpid.server.model.VirtualHost) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode) StoreConfigurationChangeListener(org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener) AbstractConfigurationChangeListener(org.apache.qpid.server.model.AbstractConfigurationChangeListener)

Example 9 with VirtualHostNode

use of org.apache.qpid.server.model.VirtualHostNode in project qpid-broker-j by apache.

the class AbstractVirtualHost method doRestart.

private ListenableFuture<Void> doRestart() {
    createHousekeepingExecutor();
    final VirtualHostStoreUpgraderAndRecoverer virtualHostStoreUpgraderAndRecoverer = new VirtualHostStoreUpgraderAndRecoverer((VirtualHostNode<?>) getParent());
    virtualHostStoreUpgraderAndRecoverer.reloadAndRecoverVirtualHost(getDurableConfigurationStore());
    final Collection<VirtualHostAccessControlProvider> accessControlProviders = getChildren(VirtualHostAccessControlProvider.class);
    if (!accessControlProviders.isEmpty()) {
        accessControlProviders.forEach(child -> child.addChangeListener(_accessControlProviderListener));
    }
    final List<ListenableFuture<Void>> childOpenFutures = new ArrayList<>();
    Subject.doAs(getSubjectWithAddedSystemRights(), (PrivilegedAction<Object>) () -> {
        applyToChildren(child -> {
            final ListenableFuture<Void> childOpenFuture = child.openAsync();
            childOpenFutures.add(childOpenFuture);
            addFutureCallback(childOpenFuture, new FutureCallback<Void>() {

                @Override
                public void onSuccess(final Void result) {
                }

                @Override
                public void onFailure(final Throwable t) {
                    LOGGER.error("Exception occurred while opening {} : {}", child.getClass().getSimpleName(), child.getName(), t);
                    onRestartFailure();
                }
            }, getTaskExecutor());
        });
        return null;
    });
    ListenableFuture<List<Void>> combinedFuture = Futures.allAsList(childOpenFutures);
    return Futures.transformAsync(combinedFuture, input -> onActivate(), MoreExecutors.directExecutor());
}
Also used : AccessControlContext(java.security.AccessControlContext) Arrays(java.util.Arrays) BufferedInputStream(java.io.BufferedInputStream) ManagedAttributeField(org.apache.qpid.server.model.ManagedAttributeField) BrokerModel(org.apache.qpid.server.model.BrokerModel) MessageStoreSerializer(org.apache.qpid.server.store.serializer.MessageStoreSerializer) Future(java.util.concurrent.Future) NetworkConnectionScheduler(org.apache.qpid.server.transport.NetworkConnectionScheduler) Map(java.util.Map) QueueEntryIterator(org.apache.qpid.server.queue.QueueEntryIterator) NotFoundException(org.apache.qpid.server.model.NotFoundException) UserPreferences(org.apache.qpid.server.model.preferences.UserPreferences) EnumSet(java.util.EnumSet) AutoCommitTransaction(org.apache.qpid.server.txn.AutoCommitTransaction) Binding(org.apache.qpid.server.model.Binding) Set(java.util.Set) AMQPConnection(org.apache.qpid.server.transport.AMQPConnection) InstanceProperties(org.apache.qpid.server.message.InstanceProperties) Iterators.cycle(com.google.common.collect.Iterators.cycle) StandardCharsets(java.nio.charset.StandardCharsets) HousekeepingExecutor(org.apache.qpid.server.util.HousekeepingExecutor) Serializable(java.io.Serializable) MessageStoreMessages(org.apache.qpid.server.logging.messages.MessageStoreMessages) Operation(org.apache.qpid.server.security.access.Operation) PreferenceRecord(org.apache.qpid.server.store.preferences.PreferenceRecord) StateTransition(org.apache.qpid.server.model.StateTransition) QpidServiceLoader(org.apache.qpid.server.plugin.QpidServiceLoader) SystemConfig(org.apache.qpid.server.model.SystemConfig) CompoundAccessControl(org.apache.qpid.server.security.CompoundAccessControl) TaskExecutor(org.apache.qpid.server.configuration.updater.TaskExecutor) UUIDGenerator(org.apache.qpid.server.model.UUIDGenerator) CustomRestHeaders(org.apache.qpid.server.model.CustomRestHeaders) Queue(org.apache.qpid.server.model.Queue) PreferencesRoot(org.apache.qpid.server.store.preferences.PreferencesRoot) Callable(java.util.concurrent.Callable) ServerMessage(org.apache.qpid.server.message.ServerMessage) ArrayList(java.util.ArrayList) ResultCalculator(org.apache.qpid.server.security.SubjectFixedResultAccessControl.ResultCalculator) PreferenceStoreUpdaterImpl(org.apache.qpid.server.store.preferences.PreferenceStoreUpdaterImpl) ManageableMessage(org.apache.qpid.server.model.ManageableMessage) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) UserPreferencesImpl(org.apache.qpid.server.model.preferences.UserPreferencesImpl) QueueEntry(org.apache.qpid.server.queue.QueueEntry) MessageHandler(org.apache.qpid.server.store.handler.MessageHandler) SubjectFixedResultAccessControl(org.apache.qpid.server.security.SubjectFixedResultAccessControl) PreferenceStore(org.apache.qpid.server.store.preferences.PreferenceStore) StoredMessage(org.apache.qpid.server.store.StoredMessage) NoFactoryForTypeException(org.apache.qpid.server.model.NoFactoryForTypeException) MessageDeletedException(org.apache.qpid.server.message.MessageDeletedException) DtxRegistry(org.apache.qpid.server.txn.DtxRegistry) MessageInstanceHandler(org.apache.qpid.server.store.handler.MessageInstanceHandler) IOException(java.io.IOException) PreferencesRecoverer(org.apache.qpid.server.store.preferences.PreferencesRecoverer) Connection(org.apache.qpid.server.model.Connection) File(java.io.File) FutureCallback(com.google.common.util.concurrent.FutureCallback) DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) Strings(org.apache.qpid.server.util.Strings) AtomicLong(java.util.concurrent.atomic.AtomicLong) Futures(com.google.common.util.concurrent.Futures) Result(org.apache.qpid.server.security.Result) SuppressingInheritedAccessControlContextThreadFactory(org.apache.qpid.server.pool.SuppressingInheritedAccessControlContextThreadFactory) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) ScheduledFuture(java.util.concurrent.ScheduledFuture) MessageReference(org.apache.qpid.server.message.MessageReference) URL(java.net.URL) Date(java.util.Date) Outcome(org.apache.qpid.server.logging.Outcome) DistributedTransactionHandler(org.apache.qpid.server.store.handler.DistributedTransactionHandler) LoggerFactory(org.slf4j.LoggerFactory) DefaultDestination(org.apache.qpid.server.exchange.DefaultDestination) TaskExecutorImpl(org.apache.qpid.server.configuration.updater.TaskExecutorImpl) SettableFuture(com.google.common.util.concurrent.SettableFuture) MessageStore(org.apache.qpid.server.store.MessageStore) ExchangeDefaults(org.apache.qpid.server.exchange.ExchangeDefaults) VirtualHostAccessControlProvider(org.apache.qpid.server.model.VirtualHostAccessControlProvider) AmqpPort(org.apache.qpid.server.model.port.AmqpPort) StoreException(org.apache.qpid.server.store.StoreException) MessageEnqueueRecord(org.apache.qpid.server.store.MessageEnqueueRecord) PatternSyntaxException(java.util.regex.PatternSyntaxException) LocalTransaction(org.apache.qpid.server.txn.LocalTransaction) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LinkModel(org.apache.qpid.server.protocol.LinkModel) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) UUID(java.util.UUID) PrivilegedAction(java.security.PrivilegedAction) RoutingResult(org.apache.qpid.server.message.RoutingResult) ConfigurationExtractor(org.apache.qpid.server.model.ConfigurationExtractor) VirtualHostLogger(org.apache.qpid.server.model.VirtualHostLogger) ConnectionValidator(org.apache.qpid.server.plugin.ConnectionValidator) MessageStoreLogSubject(org.apache.qpid.server.logging.subjects.MessageStoreLogSubject) List(java.util.List) Principal(java.security.Principal) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) VirtualHost(org.apache.qpid.server.model.VirtualHost) MessageDestination(org.apache.qpid.server.message.MessageDestination) MessageSource(org.apache.qpid.server.message.MessageSource) Pattern(java.util.regex.Pattern) CacheBuilder(com.google.common.cache.CacheBuilder) UnsupportedEncodingException(java.io.UnsupportedEncodingException) DataInputStream(java.io.DataInputStream) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) AccessControl(org.apache.qpid.server.security.AccessControl) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) JdkFutureAdapters(com.google.common.util.concurrent.JdkFutureAdapters) EventLogger(org.apache.qpid.server.logging.EventLogger) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) ConfigurationChangeListener(org.apache.qpid.server.model.ConfigurationChangeListener) Collections.newSetFromMap(java.util.Collections.newSetFromMap) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExclusivityPolicy(org.apache.qpid.server.model.ExclusivityPolicy) Preference(org.apache.qpid.server.model.preferences.Preference) AuthenticatedPrincipal(org.apache.qpid.server.security.auth.AuthenticatedPrincipal) SystemNodeCreator(org.apache.qpid.server.plugin.SystemNodeCreator) AbstractConfigurationChangeListener(org.apache.qpid.server.model.AbstractConfigurationChangeListener) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) Task(org.apache.qpid.server.configuration.updater.Task) Param(org.apache.qpid.server.model.Param) OutputStream(java.io.OutputStream) PreferenceStoreUpdater(org.apache.qpid.server.store.preferences.PreferenceStoreUpdater) ServerTransaction(org.apache.qpid.server.txn.ServerTransaction) Logger(org.slf4j.Logger) VirtualHostMessages(org.apache.qpid.server.logging.messages.VirtualHostMessages) Iterator(java.util.Iterator) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) SocketConnectionMetaData(org.apache.qpid.server.security.auth.SocketConnectionMetaData) MalformedURLException(java.net.MalformedURLException) Exchange(org.apache.qpid.server.model.Exchange) Content(org.apache.qpid.server.model.Content) Broker(org.apache.qpid.server.model.Broker) State(org.apache.qpid.server.model.State) Subject(javax.security.auth.Subject) TimeUnit(java.util.concurrent.TimeUnit) ConfiguredObjectRecordHandler(org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler) VirtualHostStoreUpgraderAndRecoverer(org.apache.qpid.server.store.VirtualHostStoreUpgraderAndRecoverer) URLEncoder(java.net.URLEncoder) AMQInvalidArgumentException(org.apache.qpid.server.filter.AMQInvalidArgumentException) Event(org.apache.qpid.server.store.Event) MessageStoreProvider(org.apache.qpid.server.store.MessageStoreProvider) MessageNode(org.apache.qpid.server.message.MessageNode) DoOnConfigThread(org.apache.qpid.server.model.DoOnConfigThread) Cache(com.google.common.cache.Cache) RestContentHeader(org.apache.qpid.server.model.RestContentHeader) Collections(java.util.Collections) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode) StatisticsReportingTask(org.apache.qpid.server.stats.StatisticsReportingTask) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) VirtualHostAccessControlProvider(org.apache.qpid.server.model.VirtualHostAccessControlProvider) VirtualHostStoreUpgraderAndRecoverer(org.apache.qpid.server.store.VirtualHostStoreUpgraderAndRecoverer) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ArrayList(java.util.ArrayList) List(java.util.List) FutureCallback(com.google.common.util.concurrent.FutureCallback)

Example 10 with VirtualHostNode

use of org.apache.qpid.server.model.VirtualHostNode in project qpid-broker-j by apache.

the class DefaultVirtualHostAliasImpl method getAddressSpace.

@Override
public NamedAddressSpace getAddressSpace(final String name) {
    if (name == null || name.trim().equals("")) {
        Broker<?> broker = getAncestor(Broker.class);
        VirtualHostNode defaultVirtualHostNode = broker.findDefautVirtualHostNode();
        return defaultVirtualHostNode == null ? null : defaultVirtualHostNode.getVirtualHost();
    }
    return null;
}
Also used : VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode)

Aggregations

VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)14 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)7 HashMap (java.util.HashMap)6 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)4 DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)4 AbstractConfigurationChangeListener (org.apache.qpid.server.model.AbstractConfigurationChangeListener)3 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)3 Broker (org.apache.qpid.server.model.Broker)3 VirtualHost (org.apache.qpid.server.model.VirtualHost)3 Test (org.junit.Test)3 File (java.io.File)2 Principal (java.security.Principal)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 TaskExecutorImpl (org.apache.qpid.server.configuration.updater.TaskExecutorImpl)2 EventLogger (org.apache.qpid.server.logging.EventLogger)2 BrokerModel (org.apache.qpid.server.model.BrokerModel)2 AccessControl (org.apache.qpid.server.security.AccessControl)2 MessageStoreProvider (org.apache.qpid.server.store.MessageStoreProvider)2 PreferenceStore (org.apache.qpid.server.store.preferences.PreferenceStore)2 Cache (com.google.common.cache.Cache)1