Search in sources :

Example 1 with StateTransition

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

the class PrincipalDatabaseAuthenticationManager method activate.

@Override
@StateTransition(currentState = { State.UNINITIALIZED, State.ERRORED }, desiredState = State.ACTIVE)
public ListenableFuture<Void> activate() {
    final SettableFuture<Void> returnVal = SettableFuture.create();
    final List<Principal> users = _principalDatabase == null ? Collections.<Principal>emptyList() : _principalDatabase.getUsers();
    _userMap.clear();
    if (!users.isEmpty()) {
        for (final Principal user : users) {
            final PrincipalAdapter principalAdapter = new PrincipalAdapter(user);
            principalAdapter.registerWithParents();
            principalAdapter.openAsync().addListener(new Runnable() {

                @Override
                public void run() {
                    _userMap.put(user, principalAdapter);
                    if (_userMap.size() == users.size()) {
                        setState(State.ACTIVE);
                        returnVal.set(null);
                    }
                }
            }, getTaskExecutor());
        }
        return returnVal;
    } else {
        setState(State.ACTIVE);
        return Futures.immediateFuture(null);
    }
}
Also used : UsernamePrincipal(org.apache.qpid.server.security.auth.UsernamePrincipal) Principal(java.security.Principal) StateTransition(org.apache.qpid.server.model.StateTransition)

Example 2 with StateTransition

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

the class HttpManagement method doStart.

@StateTransition(currentState = { State.UNINITIALIZED, State.ERRORED }, desiredState = State.ACTIVE)
@SuppressWarnings("unused")
private ListenableFuture<Void> doStart() {
    Collection<HttpPort<?>> httpPorts = getEligibleHttpPorts(getBroker().getPorts());
    if (httpPorts.isEmpty()) {
        LOGGER.warn("HttpManagement plugin is configured but no suitable HTTP ports are available.");
    } else {
        getBroker().getEventLogger().message(ManagementConsoleMessages.STARTUP(OPERATIONAL_LOGGING_NAME));
        _server = createServer(httpPorts);
        try {
            _server.start();
            logOperationalListenMessages();
        } catch (PortBindFailureException e) {
            getBroker().getEventLogger().message(PortMessages.BIND_FAILED("HTTP", e.getAddress().getPort()));
            throw e;
        } catch (Exception e) {
            throw new ServerScopedRuntimeException("Failed to start HTTP management on ports : " + httpPorts, e);
        }
        getBroker().getEventLogger().message(ManagementConsoleMessages.READY(OPERATIONAL_LOGGING_NAME));
    }
    setState(State.ACTIVE);
    return Futures.immediateFuture(null);
}
Also used : HttpPort(org.apache.qpid.server.model.port.HttpPort) PortBindFailureException(org.apache.qpid.server.transport.PortBindFailureException) IOException(java.io.IOException) PortBindFailureException(org.apache.qpid.server.transport.PortBindFailureException) BindException(java.net.BindException) ServerScopedRuntimeException(org.apache.qpid.server.util.ServerScopedRuntimeException) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ServerScopedRuntimeException(org.apache.qpid.server.util.ServerScopedRuntimeException) StateTransition(org.apache.qpid.server.model.StateTransition)

Example 3 with StateTransition

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

the class ManagementModeStoreHandlerTest method createManagementModeStoreHandler.

private ManagementModeStoreHandler createManagementModeStoreHandler() {
    _systemConfig.close();
    Map<String, Object> attributes = new HashMap<>(_systemConfigAttributes);
    attributes.put(ConfiguredObject.DESIRED_STATE, State.QUIESCED);
    attributes.remove(ConfiguredObject.TYPE);
    _systemConfig = new AbstractSystemConfig(_taskExecutor, mock(EventLogger.class), mock(Principal.class), attributes) {

        @Override
        protected void onOpen() {
        }

        @Override
        protected DurableConfigurationStore createStoreObject() {
            return _store;
        }

        @Override
        protected ListenableFuture<Void> onClose() {
            return Futures.immediateFuture(null);
        }

        @Override
        @StateTransition(currentState = State.UNINITIALIZED, desiredState = State.QUIESCED)
        protected ListenableFuture<Void> startQuiesced() {
            return Futures.immediateFuture(null);
        }
    };
    _systemConfig.open();
    return new ManagementModeStoreHandler(_store, _systemConfig);
}
Also used : AbstractSystemConfig(org.apache.qpid.server.model.AbstractSystemConfig) DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) HashMap(java.util.HashMap) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) StateTransition(org.apache.qpid.server.model.StateTransition) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Aggregations

StateTransition (org.apache.qpid.server.model.StateTransition)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 IOException (java.io.IOException)1 BindException (java.net.BindException)1 Principal (java.security.Principal)1 HashMap (java.util.HashMap)1 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)1 AbstractSystemConfig (org.apache.qpid.server.model.AbstractSystemConfig)1 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)1 HttpPort (org.apache.qpid.server.model.port.HttpPort)1 UsernamePrincipal (org.apache.qpid.server.security.auth.UsernamePrincipal)1 DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)1 PortBindFailureException (org.apache.qpid.server.transport.PortBindFailureException)1 ServerScopedRuntimeException (org.apache.qpid.server.util.ServerScopedRuntimeException)1